Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Tagged Vlan #2852

Merged
merged 2 commits into from
Oct 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions inc/formatconvert.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ static function addValues($array, $a_key) {
'pages_n_b_copy', 'pages_color_copy', 'pages_total_fax',
'cpu', 'trunk', 'is_active', 'uptodate', 'nbthreads', 'vcpu', 'ram',
'ifinerrors', 'ifinoctets', 'ifouterrors', 'ifoutoctets', 'ifmtu', 'speed',
'nbcores', 'nbthreads', 'frequency'];
'nbcores', 'nbthreads', 'frequency', 'tagged'];

foreach ($a_key as $key=>$value) {
if (!isset($a_return[$value])
Expand Down Expand Up @@ -2278,7 +2278,8 @@ static function networkequipmentInventoryTransformation($array) {
$array_tmp = $thisc->addValues($a_vlan,
[
'NAME' => 'name',
'NUMBER' => 'tag']);
'NUMBER' => 'tag',
'TAGGED' => 'tagged']);
if (isset($array_tmp['tag'])) {
$a_inventory['vlans'][$a_port['IFNUMBER']][$array_tmp['tag']] = $array_tmp;
}
Expand Down
9 changes: 5 additions & 4 deletions inc/inventorynetworkequipmentlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,13 @@ function importPortVlan($a_vlans, $networkports_id) {
$networkPort_Vlan = new NetworkPort_Vlan();

$db_vlans = [];
$query = "SELECT `glpi_networkports_vlans`.`id`, `glpi_vlans`.`name`, `glpi_vlans`.`tag`
$query = "SELECT `glpi_networkports_vlans`.`id`, `glpi_vlans`.`name`, `glpi_vlans`.`tag`, `glpi_networkports_vlans`.`tagged`
FROM `glpi_networkports_vlans`
LEFT JOIN `glpi_vlans`
ON `vlans_id`=`glpi_vlans`.`id`
WHERE `networkports_id` = '$networkports_id'";
foreach ($DB->request($query) as $data) {
$db_vlans[$data['name']."$$$$".$data['tag']] = $data['id'];
$db_vlans[$data['id']] = $data;
}

if (count($db_vlans) == 0) {
Expand All @@ -634,7 +634,7 @@ function importPortVlan($a_vlans, $networkports_id) {
} else {
foreach ($a_vlans as $key => $arrays) {
foreach ($db_vlans as $keydb => $arraydb) {
if ($arrays['name']."$$$$".$arrays['tag'] == $keydb) {
if ($arrays['name'] == $arraydb['name'] && $arrays['tag'] == $arraydb['tag'] && $arrays['tagged'] == $arraydb['tagged']) {
unset($a_vlans[$key]);
unset($db_vlans[$keydb]);
break;
Expand All @@ -645,7 +645,7 @@ function importPortVlan($a_vlans, $networkports_id) {
if (count($a_vlans) || count($db_vlans)) {
if (count($db_vlans) != 0) {
// Delete vlan in DB
foreach ($db_vlans as $id) {
foreach (array_keys($db_vlans) as $id) {
$networkPort_Vlan->delete(['id'=>$id]);
}
}
Expand Down Expand Up @@ -685,6 +685,7 @@ function addVlan($a_vlan, $networkports_id) {
$input = [];
$input['networkports_id'] = $networkports_id;
$input['vlans_id'] = $vlans_id;
$input['tagged'] = $a_vlan['tagged'];
$networkPort_Vlan->add($input);
}

Expand Down