이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 3. REST API Quick Start Example


This chapter provides an example to demonstrate the REST API's ability to setup a basic Red Hat Virtualization environment and create a virtual machine.
In addition to the standard prerequisites, this example requires the following:
  • A networked and configured Red Hat Virtualization Host;
  • An ISO file containing a desired virtual machine operating system to install. This chapter uses Red Hat Enterprise Linux Server 6 for our installation ISO example; and
  • Red Hat Virtualization's engine-iso-uploader tool to upload your chosen operating system ISO file.
This example uses cURL to demonstrate REST requests with a client application. Note that any application capable of HTTP requests can substitute for cURL.

Important

For simplicity, the HTTP request headers in this example omit the Host: and Authorization: fields. However, these fields are mandatory and require data specific to your installation of Red Hat Virtualization Manager.

Important

All cURL examples include placeholders for authentication details (USER:PASS) and certificate location (CERT). Ensure all requests performed with cURL fulfill certification and authentication requirements.

Note

Red Hat Virtualization Manager generates a globally unique identifier (GUID) for the id attribute for each resource. Identifier codes in this example might appear different to the identifier codes in your Red Hat Virtualization environment.

3.1. Example: Access API Entry Point

The following request retrieves a representation of the main entry point for version 3 of the API.

Example 3.1. Access the API v3 entry point

Request (with header):

GET /ovirt-engine/api HTTP/1.1
Version: 3
Accept: application/xml

Request (without header):

GET /ovirt-engine/api/v3 HTTP/1.1
Accept: application/xml

cURL command:

# curl -X GET -H "Accept: application/xml" -u [USER:PASS] \
    --cacert [CERT] https://[RHEVM Host]:443/ovirt-engine/api

Result:

HTTP/1.1 200 OK
Content-Type: application/xml

<api>
    <link rel="capabilities" href="/ovirt-engine/api/capabilities"/>
    <link rel="clusters" href="/ovirt-engine/api/clusters"/>
    <link rel="clusters/search" href="/ovirt-engine/api/clusters?search={query}"/>
    <link rel="datacenters" href="/ovirt-engine/api/datacenters"/>
    <link rel="datacenters/search" href="/ovirt-engine/api/datacenters?search={query}"/>
    <link rel="events" href="/ovirt-engine/api/events"/>
    <link rel="events/search" href="/ovirt-engine/api/events?search={query}"/>
    <link rel="hosts" href="/ovirt-engine/api/hosts"/>
    <link rel="hosts/search" href="/ovirt-engine/api/hosts?search={query}"/>
    <link rel="networks" href="/ovirt-engine/api/networks"/>
    <link rel="roles" href="/ovirt-engine/api/roles"/>
    <link rel="storagedomains" href="/ovirt-engine/api/storagedomains"/>
    <link rel="storagedomains/search" href="/ovirt-engine/api/storagedomains?search={query}"/>
    <link rel="tags" href="/ovirt-engine/api/tags"/>
    <link rel="templates" href="/ovirt-engine/api/templates"/>
    <link rel="templates/search" href="/ovirt-engine/api/templates?search={query}"/>
    <link rel="users" href="/ovirt-engine/api/users"/>
    <link rel="groups" href="/ovirt-engine/api/groups"/>
    <link rel="domains" href="/ovirt-engine/api/domains"/>
    <link rel="vmpools" href="/ovirt-engine/api/vmpools"/>
    <link rel="vmpools/search" href="/ovirt-engine/api/vmpools?search={query}"/>
    <link rel="vms" href="/ovirt-engine/api/vms"/>
    <link rel="vms/search" href="/ovirt-engine/api/vms?search={query}"/>
    <special_objects>
        <link rel="templates/blank"
          href="/ovirt-engine/api/templates/00000000-0000-0000-0000-000000000000"/>
        <link rel="tags/root"
          href="/ovirt-engine/api/tags/00000000-0000-0000-0000-000000000000"/>
    </special_objects>
    <product_info>
        <name>Red Hat Virtualization</name>
        <vendor>Red Hat</vendor>
        <version revision="0" build="0" minor="0" major="4"/>
    </product_info>
    <summary>
        <vms>
            <total>5</total>
            <active>0</active>
        </vms>
        <hosts>
            <total>1</total>
            <active>1</active>
        </hosts>
        <users>
            <total>1</total>
            <active>1</active>
        </users>
        <storage_domains>
            <total>2</total>
            <active>2</active>
        </storage_domains>
    </summary>
</ovirt-engine/api>

Important

When neither the header nor the URL prefix are used, the server will automatically select a version. The default is version 4. You can change the default version using the ENGINE_API_DEFAULT_VERSION parameter:
# echo "ENGINE_API_DEFAULT_VERSION=3" > \
  /etc/ovirt-engine/engine.conf.d/99-set-default-version.conf
# systemctl restart ovirt-engine
Changing this parameter affects all users of the Manager that don't specify the version explicitly.
The entry point provides a user with links to the collections in a virtualization environment. The rel= attribute of each collection link provides a reference point for each link. The next step in this example examines the datacenter collection, which is available through the rel="datacenter" link.
The entry point also contains other data such as product_info, special_objects and summary. This data is covered in chapters outside this example.
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동