You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2011-07-07 13:48:11

aglarendil
Member
Registered: 2011-07-07
Posts: 1

[BUG] Some OCS import Issues does not respect Frequency parameter

Hi, guys.

I want to tell you about some OCS import issues, which affect the correctness of information represented in GLPI

My GLPI version is 0.80.1 and OCS version is 2.0. I do not really know if these issues are OCS 2.0 specific, but they do exist.

1)

While using OCS Import I noticed that RAM used on my servers is not correctly imported into GLPI. I mean, RAM is imported only according to `designation` parameter without any respect to freqeuncy.

Here is an example:

I have two different Server models. The first one is shown in OCS as using DDR2 667 MHz RAM, the second one is using DDR2 533 MHz RAM. So that the `designation` parameter is the same for both types. Here is the code from "commondevice.class.php":

   function import($input) {
      global $DB;

      if (!isset($input['designation']) || empty($input['designation'])) {
         return 0;
      }
      $query = "SELECT `id`
                FROM `".$this->getTable()."`
                WHERE `designation` = '" . $input['designation'] . "'";

      $result = $DB->query($query);
      if ($DB->numrows($result)>0) {
         $line = $DB->fetch_array($result);
         return $line['id'];
      }
      return $this->add($input);
   }
}

Hence, the latter RAM will not be imported. For import to work correctly, I rewrote SQL Query to be used in  @import@ method in devicememoru.class.php :

--- devicememory.class.php.old  2011-07-07 15:46:14.000000000 +0400
+++ devicememory.class.php      2011-07-07 15:37:30.000000000 +0400
@@ -94,6 +94,25 @@
       return $tab;
    }
 
+   function import($input) {
+                global $DB;
+
+                      if (!isset($input['designation']) || empty($input['designation'])) {
+                                       return 0;
+                                             }
+                $query = "SELECT `id` FROM `".$this->getTable()."`
+                        WHERE `designation` = '" . $input['designation'] . "' and `frequence`='" . $input['frequence'] . "'";
+
+                      $result = $DB->query($query);
+                      if ($DB->numrows($result)>0) {
+                                       $line = $DB->fetch_array($result);
+                                                return $line['id'];
+                                             }
+                            return $this->add($input);
+                         }
+
+
+
    /**
     * return the display data for a specific device
     *

2) The second issue is related to disk import from OCS.

OCS shows Spare Drives present in some RAID Devices as "Spare Drive". Thus, the Spare Drives are not added as disks in GLPI.
How to fix:

change preg_match pattern in ocsserver.class.php:

--- ocsserver.class.php.old     2011-07-07 15:45:03.000000000 +0400
+++ ocsserver.class.php 2011-07-07 15:43:05.000000000 +0400
@@ -3425,7 +3425,7 @@
                if ($DBocs->numrows($result2) > 0) {
                   while ($line2 = $DBocs->fetch_array($result2)) {
                      $line2 = clean_cross_side_scripting_deep(addslashes_deep($line2));
-                     if (!empty ($line2["DISKSIZE"]) && preg_match("/disk/i", $line2["TYPE"])) {
+                     if (!empty ($line2["DISKSIZE"]) && preg_match("/disk|spare\sdrive/i", $line2["TYPE"])) {
                         if ($line2["NAME"]) {
                            $dd["designation"] = $line2["NAME"];
                         } else {

Offline

#2 2011-07-07 21:24:39

JMD
GLPI - Lead
Registered: 2004-09-13
Posts: 9,180
Website

Re: [BUG] Some OCS import Issues does not respect Frequency parameter

Thank for your return.

We would study this problem tomorow.

Keep in touch


JMD / Jean-Mathieu Doléans - Glpi-project.org - Association Indepnet
Apportez votre pierre au  projet GLPI   : Soutenir

Offline

#3 2011-07-08 09:24:25

MoYo
GLPI - Lead
From: Poitiers
Registered: 2004-09-13
Posts: 14,513
Website

Re: [BUG] Some OCS import Issues does not respect Frequency parameter

For the first patch, the solution is not so simple because this hack will produce troubles in the sync with already imported memories. I create a ticket to study this problem completly on the forge : https://forge.indepnet.net/issues/2991

I intregated the second.

Regards


MoYo - Julien Dombre - Association INDEPNET
Contribute to GLPI :    Support     Contribute     References     Freshmeat

Offline

Board footer

Powered by FluxBB