Syncing timeperiods from MySQL Database

This forum was archived to /woltlab and is now in read-only mode.
  • Hi,


    is it possible to sync timeperiods from a MySQL source?


    At https://github.com/Icinga/icin…odule-director/issues/141 it says "import source must of course ship nested data "ranges": { "monday": "00:00-24:00" }"

    Is it possible to ship such nested data from a MySQL source, and if so, how? Naively, I simply tried to create a SQL table as follows:

    Code
    1. mysql> describe Timeperiods;
    2. +-------+--------------+------+-----+---------+----------------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +-------+--------------+------+-----+---------+----------------+
    5. | id | int(11) | NO | PRI | NULL | auto_increment |
    6. | name | varchar(255) | NO | | NULL | |
    7. | range | varchar(255) | NO | UNI | NULL | |
    8. +-------+--------------+------+-----+---------+----------------+
    9. 3 rows in set (0.00 sec)


    and then set the range field to the JSON string as above.


    The import source DB query is SELECT name,`range` FROM Timeperiods;. The sync rule sets ranges to ${range} and object_name to ${name}. When I do the sync, I get objects as follows:


    Code
    1. object TimePeriod "test" {
    2. import "legacy-timeperiod"
    3. ranges = {
    4. "0" = "\"ranges\": { \"monday\": \"00:00-24:00\" }"
    5. }
    6. }

    This is obviously not what I wanted. Is there a way to do it?

  • Hi

    I have the same Problem. Only, I use LDAP as my datasource. I can write "Import source" that builds an attribute that looks like this:


    "monday = 00:00 - 24:00"


    But I can't forge a sync rule that would result in something like this:


    Code
    1. object TimePeriod "test" {
    2. import "legacy-timeperiod"
    3. ranges = {
    4. "monday" = "00:00-24:00"
    5. }
    6. }

    What I get is like:


    Code
    1. object TimePeriod "test" {
    2. import "legacy-timeperiod"
    3. ranges = {
    4. "0" = "monday = 00:00 - 24:00"
    5. }
    6. }

    Has anyone managed to write a sync rule that works as expected?