Merge branch 'ent-5188-IPAM-Implementacion-de-Sites' into 'develop'
Ent 5188 ipam implementacion de sites See merge request artica/pandorafms!4575
This commit is contained in:
commit
fab73dc290
|
@ -12,31 +12,46 @@ ALTER TABLE `tsync_queue` ADD COLUMN `result` TEXT;
|
|||
ALTER TABLE tagente_modulo MODIFY debug_content TEXT;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_calendar` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL default '',
|
||||
`id_group` INT(10) NOT NULL DEFAULT 0,
|
||||
`description` text,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`name`)
|
||||
`id_group` INT(10) NOT NULL DEFAULT 0,
|
||||
`description` text,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tipam_network_location` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL default '',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`name`)
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL default '',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tipam_sites` (
|
||||
`id` serial,
|
||||
`name` varchar(100) UNIQUE NOT NULL default '',
|
||||
`description` text,
|
||||
`parent` bigint unsigned null,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> '';
|
||||
UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id;
|
||||
ALTER TABLE `tipam_network` MODIFY `location` int(10) unsigned NULL;
|
||||
ALTER TABLE `tipam_network` ADD FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`;
|
||||
ALTER TABLE `talert_special_days` ADD COLUMN `id_calendar` int(10) unsigned NOT NULL DEFAULT 1;
|
||||
ALTER TABLE `talert_special_days` ADD COLUMN `day_code` tinyint(2) unsigned NOT NULL DEFAULT 0;
|
||||
ALTER TABLE `talert_special_days` DROP COLUMN `same_day`;
|
||||
ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `tipam_network` ADD COLUMN `id_site` bigint unsigned;
|
||||
ALTER TABLE `tipam_network` ADD CONSTRAINT FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE `tipam_supernet` ADD COLUMN `id_site` bigint unsigned;
|
||||
ALTER TABLE `tipam_supernet` ADD CONSTRAINT FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE `tipam_network` ADD COLUMN `vrf` int(10) unsigned;
|
||||
ALTER TABLE `tipam_network` ADD CONSTRAINT FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar');
|
||||
UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday';
|
||||
UPDATE `talert_special_days` set `day_code` = 2 WHERE `same_day` = 'tuesday';
|
||||
UPDATE `talert_special_days` set `day_code` = 3 WHERE `same_day` = 'wednesday';
|
||||
|
@ -45,11 +60,8 @@ UPDATE `talert_special_days` set `day_code` = 5 WHERE `same_day` = 'friday';
|
|||
UPDATE `talert_special_days` set `day_code` = 6 WHERE `same_day` = 'saturday';
|
||||
UPDATE `talert_special_days` set `day_code` = 7 WHERE `same_day` = 'sunday';
|
||||
|
||||
ALTER TABLE `talert_special_days` DROP COLUMN `same_day`;
|
||||
ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`;
|
||||
|
||||
INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> '';
|
||||
UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id;
|
||||
UPDATE `tconfig` c1 JOIN (select count(*) as n FROM `tconfig` c2 WHERE (c2.`token` = "node_metaconsole" AND c2.`value` = 1) OR (c2.`token` = "centralized_management" AND c2.`value` = 1) ) v SET c1. `value` = 0 WHERE c1.token = "autocreate_remote_users" AND v.n = 2;
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -3970,15 +3970,20 @@ CREATE TABLE IF NOT EXISTS `tipam_network` (
|
|||
`network` varchar(100) NOT NULL default '',
|
||||
`name_network` varchar(255) default '',
|
||||
`description` text NOT NULL,
|
||||
`location` tinytext NOT NULL,
|
||||
`location` int(10) unsigned NULL,
|
||||
`id_recon_task` int(10) unsigned NOT NULL,
|
||||
`scan_interval` tinyint(2) default 1,
|
||||
`monitoring` tinyint(2) default 0,
|
||||
`id_group` mediumint(8) unsigned NULL default 0,
|
||||
`lightweight_mode` tinyint(2) default 0,
|
||||
`users_operator` text,
|
||||
`id_site` bigint unsigned,
|
||||
`vrf` int(10) unsigned,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE
|
||||
FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tipam_ip` (
|
||||
|
@ -4033,7 +4038,9 @@ CREATE TABLE IF NOT EXISTS `tipam_supernet` (
|
|||
`address` varchar(250) NOT NULL,
|
||||
`mask` varchar(250) NOT NULL,
|
||||
`subneting_mask` varchar(250) default '',
|
||||
PRIMARY KEY (`id`)
|
||||
`id_site` bigint unsigned,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tipam_supernet_network` (
|
||||
|
@ -4052,10 +4059,16 @@ CREATE TABLE IF NOT EXISTS `tipam_network_location` (
|
|||
UNIQUE (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tipam_sites` (
|
||||
`id` serial,
|
||||
`name` varchar(100) UNIQUE NOT NULL default '',
|
||||
`description` text,
|
||||
`parent` bigint unsigned null,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> '';
|
||||
UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id;
|
||||
ALTER TABLE `tipam_network` MODIFY `location` int(10) unsigned NULL;
|
||||
ALTER TABLE `tipam_network` ADD FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE;
|
||||
|
||||
SET @insert_type = 3;
|
||||
SET @insert_name = 'IPAM Recon';
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
|
@ -3459,6 +3459,11 @@ function ui_print_datatable(array $parameters)
|
|||
}
|
||||
}
|
||||
|
||||
$export_columns = '';
|
||||
if ($parameters['csv_exclude_latest'] === true) {
|
||||
$export_columns = ',columns: \'th:not(:last-child)\'';
|
||||
}
|
||||
|
||||
$js .= '
|
||||
if (dt_'.$table_id.'.page.info().pages > 1) {
|
||||
$("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").show()
|
||||
|
@ -3489,8 +3494,7 @@ function ui_print_datatable(array $parameters)
|
|||
order : "current",
|
||||
page : "All",
|
||||
search : "applied"
|
||||
},
|
||||
columns: [1,'.$columns.']
|
||||
}'.$export_columns.'
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -43,6 +43,13 @@ abstract class Entity
|
|||
*/
|
||||
protected $existsInDB;
|
||||
|
||||
/**
|
||||
* Fields to identify register.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $primaryKeys;
|
||||
|
||||
/**
|
||||
* Entity fields (from table).
|
||||
*
|
||||
|
@ -126,6 +133,8 @@ abstract class Entity
|
|||
|
||||
if (is_array($filters) === true) {
|
||||
// New one.
|
||||
$this->primaryKeys = array_keys($filters);
|
||||
|
||||
$data = \db_get_row_filter(
|
||||
$this->table,
|
||||
$filters,
|
||||
|
@ -292,8 +301,94 @@ abstract class Entity
|
|||
* Saves current object definition to database.
|
||||
*
|
||||
* @return boolean Success or not.
|
||||
* @throws \Exception On error.
|
||||
*/
|
||||
public abstract function save();
|
||||
public function save()
|
||||
{
|
||||
$updates = $this->fields;
|
||||
// Clean null fields.
|
||||
foreach ($updates as $k => $v) {
|
||||
if ($v === null) {
|
||||
unset($updates[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->existsInDB === true) {
|
||||
// Update.
|
||||
$where = [];
|
||||
|
||||
foreach ($this->primaryKeys as $key) {
|
||||
$where[$key] = $this->fields[$key];
|
||||
}
|
||||
|
||||
if (empty($where) === true) {
|
||||
throw new \Exception(
|
||||
__METHOD__.' error: Cannot identify object'
|
||||
);
|
||||
}
|
||||
|
||||
$rs = \db_process_sql_update(
|
||||
$this->table,
|
||||
$updates,
|
||||
$where
|
||||
);
|
||||
|
||||
if ($rs === false) {
|
||||
global $config;
|
||||
throw new \Exception(
|
||||
__METHOD__.' error: '.$config['dbconnection']->error
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// New register.
|
||||
$rs = \db_process_sql_insert(
|
||||
$this->table,
|
||||
$updates
|
||||
);
|
||||
|
||||
if ($rs === false) {
|
||||
global $config;
|
||||
|
||||
throw new \Exception(
|
||||
__METHOD__.' error: '.$config['dbconnection']->error
|
||||
);
|
||||
}
|
||||
|
||||
$this->existsInDB = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove this entity.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception If no primary keys are defined.
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
if ($this->existsInDB === true) {
|
||||
$where = [];
|
||||
|
||||
foreach ($this->primaryKeys as $key) {
|
||||
$where[$key] = $this->fields[$key];
|
||||
}
|
||||
|
||||
if (empty($where) === true) {
|
||||
throw new \Exception(
|
||||
__METHOD__.' error: Cannot identify object on deletion'
|
||||
);
|
||||
}
|
||||
|
||||
\db_process_sql_delete(
|
||||
$this->table,
|
||||
$where
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3959,6 +3959,18 @@ CREATE TABLE IF NOT EXISTS `tipam_network_location` (
|
|||
UNIQUE (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tipam_sites`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tipam_sites` (
|
||||
`id` serial,
|
||||
`name` varchar(100) UNIQUE NOT NULL default '',
|
||||
`description` text,
|
||||
`parent` bigint unsigned null,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tipam_network`
|
||||
-- ----------------------------------------------------------------------
|
||||
|
@ -3974,9 +3986,13 @@ CREATE TABLE IF NOT EXISTS `tipam_network` (
|
|||
`id_group` mediumint(8) unsigned NULL default 0,
|
||||
`lightweight_mode` tinyint(2) default 0,
|
||||
`users_operator` text,
|
||||
`id_site` bigint unsigned,
|
||||
`vrf` int(10) unsigned,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE
|
||||
FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
|
@ -4043,7 +4059,9 @@ CREATE TABLE IF NOT EXISTS `tipam_supernet` (
|
|||
`address` varchar(250) NOT NULL,
|
||||
`mask` varchar(250) NOT NULL,
|
||||
`subneting_mask` varchar(250) default '',
|
||||
PRIMARY KEY (`id`)
|
||||
`id_site` bigint unsigned,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue