-
Notifications
You must be signed in to change notification settings - Fork 5
api system
The following section would describe the API for the system section of StorLever. StorLever system API has the following structure:
The following operations are used to Get/Set system general information.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/localhost
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe the system general information.
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/localhost
This API is used to set the host name to a special string, and the new name would be add to hosts list with 127.0.0.1 automatically
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/localhost
-
HTTP Method
PUT
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
hostname
string
Optional
The host name of the remote system. If absent, the host name would not be changed
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
NULL
-
Example
curl -v -X PUT -H "Content-Type: application/json; charset=UTF-8" -d '{"hostname":"localhost"}' http://192.168.1.15:6543/storlever/api/v1/system/localhost
This API is used to get the cpu info, like model, frequency, cache, in system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/cpu_list
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe the CPU info.
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/cpu_list
This API is used to measure the CPU usage percent in the given interval, and return the measure result
Note: the response would return in your given interval time
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/cpu_percent
-
HTTP Method
GET
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
interval
number
Optional
The measure time in seconds. If absent, default to 1 sec
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON number to indicate the usage percent of total CPU
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/cpu_percent
This API is used to measure the each CPU usage percent in the given interval, and return the measure result
Note: the response would return in your given interval time
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/per_cpu_percent
-
HTTP Method
GET
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
interval
number
Optional
The measure time in seconds. If absent, default to 1 sec
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON list to indicate the usage percent of per CPU
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/per_cpu_percent
This API is used to get the memory usage info, the return value is presented in byte unit.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/memory
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe the memory usage info, present in bytes
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/memory
This API is used to retrieve the current running process list in system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/ps
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON list where its each entry is a JSON object describing one process running info
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/ps
The following operations are used to maintain the system
This API is used to flush out all the page cache of system. After that, the page cache would be recycled to free memory
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/flush_page_cache
-
HTTP Method
POST
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
NULL
-
Example
curl -v -X POST http://192.168.1.15:6543/storlever/api/v1/system/flush_page_cache
SELinux is a access control tool in Linux. With it, many storage task would be failed. StorLever realize this fact and provide API to monitor & control SELinux state
This API is used to retrieve the current SELinux running info including state
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/selinux
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe the SELinux running info
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/selinux
This API is used to control the SELinux running state. After the state is changed, administrator must restart the system to make it in effect
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/selinux
-
HTTP Method
PUT
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
state
string
Optional
can only be enforcing|permissive|disabled. If absent, the state would not be changed
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
NULL
-
Example
curl -v -X PUT -H "Content-Type: application/json; charset=UTF-8" -d '{"state":"disabled"}' http://192.168.1.15:6543/storlever/api/v1/system/selinux
This API is used to get the current date and time in the system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/datetime
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe the system date & time in ISO format
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/datetime
This API is used to set the date and time in the system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/datetime
-
HTTP Method
PUT
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
datetime
string
Required
date and time in ISO format, e.g YYYY-MM-DDThh:mm:ss[+HHMM]
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
NULL
-
Example
curl -v -X PUT -H "Content-Type: application/json; charset=UTF-8" -d '{"datetime":"2014-07-18T10:55:37+0800"}' http://192.168.1.15:6543/storlever/api/v1/system/datetime
This API is used to retrieve the time from from Epoch, measure in seconds
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/timestamp
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe the timestamp in its timestamp field
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/timestamp
This API is used to power off the system. In one seconds after response is return, the system would start power off procedure
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/poweroff
-
HTTP Method
POST
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
NULL
-
Example
curl -v -X POST http://192.168.1.15:6543/storlever/api/v1/system/poweroff
This API is used to reboot the system. In one seconds after response is return, the system would start reboot procedure
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/reboot
-
HTTP Method
POST
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
NULL
-
Example
curl -v -X POST http://192.168.1.15:6543/storlever/api/v1/system/reboot
This API is used to download the system log. The system /var/log directory would tar and gzip, then return in response.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/log_download
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
The following header would be in response:
Content-Type: application/force-download
Content-Type header indicate this response include a file download content
Content-Disposition: attachment; filename=%s
Content-Disposition header give extra infomation about the response content, like filename.
-
Response Content
The tar.gz file content
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/log_download
The following operations are used to retrieve some statistic info from the system
This API is used to retrieve the total CPU time (in seconds) in each working mode. User can make use this API to measure each working mode's occupation percent for a specific period.
This API is more user-friendly than the measuring CPU usage by StorLever.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/cpu_times
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe the total CPU time (in seconds, float type) in each mode
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/cpu_times
This API is used to retrieve the per CPU time (in seconds) in each working mode. User can make use this API to measure each working mode's occupation percent for a specific period for each CPU.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/per_cpu_times
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON list where each entry is JSON object to describe each CPU time (in seconds) in each mode
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/per_cpu_times
This API is used to retrieve the disk IO counter for all disk in the system. User can make use this API to measure the total disk IO in the specific period.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/disk_io_counters
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe each IO counter for all the disk device
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/disk_io_counters
This API is used to retrieve the disk IO counter for each disk device in the system. User can make use this API to measure the disk IO for each disk device in the specific period.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/per_disk_io_counters
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON list with each entry to describe each IO counter for each disk device
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/per_disk_io_counters
This API is used to retrieve the network IO counter for all interface in the system. User can make use this API to measure the total network IO in the specific period.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/net_io_counters
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe each IO counter for all network interface
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/net_io_counters
This API is used to retrieve the network IO counter for each network interface in the system. User can make use this API to measure the network IO for each network interface in the specific period.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/per_net_io_counters
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON list with each entry to describe each IO counter for each network interface
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/per_net_io_counters
The following operations are used to handle the configuration of StorLever
This API is used to download the configuration file from StorLever, the configuration file is of the form of tar.gz, which includes all the files and directory structure related to StorLever. User can download the configuration to verify or backup for future configuration restore
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/conf_tar
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
The following response header would be added
- Content-Type: application/force-download
This header is used to tell the browser that the context in response is to download and save as a file, not for display.
- Content-Disposition: attachment; filename=[file_name]
This header is to give the [file_name] info about the download file,
-
Response Content
A tar.gz file which contains all the configuration file about StorLever
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/conf_tar > storlever_conf.tar.gz
This API is used to upload the configuration file to StorLever, the configuration file must be a tar.gz file which is download from StorLever before.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/conf_tar
-
HTTP Method
PUT
-
Request Content
A tar.gz file
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
NULL
-
Response Content
NULL
-
Example
curl -v -X PUT --data-binary @storlever_conf.tar.gz http://192.168.1.15:6543/storlever/api/v1/system/conf_tar
This API is used to clear the application server configuration of StorLever, which reset them to init state. These configuration to reset restricts to application configuration, exclude:
- block device configuration
- system related configuration
- network related configuration
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/conf_tar
-
HTTP Method
DELETE
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
NULL
-
Response Content
NULL
-
Example
curl -v -X DELETE http://192.168.1.15:6543/storlever/api/v1/system/conf_tar
This API is used to back up the configuration to the specific path in the system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/backup_conf
-
HTTP Method
POST
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
file
string
Required
The file path name to save the configuration, it would be of form of tar.gz
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
NULL
-
Response Content
NULL
-
Example
curl -v -X POST -H "Content-Type: application/json; charset=UTF-8" -d '{"file":"/root/storlever.tar.gz"}' http://192.168.1.15:6543/storlever/api/v1/system/backup_conf
This API is used to restore the configuration with the specific file in the system. This file must exists and should be the back up from StorLever before
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/restore_conf
-
HTTP Method
POST
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
file
string
Required
The file path to restore from
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
NULL
-
Response Content
NULL
-
Example
curl -v -X POST -H "Content-Type: application/json; charset=UTF-8" -d '{"file":"/root/storlever.tar.gz"}' http://192.168.1.15:6543/storlever/api/v1/system/restore_conf
The following API are used to manage the user and group in Linux system
This API is used to retrieve the user list of Linux system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/user_list
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON list with each entry to describe one user info in system
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/user_list
This API is used to retrieve one user info of Linux system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/user_list/[user_name]
[user_name] is the name of the user info to retrieve
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe this specific user info
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/user_list/root
This API is used to add a new user to the system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/user_list
-
HTTP Method
POST
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
name
string
Required
new user name
uid
int
Optional
new user's uid. Default is a system auto-increment value
password
string
Optional
new user's password. Default is empty
comment
string
Optional
new user's description. Default is empty
primary_group
string
Optional
new user's primary group name. Default is the same with user name
groups
string
Optional
This option contains the names (comma-separated) of the other groups which includes the new user. Default is empty, means no other group include that user
home_dir
string
Optional
new user's home directory. Default is system default position (like /home/[user_name] in most Linux distribution)
login
bool
Optional
The new user can login the system or not. For system user used by some service daemon, it should be false to prevent them from login. Default is True
-
Status Code
201 - Successful
Others - Error
-
Special Response Headers
The following response header would be added
Location: [user_url]
[user_url] is the URL to retrieve the new user info
-
Response Content
NULL
-
Example
curl -v -X POST -H "Content-Type: application/json; charset=UTF-8" -d '{"name":"test_user"}' http://[host_ip]:[storlever_port]/storlever/api/v1/system/user_list
This API is used to modify a user info in the system, the given user must exists in system.
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/user_list/[user_name]
[user_name] is the name of the user info to modify
-
HTTP Method
PUT
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
name
string
Required
user name
uid
int
Optional
user's uid. Default is unchanged
password
string
Optional
user's password. Default is unchanged
comment
string
Optional
user's description. Default is unchanged
primary_group
string
Optional
user's primary group name. Default is unchanged
groups
string
Optional
This option contains the names (comma-separated) of the other groups which includes the user. Default is unchanged
home_dir
string
Optional
user's home directory. Default is unchanged
login
bool
Optional
The user can login the system or not. Default is unchanged
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
NULL
-
Response Content
NULL
-
Example
curl -v -X PUT -H "Content-Type: application/json; charset=UTF-8" -d '{"name":"test_user", "comment":"test"}' http://[host_ip]:[storlever_port]/storlever/api/v1/system/user_list/test_user
This API is used to delete a user in system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/user_list/[user_name]
[user_name] is the name of the user info to delete
-
HTTP Method
DELETE
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
NULL
-
Example
curl -v -X DELETE http://192.168.1.15:6543/storlever/api/v1/system/user_list/test_user
This API is used to retrieve the group list of Linux system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/group_list
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON list with each entry to describe one group info in system
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/group_list
This API is used to retrieve one group info of Linux system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/group_list/[group_name]
[group_name] is the name of the group info to retrieve
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe this specific group info
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/group_list/root
This API is used to add a new group to the system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/group_list
-
HTTP Method
POST
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
name
string
Required
new group name
gid
int
Optional
new group's gid. Default is a system auto-increment value
-
Status Code
201 - Successful
Others - Error
-
Special Response Headers
The following response header would be added
Location: [group_url]
[group_url] is the URL to retrieve the new group info
-
Response Content
NULL
-
Example
curl -v -X POST -H "Content-Type: application/json; charset=UTF-8" -d '{"name":"test_group"}' http://[host_ip]:[storlever_port]/storlever/api/v1/system/group_list
This API is used to delete a group in system
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/group_list/[group_name]
[group_name] is the name of the group to delete
-
HTTP Method
DELETE
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
NULL
-
Example
curl -v -X DELETE http://192.168.1.15:6543/storlever/api/v1/system/group_list/test_group
The following API are used to manage the service daemon in StorLever.
Note: The services managed by these set of API are restricted to the service provided in StorLever, not including all the service in Linux service
This API is used to retrieve the service list in StorLever
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/service_list
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON list with each entry to describe one service info and state
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/service_list
This API is used to retrieve one service info of StorLever
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/service_list/[service_name]
[service_name] is the name of the service to retrieve
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe this specific service info and state
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/service_list/[service_name]
This API is used to control the service, like start/stop/restart/reload
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/service_list/[service_name]
[service_name] is the name of the service to control
-
HTTP Method
PUT
-
Request Content
A JSON object with the following field definition.
Fields
Type
Optional
Meaning
state
bool
Optional
If True, start the service. If False, stop the service. Default is no effect
restart
bool
Optional
If True, restart the service. If False or absent, no effect
reload
bool
Optional
If True, reload the configuration of the service. If False or absent, no effect
auto_start
bool
Optional
Set the auto-start state on boot. Default is no change
It should be only one field presented for state, restart, reload
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
NULL
-
Response Content
NULL
-
Example
curl -v -X PUT -H "Content-Type: application/json; charset=UTF-8" -d '{"state": true, "auto_start": true}' http://[host_ip]:[storlever_port]/storlever/api/v1/system/service_list/[service_name]
The following API are used to manage the function module in StorLever, including the standard modules and extension
Note: each module in StorLever implement one individual function. StorLever is consist of many modules.
This API is used to retrieve the function module name list in StorLever
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/module_list
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON list including all module name in StorLever
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/module_list
This API is used to retrieve one module info of StorLever
-
Resource URI
http://[host_ip]:[storlever_port]/storlever/api/v1/system/module_list/[module_name]
[module_name] is the name of the module info to retrieve
-
HTTP Method
GET
-
Request Content
NULL
-
Status Code
200 - Successful
Others - Error
-
Special Response Headers
No
-
Response Content
A JSON object to describe this specific module info
-
Example
curl -v -X GET http://192.168.1.15:6543/storlever/api/v1/system/module_list/[module_name]