Synchro Data Source, Initialize if empty

  • Anonymous - 2012-05-09


    I am doing a first implementation of iTop, and I'm running into a problem with a Synchro Data Source.

    The Synchro Data Source is supposed to sync servers from Puppet. I tried to have a strict distinction between attributes that Puppet has authority over, like hardware specs, and attributes that I want iTop to be the master of: things like serial numbers, locations and owner organisations.

    Now, the Owner organisation is an attribute that cannot be left blank when first creating a Server. If you specify it as "Update: no", the sync will fail if new servers are to be added with this error:

    Unable to create destination object: Object not following integrity rules: issues = Unexpected value for attribute 'org_id': Null not allowed, class = Server, id =

    So, I specified it as "Update: yes, Update policy: Initialize if empty".  Now the sync will run and the server will be added, but every once in a while (not always, it seems!), all other severs will have their Owner Organisation reset to the value from the sync source, which is unexpected and unwanted!

    It seems the "Initialize if empty" setting does not exactly do what it's supposed to. I tried to see if I could find an issue in the code, but I couln't work it out.  I know that the value for the setting is written to the database as 'update_policy' with value 'write_if_empty', but I couldn't find any code that actually uses that setting. I.e. a recursive grep for write_if_empty on the source only yields code for managing the setting, nothing points at the value being used anywhere.

    Is this feature supposed to work? Am I missing something?

    Best regards,

  • DemonCcC

    DemonCcC - 2012-05-09

    Initializate if empty, means that the value will be added if it didn't have any value before the synchronization I guess. id_org couldn't be NULL, you need to put the organization id of the organization that you are using. Export the info of an object and check what is the organization id that your objects are using and modify the script/app that are creating or modifying the entries to the synchro table so it/they can add the correct value to the id_org field.


  • Anonymous - 2012-05-10

    Hi demonccc,

    I understand that the value can't be Null, so when a server is first added, it is okay to just have the default org_id (1). That is not the problem.

    Later, I change the Owner Organisation through the web interface into the correct value. Then I expect the sync process to leave the value alone, since it already has a value and the update policy is set to "Initialize if empty".

    This is not the case.  If no other data is to be synced, the value remains set correctly, but if any other data is to be changed from the sync source, for any server, all the changed org_id values are reset to the default from the sync source.

    Modifying the script so it can add the correct value to the org_id field is an option, but it complicates things more than it should. I use a simple ETL script (got it from the web somewhere) that converts data from the Puppet database to the iTop database. Adding queries to it, so it can get the correct org_id from the iTop database is a big hassle.

    And from a software development point of view, it's just stupid.

    I am convinced that this is a bug in iTop, or a major oversight on my part. If it is the latter, I would like some pointers on how to prevent this behaviour, rather than to invent a silly workaround.

    Like I said in my original post, I wasn't able to find any code that acts on 'write_if_empty' as a value for 'update_policy', so that makes me curious. And even though I have some experience with PHP, iTop's code is too complex to understand and "fix" if you see it for the first time.

    Best regards,

  • Anonymous - 2012-05-10

    Admittedly, executing a query like this:

    UPDATE synchro_data_server_1 s INNER JOIN functionalci f ON = SET s.org_id = f.org_id

    after every ETL run is not a BIG hassle, but it still shouldn't be necessary.

    Best regards,


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks