Complex linking of datasources (lookup tables)

Hi, I have a complex use case which I hope would be possible to implement with Director.

I am trying to automatically populate host groups based on our naming convention.
I am using vspheredb to import all virtual machines and vm hosts. They all follow the same naming convention. The first 3 characters identify the location of an asset. We may as well work with IP ranges later, but this is where we are.

For instance, a host resource with the name ‘fraxxxxxxxx’ should be assigned to the host group ‘Frankfurt’.

For this, I have setup an import source which consists of a simple query.

select ‘1’ as ‘key’, ‘fra’ as ‘identifier’, ‘Frankfurt’ as ‘location’ union all select ‘2’ as ‘key’, … (and so on and so fourth)

The idea is that I will use modifiers for my vspheredb import, have a field with substring(0,3) and match this against the lookup table for ‘identifier’, then take what is in ‘location’ for my asset.

I don’t think I can use a modifier and the lookup table in the filter expression.
So far I have a modifier like this:

property: object_name
target property: locationidentifier
Modifier: substring
Start: 0
End: 3

This gives me a column with ‘fra’ as locationidentifier

My second modifier is this:

Property: locationidentifier
Target property: location
Set based on filter: yes
Filter Expression: locationidentifier=identifier
Modifier: Get a property from another Import Source
Import Source: location_mapping
Property: location

Unfortunately the location is always empty and I have no idea how to construct the filter to use the value instead of text…

I am trying to give an example here to make it clearer:
My location_mapping source produces the following table:

key identifier location
1 fra Frankfurt
2 wie Wiesbaden

My vspheredb imports an asset with object_name = frablablablubb

My modifier rule 1 applies substring, so that locationidentifier = fra

My modifier rule 2 should do a lookup and pull location (Frankfurt) out of location_mapping, because locationidentifier matched the column identifier.

I hope this makes sense

Why not using a Hostgroup apply rule?

Nah, too simple! :slight_smile:
Thank you, I did not think about this…