Red Hat Enterprise Virtualization 3.6- Beta Java SDK Guide



Similar documents
Red Hat Cloud Infrastructure 5 Release Notes

Red Hat CloudForms 3.2 NetApp Storage Integration Guide

Red Hat Customer Portal 1 Managing User Access to the Red Hat Customer Portal and the Red Hat Network Application

Red Hat Cloud Infrastructure 5 Introduction to Red Hat Cloud Infrastructure Architecture

Red Hat CloudForms 3.1 Management Engine 5.3 OpenShift Enterprise Deployment Guide

Red Hat JBoss Core Services Apache HTTP Server 2.4 Apache HTTP Server Installation Guide

Red Hat Enterprise Linux OpenStack Platform 7 OpenStack Data Processing

Red Hat Cloud Infrastructure 6 Getting Started with the Red Hat Cloud Infrastructure Unified Installer

Red Hat Subscription Management All Subscription Docs Quick Registration for RHEL

Red Hat Enterprise Linux 7 High Availability Add-On Overview

Red Hat JBoss Data Virtualization 6.1 Migration Guide

JBoss Developer Studio 6.0

Red Hat Customer Portal Current Customer Portal Subscription Management

Red Hat JBoss BPM Suite 6.1 IBM WebSphere Installation and Configuration Guide

Red Hat Cloud Infrastructure 4 Quick Start for Red Hat Enterprise Virtualization and Red Hat CloudForms

Red Hat JBoss Fuse 6.1 Cloud Computing with Fabric

Red Hat Enterprise Linux OpenStack Platform 7 Back Up and Restore Red Hat Enterprise Linux OpenStack Platform

Red Hat OpenStack Platform 8 DNS-as-a-Service Guide

Red Hat Enterprise Linux 7 High Availability Add-On Administration. Configuring and Managing the High Availability Add-On

Red Hat JBoss Developer Studio 8.0 Start Developing

Red Hat Enterprise Linux 7 Virtualization Security Guide

Red Hat Enterprise Linux 7 Virtualization Security Guide

JAMF Software Server Installation Guide for Linux. Version 8.6

Red Hat Enterprise Linux 6 Virtualization Getting Started Guide

Red Hat Directory Server 8.2 Using the Directory Server Console

Red Hat JBoss Fuse 6.1 Cloud Deployment Guide

Red Hat JBoss A-MQ 6.2 Cloud Deployment Guide

Red Hat Network Satellite Client Configuration Guide

JBoss Operations Network 3.1 Deploying Applications and Content

JAMF Software Server Installation Guide for Windows. Version 8.6

Red Hat Enterprise Virtualization 3.0 User Portal Guide. Accessing and Using Virtual Machines from the User Portal Edition 1

Red Hat Satellite 6.0 Installation Guide

Connection Broker Managing User Connections to Workstations, Blades, VDI, and more. Security Review

How To Manage A Server On A Jboss Application Platform (Jboss)

Chapter 1: How to Configure Certificate-Based Authentication

Red Hat Ceph Storage Hardware Guide

Red Hat Network Satellite 5.5 Channel Management Guide

Red Hat JBoss Developer Studio 4.1 Smooks Developer Tools Reference Guide

Red Hat Enterprise Linux 7 High Availability Add-On Administration. Configuring and Managing the High Availability Add-On

OnCommand Performance Manager 1.1

Red Hat Satellite 5.6 Proxy Installation Guide

Red Hat Developer Toolset 1.1

WebApp S/MIME Manual. Release Zarafa BV

JBoss Operations Network 3.0 User Guides Configuring JBoss ON Servers and Agents

Backing up the Embedded Oracle database of a Red Hat Network Satellite

An Oracle White Paper September Oracle WebLogic Server 12c on Microsoft Windows Azure

Managing Virtual Machines in Red Hat Enterprise Virtualization. Red Hat Enterprise Virtualization Documentation Team

Oracle WebLogic Server 11g: Administration Essentials

Red Hat Enterprise Linux OpenStack Platform 6 Deploying OpenStack: Enterprise Environments (Red Hat Enterprise Linux OpenStack Platform Installer)

Enabling Kerberos SSO in IBM Cognos Express on Windows Server 2008

Brekeke SIP Server Version 3 Using a Third-Party Database Tutorial Brekeke Software, Inc.

Novell Access Manager

AWS Schema Conversion Tool. User Guide Version 1.0

RHEV 2.2: REST API INSTALLATION

Connection Broker Managing User Connections to Workstations and Blades, OpenStack Clouds, VDI, and more. Security Review

IBM Cloud Manager with OpenStack

