How to install an Operating System using the API?
Publisher: Psychz Networks, December 15,2022You can use Psychz Client API to automate OS installations on your servers. Follow these steps to get started. Use the following link for OS Installation related APIs https://www.psychz.net/api/doc/dist/#/DEVICE - OS INSTALL.
Prerequisites
- Whitelist Your IP Address: Add your IP address in the “IP Address” section under the API feature in your Dashboard.
- Get Token and Username: Follow the steps in the Setup API Access article to obtain these credentials.
The API feature offers the following three functions (API calls) in sequence
- OS_INSTALL_CATEGORY: Lists available operating systems, disk partitions, and software RAID options.
- OS_INSTALL: Initiates the OS installation.
- OS_INSTALL_STATUS: Checks the status of the installation.
OS_INSTALL_CATEGORY
The Category Get request will display all the available operating systems (Linux, Windows, VMWare, etc.), disc partition, and Software Raid.
Mandatory Parameters
- access_token
- access_username
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
"7366": {
"20": {
"osId": "7366",
"partId": "20",
"partName": "CentOS 6 Default Std. Partition ext4"
}
},
"SoftwareRaidRequired": "Yes",
"HostnameRequired": "Yes",
"AuthMethodRequired": "Yes",
"PasswordRequired": "Yes",
"PasswordRepeatRequired": "Yes"
},
IMPORTANT: Download the full JSON file for detailed parameters. Note down the "osId" and "partId" of the desired OS you would like to install. For more details, visit the Psychz API Documentation.
OS_INSTALL
Use this API to start an OS installation by providing the Device ID, OS Category, OS ID, and Disk Partition ID. Additional parameters for custom installations can be obtained from the OS Category API.
Mandatory Parameters:
- access_token: Credentials from Dashboard
- access_username: Credentials from Dashboard
- device_id: Refer to the Device page on your Client Dashboard
- os_cat: OS category from os_install_category API call
- os_id: Value from os_install_category API call
- disk_partition_id: Value from os_install_category API call
- disk_partition_boot_size: Choose an integer value between bootSizeMin and bootSizeMax
- disk_partition_swap_size: Choose a value from the set {4, 8, 16, 32, 64} that falls within the range
- disk_partition_file_system: Select either of the following xfs, ext4, ntfs
- disk_partition_management: Select from lvm, hdd, sdd
- hostname: Required, verify via os_install_category API
- auth_method: Choose 1 for password (both password and password_repeat required) or 2 for SSH Key (ssh_public_keyrequired)
- password: 12-30 alphanumeric characters, special characters allowed
- password_repeat: Must match password
- ssh_public_key_id: From public key list, see “SSH Keys” page
Optional Parameters:
- plan_id: Obtain from /v1/order_plans API
- software_raid: Value from os_install_category API
- enforce_password_change: ‘0’ or ‘1’
- powershell: For Windows OS, upload shell script for post-installation tasks
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: Note down the "task_id" to check the os installation status in the next step.
OS_INSTALL_STATUS
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 from Dashboard)
- access_username (Credentials from Dashboard)
- ticket_id (Value from os_install API call)
Sample code
"status": true,
"data": {
"status": "processing",
"progress": "30%"
}
}
For more functionality-related information, kindly refer to the following page https://www.psychz.net/api/doc/dist/.