Using the REST API to manage RHEV - Red Hat

18
Using the REST API to manage RHEV Rob Locke Senior Curriculum Developer June 25, 2015

Transcript of Using the REST API to manage RHEV - Red Hat

Page 1: Using the REST API to manage RHEV - Red Hat

Using the REST API to manage RHEV

Rob LockeSenior Curriculum DeveloperJune 25, 2015

Page 2: Using the REST API to manage RHEV - Red Hat

About the RHEV-M REST API

Page 3: Using the REST API to manage RHEV - Red Hat

About the RHEV-M REST API

● Integrate RHEV-M with third-party virtualization software● Perform automated maintenance or error-checking tasks● Automate repetitive RHEV management tasks with scripts

Page 4: Using the REST API to manage RHEV - Red Hat

API features

● Infrastructure configuration● VM configuration and management● Guest networking, virtual disks, and VM properties● User and accounting management● Daily maintenance and VM life-cycle management● Advanced operations not available using the GUI

Perl, Python, or Java – HTTP and XML support

Page 5: Using the REST API to manage RHEV - Red Hat

https://rhevm.pod0.example.com/api

Page 6: Using the REST API to manage RHEV - Red Hat

Using the RHEV-M REST API with curl

Page 7: Using the REST API to manage RHEV - Red Hat

wget http://rhevm.pod0.example.com/ca.crt

Page 8: Using the REST API to manage RHEV - Red Hat

curl --cacert ca.crt

-u '[email protected]:redhat'https://rhevm.pod0.example.com/api

Page 9: Using the REST API to manage RHEV - Red Hat

curl --cacert ca.crt

-u '[email protected]'https://rhevm.pod0.example.com/api

Page 10: Using the REST API to manage RHEV - Red Hat

echo 'machine rhevm.pod0.example.com login [email protected] password redhat' > ~/.netrc

chmod 600 ~/.netrc

curl -n --cacert ca.crt https://rhevm.pod0.example.com/api

Page 11: Using the REST API to manage RHEV - Red Hat

curl -n --cacert ca.crt https://rhevm.pod0.example.com/api/vms?search=*rhel*

Page 12: Using the REST API to manage RHEV - Red Hat

curl -n --cacert ca.crt-X PUT

-H 'Accept: application/xml'-H 'Content-Type: application/xml'

-d '<vm><description>API Example</description></vm>' https://rhevm.pod0.example.com/api/vms/UUID

Page 13: Using the REST API to manage RHEV - Red Hat

curl -n --cacert ca.crt-X POST

-H 'Accept: application/xml'-H 'Content-Type: application/xml'

-d '<action><pause>true</pause></action>' https://rhevm.pod0.example.com/api/vms/UUID/start

Page 14: Using the REST API to manage RHEV - Red Hat

curl -n --cacert ca.crt-X POST

-H 'Accept: application/xml'-H 'Content-Type: application/xml'

-d '<action />' https://rhevm.pod0.example.com/api/vms/UUID/shutdown

Page 15: Using the REST API to manage RHEV - Red Hat

Using the RHEV-M REST API with python

Page 16: Using the REST API to manage RHEV - Red Hat

wgethttp://172.25.254.254/pub/materials/storage_query.py

Page 17: Using the REST API to manage RHEV - Red Hat

Exercise

Page 18: Using the REST API to manage RHEV - Red Hat