Red Hat Enterprise Linux OpenStack Platform 7 Users and Identity Management Guide

Connection Broker Managing User Connections to Workstations, Blades, VDI, and More. Quick Start with Citrix XenDesktop, XenServer & XenApp

Red Hat Subscription Asset Manager 1.2 Installation Guide. Installing and Using Red Hat Subscription Asset Manager Edition 3

Configuring TLS Security for Cloudera Manager

Qualcomm Achieves Significant Cost Savings and Improved Performance with Red Hat Enterprise Virtualization

Interstage Application Server V7.0 Single Sign-on Operator's Guide

Installing and Configuring Adobe LiveCycle 9.5 Connector for Microsoft SharePoint

Red Hat Enterprise Linux OpenStack Platform 5 Deploying OpenStack: Enterprise Environments (Red Hat Enterprise Linux OpenStack Platform Installer)

Red Hat JBoss Fuse 6.2 Management Console User Guide

Migrating LAMP stack from x86 to Power using the Server Consolidation Tool

Customer Tips. Xerox Network Scanning HTTP/HTTPS Configuration using Microsoft IIS. for the user. Purpose. Background

Universal Content Management Version 10gR3. Security Providers Component Administration Guide

Red Hat Network Satellite 5.4 Installation Guide. Red Hat Network Satellite

Using LDAP Authentication in a PowerCenter Domain

Red Hat Enterprise Linux OpenStack Platform 8 Partner Integration

HPC ON WALL ST OPENSTACK AND BIG DATA. Brent Holden Chief Field Architect, Eastern US April 2014

Red Hat Satellite 5.6 Client Configuration Guide

RED HAT INFRASTRUCTURE AS A SERVICE OVERVIEW AND ROADMAP. Andrew Cathrow Red Hat, Inc. Wednesday, June 12, 2013

identity management in Linux and UNIX environments

Overview of Web Services API

Red Hat JBoss Developer Studio Release Notes

Table of Contents Introduction and System Requirements 9 Installing VMware Server 35

HP Device Manager 4.7

JBoss Operations Network Release Notes

Creating and Managing Certificates for My webmethods Server. Version 8.2 and Later

JBoss Developer Studio 4.1

Fedora 19. Fedora Documentation Project

Building a Continuous Integration Pipeline with Docker

ZCP 7.0 (build 41322) Zarafa Collaboration Platform. Zarafa Archiver Deployment Guide

Red Hat enterprise virtualization 3.0 feature comparison

Citrix XenServer Workload Balancing Quick Start. Published February Edition

VMware vrealize Operations for Horizon Security

Connection Broker Managing User Connections to Workstations, Blades, VDI, and More. Quick Start with Microsoft Hyper-V

Using the Adobe Access Server for Protected Streaming

JBoss Operations Network 3.1 How to Manage JBoss Servers with JBoss ON

JBoss Operations Network 3.1 Setting up Monitoring Alerts and Operations

Foglight. Foglight for Virtualization, Free Edition Installation and Configuration Guide

5 Days Course on Oracle WebLogic Server 11g: Administration Essentials

Developers Integration Lab (DIL) Certificate Installation Instructions. Version 1.4

Kognitio Technote Kognitio v8.x Hadoop Connector Setup

User's Guide - Beta 1 Draft

Amazon Glacier. Developer Guide API Version

Transcription:

Red Hat Enterprise Virtualization 3.6- Beta Java SDK Guide Using the Red Hat Enterprise Virtualization Java SDK Red Hat Enterprise Virtualization Documentation Team

Red Hat Enterprise Virtualization 3.6-Beta Java SDK Guide Using the Red Hat Enterprise Virtualization Java SDK Red Hat Enterprise Virtualizatio n Do cumentatio n Team Red Hat Custo mer Co ntent Services rhev- do cs@redhat.co m

Legal Notice Copyright 2015 Red Hat. This do cument is licensed by Red Hat under the Creative Co mmo ns Attributio n- ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be remo ved. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other co untries. Linux is the registered trademark of Linus Torvalds in the United States and other countries. Java is a registered trademark o f Oracle and/o r its affiliates. XFS is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/o r o ther co untries. MySQL is a registered trademark of MySQL AB in the United States, the European Union and o ther co untries. Node.js is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project. The OpenStack Wo rd Mark and OpenStack Lo go are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endo rsed o r spo nso red by the OpenStack Fo undatio n, o r the OpenStack co mmunity. All o ther trademarks are the pro perty o f their respective o wners. Abstract This guide describes Red Hat Enterprise Virtualizatio n's Java So ftware Develo pment Kit.

