This application provides a REST API that communicates with the libvirt daemon to create, modify, and delete virtual machines.
It assumes that you have libvirt installed and configured along the lines of this blog post.
The /virtual_machines/
namespace is where all CRUD operations for a virtual machine and their dependents live.
Request:
$ curl -s http://localhost:4567/virtual_machines
Response:
200 OK
[
{
"uuid": "2de02519-c347-432c-9923-3753c3538e02",
"state": "shut off",
"cpus": 2,
"memory": 8388608
}
]
Request:
$ curl -s http://localhost:4567/virtual_machines/2de02519-c347-432c-9923-3753c3538e02
Response:
200 OK
{
"uuid": "2de02519-c347-432c-9923-3753c3538e02",
"state": "shut off",
"cpus": 2,
"memory": 8388608
}
Request:
$ curl -s http://localhost:4567/virtual_machines -X POST -d '{"cpus": 2, "memory": 8388608}'
Response:
201 Created
{
"uuid": "2de02519-c347-432c-9923-3753c3538e02",
"state": "shut off",
"cpus": 2,
"memory": 8388608
}
Request:
$ curl -s http://localhost:4567/virtual_machines/2de02519-c347-432c-9923-3753c3538e02 -X PATCH -d '{"state":"started"}'
Name | Type | Description |
---|---|---|
state |
string |
The state of the virtual machine. Can be one of started , shutdown (graceful), or halted (forced). |
Response:
200 OK
{
"uuid": "2de02519-c347-432c-9923-3753c3538e02",
"state": "started",
"cpus": 2,
"memory": 8388608
}
Request:
$ curl -s http://localhost:4567/virtual_machines/2de02519-c347-432c-9923-3753c3538e02 -X DELETE
Response:
200 OK
git clone https://github.com/neptune-networks/virtualization-server
script/bootstrap
The server requires libvirt installed on your computer, assuming that you are running on a Mac, you should be able to get everything running by running:
brew install libvirt qemu
script/server
script/test