Lenovo Physical Infrastructure Provider REST API
A reference to the Lenovo physical infrastructure provider REST API
Abstract
Chapter 1. REST API
You can use the REST API to retrieve information about providers, physical-infrastructure providers, and physical servers. You can use the CloudForms REST API if you need information about the servers in your physical infrastructure.
Before you begin
To use the REST API, you must log in to CloudForms Management Engine API as a user who has permission to access the API. The default user is admin, password is smartvm.
Use the following URL to access the CloudForms REST API:
<CloudForms_address>:<port>/api
For example:
localhost:3000/api
1.1. Retrieving Provider Details
To retrieve information for all providers, use the following request URL:
GET <CloudForms_address>:<port>/api/providers
A JSON response with the following keys is returned.
actions (list of actions that can be used) count (total number of providers) name (URI name) pages (count of pages) resource (list of URLs for each provider that is managed by CloudForms) subcount (number of providers returned)
Examples
To retrieve all information about the providers, use the ?expand=resources query parameter, for example:
GET localhost:3000/api/providers?expand=resources
To retrieve a specific information about the providers (such as name and ID), use the ?expand=resources&attributes=<attribute_list> query parameters, for example:
GET localhost:3000/ api/providers?expand=resources&attributes=id,name
To retrieve additional information about the providers (such as port, hostname, and IP address), use the ?expand=resources&attributes=<attribute_list> query parameters, for example:
GET localhost:3000/api/providers?expand=resources&attributes=port,hostname,ipaddress
To retrieve information about only Lenovo physical-infrastructure providers, use the ?expand=resources&filter[]=type=<provider_type> attribute against all provider resources, for example:
GET localhost:3000/api/providers?expand=resources&filter[]=type=ManageIQ::Providers::Lenovo::PhysicalInfraManager
1.2. Retrieving Provider Details by ID
To retrieve information for a specific provider, use the following request URL where <provider_ID> is the unique identifier of the provider:
GET <CloudForms_address>:<port>/api/providers/<provider_ID>
A JSON response with the following keys is returned.
href id name created_on updated_on guid zone_id type last_refresh_date tenant_id enabled options actions
Examples
To retrieve a specific information about the provider (such as name and ID), use the ?attributes=<attribute_list> query parameters, for example:
GET localhost:3000/api/providers/<provider_ID>?expand=resources&attributes=id,name
To retrieve additional information about the provider (such as port, hostname, and IP address), use the ?attributes=<attribute_list> query parameters, for example:
GET localhost:3000/api/providers/<provider_ID>?expand=resources &attributes=port,hostname,ipaddress
1.3. Performing physical-infrastructure provider actions
You can use the REST API to perform actions on a physical-infrastructure provider, such as creating, modifying and deleting.
Note: To perform actions on physical-infrastructure providers, you must create a basic authentication using your preferred tool or library, and use the user name and password for the CloudForms instance when using the REST API.
1.3.1. Creating a Lenovo physical-infrastructure provider
To create a Lenovo physical-infrastructure provider, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/providers
Request body:
{
"action": "create",
"credentials": {
"password": "<PASSWORD>",
"userid": "<USERNAME>"
},
"hostname": "<LENOVO XCLARITY ADMINISTRATOR ADDRESS>",
"name": "<NAME>",
"port": "<THE SERVICE PORT>",
"type": "ManageIQ::Providers::Lenovo::PhysicalInfraManager"
}1.3.2. Modifying properties for a Lenovo physical-infrastructure provider
To modify properties of a Lenovo physical-infrastructure provider, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/providers
Request body:
{
"action":"edit",
"credentials": {
"password":"<new_passowrd>",
"userid":"<new_user_name>"
},
"hostname":"<New_Lenovo_XClarity_Administrator_address>",
"name":"<new_provider_name>",
"port":"<new_service_port>"
}1.3.3. Refreshing information about all providers
To refresh information about all providers, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/providers
Request body:
{
"action":"refresh"
}1.3.4. Deleting a physical-infrastructure provider
To delete a specific provider:
Send a DELETE request using the following request URL.
DELETE <CloudForms_address>:<port>/api/providers/<provider_ID>
Send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/providers/<provider_ID>
Request body:
{ "action":"delete" }
1.3.5. Performing an action on multiple physical-infrastructure providers
To perform an action on more than one physical-infrastructure providers, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/providers
Request body:
{
"action":"<action>",
"resources": [{
"href":"<provider_ID>"
},
{
"href":"<provider_ID>"
}]
}1.4. Retrieving Physical Server Details
To retrieve information for all physical servers, use the following request URL:
GET <CloudForms_address>:<port>/api/physical_servers
A JSON response with the following keys is returned.
actions (list of actions that can be used) count (count of the physical servers) name (URI name) pages (count of pages) resource (list of URLs of the each physical servers) subcount (count of the physical servers returned)
Examples
To retrieve all information about the physical servers, use the ?expand=resources query parameter, for example:
GET localhost:3000/api/physical_servers?expand=resources
To retrieve a specific information about the physical servers (such as name and ID), use the ?expand=resources&attributes=<attribute_list> query parameters, for example:
GET localhost:3000/api/physical_servers?expand=resources&attributes=id,name
To retrieve specific information about the physical servers (such as firmware, networks, guest devices, and asset details), use the ?expand=resources&attributes=<attribute_list> query parameters, for example:
GET localhost:3000/api/physical_servers?expand=resources&attributes= hardware.firmwares,hardware.networks,hardware.guest_devices,hardware.assets_details
To retrieve information about only a specific physical server, use the ?expand=resources&filter[]=name=<server_name> query attributes on all physical-server resources, for example:
GET localhost:3000/api/physical_servers?expand=resources&filter[]=name=Server1-20127X5462
1.5. Retrieving Physical Server Details by ID
To retrieve information for a specific physical server, use the following request URL:
GET <CloudForms_address>:<port>/api/physical_servers/<server_ID>
A JSON response with the following keys is returned.
actions created_at ems_id ems_ref field_replaceable_unit health_state hostname href location_led_state machine_type manufacturer model name power_state product_name serial_number type uid_ems updated_at vendor
Examples
To retrieve a specific information about a specific physical server (such as name and ID), use the ?expand=resources&attributes=<attribute_list> query parameters, for example:
GET localhost:3000/api/physical_servers/<server_ID>?expand=resources&attributes=id,name
To retrieve a specific information about a specific physical server (such as firmware, networks, guest devices, and asset details), use the ?expand=resources&attributes=<attribute_list> query parameters, for example:
GET localhost:3000/api/physical_servers/<server_ID>?expand=resources &attributes=hardware.firmwares,hardware.networks,hardware.guest_devices,hardware.assets_details
1.6. Performing physical server actions
You can use the REST API to perform management tasks on a physical server, such as powering on an off, restarting, and changing the location-LED state.
Note: To perform actions on physical servers, you must create a basic authentication using your preferred tool or library, and enter your user name and password to access the CloudForms REST API.
1.6.1. Powering on a physical server
To power on a specific physical server, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/physical_servers/<server_ID>
Request body:
{
"action":"power_on"
}1.6.2. Powering off a physical server
To shut down the operating system and power off a specific physical server, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/physical_servers/<server_ID>
Request body:
{
"action":"power_off"
}1.6.3. Immediately powering off a physical server
To immediately power off a specific physical server, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/physical_servers/<server_ID>
Request body:
{
"action":"power_off_now"
}1.6.4. Restarting a physical server
To shut down the operating system and restart a specific physical server, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/physical_servers/<server_ID>
Request body:
{
"action":"restart"
}1.6.5. Immediately restarting a physical server
To immediately restart a specific physical server, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/physical_servers/<server_ID>
Request body:
{
"action":"restart_now"
}1.6.6. Changing the location LED state on a physical server to blinking
To change the location-LED state to blinking on a specific server, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/physical_servers/<server_ID>
Request body:
{
"action":"blink_loc_led"
}1.6.7. Performing an action on multiple physical servers
To perform an action on more than one physical severs, send a POST request using the following request URL and JSON request body.
POST <CloudForms_address>:<port>/api/physical_servers
Request body:
{
"action":"<action>",
"resources": [{
"href":"<server_ID>"
},
{
"href":"<server_ID>"
}]
}