T able of Cont ent s Table of Contents. Chapt..... er.. 1.. O.. verview......................................................................... 2.......... 1.1. Prereq uisites 2. Chapt..... er.. 2.. Creat..... ing... a.. Build..... Environment............................................................ 3.......... 2.1. Installing the Java So ftware Develo p ment Kit 3 2.2. Dep end encies 3 2.3. Co nfig uring SSL 3. Chapt..... er.. 3... Using...... t. he.. Soft.... ware..... Development............ Kit............................................. 5.......... 3.1. Co nnecting to the Red Hat Enterp rise Virtualizatio n Manag er 5 3.2. Listing Entities 6 3.3. Mo d ifying the Attrib utes o f Reso urces 6 3.4. G etting a Reso urce 6 3.5. Ad d ing Reso urces 6 3.6. Perfo rming Actio ns o n Reso urces 7 3.7. Listing Sub -Reso urces 8 3.8. G etting Sub -Reso urces 8 3.9. Ad d ing Sub -Reso urces to a Reso urce 8 3.10. Mo d ifying Sub -Reso urces 9 3.11. Perfo rming Actio ns o n Sub -Reso urces 9. Appendix........ A... Revision........ Hist... ory............................................................. 1. 1.......... 1

Java SDK G uide Chapter 1. Overview The Java software development kit is a collection of classes that allows you to interact with the Red Hat Enterprise Virtualization Manager in Java-based projects. By downloading these classes and adding them to your project, you can access a range of functionality for high-level automation of administrative tasks. The Java software development kit uses the rhevm-sdk-java package, which is available to systems subscribed to a R ed Hat Enterpri se Vi rtual i zati o n entitlement pool in Red Hat Subscription Manager. 1.1. Prerequisit es To install the Java software development kit, you must have: A system where Red Hat Enterprise Linux 6.6 or 7 is installed. Both the Server and Workstation variants are supported. A subscription to Red Hat Enterprise Virtualization entitlements. Important The rhevm-sdk-java package must be installed on each system where scripts that use the software development kit will be run. Important The software development kit is an interface for the Red Hat Enterprise Virtualization REST API. As such, you must use the version of the software development kit that corresponds to the version of your Red Hat Enterprise Virtualization environment. For example, if you are using Red Hat Enterprise Virtualization 3.5, you must use the version of the software development kit designed for 3.5. 2

Chapt er 2. Creat ing a Build Environment Chapter 2. Creating a Build Environment This chapter describes how to create a build environment to develop applications using the Java software development kit. 2.1. Inst alling t he Java Soft ware Development Kit Install the Java software development kit and accompanying documentation. Procedure 2.1. Installing the Java Software Development Kit 1. Ensure your system is subscribed to the R ed Hat Enterpri se Vi rtual i zati o n entitlement in Red Hat Subscription Manager: # subscription-manager list --available grep -A8 "Red Hat Enterprise Virtualization" # subscription-manager attach --pool=pool_id # subscription-manager repos --enable=rhel-6-server-rpms # subscription-manager repos --enable=rhel-6-server-rhevm-3.6-betarpms # subscription-manager repos --enable=jb-eap-6-for-rhel-6-serverrpms 2. Install the required packages: # yum install rhevm-sdk-java # yum install rhevm-sdk-java-javadoc The Java software development kit and accompanying documentation are downloaded to the /usr/share/java/rhevm-sd k-java directory, and can now be added to Java projects. 2.2. Dependencies To use the Java software development kit in Java applications, you must add the following JAR files to the class path of those applications: co mmo ns-beanuti l s. jar co mmo ns-co d ec. jar httpcl i ent. jar httpco re. jar jakarta-co mmo ns-l o g g i ng. jar l o g 4 j. jar The packages that provide these JAR files are installed as dependencies to the rhevm-sdk-java package. By default, they are available in the /usr/share/java directory on Red Hat Enterprise Linux 6 and Red Hat Enterprise Linux 7 systems. 2.3. Configuring SSL 3

