ManageIQ - Attach disk to RHV VM using button
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.
Automate datastore
Now datastores can be managed by git
as seen
below. Enter git repository URL with valid credentials and click
submit button.
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.
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.
Create button to add disk
A button will be visible under ‘Actions’ dropdown on VM’s summary page as below.
Add disk button on VM's summary page
Notifications
Once the disk is attached, user will be notified.
Notification
Finally, an additional disk will be attached to VM.
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
2
3
4
5
6
7
8
ssh root@<ManageIQ Appliance>
vmdb
git fetch --all
git checkout euwe-2
git checkout -b euwe-2
bundle install # or bin/install
bundle exec rake evm:compile_assets
bundle exec rake evm:restart