Red Hat

Men and Mice API Client Gem for Ruby

Part of what I am doing these days is integrating Red Hat CloudForms / ManageIQ with the Men and Mice IP address management (IPAM) application. In order to reduce gem dependencies, reduce duplication, and handle some architecture issues I have been working on a client gem that uses the JSON-RPC API provided by Men and Mice.

If you are using Ruby and want to integrate with M&M please check out the gem and provide any feedback you have through Github issues.

The gem:
The source:

Helper utility for ManageIQ/CloudForms Automate

As I do Automate development on RedHat CloudForms I am seeing a lot of copy/paste code which is the opposite of DRY. Our process was to put commonly used code in a starting template for an Automate method. This is nice because someone new to development gains the experience of a nice starting point, but it results in a lot of extra code. We also lose the benefit of bug fixes to the helper methods.

To try and reduce the amount of copy/paste coding going on I created a Ruby gem that contains commonly used code and can be distributed via the standard gem installation mechanism. Its current focus is on logging and a few miscellaneous helpers.

More details can be found in the README on the github repo:

Feel free to try it out and submit bug reports or pull requests.

Getting ManageIQ instance attributes without executing methods/states

I want to use the values from the ProvisionRequestQuotaVerification instance. The problem is that using $evm.instantiate will cause the code to run. This results in an exception or error.

Digging around I found


Which works as long as you know the full path including the domain, but then you can not rely on domain inheritance.

my_instance = $evm.instance_get("/ManageIQ/Infrastructure/VM/Provisioning/StateMachines/ProvisionRequestQuotaVerification/default")

Here is my current workaround:

# Sending a fake message does not invoke the state because it is
# tied to the create message.
fake_message = "doesnotreallywork"
empty_instance = $evm.instantiate("/Infrastructure/VM/Provisioning/StateMachines/ProvisionRequestQuotaVerification/Default##{fake_message}")
# Unfortunately so are the attributes. However, now we know the real
# name of the resolved instance and can use that to get our attributes.
instance_name =
my_instance = $evm.instance_get(instance_name)
$evm.log(:info, "The instance contains: #{my_instance.inspect}

Red Hat CloudForms/ManageIQ – Examples

For me, one of the easier ways to begin to learn something is to learn by example. Even if the example does not solve my exact problem, I can use it to figure out ways of extracting the information I need and patterns for implementing new functionality. As a response to a forum question regarding provisioning approvals, Kevin Morey pointed out a Github repository that I was unaware of ( This repo is a great source of example code to get you started exploring more advanced usage of CloudForms.

I would suggest that reading the docs and playing the the code enough to feel comfortable with it are critically important if you plan to use CloudForms or ManageIQ, but this is a great reference for one way of solving the problem.