ManageIQ - Attach disk to RHV VM using button
Published on Mar 04, 2017 by Sachin.
Post describes a way to attach additional disk to RHV VM using button.
Just to get my hands dirty on ManageIQ’s Automate model, I started working on a way to attach additional disk to VM running on Red Hat Virtualization. Although it can be easily done by “Reconfigure this VM”, I wanted a way to do this via Automate. I did found two ways to do this, one described in Mastering Automation in CloudForms & ManageIQ and other here. Both uses ReST APIs to achieve the task but then I came across this Pull Request which made the job quite easy.
Datastore
I have created a domain – AutomateMIQ which has a custom method
– add_disk
. It is called by instance hot_add_disk
. add_disk
has everything you need to attach new disk to VM including
notifications and email.
Figure 1: Automate datastore
Now datastores can be managed by git as seen below. Enter git repository URL with valid credentials and click submit button.
Figure 2: Use Automate git to manage datastore
Service dialog
One also needs to create a service dialog which prompts for disk
size and disk provisioning type. These fields are then
imported by add_disk
. The disk is then attached based on user
defined parameters. I have imported Add disk service dialog in
form of yaml for reference.
Figure 3: Service dialog prompts for disk size and provisioning type
Button
Finally we need a button to call instance hot_add_disk
. A button
calls request type
“AddDisk” from /System/Process/
as seen
below. Please find button in form of yaml here.
Figure 4: Create button to add disk
A button will be visible under ’Actions’ dropdown on VM’s summary page as below.
Figure 5: Add disk button on VM’s summary page
Notifications
Once the disk is attached, user will be notified.
Figure 6: Notification
Finally, an additional disk will be attached to VM.
Figure 7: Newly attached disk
Note that the feature work on euwe release of ManageIQ. If not already done, please upgrade ManageIQ version following below steps.
1: ssh root@<ManageIQ Appliance> 2: vmdb 3: git fetch --all 4: git checkout euwe-2 5: git checkout -b euwe-2 6: bundle install # or bin/install 7: bundle exec rake evm:compile_assets 8: bundle exec rake evm:restart