Dialogs – Dynamic DropDowns

Its here and looks great. You can now populate a drop down list from an external source!

Simply create an Instance and Method, its advised you create a new Namespace to store dialog controls into rather than mixing them up into the general automation model.

The method requires the following code behind it;

dialog_field = $evm.object</code>

# sort_by: value / description / none
dialog_field["sort_by"] = "value"

# sort_order: ascending / descending
#dialog_field["sort_order"] = "ascending"

# data_type: string / integer
dialog_field["data_type"] = "integer"

# required: true / false
#dialog_field["required"] = "true"

#Return as a hash

dialog_field["values"] = {1 =&gt; "one", 2 =&gt; "two", 10 =&gt; "ten", 50 =&gt; "fifty"}

#Return as an array

dialog_field["values"] = [[1, "one"], [2, "two"], [10, "ten"], [50, "fifty"]]

dialog_field["default_value"] = 2

exit MIQ_OK

So the code is very simple, there are a number of settings you can control such as;

  • data_type
  • sort_order
  • sort_by
  • required

The the values are simply inserted into the drop down as EITHER a hash or array. The above example shows both, you would use either.

The next step is to create a dialog and add the element “Dynamic Dropdown List” to your form and set the NameSpace/Class/Instance to your Instance/Method you created in the previous step.

Screen Shot 2013-10-24 at 11.55.37

And what does it look like when finished?

Screen Shot 2013-10-24 at 11.56.29

The use cases for this are quite large, here are some;

  • Populate the list of Load Balancer Pools available from F5 Big IP, allow the consumer to choose which pool to place their service into.
  • Populate the list with the available AMI’s in Amazon you wish to share off based on a tag.
  • Populate the list with the OpenStack environments available, allowing the user to place their Instance based on that or even linked to department etc..
  • Populate the list with catalogs from a software distribution system to allow the user to have collections of software installed into the service. This could be SCCM, Puppet, Chef etc..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s