Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Advanced integration with Red Hat Enterprise Virtualization Manager (RHEV-M) - Part 1 of 2

December 12, 2013
Oved Ourfali
Related topics:
DevOps
Related products:
Red Hat Enterprise Linux

Share:

    This is part 1 of a 2-part article about Advanced Integration with RHEV-M. 

    Background

    At CloudOpen Europe 2013, in Edinburgh, I presented a talk about advanced integration with the oVirt engine. This technical article is covering the contents of this session.

    RHEV-M is a Large scale, centralized management for server and desktop virtualization. It is based on leading performance, scalability and security infrastructure technologies, focusing on KVM for best integration/performance. It provides an alternative to Center/vSphere, providing end-to-end IaaS platform.

    rhevm

    In this post I'll show you how you can integrate with the RHEV-M engine, covering both new and cool features, as well as some "old" useful features.  Let's start with the REST-based APIs. These APIs allow you to perform different operations on the engine externally. You can do anything using the REST APIs, even operations that aren't exposed through the different UI interfaces.

    REST-based APIs

    We have several REST-based APIs in the RHEV-M engine:

    • REST API - provides application programming interface for the RHEV-M engine, using basic HTTP operations
    • SDKs (Python, Java) - based on the REST API - provides python based SDK to the RHEV-M engine
    • CLI (based on the Python SDK) - provides command line utility to the RHEV-M engine

    So, what should you use?

    That depends mostly on who you are, and what you are trying to accomplish:

    • If you're a sysadmin running a virtualized environment, and you would like to troubleshoot some issues without going into the UI, then you should use the CLI.
    • If you're a developer and you would like to integrate with the RHEV-M engine in your application, and your application is Java/Python based, then you should use the proper SDK.
    • If you're a developer using other languages, then you should use the API, using some HTTP library available in your platform.
    • If you just want to automate some tasks, then you should use the Python SDK or the CLI, depending on your preferable scripting language.

    Let's dive a little deeper into the API and the SDK. I won't cover the CLI in this post. For more information on that have a look at CLI Wiki page

    REST API

    The REST API provides application programming interface for the RHEV-M engine, using basic HTTP operations:

    • GET - Requests a resource
    • POST - Creates a new resource. The new resource data is included in the body of the request
    • PUT - Modifies an existing resource. The modified resource data is included in the body of the request
    • DELETE - Deletes a resource

    The API URI structure is as follows:

    protocol://server_details/entry_point/collection/resource/sub-collection/subresource

    For example, the following URL is a representation of the disk sub-resource with ID yyy-yyy in the VM resource with ID xxx-xxx, on our (secured) RHEV-M that's installed on machine rhevm port 8443:

    https://rhevm:8443/api/vms/{xxx}/disks/{yyy}

    Some basic examples:

    1. To list all collection resources, use HTTP GET
      • GET http(s)://server:port/api/vms
    2. To retrieve a specific resource, use HTTP GET
      • GET http(s)://server:port/api/vms/{xxx}
      • curl -v -u "user@domain:password" -H "Content-type: application/xml" -X GET http(s)://server:port/api/vms/{xxx}
    3. To create a resource, use POST.
      • POST http(s)://server:port/api/vms
        <vm>...</vm>
      • curl -v -u "user@domain:password"
        -H "Content-type: application/xml"
        -d
        '<vm>
        <name>my_new_vm</name>
        <cluster><name>cluster_name</name></cluster>
        <template><name>template_name</name></template>
        </vm>' 'http(s)://server:port/api/vms'
    4. To update the resource, use PUT.
      • PUT http(s)://server:port/api/vms/{xxx}
        <vm><name>aaa</name></vm>
      • echo "<vm><name>new_name</name></vm>" > /tmp/upload.xml
        curl -v -u "user@domain:password"
        -H "Content-type: application/xml"
        -T /tmp/upload.xml
        'http(s)://server:port/api/vms/{xxx}'
    5. To remove the resource, use DELETE.
      • DELETE http(s)://server:port/api/vms/{xxx}
      • curl -v -u "user@domain:password" -X DELETE http(s)://server:port/api/vms/{xxx}

    RSDL- RESTful Service Description Language

    How do you know what arguments to use when doing different operations?

    You can use the RSDL (RESTful Service Description Language) - machine and human readable XML description of HTTP-based web applications (typically REST web services). It models the resource/s provided by a service, the relationship between them, parameters that has to be supplied for the certain operation, specifies if parameter/s has to be mandated, and describes possible overloads as parameters sets.

    RSDL is intended to simplify the reuse of web services that are based on the HTTP architecture of the Web. It is platform and language independent and aims to promote reuse of applications beyond the basic use in a web browser, by both humans and machines.

    In order to get the RSDL, just follow the basic API URI, followed by "?rsdl":

    • https://rhevm:8080/ovirt-engine/api?rsdl

    And then you'll get all the different options for each and every HTTP request you can do on each and every resource.

    For example, here you see a partial list of available parameters when adding a new VM using HTTP POST on the VMs collection:

    rsdl

    SDK

    The Python-SDK is auto-generated software development kit for the RHEV-M engine API. Let's show some examples on how to use it.

    1. First, you need to create a proxy to the API
      • api = API(url='http://localhost:8080', username='user@domain', password='password')
    2. Now, you can access the different collections, (api.vms(), api.clusters(), etc...)
    3. Create new resources, for example create a new VM:
      • cluster = api.clusters().get(name='my_cluster') #destination cluster

      • template = api.templates().get(name='my_template') #source template
      • param = params.VM(name='new_vm', cluster=cluster, template=template, memory=1073741824) #setting additional parameters

      • new_vm = api.vms().add(param) #creating the VM
    4. List resources by query (server side query)
      • vms = api.vms().list(query = 'name=my_vm')
    5. List resources by property constraint (client side filtering)
      • vms = api.vms().list(memory=1073741824)
    6. Get a resource by constraint
      • vm = api.vms().get(id='f70d7c72-0232-4859-8fd7-fdaf1fd29d6d')
    7. Access resource methods and properties
      • vm.start()
      • vm.start_time

    Depending on your development environment, you'll get auto-completion, and documentation that will ease the development process using the SDK.

    In this part you learned how to perform different operations on the engine from the outside using the API/SDK. In the next part you'll learn how you can influence the engine from the inside, using extension APIs.

    Find Part 2 of this article here.

    Last updated: January 10, 2023

    Recent Posts

    • AI meets containers: My first step into Podman AI Lab

    • Live migrating VMs with OpenShift Virtualization

    • Storage considerations for OpenShift Virtualization

    • Upgrade from OpenShift Service Mesh 2.6 to 3.0 with Kiali

    • EE Builder with Ansible Automation Platform on OpenShift

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue