yum install curl
Usage: curl [options]
uri
uri
refers to target HTTP address to send the request. This is a location on your Red Hat Enterprise Virtualization Manager host within the API entry point path (/api
).
COMMAND
, --request COMMAND
GET
, POST
, PUT
or DELETE
.
-X GET
LINE
, --header LINE
-H "Accept: application/xml" -H "Content-Type: application/xml"
USERNAME:PASSWORD
, --user USERNAME:PASSWORD
Authorization:
header.
-u admin@internal:p@55w0rd!
CERTIFICATE
-k
attribute to bypass SSL. See Chapter 2, Authentication and Security for more information on obtaining a certificate.
--cacert ~/Certificates/rhevm.cer
BODY
, --data BODY
POST
, PUT
and DELETE
requests. Ensure to specify the Content-Type: application/xml
header if a body exists in the request.
-d "<cdrom><file id='rhel-server-6.0-x86_64-dvd.iso'/></cdrom>"
GET
requestGET
request lists the virtual machines in the vms
collection. Note that a GET
request does not contain a body.
GET /api/vms HTTP/1.1 Accept: application/xml
GET
), header (Accept: application/xml
) and URI (https://[RHEVM-Host]
:8443/api/vms
) into the following cURL command:
$ curl -X GET -H "Accept: application/xml" -u[USER:PASS]
--cacert[CERT]
https://[RHEVM-Host]
:8443/api/vms
vms
collection displays.
POST
requestPOST
request creates a virtual machine in the vms
collection. Note that a POST
request requires a body.
POST /api/vms HTTP/1.1 Accept: application/xml Content-type: application/xml <vm> <name>vm1</name> <cluster> <name>default</name> </cluster> <template> <name>Blank</name> </template> <memory>536870912</memory> <os> <boot dev="hd"/> </os> </vm>
POST
), headers (Accept: application/xml
and Content-type: application/xml
), URI (https://[RHEVM-Host]
:8443/api/vms
) and request body into the following cURL command:
$ curl -X POST -H "Accept: application/xml" -H "Content-type: application/xml" -u[USER:PASS]
--cacert[CERT]
-d "<vm><name>vm1</name><cluster><name>default</name></cluster><template><name>Blank</name></template><memory>536870912</memory><os><boot dev='hd'/></os></vm>" https://[RHEVM-Host]
:8443/api/vms
PUT
requestPUT
request updates the memory of a virtual machine resource. Note that a PUT
request requires a body.
PUT /api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1 Accept: application/xml Content-type: application/xml <vm> <memory>1073741824</memory> </vm>
PUT
), headers (Accept: application/xml
and Content-type: application/xml
), URI (https://[RHEVM-Host]
:8443/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399
) and request body into the following cURL command:
$ curl -X PUT -H "Accept: application/xml" -H "Content-type: application/xml" -u[USER:PASS]
--cacert[CERT]
-d "<vm><memory>1073741824</memory></vm>" https://[RHEVM-Host]
:8443//api/vms/082c794b-771f-452f-83c9-b2b5a19c039
DELETE
requestDELETE
request removes a virtual machine resource.
DELETE /api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
DELETE
) and URI (https://[RHEVM-Host]
:8443/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399
) into the following cURL command:
$ curl -X DELETE -u[USER:PASS]
--cacert[CERT]
https://[RHEVM-Host]
:8443//api/vms/082c794b-771f-452f-83c9-b2b5a19c039
Accept: application/xml
request header is optional due to the empty result of DELETE
requests.
DELETE
request with bodyDELETE
request force removes a virtual machine resource as indicated with the optional body.
DELETE /api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1 Accept: application/xml Content-type: application/xml <action> <force>true</force> </action>
DELETE
), headers (Accept: application/xml
and Content-type: application/xml
), URI (https://[RHEVM-Host]
:8443/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399
) and request body into the following cURL command:
$ curl -X DELETE -H "Accept: application/xml" -H "Content-type: application/xml" -u[USER:PASS]
--cacert[CERT]
-d "<action><force>true</force></action>" https://[RHEVM-Host]
:8443//api/vms/082c794b-771f-452f-83c9-b2b5a19c039