Unverified Commit 8460a5dc authored by Curtis Conard's avatar Curtis Conard Committed by GitHub
Browse files

UUID for OS-capable Itemtypes (#7418)



* Add UUID to OS-capable devices

Update changelog

* Add missing default schema changes

* Add missing keys

* Fix monitor tests

* Move migration to its own file
Co-authored-by: default avatarJohan Cwiklinski <jcwiklinski@teclib.com>
parent c1ee83a0
......@@ -6,6 +6,7 @@ The present file will list all changes made to the project; according to the
## [x.x.x] unreleased
### Added
- Added UUID to all other itemtypes that are related to Operating Systems (Phones, Printers, etc)
### Changed
......
......@@ -273,6 +273,13 @@ class Monitor extends CommonDBTM {
<textarea cols='45' rows='10' name='comment' >".$this->fields["comment"]."</textarea>";
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>".__('UUID')."</td>";
echo "<td>";
Html::autocompletionTextField($this, 'uuid');
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>".__('Size')."</td>";
echo "<td>";
......
......@@ -395,6 +395,12 @@ class NetworkEquipment extends CommonDBTM {
Html::autocompletionTextField($this, "ram");
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>".__('UUID')."</td>";
echo "<td>";
Html::autocompletionTextField($this, 'uuid');
echo "</td></tr>";
// Display auto inventory informations
if (!empty($ID)
&& $this->fields["is_dynamic"]) {
......
......@@ -275,6 +275,13 @@ class Peripheral extends CommonDBTM {
<textarea cols='45' rows='".($rowspan+3)."' name='comment' >".$this->fields["comment"];
echo "</textarea></td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".__('UUID')."</td>\n";
echo "<td>";
Html::autocompletionTextField($this, 'uuid');
echo "</td>\n";
echo "</tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".__('Brand')."</td>\n";
echo "<td>";
......
......@@ -284,6 +284,13 @@ class Phone extends CommonDBTM {
Html::autocompletionTextField($this, "number_line");
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".__('UUID')."</td>";
echo "<td >";
Html::autocompletionTextField($this, 'uuid');
echo "</td>";
echo "</tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".__('Flags')."</td>";
echo "<td>";
......
......@@ -415,6 +415,12 @@ class Printer extends CommonDBTM {
Html::autocompletionTextField($this, "last_pages_counter", ['size' => 10]);
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>".__('UUID')."</td>\n";
echo "<td>";
Html::autocompletionTextField($this, 'uuid');
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>"._n('Port', 'Ports', Session::getPluralNumber())."</td>";
echo "<td>\n<table>";
......
......@@ -3978,6 +3978,7 @@ CREATE TABLE `glpi_monitors` (
`states_id` int(11) NOT NULL DEFAULT '0',
`ticket_tco` decimal(20,4) DEFAULT '0.0000',
`is_dynamic` tinyint(1) NOT NULL DEFAULT '0',
`uuid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`date_creation` timestamp NULL DEFAULT NULL,
`is_recursive` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
......@@ -3998,6 +3999,7 @@ CREATE TABLE `glpi_monitors` (
KEY `is_dynamic` (`is_dynamic`),
KEY `serial` (`serial`),
KEY `otherserial` (`otherserial`),
KEY `uuid` (`uuid`),
KEY `date_creation` (`date_creation`),
KEY `is_recursive` (`is_recursive`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
......@@ -4112,6 +4114,7 @@ CREATE TABLE `glpi_networkequipments` (
`states_id` int(11) NOT NULL DEFAULT '0',
`ticket_tco` decimal(20,4) DEFAULT '0.0000',
`is_dynamic` tinyint(1) NOT NULL DEFAULT '0',
`uuid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`date_creation` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
......@@ -4132,6 +4135,7 @@ CREATE TABLE `glpi_networkequipments` (
KEY `is_dynamic` (`is_dynamic`),
KEY `serial` (`serial`),
KEY `otherserial` (`otherserial`),
KEY `uuid` (`uuid`),
KEY `date_creation` (`date_creation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
......@@ -4742,6 +4746,7 @@ CREATE TABLE `glpi_peripherals` (
`states_id` int(11) NOT NULL DEFAULT '0',
`ticket_tco` decimal(20,4) DEFAULT '0.0000',
`is_dynamic` tinyint(1) NOT NULL DEFAULT '0',
`uuid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`date_creation` timestamp NULL DEFAULT NULL,
`is_recursive` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
......@@ -4763,6 +4768,7 @@ CREATE TABLE `glpi_peripherals` (
KEY `is_dynamic` (`is_dynamic`),
KEY `serial` (`serial`),
KEY `otherserial` (`otherserial`),
KEY `uuid` (`uuid`),
KEY `date_creation` (`date_creation`),
KEY `is_recursive` (`is_recursive`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
......@@ -4851,6 +4857,7 @@ CREATE TABLE `glpi_phones` (
`states_id` int(11) NOT NULL DEFAULT '0',
`ticket_tco` decimal(20,4) DEFAULT '0.0000',
`is_dynamic` tinyint(1) NOT NULL DEFAULT '0',
`uuid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`date_creation` timestamp NULL DEFAULT NULL,
`is_recursive` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
......@@ -4873,6 +4880,7 @@ CREATE TABLE `glpi_phones` (
KEY `is_dynamic` (`is_dynamic`),
KEY `serial` (`serial`),
KEY `otherserial` (`otherserial`),
KEY `uuid` (`uuid`),
KEY `date_creation` (`date_creation`),
KEY `is_recursive` (`is_recursive`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
......@@ -4986,6 +4994,7 @@ CREATE TABLE `glpi_printers` (
`states_id` int(11) NOT NULL DEFAULT '0',
`ticket_tco` decimal(20,4) DEFAULT '0.0000',
`is_dynamic` tinyint(1) NOT NULL DEFAULT '0',
`uuid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`date_creation` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
......@@ -5008,6 +5017,7 @@ CREATE TABLE `glpi_printers` (
KEY `is_dynamic` (`is_dynamic`),
KEY `serial` (`serial`),
KEY `otherserial` (`otherserial`),
KEY `uuid` (`uuid`),
KEY `date_creation` (`date_creation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
......
......@@ -52,7 +52,8 @@ function update95toXX() {
'domains',
'reservationitem',
'softwares',
'recurrentchange'
'recurrentchange',
'uuids'
];
foreach ($update_scripts as $update_script) {
......
<?php
/**
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2020 Teclib' and contributors.
*
* http://glpi-project.org
*
* based on GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* GLPI is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
/**
* @var DB $DB
* @var Migration $migration
*/
/** Add UUIDs */
$to_add_uuid = ['Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer'];
foreach ($to_add_uuid as $class) {
$migration->addField($class::getTable(), 'uuid', 'string', [
'after' => 'is_dynamic',
'null' => true
]);
$migration->addKey($class::getTable(), 'uuid');
}
......@@ -74,7 +74,8 @@ class Monitor extends DbTestCase {
'ticket_tco' => '0.0000',
'is_dynamic' => 0,
'date_creation' => $date,
'is_recursive' => 0
'is_recursive' => 0,
'uuid' => null,
];
}
......@@ -97,7 +98,7 @@ class Monitor extends DbTestCase {
$monitor = getItemByTypeName('Monitor', '_test_monitor01');
$expected = Monitor::getMonitorFields($added, $date);
$this->array($monitor->fields)->isIdenticalTo($expected);
$this->array($monitor->fields)->isEqualTo($expected);
return $monitor;
}
......@@ -119,6 +120,6 @@ class Monitor extends DbTestCase {
$expected = Monitor::getMonitorFields($added, $date);
$this->array($clonedMonitor->fields)->isIdenticalTo($expected);
$this->array($clonedMonitor->fields)->isEqualTo($expected);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment