We want to programmatically retrieve the instances of a class


#1

Hello, everyone,

We have created a tree structure with namespaces, classes and instances.

My question, how from a class it is possible to retrieve by programming all the instances that are under the class.

Thank you for your help.


#2

You can access ManaeIQs internal Rails objects from Automate, like this

id = MiqAeClass.where(name: 'class_name').first.id
MiqAeInstance.where(class_id: id)

Can you explain what you are trying to achieve? Accessing the Automate Domain like this sounds like something you should not have to do.


#3

Thank you for your feedback.

We have created a tree structure that saves our configurations for each of our environments. We have an automate class that contains an entry (instance) and each instance contains fields for an environment.

As we can have more than 30 environments and we need to load these environments into a dropdown, I would like to go read and load them by programming into the dropdown instead of doing them by hand.

Datastore

  • Config (namespace)
    • environment (class)
      • name of environment (instance)
      • name of environment (instance)
      • name of environment (instance)
      • etc

I hope it’s clearer…

Thank


#4

We have basically the same setup in our configuration domain.
However we also have a tag category “environment”, which has a tag for each environment, that matches the instance name and use that, whenever we need a list of all the environments.

If you want (need) that environment class to be the source of truth for your environments, that’s probably the way to go (at least I can’t think of anything better from the top of my head).

I was just wondering if you are trying to do something, that would be better handled with relations (not in this case)