User Tools

Site Tools


extensions:itop-data-collector-base

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
extensions:itop-data-collector-base [2019/11/12 10:27]
vdumas [Data Collector Base]
extensions:itop-data-collector-base [2020/07/07 18:47] (current)
Line 4: Line 4:
 description_wiki : Inventory Data Collector toolkit for creating your own data collectors for iTop description_wiki : Inventory Data Collector toolkit for creating your own data collectors for iTop
 index_hidden ​    : yes index_hidden ​    : yes
-version ​         : 1.1.2 +version ​         : 1.1.4 
-release_dt ​      : ​2019-11-07 +release_dt ​      : ​2020-07-07 
-itop-version-min :  +code             : ​itop-data-collector-base 
-download_url ​    http://​www.combodo.com/​itop-extensions/​itop-data-collector-base-1.1.2-496.zip+state            ​stable 
 +product_hidden ​  not-included 
 +module-lists_hidden ​: itop-data-collector-base/1.1.
 +diffusion ​       : Client Store, Combodo Site
 ---- ----
  
Line 13: Line 16:
  
  
-This module provides the base for creating an industrial data collection and synchronization application for iTop. Developers can rely on this module to perform all the heavy lifting related to the iTop data import and synchronization process in order to focus on the data collection. 
  
 +This module provides the base for creating an industrial data collection and synchronization application for iTop. Developers can rely on this module to perform all the heavy lifting related to the iTop data import and synchronization process in order to focus on the data collection.
  
 +|  [[http://​www.combodo.com/​itop-extensions/​itop-data-collector-base-1.1.4-592.zip|Download 1.1.4]] ​ |
 ===== Features ===== ===== Features =====
  
Line 34: Line 38:
 ===== Revision History ===== ===== Revision History =====
 ^  Release Date  ^  Version ​ ^  Comments ​ ^ ^  Release Date  ^  Version ​ ^  Comments ​ ^
 +|  2020-06-24 ​ |  1.1.4  | * The path to the configuration file can now be specified via the option ''<​nowiki>​--config_file</​nowiki>''​ on the command line.\\ * The location where to store the collected data is now a parameter in the configuration file: ''​data_path''​.\\ * Better checking of Data Source definitions ​ to catch missing reconciliation keys\\ * Option on the Lookuptable class to treat lookup errors as normal|
 +|  2020-04-30 ​ |  1.1.3  | * New CSV collector \\ * Configurable timestamp added in the logs \\ * New option for usage: --help|
 |  2019-11-07 ​ |  1.1.2  | Fix "​undefined constant TABLENAME_PATTERN"​ | |  2019-11-07 ​ |  1.1.2  | Fix "​undefined constant TABLENAME_PATTERN"​ |
 |  2019-10-28 ​ |  1.1.1  | Contains upgrades from both 1.0.13 and 1.1.0 \\ * Reject invalid characters for database_table_name | |  2019-10-28 ​ |  1.1.1  | Contains upgrades from both 1.0.13 and 1.1.0 \\ * Reject invalid characters for database_table_name |
Line 95: Line 101:
 | stop_on_synchro_error | Whether or not to stop when an error occurs during a synchronization (''​yes''​ or ''​no''​). | no | | stop_on_synchro_error | Whether or not to stop when an error occurs during a synchronization (''​yes''​ or ''​no''​). | no |
 | console_log_level | Level of ouput to the console. From -1 (none) to 9 (debug). | 6 (info) | | console_log_level | Level of ouput to the console. From -1 (none) to 9 (debug). | 6 (info) |
 +| console_log_dateformat| Logger timestamp format | [Y-m-d H:i:s] |
 | curl_options | When using cUrl to connect to the iTop Webservices the cUrl options can be specified in this section. The syntax is <​CURLOPT_NAME_OF_THE_OPTION1>​VALUE_1</​CURLOPT_NAME_OF_THE_OPTION1>​ where VALUE_x are either:\\ The numeric value of the option,\\ or the string representation of the corresponding PHP "​define"​ (case sensitive).\\ It is possible to define several php_curl options like in the example below| ​ | | curl_options | When using cUrl to connect to the iTop Webservices the cUrl options can be specified in this section. The syntax is <​CURLOPT_NAME_OF_THE_OPTION1>​VALUE_1</​CURLOPT_NAME_OF_THE_OPTION1>​ where VALUE_x are either:\\ The numeric value of the option,\\ or the string representation of the corresponding PHP "​define"​ (case sensitive).\\ It is possible to define several php_curl options like in the example below| ​ |
 +| data_path | **New in 1.1.4** The path where to store the temporary files generated by the collector. You can use the special placeholder ''​%APPROOT%''​ to specify a pth relative to the root folder of the collector. | ''​%APPROOT%/​data''​ |
 <note tip> <note tip>
 <​code>​ <​code>​
 <​curl_options>​ <​curl_options>​
-    <​CURLOPT_SSLVERSION>​CURL_SSLVERSION_SSLv3</​CURLOPT_SSLVERSION>​ 
     <​CURLOPT_SSL_VERIFYHOST>​0</​CURLOPT_SSL_VERIFYHOST>​     <​CURLOPT_SSL_VERIFYHOST>​0</​CURLOPT_SSL_VERIFYHOST>​
     <​CURLOPT_SSL_VERIFYPEER>​1</​CURLOPT_SSL_VERIFYPEER>​     <​CURLOPT_SSL_VERIFYPEER>​1</​CURLOPT_SSL_VERIFYPEER>​
Line 120: Line 126:
  
 ^ Option ^ Meaning ^ default value ^ ^ Option ^ Meaning ^ default value ^
 +| <​nowiki>​--config_file</​nowiki>​ | Specify the full path to the configuration file. The file ''​conf/​params.local.xml''​ is used by default if this parameter is omitted. | empty |
 | <​nowiki>​--console_log_level=<​level></​nowiki>​ | Level of ouput to the console. From -1 (none) to 9 (debug). | 6 (info) | | <​nowiki>​--console_log_level=<​level></​nowiki>​ | Level of ouput to the console. From -1 (none) to 9 (debug). | 6 (info) |
 | <​nowiki>​--collect_only</​nowiki>​ | Run only the data collection, but do not synchronize the data with iTop | false | | <​nowiki>​--collect_only</​nowiki>​ | Run only the data collection, but do not synchronize the data with iTop | false |
Line 125: Line 132:
 | <​nowiki>​--configure_only</​nowiki>​ | Check (and update if necessary) the synchronization data sources in iTop and exit. Do NOT run the collection or the synchronization | | <​nowiki>​--configure_only</​nowiki>​ | Check (and update if necessary) the synchronization data sources in iTop and exit. Do NOT run the collection or the synchronization |
 | <​nowiki>​--max_chunk_size=<​size></​nowiki>​ | Maximum number of items to process in one pass, for preserving the memory of the system. If there are more items to process, the application will iterate. | 1000 | | <​nowiki>​--max_chunk_size=<​size></​nowiki>​ | Maximum number of items to process in one pass, for preserving the memory of the system. If there are more items to process, the application will iterate. | 1000 |
 +| <​nowiki>​--help</​nowiki>​ | Usage mode to display exec.php help. | |
  
 +==== Running several instances of the collector ====
 +
 +In many circumstances it may be useful to run several times the collector with a different set of parameters. For example to collect persons information from several LDAP servers (iTop Data Collector for LDAP) or Virtual Machines information from several vSphere servers (iTop Data Collector for vSphere).
 +
 +Prior to version 1.1.4 of the framework, you had to completely duplicate the collector application and adjust the file ''​conf/​params.local.xml''​ on each copy.
 +
 +Since version 1.1.4 you can have just one single copy the of the collector application and specify a different configuration file (with the command line option ''<​nowiki>​--config_file</​nowiki>''​) for each collection to run (i.e. one configuration file per LDAP or vSphere server).
 +
 +However, to avoid any troubles during the collection of the data and the synchronization with iTop, the following parameters must be properly configured inside the configuration file:
 +  * Use a different ''<​prefix>''​ inside each different configuration file. This ensures that a specific set of Synchronization Data Sources will be created for each configuration file.
 +  * Use a different ''<​data_path>''​ variable for each configuration file. This will cause the collector to store all its collected data (including some temporary files) in a dedicated directory. This prevents one instance of the collector to overwrite the data of another one. You can use the syntax ''<​data_path>​%APPROOT%/​data/​collector1</​data>''​ to have a subfolder ''​collector1''​ created inside the ''​data''​ folder.
 +
 + 
 ===== Creating a collector ===== ===== Creating a collector =====
  
Line 752: Line 773:
 </​code>​ </​code>​
  
-Then in ''​params.distrib.xml'',​ add the foollowing ​entries:+Then in ''​params.distrib.xml'',​ add the following ​entries:
 <code xml> <code xml>
   <​sql_database>​test</​sql_database>​   <​sql_database>​test</​sql_database>​
Line 770: Line 791:
 require_once(APPROOT.'​collectors/​DocumentNoteCollector.class.inc.php'​);​ require_once(APPROOT.'​collectors/​DocumentNoteCollector.class.inc.php'​);​
 Orchestrator::​AddCollector(1 /* $iRank */, '​DocumentNoteCollector'​);​ Orchestrator::​AddCollector(1 /* $iRank */, '​DocumentNoteCollector'​);​
 +</​code>​
 +
 +==== CSV Collector ====
 +
 +The '​core'​ folder provides an abstract class ''​CSVCollector''​ which can serve as the basis for quickly creating collectors that retrieve their data from CSV files.
 +
 +To create such a collector you need to:
 +  - Create a class derived from CSVCollector
 +  - Create the json definition file for the data synchro source
 +  - Add a configuration parameter (in ''​params.distrib.xml''​) to define the CSV file to parse
 +  - Register your collector in ''​collectors/​main.php''​
 +
 +The configuration parameters for the CSV Collectors are:
 +
 +^ Parameter ^ Meaning ^ Default Value ^
 +| //​collector_class//​_csv | The csv file to parse for the collector which PHP class is. You can specify the full path of this file (/​tmp/​myfile.csv) or a relative path to the collector //​collector_class//​. This parameter is mandatory | |
 +| //​collector_class//​_command | The CLI command to execute BEFORE parsing csv file for the collector which PHP class is //​collector_class//​. This parameter is optional | |
 +| //​collector_class//​_encoding | The csv file encoding for the collector which PHP class is //​collector_class//​. This parameter is optional| UTF-8|
 +| //​collector_class//​_separator| The separator to use for the csv file to parse. This parameter is optional| ;|
 +
 +=== Example of a simple CSV Collector ===
 +
 +Let's create a very simple CSV collector which copies the "​Person"​ objects (class Person)
 +
 +Since the collector inherits all its behavior from the base class, the PHP code for the collector is simply:
 +
 +<code php iTopPersonCsvCollector.class.inc.php>​
 +<?php
 +class iTopPersonCsvCollector extends CSVCollector
 +{
 +}
 +</​code>​
 +
 +The JSON definition file is
 +<code json iTopPersonCsvCollector.json>​
 +{
 + "​name":​ "​$prefix$Synchro CSV Person",​
 + "​description":​ "​Synchronization of persons from CSV",
 + "​status":​ "​$synchro_status$",​
 + "​user_id":​ "​$synchro_user$",​
 + "​notify_contact_id":​ "​$contact_to_notify$",​
 + "​scope_class":​ "​Person",​
 + "​database_table_name":​ "​$persons_data_table$",​
 + "​scope_restriction":​ "",​
 + "​full_load_periodicity":​ "​$full_load_interval$",​
 + "​reconciliation_policy":​ "​use_primary_key",​
 + "​action_on_zero":​ "​create",​
 + "​action_on_one":​ "​update",​
 + "​action_on_multiple":​ "​error",​
 + "​delete_policy":​ "​ignore",​
 + "​delete_policy_update":​ "",​
 + "​delete_policy_retention":​ "​0",​
 + "​attribute_list":​ [
 + {
 + "​attcode":​ "​cis_list",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​row_separator":​ "​|",​
 + "​attribute_separator":​ ";",​
 + "​value_separator":​ ":",​
 + "​attribute_qualifier":​ "'",​
 + "​finalclass":​ "​SynchroAttLinkSet",​
 + "​friendlyname":​ "​cis_list"​
 + },
 + {
 + "​attcode":​ "​email",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​1",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​email"​
 + },
 + {
 + "​attcode":​ "​employee_number",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​employee_number"​
 + },
 + {
 + "​attcode":​ "​first_name",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​1",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​first_name"​
 + },
 + {
 + "​attcode":​ "​function",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​function"​
 + },
 + {
 + "​attcode":​ "​location_id",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​reconciliation_attcode":​ "​name",​
 + "​finalclass":​ "​SynchroAttExtKey",​
 + "​friendlyname":​ "​location_id"​
 + },
 + {
 + "​attcode":​ "​manager_id",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​reconciliation_attcode":​ "​email",​
 + "​finalclass":​ "​SynchroAttExtKey",​
 + "​friendlyname":​ "​manager_id"​
 + },
 + {
 + "​attcode":​ "​mobile_phone",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​mobile_phone"​
 + },
 + {
 + "​attcode":​ "​name",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​1",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​name"​
 + },
 + {
 + "​attcode":​ "​notify",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​notify"​
 + },
 + {
 + "​attcode":​ "​org_id",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​1",​
 + "​update_policy":​ "​master_locked",​
 + "​reconciliation_attcode":​ "​name",​
 + "​finalclass":​ "​SynchroAttExtKey",​
 + "​friendlyname":​ "​org_id"​
 + },
 + {
 + "​attcode":​ "​phone",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​phone"​
 + },
 + {
 + "​attcode":​ "​status",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​status"​
 + },
 + {
 + "​attcode":​ "​team_list",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​row_separator":​ "​|",​
 + "​attribute_separator":​ ";",​
 + "​value_separator":​ ":",​
 + "​attribute_qualifier":​ "'",​
 + "​finalclass":​ "​SynchroAttLinkSet",​
 + "​friendlyname":​ "​team_list"​
 + }
 + ],
 + "​user_delete_policy":​ "​nobody",​
 + "​url_icon":​ "",​
 + "​url_application":​ "",​
 + "​notify_contact_id_obsolescence_flag":​ ""​
 +}
 +</​code>​
 +
 +Then in ''​params.distrib.xml'',​ add the following entries:
 +<code xml>
 +<?xml version="​1.0"​ encoding="​UTF-8"?>​
 +<​parameters>​
 +  <​iTopPersonCsvCollector_csv>​collectors/​iTopPersonCsvCollector.csv</​iTopPersonCsvCollector_csv>​
 +  <​iTopPersonCsvCollector_command>​sed -i -e '​s|isaac|ISAAC|g'​ collectors/​iTopPersonCsvCollector.csv</​iTopPersonCsvCollector_command>​
 +  <​iTopPersonCsvCollector_encoding>​UTF-8</​iTopPersonCsvCollector_encoding>​
 +</​parameters>​
 +</​code>​
 +
 +Finally, in ''​collectors/​main.php''​ add the following lines:
 +
 +<code php main.php>​
 +<?php
 +require_once(APPROOT.'​collectors/​iTopPersonCsvCollector.class.inc.php'​);​
 +Orchestrator::​AddCollector($index++,​ '​iTopPersonCsvCollector'​);​
 +</​code>​
 +
 +
 +
 +==== JSON Collector ====
 +
 +The '​core'​ folder provides an abstract class ''​JSONCollector''​ which can serve as the basis for quickly creating collectors that retrieve their data from JSON files.
 +
 +To create such a collector you need to:
 +  - Create a class derived from JSONCollector
 +  - Create the json definition file for the data synchro source
 +  - Add a configuration parameter (in ''​params.distrib.xml''​) to define the JSON file to parse
 +  - Register your collector in ''​collectors/​main.php''​
 +
 +The configuration parameters for the JSON Collectors are:
 +
 +^ Parameter ^ Meaning ​ ^
 +| //​collector_class//​_jsonfile | Define relative or absolute path to the json file to parse for the collector which PHP class is collector //​collector_class//​. This parameter or  //​collector_class//​_jsonurl is mandatory | 
 +| //​collector_class//​_jsonurl | The URL of json file to parse for the collector which PHP class is. This parameter or //​collector_class//​_jsonpath is mandatory | 
 +| //​collector_class//​_jsonpost | Xml of params to post with the url in order to get Json file //<​name_of_param>​value</​name_of_param>//​| ​
 +| //​collector_class//​_command | The CLI command to execute BEFORE parsing json file for the collector which PHP class is //​collector_class//​. This parameter is optional | 
 +| //​collector_class//​_way| way in order to find data to synchronize in json separator is / and * replace any word       //by example aa/bb for {"​aa":​{"​bb":​{mydata},"​cc":"​xxx"​} and aa/ * /bb  for {"​aa":​{cc":​{"​bb":​{mydata1}},"​dd":​{"​bb":​{mydata2}}}//​|
 +| //​collector_class//​_fields| xml witch describe connection between name in json and name in itop  // <​name_in_json>​name_in_itop</​name_in_json>​ //|
 +
 +=== Example of a simple JSON Collector ===
 +
 +Let's create a very simple JSON collector which copies the "​Person"​ objects (class Person) from one iTop to another
 +
 +Since the collector inherits all its behavior from the base class, the PHP code for the collector is simply:
 +
 +<code php ITopPersonJsonCollector.class.inc.php>​
 +<?php
 +class ITopPersonJsonCollector extends JsonCollector
 +{
 +}
 +</​code>​
 +
 +The JSON definition file is
 +<code json ITopPersonJsonCollector.json>​
 +{
 + "​name":​ "​Persons from JSON",
 + "​description":​ "",​
 + "​status":​ "​implementation",​
 + "​user_id":​ "​$synchro_user$",​
 + "​notify_contact_id":​ "​$contact_to_notify$",​
 + "​scope_class":​ "​Person",​
 + "​database_table_name":​ "​synchro_data_person_1",​
 + "​scope_restriction":​ "",​
 + "​full_load_periodicity":​ "​0",​
 + "​reconciliation_policy":​ "​use_attributes",​
 + "​action_on_zero":​ "​create",​
 + "​action_on_one":​ "​update",​
 + "​action_on_multiple":​ "​error",​
 + "​delete_policy":​ "​ignore",​
 + "​delete_policy_update":​ "",​
 + "​delete_policy_retention":​ "​0",​
 + "​attribute_list":​ [
 + {
 + "​attcode":​ "​cis_list",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​row_separator":​ "​|",​
 + "​attribute_separator":​ ";",​
 + "​value_separator":​ ":",​
 + "​attribute_qualifier":​ "'",​
 + "​finalclass":​ "​SynchroAttLinkSet",​
 + "​friendlyname":​ "​cis_list"​
 + },
 + {
 + "​attcode":​ "​civility",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​civility"​
 + },
 + {
 + "​attcode":​ "​email",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​1",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​email"​
 + },
 + {
 + "​attcode":​ "​employee_number",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​employee_number"​
 + },
 + {
 + "​attcode":​ "​first_name",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​1",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​first_name"​
 + },
 + {
 + "​attcode":​ "​function",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​function"​
 + },
 + {
 + "​attcode":​ "​location_id",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​reconciliation_attcode":​ "",​
 + "​finalclass":​ "​SynchroAttExtKey",​
 + "​friendlyname":​ "​location_id"​
 + },
 + {
 + "​attcode":​ "​manager_id",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​reconciliation_attcode":​ "",​
 + "​finalclass":​ "​SynchroAttExtKey",​
 + "​friendlyname":​ "​manager_id"​
 + },
 + {
 + "​attcode":​ "​mobile_phone",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​mobile_phone"​
 + },
 + {
 + "​attcode":​ "​name",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​1",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​name"​
 + },
 + {
 + "​attcode":​ "​notify",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​notify"​
 + },
 + {
 + "​attcode":​ "​org_id",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​1",​
 + "​update_policy":​ "​master_locked",​
 + "​reconciliation_attcode":​ "",​
 + "​finalclass":​ "​SynchroAttExtKey",​
 + "​friendlyname":​ "​org_id"​
 + },
 + {
 + "​attcode":​ "​phone",​
 + "​update":​ "​1",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​phone"​
 + },
 + {
 + "​attcode":​ "​picture",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​picture"​
 + },
 + {
 + "​attcode":​ "​projects_list",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​row_separator":​ "​|",​
 + "​attribute_separator":​ ";",​
 + "​value_separator":​ ":",​
 + "​attribute_qualifier":​ "'",​
 + "​finalclass":​ "​SynchroAttLinkSet",​
 + "​friendlyname":​ "​projects_list"​
 + },
 + {
 + "​attcode":​ "​status",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​status"​
 + },
 + {
 + "​attcode":​ "​team_list",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​row_separator":​ "​|",​
 + "​attribute_separator":​ ";",​
 + "​value_separator":​ ":",​
 + "​attribute_qualifier":​ "'",​
 + "​finalclass":​ "​SynchroAttLinkSet",​
 + "​friendlyname":​ "​team_list"​
 + },
 + {
 + "​attcode":​ "​vip",​
 + "​update":​ "​0",​
 + "​reconcile":​ "​0",​
 + "​update_policy":​ "​master_locked",​
 + "​finalclass":​ "​SynchroAttribute",​
 + "​friendlyname":​ "​vip"​
 + }
 + ],
 + "​user_delete_policy":​ "​nobody",​
 + "​url_icon":​ "",​
 + "​url_application":​ "",​
 + "​notify_contact_id_obsolescence_flag":​ ""​
 +}
 +
 +</​code>​
 +
 +Then in ''​params.distrib.xml'',​ add the following entries:
 +<code xml>
 +<?xml version="​1.0"​ encoding="​UTF-8"?>​
 +<​parameters>​
 + <​itoppersonjsoncollector_jsonurl>​http://​localhost/​iTop/​webservices/​rest.php</​itoppersonjsoncollector_jsonurl>​
 + <​itoppersonjsoncollector_jsonpost>​
 + <​auth_user>​restuser</​auth_user>​
 + <​auth_pwd>​restuserpassword</​auth_pwd>​
 + <​json_data>​{"​operation":​ "​core/​get",​ "​class":​ "​Person",​ "​key":​ "​SELECT Person WHERE email LIKE '​%.com'",​ "​output_fields":​ "​friendlyname,​ email, first_name, function, name, id, org_id,​phone"​}</​json_data>​
 + <​version>​1.3</​version>​
 + </​itoppersonjsoncollector_jsonpost>​
 + <​itoppersonjsoncollector_way>​objects/​*/​fields</​itoppersonjsoncollector_way>​
 + <​itoppersonjsoncollector_fields>​
 + <​primary_key>​id</​primary_key>​
 + <​name>​name</​name>​
 + <​status>​status</​status>​
 + <​first_name>​first_name</​first_name>​
 + <​email>​email</​email>​
 + <​phone>​phone</​phone>​
 + <​mobile_phone>​mobile</​mobile_phone>​
 + <​function>​function</​function>​
 + <​employee_number>​employee_number</​employee_number>​
 + <​org_id>​org_id</​org_id>​
 + </​itoppersonjsoncollector_fields>​
 + <​itoppersonjsoncollector_defaults>​
 + <​org_id>​Demo</​org_id>​
 + <​status>​active</​status>​
 + </​itoppersonjsoncollector_defaults>​
 + <​json_placeholders>​
 + <!-- For compatibility with the version 1.1.x of the collector, define the data table names as following:
 + <​prefix></​prefix>​
 + <​persons_data_table>​synchro_data_PersonAD</​persons_data_table>​
 + <​users_data_table></​users_data_table>​
 + -->
 + <​prefix>​$prefix$</​prefix>​
 + <​persons_data_table>​synchro_data_person</​persons_data_table>​
 + </​json_placeholders>​
 +</​parameters>​
 +
 +</​code>​
 +
 +Finally, in ''​collectors/​main.php''​ add the following lines:
 +
 +<code php main.php>​
 +<?php
 +require_once(APPROOT.'​collectors/​ITopPersonJsonCollector.class.inc.php'​);​
 +Orchestrator::​AddCollector($index++,​ '​ITopPersonJsonCollector'​);​
 </​code>​ </​code>​
  
Line 857: Line 1350:
 <note tip> <note tip>
 **Since version 1.0.6**, the ''​Lookup''​ method returns false if not corresponding lookup was found. In such a case the code can either supply a default value, of throw an exception ''​IgnoredRowException''​ to tell the collector to reject the whole line of collected data. **Since version 1.0.6**, the ''​Lookup''​ method returns false if not corresponding lookup was found. In such a case the code can either supply a default value, of throw an exception ''​IgnoredRowException''​ to tell the collector to reject the whole line of collected data.
 +</​note>​
 +
 +<note tip>
 +**Since version 1.1.4**, the constructor of ''​LookupTable''​ accepts one extra (optional) parameter: ''​$bIgnoreMappingErrors''​ (default to ''​false''​). If this parameter is set to ''​true'',​ the ''​LookupTable''​ will consider that lookup errors are //normal// and will not report them as warnings (but still list them in debug mode). This can be useful when the Lookuptable is used for filtering the collected data against a catalog defined in iTop. In such a case, lookup errors are the expected behavior.
 </​note>​ </​note>​
  
Line 952: Line 1449:
  if (!$this->​oOSVersionLookup->​Lookup($aLineData,​ array('​osfamily_id',​ '​osversion_id'​),​ '​osversion_id',​ $iLineIndex))  if (!$this->​oOSVersionLookup->​Lookup($aLineData,​ array('​osfamily_id',​ '​osversion_id'​),​ '​osversion_id',​ $iLineIndex))
  {  {
-     throw New IgnoreRowException('​Unknown OS Version'​);​+     throw New IgnoredRowException('​Unknown OS Version'​);​
  }  }
  if (!$this->​oModelLookup->​Lookup($aLineData,​ array('​brand_id',​ '​model_id'​),​ '​model_id',​ $iLineIndex))  if (!$this->​oModelLookup->​Lookup($aLineData,​ array('​brand_id',​ '​model_id'​),​ '​model_id',​ $iLineIndex))
  {  {
-     throw New IgnoreRowException('​Unknown Model'​);​+     throw New IgnoredRowException('​Unknown Model'​);​
  }  }
 } }
extensions/itop-data-collector-base.1573550863.txt.gz · Last modified: 2019/11/12 10:27 (external edit)

";