Miscellaneous Tips
Updating the Appliance
When a minor update to CloudForms Management Engine is released and installed (e.g. 5.4.1 -> 5.4.2), any changes to the Automate code are not automatically visible to the Automate Explorer. Go to Import / Export, and Reset all Datastore custom classes and instances to default to get the updates added and visible.
The ManageIQ Coding Style and Standards Guide
There is a ManageIQ Coding Style and Standards Guide here, and a Ruby Style Guide here. Although the guides don't specifically refer to Automation Coding style (it's more a guideline for ManageIQ code development), we can adopt the recommendations to keep our code clean and standards-compliant.
The guides recommend naming Instances in CamelCase and Methods in snake_case, i.e.
Defensive Programming
The dynamic nature of the object structure means that we have to be more careful about testing for nil conditions, testing whether hash keys exist before we access them, test whether variables are enumerable before we call .each on them, etc.
Some examples are:
if this_object.respond_to?(:attributes)
if this_object.attributes.respond_to? :each
this_object.attributes.each do |key, value|
...
user = $evm.root['user'] rescue nil
unless user.nil?
...
prov = $evm.root['miq_provision']
if prov.options.key?(:ws_values)
ws_values = prov.options[:ws_values]
...
Use an External IDE
The in-built WebUI code editor is fairly basic. It is often easier to develop in an external editor or IDE, and copy and paste code into the in-built editor when complete.
Version Control
There isn't any (yet). Git integration for the Automation Datastore is planned for a future release of ManageIQ/CloudForms. In the meantime, use a separate Git repository, but this is a manual process unfortunately.
Several of Red Hat's US consultants including Cameron Wyatt and Alex Smith have created a really cool open source project for doing version control/Continuous Integration of CloudForms automate, dialogs, etc. across regions.
This project provides a Continuous Integration (CI) pipeline for ManageIQ region data using Jenkins. It provides a pipeline view that allows you to visualize which version of region data (automate domains, dialogs, service catalogs, etc.) is in a region at a given time.
See https://github.com/rhtconsulting/miq-ci for more information.