Web based API (new, since version 6)


Ezeelogin version 6 introduced web based API using HTTP and JSON with which 3rd party applications can directly communicate with ezeelogin web panel.


A PHP library for calling the API functions in ezeelogin can be found unencoded in /usr/local/ezlogin/apilib/Ezlogin.php


Copy the above library file to the place where API client needs to be implemented. To use the library from PHP:


<?php

require_once('/path/to/apilib/Ezlogin.php');


$api_secret = 'xxx'; // replace with the API secret entered in API Settings

$api_url = 'http://ezeelogin_host.com/ezlogin'; // replace with the base URL of ezeelogin web panel without the trailing slash


$server = array(

       // fill the array with server details

);


$ezlogin = new Ezlogin($api_secret,$api_url);

$result = $ezlogin->add_server($server);


$result_obj = json_decode($result);

var_dump($result_obj);

?>


A sample unencoded PHP script using the above PHP ezeelogin API library can be found in /usr/local/ezlogin/ezwapi.php

The script is a replacement for old API script making use of the new web based API instead.


The library will also serve as an example for directly calling web API in other languages using JSON and HTTP or to write a wrapper library for other languages.


API Functions


  1. add_server

Parameters:

       name: Server hostname

       ip_address: List of IP Address separated by newline

       password: Server password

       group: Name of server group (which is already in ezeelogin)

       ssh_port: SSH port

       ssh_user: SSH user

       keep_password: N - automatic, Y - keep given password or S - keep server password

       enable_ssh: Y - enable, N - disable, H - via hostnode

       ishn: Y - hostnode, N - not a hostnode

       cp: Name of control panel (which is already in ezeelogin)

       dc: Name of data center (which is already in ezeelogin)

       onhost: Hostname of hostnode (which is already in ezeelogin)

       switch_user: Username to switch to after SSH login

       prompt1: Shell prompt after SSH login

       prompt2: Password prompt for switch user (su)

       prompt3: Shell prompt after switch user

       rc_host: Remote console host

       rc_user: Remote console username

       rc_pass: Remote console password

Return:

       status: Status message

       error: Error message


  1. update_server

Parameters:

       name: Server hostname (which is already in ezeelogin)

       newname: New hostname

       ip_address: List of IP Address separated by newline

       password: Server password

       group: Name of server group (which is already in ezeelogin)

       ssh_port: SSH port

       ssh_user: SSH user

       keep_password: N - automatic, Y - keep given password or S - keep server password

       enable_ssh: Y - enable, N - disable, H - via hostnode

       ishn: Y - hostnode, N - not a hostnode

       cp: Name of control panel (which is already in ezeelogin)

       dc: Name of data center (which is already in ezeelogin)

       onhost: Hostname of hostnode (which is already in ezeelogin)

       switch_user: Username to switch to after SSH login

       prompt1: Shell prompt after SSH login

       prompt2: Password prompt for switch user (su)

       prompt3: Shell prompt after switch user

       rc_host: Remote console host

       rc_user: Remote console username

       rc_pass: Remote console password

Return:

       status: Status message

       error: Error message


  1. delete_server

Parameters:

       name: Server hostname (which is already in ezeelogin)

Return:

       status: Status message

       error: Error message


API Script (deprecated)


An API script is provided for automating server add/edit/delete tasks in Ezeelogin. With the help of this script, you can integrate Ezeelogin with any 3rd party application managing your clients/customers. Also, make sure to enable API.

The API script can be executed as:


php /usr/local/ezlogin/ezapi.php [params...]

For help:


php /usr/local/ezlogin/ezapi.php -help

API action specific parameters and help can be obtained with:


php /usr/local/ezlogin/ezapi.php -help add_server


If you need to execute the API script from a server other than the Ezeelogin installed SSH gateway server, copy /usr/local/ezeelogin/ezlapi.php file and necessary sourceguardian loaders into the server. In this case, you must pass the Ezeelogin installed SSH gateway server IP address with –ezeelogin option to the API script. Also grant access for the server to Ezeelogin by executing the following command on Ezeelogin installed SSH gateway server:


php /usr/local/ezlogin/grant_host.php <IP address of server on which API script runs>

Make sure API is enabled in API settings for the API script to work.


PS: For “IP of Ezeelogin installed server” to provide with –ezeelogin option, you can give either master or slave node IP address.