Vm Management
Management of Virtual Machines adds support of the following actions:
Action | Description |
---|---|
start |
Starts a VM |
stop |
Stops a VM |
suspend |
Suspends a VM |
refresh |
Refreshes a VM |
reset |
Resets a VM |
reboot_guest |
Reboots guest in VM |
shutdown_guest |
Shuts down guest in VM |
scan |
Scans a VM (Perform SmartState Analysis) |
set_miq_server |
Sets the server of a VM |
set_owner |
Sets the owner of a VM |
add_event |
Adding an Event to a VM |
add_lifecycle_event |
Add a Lifecycle Event to a VM |
edit |
Edits a VM |
delete |
Deletes a VM in the Appliance |
Targeting VMs
These actions can be triggered on individual vm resources:
/api/vms/:id
As simply as POSTing the following action to a VM.
{
"action" : "start"
}
Requests can also be made on multiple vms by targetting the primary collection:
/api/vms
{
"action" : "start",
"resources" : [
{ "href" : "http://localhost:3000/api/vms/11" },
{ "href" : "http://localhost:3000/api/vms/12" },
...
]
}
Querying VMs
Virtual Machines are queried via the primary collection URL:
/api/vms
Filtering, sorting and paging as mentioned on the Querying page.
When querying vms, expanding the resources themselves as well as the following subcollections:
accounts |
software |
For example:
GET /api/vms?expand=resources,accounts,software
Or querying and individual vm
GET /api/vms/:id?expand=accounts,software
Setting Server of a VM
{
"action" : "set_miq_server",
"resource" : {
"miq_server" : { "href" : "http://localhost:3000/api/servers/5" }
}
}
{
"action" : "set_miq_server",
"resource" : {
"miq_server" : { "id" : "6" }
}
}
To remove the Server from the VM, pass in an empty reference as follows:
{
"action" : "set_miq_server",
"resource" : {
"miq_server" : {}
}
}
Adding an Event to a VM
{
"action" : "add_event",
"resource" : {
"event_type" : "...",
"event_message" : "...",
"event_time" : "UTC Time"
}
}
event_time above is optional. If skipped, current time will be used. |
Adding a Lifecycle Event to a VM
{
"action" : "add_lifecycle_event",
"resource" : {
"event" : "...",
"status" : "...",
"message" : "...",
"created_by" : "..."
}
}
Editing a VM
Basic information of VMs can be edited. This includes the following:
VM Info | Attribute |
---|---|
description |
description |
custom attributes |
custom_1 … custom_9 |
parent resource |
parent_resource - resource href reference |
child resources |
child_resources - array of resource href references |
VM resources can be edited as follows:
POST /api/vms/:id
{
"action" : "edit",
"resource" : {
"description" : "Updated VM Description",
"custom_1" : "custom_attribute_1",
"parent_resource" : { "href" : "http://localhost:3000/api/vms/11" },
"child_resources" : [
{ "href" : "http://localhost:3000/api/vms/101" },
{ "href" : "http://localhost:3000/api/vms/102" },
{ "href" : "http://localhost:3000/api/vms/103" },
{ "href" : "http://localhost:3000/api/vms/104" }
]
}
}
VMs can also be edited in Bulk as follows:
POST /api/vms
{
"action" : "edit",
"resources" : [
{
"href" : "http://localhost:3000/api/vms/11",
"custom_9" : "vm_class_a"
},
{
"href" : "http://localhost:3000/api/vms/12",
"custom_9" : "vm_class_a"
},
{
"href" : "http://localhost:3000/api/vms/13",
"custom_9" : "vm_class_a"
}
]
}