Java SDK G uide The Red Hat Enterprise Virtualization Manager Java SD K provides full support for HTTP over Secure Socket Layer (SSL) and the IETF Transport Layer Security (TLS) protocol using the Java Secure Socket Extension (JSSE). JSSE has been integrated into the Java 2 platform as of version 1.4 and works with the Java SDK out of the box. On older Java 2 versions, JSSE must be manually installed and configured. Procedure 2.2. Configuring SSL 1. D ownload the certificate for the Red Hat Enterprise Virtualization Manager: https://[your manager's address]:[port]/ca.crt 2. Generate a keystore: keytool -import -alias "server.crt truststore" -file ca.crt - keystore server.truststore 3. Make the Java software development kit aware of the keystore via one of the following methods: Create a keystore lookup path: $ mkdir ~/.ovirtsdk/ $ cp server.truststore ~/.ovirtsdk/ovirtsdk-keystore.truststore Once ovirtsdk-keystore.truststore is copied to the ~ /. o vi rtsd k directory, it will be used for host identity validation upon handshake with the destination host. Use the following signature to specify a custom truststore when declaring instances of the Api class: Api api = new Api(url, user, password, "/path/server.truststore"); Note Validation of host identities can also be disabled. This method should not be used for production systems due to security reasons, unless it is a conscious decision and you are perfectly aware of the security implications of not validating host identity. To disable host identity validation, use the following signature when declaring instances of the Api class: Api api = new Api(url, user, password, true); 4

