By sending requests to the Virtual Machine endpoint /vm/ you can list, create, update or delete VMs.
Note |
---|
HTTPie is highly recommended: CLI HTTP client, user-friendly curl replacement with intuitive UI, JSON support, syntax highlighting, wget-like downloads, extensions, etc. http://httpie.org |
List all virtual machines
...
Name | Type | Description |
---|---|---|
uuid | string | 128-bit UUID of a virtual machine, represented as a hexademical string. This identifier is used by VirtualCenter to uniquely identify all virtual machine instances, including those that may share the same SMBIOS UUID. |
name | string | Virtual Machine name including VSS prefix. |
guestFullName | string | This is the full name of the guest operating system for the virtual machine. For example: Windows 2000 Professional. |
ipAddress | string | Primary IP address assigned to the guest operating system, if known. |
memoryMB | integer | Memory size of the virtual machine, in megabytes. |
cpuCount | integer | Number of processors in the virtual machine. |
overallStatus | string | Overall alarm status on this node. |
powerState | string | The current power state of the virtual machine. |
provisionedGB | integer | Sum of Committed and Uncommitted storage. |
...
The following example uses HTTPie to request all Virtual Machine managed by given user without filters:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
HTTP/1.0 200 OK Allow: HEAD, POST, OPTIONS, GET Content-Length: 14498 Content-Type: application/json Date: Mon, 25 Apr 2016 20:50:35 GMT Server: Werkzeug/0.11.3 Python/2.7.10 X-RateLimit-Limit: 7200 X-RateLimit-Remaining: 7171 X-RateLimit-Reset: 1461618000 { "_links": { "api": "https://vss-api.eis.utoronto.ca:8001/v2/", "self": "https://vss-api.eis.utoronto.ca:8001/v2/vm/" }, "data": [ { "_links": { "self": "http://localhost:5000/v2/vm/50125944-d5e0-248d-0f3c-c499acbeb1ce/" }, "cpuCount": 2, "folder": { "_links": { "self": "http://localhost:5000/v2/folder/group-v6557" }, "moref": "group-v6557", "name": "Swarm", "parent": "Sandbox" }, "guestFullName": "Other 3.x Linux (64-bit)", "ipAddress": "128.100.228.72", "memoryMB": 2048, "name": "1604P-docker-node2", "overallStatus": "green", "powerState": "poweredOn", "provisionedGB": 22, "uuid": "50125944-d5e0-248d-0f3c-c499acbeb1ce" } ], "meta": { "count": 22, "time": "1.04441s", "user": "jm" } } |
Filters
Filtering VM results The main Virtual Machine resource has three main filters to reduce the number of VMs shown in the result or to locate a VM by hostname or ip address.
Name | Description |
---|---|
name | Virtual Machine name string to filter VMs |
ip | Primary IP address assigned to the Guest operating system. |
dns | Hostname of the guest operating system. |
Examples
...
summary | Disables VM summary in results. |
The following examples show how to implement a GET request with the first three parameters shown below. The result is similar to the previous section.
Code Block | ||||
---|---|---|---|---|
| ||||
http -a $TK GET https://vss-api.eis.utoronto.ca:8001/v2/vm/?name=Test
http -a $TK GET https://vss-api.eis.utoronto.ca:8001/v2/vm/?ip=10.2.1.2
http -a $TK GET https://vss-api.eis.utoronto.ca:8001/v2/vm/?dns=wiki.eis.utoronto.ca |
If you decide to add summary in the list of parameters, you'll disable the summary provided by the API about any given VM for this particular request. For example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
http -a $TK GET https://vss-api.eis.utoronto.ca:8001/v2/vm/?name=Test&summary
HTTP/1.0 200 OK
Allow: HEAD, POST, OPTIONS, GET
Content-Length: 414
Content-Type: application/json
Date: Tue, 26 Apr 2016 01:36:41 GMT
Server: Werkzeug/0.11.3 Python/2.7.10
X-RateLimit-Limit: 7200
X-RateLimit-Remaining: 7196
X-RateLimit-Reset: 1461636000
{
"_links": {
"api": "https://vss-api.eis.utoronto.ca:8001/v2/",
"self": "https://vss-api.eis.utoronto.ca:8001/v2/vm/"
},
"data": [
{
"_links": {
"self": "https://vss-api.eis.utoronto.ca:8001/v2/vm/5012bd15-c20c-a971-aa68-af1a3cf3d0db/"
},
"name": "1604Q-VMTest_1",
"uuid": "5012bd15-c20c-a971-aa68-af1a3cf3d0db"
}
],
"meta": {
"count": 1,
"time": "1.86220s",
"user": "jm"
}
} |
Note |
---|
From now on, you will need the UUID of any virtual machine, provided by the "_links" section, to get further information about it and eventually to modify properties. |
List specific virtual machine info
...