How to install an Operating System using the API?
Publisher: Psychz Networks, December 15,2022The following instructions will guide you on installing an Operating System using Psychz Client API. With the help of our APIs, you can integrate your system to perform seamless processing of OS installations on your servers which are part of your service from Psychz Networks. You can fetch OS Installation related APIs from the following link https://www.psychz.net/api/doc/dist/#/DEVICE - OS INSTALL.
Let us begin with gathering all the required details to perform successful API testing.
Prerequisites
- Whitelist your IP Address that is in use. To do so, please add the desired IP address in the "IP Address" section under API feature in your Dashboard.
- To perform the test, you will need a Token and a Username. To fetch these details, follow the steps given in the article here Setup API Access
Now that you have the token and the username, you can try the APIs related to OS Install.
The API feature offers the following three functions (API calls) in sequence
- OS_Install_Category
- OS_Install
- OS_Install_Status
OS_INSTALL_Category API call
The Category Get request will display all the available operating systems (Linux, Windows, VMWare, etc.), disc partition, and Software Raid.
- Mandatory Parameters
- access_token (Credentials that can be obtained from Dashboard)
- access_username (Credentials that can be obtained from Dashboard)
- Optional Parameters
- device_id (Refer to the Device page on your Client Dashboard)
- plan_id (Use the /v1/order_plans feature under the API page to obtain a plan ID)
Sample Code
"os_list": {
"7366": {
"osId": "7366",
"osName": "CentOS 6 Latest Stable - $0.00/Month",
"osCategory": "Linux",
"osPartitions": {
"9": {
"osId": "7366",
"partId": "9",
"partName": "CentOS 6 Default LVM Partition"
},
"20": {
"osId": "7366",
"partId": "20",
"partName": "CentOS 6 Default Std. Partition ext4"
}
},
"SoftwareRaidRequired": "Yes",
"HostnameRequired": "Yes",
"AuthMethodRequired": "Yes",
"PasswordRequired": "Yes",
"PasswordRepeatRequired": "Yes"
},
NOTE: The above is only a piece of code for your reference. You can download the entire JSON file at your end to view the parameters in detail.
IMPORTANT: From the above response, please note down the "osId" and "osPartitions" -> "partId" of the desired OS you would like to install.
OS_INSTALL API Call
Using this API feature, you can initiate OS installation by passing the Device ID, Category (1-Linux, 2-Windows), OS ID, and Disk Partition ID. Apart from these, there are many other values that you can pass to further custom install the OS. These values can be obtained from OS Category API.
- Mandatory Parameters
- access_token (Credentials that can be obtained from Dashboard)
- access_username (Credentials that can be obtained from Dashboard)
- device_id (Refer to the Device page on your Client Dashboard)
- os_cat (OS category - To be noted from os_install_category API call)
- os_id (value to be noted from os_install_category API call)
- disk_partition_id (value to be noted from os_install_category API call)
- Optional Parameters
- plan_id (Use the /v1/order_plans feature under the API page to obtain a plan ID)
- software_raid (Value can be obtained from api /os_install_category.)
- hostname (Value can be obtained from api /os_install_category.)
- auth_method (OS dependent field either 'YES' or 'NO'. Refer to api /os_install_category.)
- password (Must contain 12-20 alphanumeric characters except special characters)
- password_repeat (OS dependent field. Must be same as password)
- enforce_password_change (Enforce user to change password on 1st login. Value either '0' or '1')
- powershell (For windows OS only. Upload shell script file to perform post installation executions.)
Sample code
{
"status": 200,
"data": {
"status": true,
"response": {
"status": "1",
"message": "OS install request added Successfully. You can check status with api /os_install_status task_id : 906667"
}
}
}
IMPORTANT: Please note down "task_id" to check the os installation status in the next step.
OS_INSTALL_STATUS API Call
Installation status allows you to check the progress of your OS installation in real time. The completion status is shown in %.
- Mandatory Parameters
- access_token (Credentials that can be obtained from Dashboard)
- access_username (Credentials that can be obtained from Dashboard)
- ticket_id (Value noted from os_install API call)
Sample code
{
"status": true,
"data": {
"status": "processing",
"progress": "82%"
}
}
For more functionality-related information, kindly refer to the following page https://www.psychz.net/api/doc/dist/.