Refers to ticket #2235

Improve OCS computers Fusion by using the GLPI rules engine

Goal : replace existing parameters in Mode OCSNG configuration to perform automatic fusion between a computer in GLPI and comping from external softwares (like OCS Inventory NG).
Theses parameters are not precise enough to cover all the cases.

Rules Engine

  • Add a new type of Rule : RuleImportComputer
  • The engine stop at the first matched rule
  • Improve management of criterias : can have special criteria "is equal" only for this type or rule

Criteria :

  • Target entity : is / is not / regex / equal
  • Serial number : is / is not / regex / equal
  • Name : blank / equal / is / regex / blank
  • Mac Address : is / is not / regex / equal
  • IP Address : is / is not / regex / equal
  • TAG : is/is not/regex / empty

Actions :

  • Fusion if possible, otherwise refuse import
  • Fusion if possible, otherwise import
  • Ignore from import : yes

Rules engine stop at the first matched rule.

With theses criteria and actions the ocs import can be very precisely controlled.
  • possibility to define special fusion rules by entity (using the Target entity criterion)
  • can globally refuse import of some computers based on some rules
  • can chain rules, so that the administrator can define several rules

Devices where we apply this criterias

  • Computers

Impact on the Rule engine

It is not currenlty possible to handle the criterion's condition : is equal.
Introduce a 2 way process in Rule->checkCriterias() :
  1. check standard conditions : is / is not / regex machtes / begin with / end with / contains
  2. check complex conditions : is equal
For RuleLinkComputer :
  • standard checks : for example "serial is not 'To be Filled by OEM'
  • complex checks : 'serial is already present in GLPI' & 'Mac address is already present in GLPI'. Need to build our own request
Actions :
  • the 3 actions as defined above : import / fusion / refuse import
OCS Import process :
  • replace old link code with the rule engine
  • ocsProcessComputer now returns an array('status'=>www, 'entities_id' => xxx, 'rule_matched' => zzz)

status : the status : imported / synchronized / failed entity assignation rules / linked / cannot import because import is refused / nothing to do
entities_id : the entity in which the computer is imported/synchronized or in which is should have been imported (interesting in massocsimport to present import statistics by entity, or to improve fusion rules)
rule_matched : the last rule that matched (can be RuleOCS or RuleLinkComputer)

  • improve manual import by displaying live staticts (the same as the ones in massocsimport plugin) => done
Migration / install :
  • replace static criteria in OCSNG mode by a rule. During migration, create a rule with all the static parameters
  • during install, do not create any rule