In this video, I'll introduce you to the REST API for Oracle Linux Virtualization Manager.
We'll view the Representational State Transfer, or REST, API guide.
I'll demonstrate a method to obtain the CA certificate from the API server.
I'll describe the prerequisites for using the REST API.
And I'll describe and demonstrate use of the curl command line tool to initiate API requests.
Documentation for the REST API is accessible from the console.
I'll click REST API Guide and then click Documents. I'll click Authentication and Security and
see different methods for obtaining the CA certificate.
Method 1, using the openssl s_client command line tool, is the preferred method.
Run the command shown and provide the name of your server, then colon 443.
Sample output is shown. As directed, copy the CA certificate and save
it to a local file. In this video, I'm going to scroll down to
Method 2 and use the curl command to download the CA certificate.
I'll type the command as shown, substituting my server name, and save the output to a file
named ovirt-cacert.pem. Now I'll run the file star command to see
that the file is a PEM certificate as expected. I'm going to return to the REST API Guide
and then click Documents. I'll click Introduction and scroll down to
the API Prerequisites. Prerequisites for using the oVirt API include
a client or programming library that initiates and receives HTTP requests from the API server.
You can use either the oVirt Python SDK, the Ruby SDK, the Java SDK, the curl command line
tool, or the RESTClient. In this video, I'm going to use curl to initiate
requests. I'll go back to review the list of Documents
and then select Quick Start Examples. This document provides examples of using the
curl command. This example uses the GET HTTP method to request
information from the API server. For action methods, the HTTP method is always
POST. I'll search for POST and scroll down to see
an example of using POST with curl. This example shows how to create NFS data
storage. We'll use POST and GET methods in this video.
To demonstrate use of the curl command, I'll create a snapshot of a virtual machine named
test-vlan02-b. Our curl command to create a snapshot requires
the VM ID which I'll copy from here. Before I run this curl command, I want to
view the existing snapshots for this VM. Curently there is only one snapshot, named
Active VM. I'll open up a terminal window and I've created
a script which contains the curl command to create a snapshot.
You need to provide the CA certificate that we wrote to this file earlier in this video.
You need to provide the user and password required to log in to the API server.
The HTTP method is POST. Provide these 3 header lines.
Provide the name of the snapshot to create. I'll just name it backup.
Provide this https line, with the name of your API server, slash ovirt-engine, slash
api, slash vms, slash the VM ID of the VM that we want to create a snapshot of, slash
snapshots. I'll paste in the VM ID that I copied earlier
in this video. I'll save the file, then run this script to
create the snapshot. Now I can go back in and verify that the snapshot
was created. And here is the new backup snapshot.
The next thing I want to demonstrate is how to get the snapshot ID.
I'll open up my terminal window and I've created a script which contains the curl command to
get the snapshot ID. Again you need to provide the CA certificate
file, the header lines, the user information and the https line.
The HTTP method in this command is GET. I'll save the file, then run this script to
get the snapshot ID. I'm going to redirect the output to a file
as it's easier to locate the snapshot ID in the file.
I'll open the file and search for the name of the snapshot, backup.
The snapshot ID is provided in the following line.
I'll highlight it and copy it for future reference. The last curl command I'll demonstrate is
to delete a snapshot. This curl command uses the DELETE HTTP method
to remove the snapshot. The https line requires the VM ID of the VM
whose snapshot we made earlier, and the snapshot ID that we want to remove.
I'll save the file, then run this script to delete the snapshot.
To confirm, I'll view the snapshots for our VM named test-vlan02-b.
I'll refresh the screen and confirm that the backup snapshot no longer exists.
This concludes this presentation, thanks for watching.