The following section describes Server URIs. Version 1.1 of the BFC API supports retrieving information about servers in the BFC. For example, you can retrieve information for all servers in the system, including available servers, and servers allocated to grids. You can also retrieve information about a single server through its boot MAC address.
You can retrieve information about all servers in the system:
GET BFC/servers
None
Returns HTTP return code 200 and a list of server records on success. Returns an HTTP error code and the associated fault information on error.
Retrieves information about the current set of servers in the system as a list of server records. For the 1.1 release of the BFC API, you cannot specify the range of server records to return. Instead, records are returned for all servers in the system.
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='GET',
url='/BFC/servers',
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
servers = json.loads(r1.read())
print json.dumps(servers, sort_keys=True, indent=4)
Example JSON Payload
[{"server":{
"comp_id":1557,
"state":"resource_running_state",
"server_state_info":{
"server_state_info":{
"effective_state":
"resource_running_state",
"category_code_args":[],
"category_code":"core/resources.compute_host.category_compute_host_power",
"category_format":"Compute Host Power Status",
"code":"core/resources.compute_host.compute_host_normal_powered",
"format":"Functioning normally.",
"inventorying":false,
"applogic_server_name":"srv1",
"applogic_server_state":"up",
"applogic_server_enabled":true,
"has_grid_controller":true,"vmware":false}},
"grid_name":"gridtest",
"power_status":"on",
"description":[],
"discovery_date":1344988800000,
"cpu_cores":4,"cpu_speed":3.0,"memory_size":4.0,"disk_count":1,
"total_disk_space":146.81302272,"force_manual_power":false,
"network_interfaces":[{
"network_interface":{
"connectivity":
"backbone",
"ip_address":"192.168.0.x",
"is_boot":true,
"mac_address":"00:01:02:03:04:05",
"name":"eth0","speed":1000}},{
"network_interface":{
"connectivity":"external",
"ip_address":"10.10.x.x",
"is_boot":false,
"mac_address":"00:01:02:03:04:05",
"name":"eth1",
"speed":1000}}],
"disks": [{
"disk":{
"name":"/dev/sda",
"size":146.81302272}}],
"power_controllers":[{
"power_controller":{
"comp_id":1574,
"ip_address":"10.10.x.x",
"mac_address":"00:01:02:03:04:05",
"type":"controlled",
"username":"PowerAdmin__BFC",
"password":"*****",
"credential_set_time":134580.189,
"power_status":"on"}
}],
"tags":["Blue","Green"]}}]%
You can retrieve information about a single server in the system by specifying the boot MAC address of the server in the GET URI.
GET BFC/servers/<server MAC address>
None
Returns HTTP return code 200 and a payload that is a server record on success. Returns an HTTP error code and the associated fault information on error.
Retrieves information about a single servers in the system. The information is returned in a server records.
Example GET
GET BFC/servers/00:01:02:03:04:05
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='GET',
url='/BFC/servers/' + serverMac,
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1=conn.getresponse()
server = json.loads(r1.read())
print 'HTTP Response Code: {0}'.format(r1.status)
print json.dumps(server, sort_keys=True, indent=4)
Example JSON Payload
{
"server": {
"comp_id": 1575,
"description": [],
"discovery_time": 1349136000000,
"grid_info": {
"grid_info": {
"category": null,
"comp_id": 1603,
"message": "Waiting for grid cleanup",
"name": "mygrid",
"state": "resource_booting_state",
"uri": "BFC/grids/mygrid"
}
},
"grid_os_info": {
"grid_os_info": {
"applogic_server_enabled": false,
"applogic_server_name": null,
"applogic_server_state": "creating_grid",
"category": "Compute Host Power Status",
"comp_id": 1628,
"has_grid_controller": false,
"hypervisor_type": "Xen",
"message": "Compute host is currently under active power control.",
"state": "resource_running_state"
}
},
"ignore_power_controllers_during_inventory": false,
"inventory": {
"inventory": {
"cpu_cores": 4,
"cpu_speed": 3.0,
"disk_count": 1,
"disks": [
{
"disk": {
"name": "/dev/sda",
"size": 146.81302271999999
}
}
],
"inventory_time": 1349136000000,
"memory_size": 4.0,
"network_interfaces": [
{
"network_interface": {
"connectivity": [
"backbone"
],
"ip_address": "192.168.X.X",
"is_boot": true,
"mac_address": "00:01:02:03:04:05",
"name": "eth0",
"speed": 1000
}
},
{
"network_interface": {
"connectivity": [
"external"
],
"ip_address": "10.10.X.X",
"is_boot": false,
"mac_address": "01:02:03:04:05:06",
"name": "eth1",
"speed": 1000
}
}
],
"power_controllers": [
{
"power_controller": {
"comp_id": 1592,
"credential_mode": "system_configured",
"credential_set_time": 1349226625437.5129,
"ip_address": "10.10.X.X",
"mac_address": "02:03:04:05:06:07",
"power_status": "on",
"type": "controlled",
"user_number": 3,
"username": "PowerAdmin__BFC"
}
}
],
"total_disk_space": 146.81302271999999
}
},
"inventorying": false,
"mac_address": "00:01:02:03:04:05",
"power_ip_address": "10.10.X.X",
"power_mode": "controlled",
"power_status": "on",
"server_info": {
"server_info": {
"category": "Compute Host Power Status",
"message": "Compute host is currently under active power control.",
"state": "resource_running_state",
"uri": "BFC/servers/00:01:02:03:04:05"
}
},
"tags": []
}
}
POST BFC/servers/<server mac>/operations/forceManualPower
None
Returns the HTTP return code 200 and sets the ignore_power_controller flag is set to true. Returns an HTTP error code and the associated fault information on error.
Use this operation to place the server into manual power mode. This operation also implicitly enables PUT operations to the field ignore_power_controllers_during_inventory in the server record.
Example POST
POST BFC/servers/00:01:02:03:04:05/operations/forceManualPower
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='POST',
url='/BFC/servers/' + serverMac + '/operations/forceManualPower',
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
if r1.status > 200:
error = json.loads(r1.read())
print error
POST BFC/servers/<server mac>/operations/quarantine
Arguments
None
Return
Returns the HTTP return code 202 on success and displays that the server record has the state of resource_quarantined_state. Returns an HTTP error code and the associated fault information on error. No payload is returned by this operation. The user must do a GET on servers or this particular server to retrieve state information
Use this operation to quarantine the server. For example, if you need to replace a hard disk on one of your servers in a grid, you can quarantine the server so that grids cannot use this server.
Note: You cannot quarantine a server that is in a grid. The server must first be removed from the grid, then quarantined.
Example POST
POST BFC/servers/00:01:02:03:04:05/operations/quarantine
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='POST',
url='/BFC/servers/' + serverMac + '/operations/quarantine',
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
POST BFC/servers/<server mac>/operations/unquarantine
Arguments
None
Returns the HTTP return code 202 on success and displays that the server record has the state of resource_ready_state and the inventorying flag is true. No payload is returned by this operation.
Use this operation to unquarantine the server. The user must do a GET on servers or this particular server to retrieve state information.
Example POST
POST BFC/servers/00:01:02:03:04:05/operations/unquarantine
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='POST',
url='/BFC/servers/' + serverMac + '/operations/unquarantine',
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
POST BFC/servers/<server mac>/operations/powerOff
None
Returns the HTTP return code 200 and powers off the server. Returns an HTTP error code and the associated fault information on error. No payload is returned by this operation.
Use this operation to power off the server. Find the available server and quarantine the server before you execute the power off command, or the operation fails. After you power the server again, unquarantine the server.
Example POST
POST BFC/servers/00:01:02:03:04:05/operations/powerOff
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='POST',
url='/BFC/servers/' + serverMac + '/operations/powerOff',
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
POST BFC/servers/<server mac>/operations/powerCycle
None
Returns the HTTP return code 200 and a powers on the server. Returns an HTTP error code and the associated fault information on error. No payload is returned by this operation.
Use this operation to power the server back on again. For example, you quarantined a server and turned it off, and you want to power the server again.
Example POST
POST BFC/servers/00:01:02:03:04:05/operations/powerCycle
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='POST',
url='/BFC/servers/' + serverMac + '/operations/powerCycle',
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
POST BFC/servers/<server mac>/operations/clearFailure
None
Returns the HTTP return code 202 on success. Returns an HTTP error code and the associated fault information on error. No payload is returned by this operation.
Use this operation to clear the list of failures from the server. For example, you unquarantined the server after you turned off the power. The server fails and you power on the server. You can unquarantine the server after you clear the failure.
Example POST
POST BFC/servers/00:01:02:03:04:05/operations/clearFailure
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='POST',
url='/BFC/servers/' + serverMac + '/operations/clearFailure',
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
POST BFC/servers/<server mac>/inventory/power_controllers/<power_mac>/operations/useUserLoginCredentials
Payload is the username and password.
Returns the HTTP return code 200 and updates the credential_mode field on success. Returns an HTTP error code and the associated fault information on error.
Use this operation to use the credentials set up by the administrator to communicate with the power controller remotely.
Note: This operation updates the credential_mode field.
Example POST
POST BFC/servers/00:01:02:03:04:05/inventory/power_controllers/01:02:03:04:05:06/operations/useUserLoginCredentials
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
powerMac = sys.argv[2]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='POST',
url='/BFC/servers/' + serverMac + '/inventory/power_controllers' + 'powerMac' + '/operations/useUserLoginCredentials',
body='{"power_controller":{"username":"user1","credential_mode":"user_preset"}})',
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
POST BFC/servers/<server mac>/inventory/power_controllers/<power_mac>/operations/useSystemLoginCredentials
None
Returns the HTTP return code 200 and updates the credential_mode field on success. Returns an HTTP error code and the associated fault information on error.
Uses the system login credentials to communicate with the power controller remotely. This operation uses the login configured in the power controller during discovery. If BFC power credential configuration failed, this command uses the system-wide preset backup credentials that you set through BFC admin operations.
Note: This operation updates the credential_mode field.
Example POST
POST BFC/servers/00:01:02:03:04:05/inventory/power_controllers/01:02:03:04:05:06/operations/useSystemLoginCredentials
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
powerMac = sys.argv[2]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='POST',
url='/BFC/servers/' + serverMac + '/inventory/power_controllers' + 'powerMac' + '/operations/useSystemLoginCredentials',
body='{"power_controller":{"credential_mode":"system_preset"}})',
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
POST BFC/servers/<server mac>/tags
Payload is a tag name that you want to add.
Returns the HTTP return code 200 and adds the specified tag to the server's list of tags on success. Returns an HTTP error code and the associated fault information on error.
Use this operation add a specified tag to the list of tags on the server.
Example POST
POST BFC/servers/00:01:02:03:04:05/tags
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
serverTag = sys.argv[2]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='POST',
url='/BFC/servers/' + serverMac + '/tags',
headers={'Content-Type':'application/json',
'Authorization':bfcSession},
body=json.dumps('mytag'))
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
DELETE BFC/servers/<server mac>/tags/<tag name>
Payload is the tag name that you want to delete.
Returns the HTTP return code 200 and deletes the tag on success.
Use this operation to delete a tag from the server. You can also do a PUT of a server record to BFC/servers/<server mac> to completely replace the set of tags associated with this server.
Example DELETE
DELETE BFC/servers/00:01:02:03:04:05/tags/mytag
Python Example
from httplib import HTTPSConnection
import json
import os
import sys
serverMac = sys.argv[1]
serverTag = sys.argv[2]
print 'serverMac: {0}'.format(serverMac)
bfcHost = os.environ["BFC_HOST"]
bfcSession = os.environ["BFC_SESSION"]
conn = HTTPSConnection(bfcHost + ':8443')
conn.connect()
conn.request(method='DELETE',
url='/BFC/servers/' + serverMac + '/tags' + '/' + serverTag,
headers={'Content-Type':'application/json',
'Authorization':bfcSession})
r1 = conn.getresponse()
print 'HTTP Response Code: {0}'.format(r1.status)
|
Copyright © 2013 CA Technologies.
All rights reserved.
|
|