Chapt er 3. Using t he Soft ware Development Kit Chapter 3. Using the Software Development Kit This chapter outlines several examples of how to use the Java Software D evelopment Kit. 3.1. Connect ing t o t he Red Hat Ent erprise Virt ualizat ion Manager The Api class acts as the gateway through which you connect to and manipulate objects in the Red Hat Enterprise Virtualization Manager. You must declare an instance of this class each time you interact with the Manager in a project. To declare an instance of the Api class, first import the Api class into your project: import org.ovirt.engine.sdk.api; Next, declare an instance of the class using the following signature: Api api = new Api("[your manager's address]", "[user name]@ [domain]", "[password]", "[path to certificate]"); In this signature, the address to manager is the address and port name by which to connect to the Red Hat Enterprise Virtualization Manager, the user name, domain and password are the credentials with which to log in, and the path to certificate is the local path on your system to the certificate of the Manager for SSL communication. For more information on using certificates, see Section 2.3, Configuring SSL. The following example outlines this process in more detail: import org.ovirt.engine.sdk.api; import java.io.ioexception; public class Main { private static final String URL = "https://localhost:443/api"; @ SuppressWarnings("unused") public static void main(string[] args) throws ClientProtocolException, ServerException, UnsecuredConnectionAttemptError, IOException { // #1 Authenticate using the user name and password Api api = new Api(URL, "admin@ interal", "123456", "/home/user/.ovirtsdk/");... } } Note The Api class does not implement the Auto cl o seabl e interface. As such, it is recommended that you shut down instances of the Api class in a fi nal l y block to ensure the connection with the Red Hat Enterprise Virtualization Manager is shut down gracefully. 5

Java SDK G uide 3.2. List ing Ent it ies The following example outlines how to list entities in the Red Hat Enterprise Virtualization Manager. In this example, the entities to be listed are virtual machines, which are listed using the g etvms() method of the Api class. Procedure 3.1. Listing Entities Declare a Li st of the type of entity to be listed and use the corresponding method to get the list of entities: List<VM> vms = api.getvms().list(); 3.3. Modifying t he At t ribut es of Resources The following example outlines how to modify the attributes of a resource. In this example, the attribute to be modified is the description of the virtual machine with the name 'test', which is changed to 'java_sdk'. Procedure 3.2. Modifying the Attributes of a Resource 1. D eclare an instance of the resource whose attributes are to be modified: 2. Set the new value of the attribute: vm.setdescription("java_sdk"); 3. Update the virtual machine to apply the change: VM newvm = vm.update(); 3.4. Get t ing a Resource In the Java Software Development Kit, resources can be referred to via two attributes: name, and UUID. Both return an object with the specified attribute if that object exists. To get a resource using the value of the name attribute: To get a resource using the value of the UUID attribute: VM vm = api.getvms().get(uuid.fromstring("5a89a1d2-32be-33f7-a0d1- f8b5bc974ff6")); 3.5. Adding Resources 6

Chapt er 3. Using t he Soft ware Development Kit The following examples outline two ways to add resources to the Red Hat Enterprise Virtualization Manager. In these examples, the resource to be added is a virtual machine. Example 1 In this example, an instance of the VM class is declared to represent the new virtual machine to be added. Next, the attributes of that virtual machine set to the preferred values. Finally, the new virtual machine is added to the Manager. org.ovirt.engine.sdk.entities.vm vmparams = new org.ovirt.engine.sdk.entities.vm(); vmparams.setname("myvm"); vmparams.setcluster(api.getclusters().get("mycluster")); vmparams.settemplate(api.gettemplates().get("mytemplate"));... VM vm = api.getvms().add(vmparams); Example 2 In this example, an instance of the VM class is declared in the same way as Example 1. However, rather than using the g et method to reference existing objects in the Manager, each attribute is referenced by declaring an instance of that attribute. Finally, the new virtual machine is added to the Manager. org.ovirt.engine.sdk.entities.vm vmparams = new org.ovirt.engine.sdk.entities.vm(); vmparams.setname("myvm"); org.ovirt.engine.sdk.entities.cluster clusterparam = new Cluster(); clusterparam.setname("mycluster"); vmparams.setcluster(clusterparam); org.ovirt.engine.sdk.entities.template templateparam = new Template(); templateparam.setname("mytemplate"); vmparams.settemplate(templateparam);... VM vm = api.getvms().add(vmparams); 3.6. Performing Act ions on Resources The following example outlines how to perform actions on a resource. In this example, a virtual machine with the name 'test' is started. Procedure 3.3. Performing an Action on a Resource 1. D eclare an instance of the resource: 2. D eclare action parameters to send to the resource: 7

Java SDK G uide Action actionparam = new Action(); org.ovirt.engine.sdk.entities.vm vmparam = new org.ovirt.engine.sdk.entities.vm(); actionparam.setvm(vmparam); 3. Perform the action: Action res = vm.start(actionparam); Alternatively, you can perform the action as an inner method: Action res = vm.start(new Action() { { setvm(new org.ovirt.engine.sdk.entities.vm()); } }); 3.7. List ing Sub-Resources The following example outlines how to list the sub-resources of a resource. In this example, the subresources of a virtual machine with the name 'test' are listed. Procedure 3.4. Listing Sub-Resources 1. D eclare an instance of the resource whose sub-resources are to be listed: 2. List the sub-resources: List<VMDisk> disks = vm.getdisks().list(); 3.8. Get t ing Sub-Resources The following example outlines how to reference the sub-resources of a resource. In this example, a disk with the name 'my disk' that belongs to a virtual machine with the name 'test' is referenced. Procedure 3.5. G etting the Sub-Resources of a Resource 1. D eclare an instance of the resource whose sub-resources are to be referenced: 2. D eclare an instance of the sub-resource to be referenced: VMDisk disk = vm.getdisks().get("my disk"); 3.9. Adding Sub-Resources t o a Resource 8

Chapt er 3. Using t he Soft ware Development Kit The following example outlines how to add sub-resources to a resource. In this example, a new disk with a size of '1073741824L', interface 'virtio' and format 'cow' are added to a virtual machine with the name 'test'. Procedure 3.6. Adding a Sub-Resource to a Resource 1. Declare an instance of the resource to which sub-resources are to be added: 2. Create parameters to define the attributes of the resource: Disk diskparam = new Disk(); diskparam.setprovisionedsize(1073741824l); diskparam.setinterface("virtio"); diskparam.setformat("cow"); 3. Add the sub-resource: Disk disk = vm.getdisks().add(diskparam); 3.10. Modifying Sub-Resources The following example outlines how to modify sub-resources. In this example, the name of a disk with the name 'test_disk1' belonging to a virtual machine with the name 'test' is changed to ' test_d isk1_updated'. Procedure 3.7. Updating a Sub-Resource 1. D eclare an instance of the resource whose sub-resource is to be modified: 2. D eclare an instance of the sub-resource to be modified: VMDisk disk = vm.getdisks().get("test_disk1"); 3. Set the new value of the attribute: disk.setalias("test_disk1_updated"); 4. Update the sub-resource: VMDisk updatedisk = disk.update(); 3.11. Performing Act ions on Sub-Resources The following example outlines how to perform actions on sub-resources. In this example, a disk with the name 'test_disk1' belonging to a virtual machine with the name 'test' is activated. Procedure 3.8. Performing an Action on a Sub-Resource 9

Java SDK G uide 1. Declare an instance of the resource containing the sub-resource on which the action is to be performed: 2. D eclare an instance of the sub-resource: VMDisk disk = vm.getdisks().get("test_disk1"); 3. D eclare action parameters to send to the sub-resource: Action actionparam = new Action(); 4. Perform the action: Action result = disk.activate(actionparam); 10

Appendix A. Revision Hist ory Appendix A. Revision History Revision 3.6-2 Wed 18 Nov 2015 Red Hat Enterprise Virtualiz ation Documentation Team Final revision for Red Hat Enterprise Virtualization 3.6 beta. Revision 3.6-1 Mon 10 Aug 2015 Red Hat Enterprise Virtualiz ation Documentation Team Initial creation for the Red Hat Enterprise Virtualization 3.6 release. 11