Creating a custom import source for Icinga Director

Hi,

Is there some documentation on creating a custom import source (for us a combination of multiple API endpoints from https://www.quattor.org/) for Icinga Director?

And are you able to set the host template imports for a host from data from the import source?

Thanks!

Yes, you can do that. You do that on the sync rule.

Andfor the API import: You will have to play around with it yourself, If you haven’t found anything on the net yourself. The docs only provide a basic example for Active Directory, which is something widely used and not as specific as what you are looking for.

But if you figure out the import/sync why not share a How To with the community :slight_smile:

1 Like

Ah okay thanks for the info. Are there any docs on what the icingaweb2 wants from a module when importing? eg. in this module I picked at random here https://github.com/Icinga/icingaweb2-module-fileshipper/blob/master/library/Fileshipper/ProvidedHook/Director/ImportSource.php which bit do I actually need to pay attention to and in which format should I provide data to the system/which function will be called to do it etc?

I’d suggest to look at the base class for import sources. There are all the required methods defined. Most importantly:

fetchData() is the one method initiating the import. It should return an iterable that provides simple php objects with public properties as columns. (e.g. `(object) [‘foo’ => ‘bar’])

Further down are two methods you might override if you require further configuration for your import source.

2 Likes

Thank you very much! This has definitely helped me get to a stage that looks like it should import stuff!
I’d like the user when setting up the import source to be able to select any number of ‘personalities’ (an array of values that I’ll give them to choose from, of which they can choose many). What would be the best way to do this with your Form classes?


Thanks!

1 Like

Ah looks like an ExtensibleSet is what I need!

    $form->addElement('ExtensibleSet', 'personalities', array(
        'label'    => $form->translate('Personalities'),
        'required' => true,
        'value'    => $aq->getPersonalities()
    ));