Go to main content

Remote Administration Daemon Developer's Guide

Exit Print View

Updated: April 2020
 
 

RESTful Interface and RAD

The RESTful interface can be accessed by any HTTP client that supports UNIX domain sockets. The rad:local-http RAD service instance that is enabled by default facilitates communication with the HTTP clients.


Note -  By design, connections over UNIX domain sockets are local only.

The following example provides a quick look at the interaction with RAD by using REST.

Example 56  Interacting With RAD by Using REST

This example assumes that you have installed the pkg:/library/python/pycurl developer package.

  1. Create a new authentication session.

    # curl -X POST -c cookie.txt -b cookie.txt \ 
     --header 'Content-Type:application/json' 
     --data '{"username":"username","password":"password","scheme":"pam","timeout":-1, "preserve":true}' \
     localhost/api/com.oracle.solaris.rad.authentication/1.0/Session/ \
     --unix-socket /system/volatile/rad/radsocket-http

    Note -  Replace the username and password with values for any user on your system.
  2. Request a list of all the zones running on your system.

    # curl -H 'Content-Type:application/json' -X GET \
     localhost/api/com.oracle.solaris.rad.zonemgr/1.0/Zone?_rad_detail \
     --unix-socket /system/volatile/rad/radsocket-http -b cookie.txt

    If your system has zones, you will get a response similar to the following:

    {
            "status": "success",
            "payload": [
                    {
                            "href": "api/com.oracle.solaris.rad.zonemgr/1.2/Zone/testzone1",
                            "Zone": {
                                    "auxstate": [],
                                    "brand": "solaris",
                                    "id": 1,
                                    "uuid": "b54e20c1-3ecb-407f-ad26-befed9221860",
                                    "name": "testzone1",
                                    "state": "running"
                            }
                    },
                    {
                            "href": "api/com.oracle.solaris.rad.zonemgr/1.2/Zone/testzone2",
                            "Zone": {
                                    "auxstate": [],
                                    "brand": "solaris",
                                    "id": 2,
                                    "uuid": "358b43ba-32f9-4f27-9efa-de15ae4100a6",
                                    "name": "testzone2",
                                    "state": "running"
                            }
                    }
            ]
    }