Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icinga Director Import Source CoreAPI does not work in current state #2763

Closed
Donien opened this issue Jun 6, 2023 · 1 comment
Closed
Labels
Milestone

Comments

@Donien
Copy link

Donien commented Jun 6, 2023

Expected Behavior

The Director should be able to import objects (e.g. hosts) with their attributes from icinga2 API using a Director Import Source (Source Type: CoreAPI).

Current Behavior

The Director is not able to import anything at all apart from the actual object_name.
Thus you get a list of all the object names but nothing else.

Possible Solution

The problem seems to lie within library/Director/Import/ImportSourceCoreApi.php.

The function that lists the columns checks wether the variable data is empty or not. This variable however does not seem to be set anywhere and thus nothing gets listed (defaulting to only the object_name).

Comparing this to other Import Sources a simple fix seems to be to rename data to res.
We tried that and instantly had success, giving us a list of the other columns as well.

Current:

public function listColumns()
{
    $res = $this->fetchData();
    if (empty($data)) {
        return array('object_name');
    }

    return array_keys((array) $res[0]);
}

Fixed:

public function listColumns()
{
    $res = $this->fetchData();
    if (empty($res)) {
        return array('object_name');
    }

    return array_keys((array) $res[0]);
}

Steps to Reproduce

Create an Import Source

  • Source Type: CoreAPI
  • Key column name: object_name
  • Object type: Hosts

and then Store and Check for changes.
Now look at the preview. object_name is the only available column.

Environment

  • Director version: 1.10.2
  • Icinga Web 2 version and modules: 2.11.4
  • Icinga 2 version: r2.13.7-1
  • Operating System and version: Debian 11 (bullseye)
  • Apache Webserver: Apache/2.4.56 (Debian)
  • PHP: 7.4.33
@Thomas-Gelf Thomas-Gelf added the bug label Jun 6, 2023
@Thomas-Gelf Thomas-Gelf added this to the v1.11.0 milestone Jun 6, 2023
@Thomas-Gelf
Copy link
Contributor

Good catch, thank you! Just for the records, the ImportSource worked as expected even without this change, all properties got imported. As you correctly figured out, they didn't show up as available columns. Therefore, preview didn't show them - while they where there and usable.

Not sure why this didn't get noticed before, probably because this ImportSource is rarely used in the real world. Usually there isn't much one wants to import from Icinga into the Director, as it's configuration comes from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants