SlideShare a Scribd company logo
Managing PowerVC via REST APIs
1
© 2016 IBM Corporation
• Types of REST APIs : OpenStack, PowerVC Enhanced OpenStack and PowerVC supported APIs
• Example PowerVC APIs: PowerVM, HMCs, and SCGs
• PowerVC GUI uses REST APIs
• http://www-01.ibm.com/support/knowledgecenter/api/content/nl/en-
us/SSXK2N_1.3.2/com.ibm.powervc.standard.help.doc/powervc_pg_kickoff_hmc.html
• Secured with https (TLS 1.2)
• Can be used on any system running Python 2.7 (do not need PowerVC installed to run APIs)
• Need a recent level of Python 2.7 version
Overview
© 2016 IBM Corporation
Basic flow:
Authenticate (PowerVC uses TLS 1.2)
Use authentication token to make subsequent API calls
Example: Display list of PowerVC Networks
REST
API
client
Keystone
Neutron
(Post) Authentication
Request
Authentication
Response – includes the
token needed for
subsequent requests
(Get) list of networks
Using authorization
token
JSON based response
A list of networks
Working with REST APIs
© 2016 IBM Corporation
 The easiest way to get started is to observe the PowerVC UI as it makes API calls
 Use a browser plugin like Firebug for Firefox or the Chrome Developers Toolkit
Getting Started
© 2016 IBM Corporation
Example: logging in
From the PowerVC GUI, log into PowerVC
Make sure you have selected the Persist button to see all the requests. The login
process sends a POST request to the PowerVC server as the first request
Hover over request to see the URL
Getting Started
© 2016 IBM Corporation
Select the Post tab to see the actual JSON data that is sent from the browser in the request
to PowerVC
Using Firebug you can see the source data or a more readable JSON version. This source data
is exactly the same data you would use from your own custom client script or application!
Getting Started
© 2016 IBM Corporation
From the Response tab you can see the entire raw JSON response
These are the data your custom client script or application will need to process
Getting Started
© 2016 IBM Corporation
You can also view the response in a more user-friendly JSON display format.
Getting Started
© 2016 IBM Corporation
REST API – Creation of an LPAR
 For creating an LPAR/VM you need:
– An API token
• After authenticating with user/password you get a token
– The tenant
• A tenant is a project. The terms project or tenant are interchangeable.
• The default project is “ibm-default”, but since PowerVC 1.3.1 also other user
defined projects are possible.
– The IDs of:
• The used network
• The desired image
• The Storage Connectivity Group
– Details of the new LPAR, like name, size and so on …
© 2016 IBM Corporation
REST API – using curl – Get token
 Create the following file auth.json with the correct user name and password:
{"auth":
{"scope":
{"project":
{"name": "ibm-default", "domain":
{"name": "Default"}
}
}, "identity":
{"methods": ["password"], "password":
{"user":
{"domain":
{"name": "Default"},
"name": "userName",
"password": "userPassword"
}
}
}
}
}
© 2016 IBM Corporation
REST API – using curl – Get token
 Use the file auth.json with the following curl command:
# curl -1 -k -i -X POST https://<PowerVC URL>:5000/v3/auth/tokens -H "Accept:
application/json" -H "Content-Type: application/json" -d @auth.json
HTTP/1.1 201 Created
Date: Fri, 15 Apr 2016 11:29:38 GMT
Server: Apache
X-Subject-Token: 35af31a38ca948788b771b5e8fbb0ddc
Vary: X-Auth-Token
x-openstack-request-id: req-a90f45bc-354e-4e76-8c2e-fda44508c7c1
Content-Length: 4858
Content-Type: application/json
{"token": {"methods": ["password"], "roles": [{"id": "b7d2cade8fa1493a962ac7fb926324fe",
"name": "admin"}], "expires_at": "2016-04-15T17:29:39.061651Z", "project": {"domain":
{"id": "default", "name": "Default"}, "id": "1953082a91d54db8a51fc8a742df46c6", "name":
"ibm-default"}, "catalog": [{"endpoints": [{"region_id": "RegionOne", "url": "https://cl-
powervc.ibm-tce-cloud.com:35357/v3", "region": "RegionOne", "interface": "a …
© 2016 IBM Corporation
REST API – using curl – Get tenant
 Get the tenant using the token …
# curl -1 -k -i -X GET https://powervc:5000/v3/projects -H "X-Auth-Token:<Token>“
HTTP/1.1 200 OK
Date: Fri, 15 Apr 2016 12:03:55 GMT
Server: Apache
Vary: X-Auth-Token
x-openstack-request-id: req-caba8d80-e4a0-4b23-a5bf-2f250dcd6949
Content-Length: 725
Content-Type: application/json
{"links": {"self": "https://cl-powervc.ibm-tce-cloud.com:5000/v3/projects", "previous":
null, "next": null}, "projects": [{"is_domain": false, "description": "IBM Default
Tenant", "links": {"self": "https://cl-powervc.ibm-tce-
cloud.com:5000/v3/projects/1953082a91d54db8a51fc8a742df46c6"}, "enabled": true, "id":
"1953082a91d54db8a51fc8a742df46c6", "parent_id": null, "domain_id": "default", "name":
"ibm-default"}, {"is_domain": false, "description": "Service Tenant", "links": {"self":
"https://cl-powervc.ibm-tce-
cloud.com:5000/v3/projects/d8d34c62047647598eb3fc2caca25027"}, "enabled": true, "id":
"d8d34c62047647598eb3fc2caca25027", "parent_id": null, "domain_id":
"495548495c1d4cbb928a80a141c3b775", "name": "service"}]}
© 2016 IBM Corporation
Tipp: REST API – using curl – Get tenant – with JSON parser
 To make the output better readable, remove the “-i” and add “| python -
mjson.tool”
# curl -1 -k -X GET https://powervc:5000/v3/projects -H "X-Auth-Token:<Token>“| python -
mjson.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 725 100 725 0 0 1942 0 --:--:-- --:--:-- --:--:-- 1943
{
"links": {
"next": null,
"previous": null,
"self": "https://cl-powervc.ibm-tce-cloud.com:5000/v3/projects"
},
"projects": [
{
"description": "IBM Default Tenant",
"domain_id": "default",
"enabled": true,
"id": "1953082a91d54db8a51fc8a742df46c6",
© 2016 IBM Corporation
REST API – using curl – Get networks
 Get the networks using the token …
# curl -1 -k -i -X GET https://powervc:5000//powervc/openstack/network/v2.0/networks -H
"X-Auth-Token: <Token>" -H "Content-Type: application/json“
HTTP/1.1 200 OK
Date: Fri, 15 Apr 2016 12:08:59 GMT
Server: Apache
Content-Type: application/json; charset=UTF-8
Content-Length: 767
X-Openstack-Request-Id: req-be727fca-2bee-4f06-9a7b-aa577676ecaa
Cache-control: no-cache
Pragma: no-cache
{"networks": [{"status": "ACTIVE", "subnets": ["749dbcf1-3f63-4e69-9233-c2f6cd38c0b6"],
"name": "Cloud Network", "provider:physical_network": "default", "admin_state_up": true,
"tenant_id": "1953082a91d54db8a51fc8a742df46c6", "mtu": null, "router:external": false,
"shared": true, "provider:network_type": "vlan", "id": "c50d3a61-a2a5-43eb-9c6b-
dcf38b4f1dd3", "provider:segmentation_id": 1}, {"status": "ACTIVE", "subnets":
["7b27af7b-3ac4-4bb0-94fe-87a5efd2017d"], "name": "9erNetwork",
"provider:physical_network": "default", "admin_state_up": true, "tenant_id":
"1953082a91d54db8a51fc8a742df46c6", "mtu": null, "router:external": false, "shared":
true, "provider:network_type": "vlan", "id": "f9de96c4-c5eb-4f74-912d-43a658e88e92",
"provider:segmentation_id": 2}]}
© 2016 IBM Corporation
REST API – using curl – Get images
 Get the images using the token for the tenant …
# curl -1 -k -i -X GET https://powervc:5000/powervc/openstack/compute/v2/<Tenant>/images
-H "X-Auth-Token: <Token> " -H "Content-Type: application/json“
HTTP/1.1 200 OK
Date: Fri, 15 Apr 2016 12:13:21 GMT
Server: Apache
Content-Type: application/json
Content-Length: 4987
X-Compute-Request-Id: req-cd36fc90-7d0b-473f-b7fd-21c505b6326a
Cache-control: no-cache
Pragma: no-cache
{"images": [{"id": "c3f2de51-385d-4ee7-8a2e-61ca0bf7c58a", "links": [{"href":
"https://cl-powervc.ibm-tce-
cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/images/c3f2de51-385d-4ee7-8a2e-
61ca0bf7c58a", "rel": "self"}, {"href": "https://cl-powervc.ibm-tce-
cloud.com:8774/1953082a91d54db8a51fc8a742df46c6/images/c3f2de51-385d-4ee7-8a2e-
61ca0bf7c58a", "rel": "bookmark"}, {"href": "https://cl-powervc.ibm-tce-
cloud.com:9292/images/c3f2de51-385d-4ee7-8a2e-61ca0bf7c58a", "type":
"application/vnd.openstack.image", "rel": "alternate"}], "name": "SLES11CI"}, {"id":
"a1ad5dfd-e990-4f07-bcb4-10a8a4e25c54", "links": [{"href": "https://cl-powervc.ibm-tce-
cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/images/a1ad5dfd-e990-4f07-bcb4-
10a8a4e25c54", "rel": "self"}, {"href": "https://cl-powervc.ibm-tce-
cloud.com:8774/1953082a91d54db8a51fc8a742df46c6/images/a1ad5dfd-e990-4f07-bcb4-
…
© 2016 IBM Corporation
REST API – using curl – Get Storage Connectivity Group
 Get the SCGs using the token for the tenant …
# curl -1 -k -i -X GET
https://powervc:5000/powervc/openstack/compute/v2/<Tenant>/storage-connectivity-groups -H
"X-Auth-Token: <Token>" -H "Content-Type: application/json“
HTTP/1.1 200 OK
Date: Fri, 15 Apr 2016 12:17:07 GMT
Server: Apache
Content-Type: application/json; charset=UTF-8
Content-Length: 749
X-Compute-Request-Id: req-56b63f94-534f-4853-bc06-8ddb361531e1
Cache-control: no-cache
Pragma: no-cache
{"storage_connectivity_groups": [{"display_name": "Any host, all VIOS", "id": "6a180ca0-
b2a4-483d-a864-0c1f92294e21"}, {"display_name": "Any host in cl-cluster", "id":
"be661942-4e87-4517-8678-5cbe3ff79b2b"}, {"display_name": "Belt", "id": "485ed115-5b6d-
429d-bf5c-782428699d9b"}, {"display_name": "vSCSI", "id": "b15e278d-ee5e-41bb-9ab9-
770955c8082a"}, {"display_name": "BB_vSCSI", "id": "5befa22d-5fd1-4f19-ab28-
dc374e0e0b21"}, {"display_name": "auto-vscsi_npiv", "id": "a29ba01d-a7ae-47b8-8734-
90ddd769d1a3"}, {"display_name": "Braces", "id": "99bcb22f-c7c0-4020-b07e-af0451b5acdc"},
{"display_name": "vSCSI_NPIV", "id": "edc59fbe-e305-405e-959f-1d1785c55565"},
{"display_name": "auto-vscsi_vscsi", "id": "017a9f94-2cd1-4576-8969-e3203df955d0"}]}
© 2016 IBM Corporation
REST API – using curl – Deploy a VM
 Use all the data to deploy a VM
# curl -1 -k -i -X POST
https://powervc:5000/powervc/openstack/compute/v2/<Tenant>/servers -H "X-Auth-Token:
<Token>" -H "Content-Type: application/json" -d '{"server":{ "name": “MyName",
"max_count": 1,"networkId":“<Network ID>", "imageRef": “<Image ID>", "networks":[{"uuid":
“<Network ID>"}],"flavor": {"ram":1024,"vcpus":1,"disk": 30,"extra_specs": {
"powervm:proc_units":"0.1", "powervm:storage_connectivity_group":“<Storage Connectivity
Group ID>"}}}}‘
HTTP/1.1 202 Accepted
Date: Fri, 15 Apr 2016 12:20:39 GMT
Server: Apache
Location: https://cl-powervc.ibm-tce-
cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/servers/f312a9f0-2b96-4645-b588-
a7d7b2473c71
Content-Type: application/json
Content-Length: 474
X-Compute-Request-Id: req-2ace156a-0993-4cd9-8cd8-ce208fcd179d
Cache-control: no-cache
Pragma: no-cache
{"server": {"security_groups": [{"name": "default"}], "OS-DCF:diskConfig": "MANUAL",
"id": "f312a9f0-2b96-4645-b588-a7d7b2473c71", "links": [{"href": "https://cl-powervc.ibm-
tce-cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/servers/f312a9f0-2b96-4645-b588-
a7d7b2473c71", "rel": "self"}, {"href": "https://cl-powervc.ibm-tce-
cloud.com:8774/1953082a91d54db8a51fc8a742df46c6/servers/f312a9f0-2b96-4645-b588-
a7d7b2473c71", "rel": "bookmark"}], "adminPass": "73kgFCSZXEhW"}}
© 2016 IBM Corporation
REST API – using curl – List VMs
© 2016 IBM Corporation
REST API – using curl – List Volume, WWPN and Zoning for VM
© 2016 IBM Corporation
REST API – using curl – List Volume, WWPN and Zoning for VM
© 2016 IBM Corporation
REST API – using curl – List Volume, WWPN and Zoning for VM
© 2016 IBM Corporation
REST API – Using Python – Creation of an LPAR – API token
– Get the token … If you did not specify user and password
# openstack token issue --os-username=<User>
Password:
+------------+------------------------------------------------------------------+
| Field | Value |
+------------+------------------------------------------------------------------+
| expires | 2016-07-19T19:46:46.961130Z |
| id | c400003fc6a24c48b52abe52b7f9a51b |
| project_id | 3c10a75d0cd14cb19c1567cccaf76991 |
| user_id | 4b0d1b529006c03834a03106992f24c73a31c4b7537d91560e73973c63a685f8 |
+------------+------------------------------------------------------------------+
– The token is valid for 4 hours
– If you did not source anything and want another project (ex. marketing), use:
# openstack token issue --os-username=<user> --os-auth-url=https://cl-powervc.ibm-
tce-cloud.com:5000/v3/ --os-project-name=marketing --os-cacert=/etc/pki/tls/certs/
powervc.crt --os-user-domain-name=Default --os-project-domain-name=Default
Password:
+------------+-----------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------+
| expires | 2016-07-19T20:18:56.945144Z |
| id | 4c90450a0879471694a4c10f772a2d68 |
| project_id | 804682d760974ca9949d55da7efe9662 |
| user_id | 4b0d1b529006c03834a03106992f24c73a31c4b7537d91560e73973c63a685f8|
+------------+-----------------------------------------------------------------+
© 2016 IBM Corporation
REST API – Creation of an LPAR – Tenant
 To get the tenant, the following script could be used <tenants>*):
#!/usr/bin/python
import httplib
import json
import os
import sys
def main():
token = raw_input("Please enter PowerVC token : ")
print "PowerVC token used = "+token
conn = httplib.HTTPSConnection('localhost')
headers = {"X-Auth-Token":token, "Content-type":"application/json"}
body = ""
conn.request("GET", "/powervc/openstack/identity/v2.0/tenants", body, headers)
conn.request("GET", "/powervc/openstack/identity/v3/projects", body, headers)
response = conn.getresponse()
raw_response = response.read()
conn.close()
json_data = json.loads(raw_response)
print json.dumps(json_data, indent=4, sort_keys=True)
if __name__ == "__main__":
main()
© 2016 IBM Corporation
REST API – Creation of an LPAR – Tenant
The output of the tenants script:
# ./tenants
Please enter PowerVC token : c192e0016c844d1c865238beb5994aac
PowerVC token used = c192e0016c844d1c865238beb5994aac
{
"links": {
"next": null,
"previous": null,
"self": "https://cl-powervc.ibm-tce-cloud.com/powervc/openstack/identity/v3/projects"
},
"projects": [
{
"description": "IBM Default Tenant",
"domain_id": "default",
"enabled": true,
"id": "b8b4106dee504ed9b2882bf39db94486",
"is_domain": false,
…
© 2016 IBM Corporation
REST API – Creation of an LPAR – Network ID
 To get the network IDs, the following script could be used <networks>*):
#!/usr/bin/python
import httplib
import json
import os
import sys
def main():
token = raw_input("Please enter PowerVC token : ")
conn = httplib.HTTPSConnection('localhost')
headers = {"X-Auth-Token":token, "Content-type":"application/json"}
body = ""
conn.request("GET", "/powervc/openstack/network/v2.0/networks", body, headers)
response = conn.getresponse()
raw_response = response.read()
conn.close()
json_data = json.loads(raw_response)
print json.dumps(json_data, indent=4, sort_keys=True)
if __name__ == "__main__":
main()
© 2016 IBM Corporation
REST API – Creation of an LPAR – Network ID
The output of the networks script:
# ./networks
Please enter PowerVC token : c192e0016c844d1c865238beb5994aac
{
"networks": [
{
"admin_state_up": true,
"id": "8e11a651-c019-4d87-a648-ab7e04842094",
"mtu": null,
"name": "Cloud Network",
"provider:network_type": "vlan",
"provider:physical_network": "default",
"provider:segmentation_id": 1,
"router:external": false,
"shared": true,
"status": "ACTIVE",
"subnets": [
"2d395a1c-e25b-4ed7-b5b7-2c7fdb487c9b"
],
"tenant_id": "b8b4106dee504ed9b2882bf39db94486"
},
{
"admin_state_up": true,
"id": "a24cbb7d-65fb-43af-9750-dec63dd50389",
"name": "9er Network",
…
© 2016 IBM Corporation
REST API – Creation of an LPAR – Image ID
 To get the image IDs, the following script could be used <images>*):
#!/usr/bin/python
import httplib
import json
import os
import sys
def main():
token = raw_input("Please enter PowerVC token : ")
tenant_id = raw_input("Please enter PowerVC Tenant ID : ")
conn = httplib.HTTPSConnection('localhost')
headers = {"X-Auth-Token":token, "Content-type":"application/json"}
body = ""
conn.request("GET", "/powervc/openstack/compute/v2/"+tenant_id+"/images", body, headers)
response = conn.getresponse()
raw_response = response.read()
conn.close()
json_data = json.loads(raw_response)
print json.dumps(json_data, indent=4, sort_keys=True)
if __name__ == "__main__":
main()
© 2016 IBM Corporation
REST API – Creation of an LPAR – Image ID
The output of the images script:
# ./images
Please enter PowerVC token : c192e0016c844d1c865238beb5994aac
Please enter PowerVC Tenant ID : b8b4106dee504ed9b2882bf39db94486
{
"images": [
{
"id": "8f0ca045-ddab-4d6d-8294-adbc0941e336",
"links": [
{
"href": "https://powervc:8774/v2/b8b4106dee504ed9b2882bf39db94486/images/8f0ca045-
ddab-4d6d-8294-adbc0941e336",
"rel": "self"
},
{
"href": "https://powervc:8774/b8b4106dee504ed9b2882bf39db94486/images/8f0ca045-ddab-
4d6d-8294-adbc0941e336",
"rel": "bookmark"
},
{
"href": "https://powervc:9292/b8b4106dee504ed9b2882bf39db94486/images/8f0ca045-ddab-
4d6d-8294-adbc0941e336",
"rel": "alternate",
"type": "application/vnd.openstack.image"
}
],
"name": "AIX_71_TL3_Standard_Image_NPIV"
},
…
© 2016 IBM Corporation
REST API – Creation of an LPAR – SCG ID
 To get the IDs of the storage connectivity groups, the following script could be
used <scg>*):
#!/usr/bin/python
import httplib
import json
import os
import sys
def main():
token = raw_input("Please enter PowerVC token : ")
tenant_id = raw_input("Please enter PowerVC Tenant ID : ")
conn = httplib.HTTPSConnection('localhost')
headers = {"X-Auth-Token":token, "Content-type":"application/json"}
body = ""
conn.request("GET", "/powervc/openstack/compute/v2/"+tenant_id+"/storage-connectivity-groups", body, headers)
response = conn.getresponse()
raw_response = response.read()
conn.close()
json_data = json.loads(raw_response)
print json.dumps(json_data, indent=4, sort_keys=True)
if __name__ == "__main__":
main()
© 2016 IBM Corporation
REST API – Creation of an LPAR – SCG ID
The output of the scg script:
# ./scg
Please enter PowerVC token : eee5d529e2eb4f13a30ba32aafcc5601
Please enter PowerVC Tenant ID : 1953082a91d54db8a51fc8a742df46c6
{
"storage_connectivity_groups": [
{
"display_name": "Any host, all VIOS",
"id": "6a180ca0-b2a4-483d-a864-0c1f92294e21"
},
{
"display_name": "Any host in cl-cluster",
"id": "be661942-4e87-4517-8678-5cbe3ff79b2b"
},
…
© 2016 IBM Corporation
REST API – Creation of an LPAR
 The final creation script <create>*):
#!/usr/bin/python
import httplib
import json
import os
import sys
def main():
token = raw_input("Please enter PowerVC token : ")
print "PowerVC token used = "+token
tenant_id = raw_input("Please enter PowerVC Tenant ID : ")
print "Tenant ID = "+tenant_id
lpar_name = raw_input("Please enter the new LPAR name: ")
print "LPAR Name = "+lpar_name
network_id = raw_input("Please enter the ID for the network: ")
print "Network ID = "+network_id
image_id = raw_input("Please enter the ID for the image: ")
print "Image ID = "+image_id
scg_id = raw_input("Please enter the ID for the SCG: ")
print "SCG = "+scg_id
headers = {"Content-Type": "application/json"}
conn = httplib.HTTPSConnection('localhost')
headers = {"X-Auth-Token":token, "Content-type":"application/json"}
…
© 2016 IBM Corporation
REST API – Creation of an LPAR
 The final creation script <create>*):
…
body = {
"server": {
"name": lpar_name,
"max_count": 1,
"networkId": network_id,
"imageRef": image_id,
"networks": [ {
"uuid": network_id } ],
"flavor": {
"ram": 1024,
"vcpus": 1,
"disk": 30,
"extra_specs": {
"powervm:proc_units": 0.1,
"powervm:storage_connectivity_group": scg_id }
}
}
}
conn.request("POST", "/powervc/openstack/compute/v2/"+tenant_id+"/servers",
json.dumps(body), headers)
response = conn.getresponse()
raw_response = response.read()
conn.close()
json_data = json.loads(raw_response)
print json.dumps(json_data, indent=4, sort_keys=True)
if __name__ == "__main__":
main()
To use a fixed IP, add the attribute “fixed_ip” in the “networks” section.
© 2016 IBM Corporation
REST API – Creation of an LPAR
The output of the create script:
# ./create
Please enter PowerVC token : c192e0016c844d1c865238beb5994aac
Please enter PowerVC Tenant ID : b8b4106dee504ed9b2882bf39db94486
Please enter the new LPAR name: aix123
Please enter the ID for the image: 8f0ca045-ddab-4d6d-8294-adbc0941e336
Please enter the ID for the network: 8e11a651-c019-4d87-a648-ab7e04842094
Please enter the ID for the SCG: 6a180ca0-b2a4-483d-a864-0c1f92294e21
{
"server": {
"OS-DCF:diskConfig": "MANUAL",
"adminPass": "Lh8f8NhqB4iB",
"id": "d7cb48e1-47f6-48c4-a939-08082cd26400",
"links": [
{
"href": "https://cl-powervc.ibm-tce-
cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/servers/d7cb48e1-47f6-48c4-a939-08082cd26400",
"rel": "self"
},
…
© 2016 IBM Corporation
pvcmd commands
 Benoit Creau also created ready to use commands using the REST API of
PowerVC:
– pvcmkvm – Create a virtual machine
– pvcgrowlun – Extend a LUN
 More Information could be found in GitHub:
https://github.com/chmod666org/pvcmd
or:
http://chmod666.org/index.php/tips-and-tricks-for-powervc-1-2-3-pvid-ghostdev-
clouddev-rest-api-growing-volumes-deleting-boot-volume-powervc-1-2-3-redbook/
© 2016 IBM Corporation
PowerVC – Metering
 With PowerVC 1.3.1 metering was introduced. In this first version with metering,
the following meters (meter name in brackets) are available:
– Dedicated memory of an LPAR (total_memory)
– Capacity Entitlement (total_vcpu)
– Allocated disk space (total_volumes)
– CPU usage on a host basis (compute.node.cpu.percent)
 The default sampling interval is 10 minutes for total_memory, total_vcpu,
total_volumes and 1 minute for compute.node.cpu.percent.
 Metering data is stored for 14 days per default:
# powervc-config metering meter_ttl
Current value: 14 days, 0:00:00
Default value: 14 days, 0:00:00
To change it (for example to 30 days - 30*24=720) use:
# powervc-config metering meter_ttl --set 720 --unit hr
Setting metering_time_to_live to 720 hr
© 2016 IBM Corporation
PowerVC – Metering
 To get metering data using “the curl method” do the following:
– Source environment (for a specific project - example here ibm-default)
# source /opt/ibm/powervc/powervcrc
– Get token
# openstack token issue
+------------+------------------------------------------------------------------+
| Field | Value |
+------------+------------------------------------------------------------------+
| expires | 2016-07-20T20:15:59.033226Z |
| id | 8237ab6075454c408dbf291370af0246 |
| project_id | 1953082a91d54db8a51fc8a742df46c6 |
| user_id | 4b0d1b529006c03834a03106992f24c73a31c4b7537d91560e73973c63a685f8 |
+------------+------------------------------------------------------------------+
– Examples how to get data:
• Get all data for a given project for all users in that project (in JSON Format)
# curl -1 -k -X GET
"https://localhost:5000/powervc/openstack/metering/v2/samples?q.field=project_
id&q.value=<Project ID>" -H "X-Auth-Token:<Token ID>" | python -mjson.tool
• Get all data for a given user for all projects that user belongs to (in JSON Format)
# curl -1 -k -X GET
"https://localhost:5000/powervc/openstack/metering/v2/samples?q.field=user_id&
q.value=<User ID>" -H "X-Auth-Token:<Token ID>" | python -mjson.tool
© 2016 IBM Corporation
PowerVC – Metering
– (more examples) …
• Get CPU EC values for a given project for all users in that project (in JSON Format)
# curl -1 -k -X GET
"https://localhost:5000/powervc/openstack/metering/v2/meters/total_vcpu?q.field
=project_id&q.value=<Project ID>" -H "X-Auth-Token:<Token ID>" | python -
mjson.tool
• Get host CPU utilization values for a given project for all users in that project (in JSON
Format)
# curl -1 -k -X GET
"https://localhost:5000/powervc/openstack/metering/v2/meters/compute.node.cpu.p
ercent?" -H "X-Auth-Token:<Token ID>" | python -mjson.tool
– Output see next foil …
© 2016 IBM Corporation
PowerVC – Metering - Output
[
{
"id": "3b908cc2-4cc4-11e6-b6a0-6afdedb69202",
"metadata": {},
"meter": "total_memory",
"project_id": "804682d760974ca9949d55da7efe9662",
"recorded_at": "2016-07-18T08:47:17.885101",
"resource_id": "instances",
"source": "openstack",
"timestamp": "2016-07-18T08:47:17.800824",
"type": "gauge",‘
"unit": "MB",
"user_id": "b7f3a90cc35f00ce747b1b8162ad7e912f33660e2138840765b492390c06df5a",
"volume": 1024.0
},
{
"id": "3b9078ea-4cc4-11e6-b6a0-6afdedb69202",
…
ID of the sampling interval itself
Name of the meter
ID of the project. To find the
project name, use:
# openstack project list
Timestamp
Unit
Value
ID of the user. To find the user
name, use:
# openstack user list
The output above is from “metering/v2/samples”. The output of a specific meter
“metering/v2/meters/<specific meter>” has some other keywords, but shows the
same amount of data.
© 2016 IBM Corporation
PowerVC – Metering - Output of a host
[
{
"counter_name": "compute.node.cpu.percent",
"counter_type": "gauge",
"counter_unit": "percent",
"counter_volume": 13.0,
"message_id": "5d541b86-4e6c-11e6-a197-6afdedb69202",
"project_id": null,
"recorded_at": "2016-07-20T11:23:21.090247",
"resource_id": "8205E6B_061E6AR_8205E6B_061E6AR",
"resource_metadata": {
"event_type": "compute.metrics.update",
"host": "compute.8205E6B_061E6AR",
"source": "powervc_nova.virt.ibmpowervm.hmc.driver.PowerVMDriver"
},
"source": "openstack",
"timestamp": "2016-07-20T11:23:20.625730",
"user_id": null
},
… Timestamp
Unit
Value
Type/model_serial of the host
© 2016 IBM Corporation
PowerVC – Metering - Output of a host
 Per default, a query for data gives back a maximum of 100 entries. If you want
more entries add a “?limit=<Number>” to the query.
 Default example with 100 entries:
# curl -1 -k -X GET
"https://localhost:5000/powervc/openstack/metering/v2/meters/total_volumes?q.field=project
_id&q.value=<Project ID>" -H "X-Auth-Token:<Token ID>" | python -mjson.tool | grep
counter_name | wc -l
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed100 45100 100 45100 0 0 99k 0
--:--:-- --:--:-- --:--:-- 99k
100
 Now for 1000 entries:
# curl -1 -k -X GET
"https://localhost:5000/powervc/openstack/metering/v2/meters/total_volumes?limit=1000
?q.field=project_id&q.value=<Project ID>" -H "X-Auth-Token:<Token ID>" | python
-mjson.tool | grep counter_name | wc -l
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed100 431k 100 431k 0 0 402k 0
0:00:01 0:00:01 --:--:-- 402k
1000
© 2016 IBM Corporation
For more information about metering see:
1. AIXpert Blog - PowerVC 1.3.1 Cloud Edition - Metering via REST API
https://www.ibm.com/developerworks/community/blogs/aixpert/entry/PowerVC_1_3_1_Cloud_Edition_Metering_via_REST_
API?lang=en
© 2016 IBM Corporation
Technical Resources
 PowerVC Knowledge Center:
https://www.ibm.com/support/knowledgecenter/SSXK2N_1.3.2/com.ibm.powervc.standard.help.
doc/powervc_hwandsw_reqs_hmc.html
Thank you

More Related Content

What's hot

Kubernetes security
Kubernetes securityKubernetes security
Kubernetes security
Thomas Fricke
 
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
OpenStack Korea Community
 
OpenStack Keystone with LDAP
OpenStack Keystone with LDAPOpenStack Keystone with LDAP
OpenStack Keystone with LDAP
Jesse Pretorius
 
infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
Amazon Web Services
 
Kubernetes a comprehensive overview
Kubernetes   a comprehensive overviewKubernetes   a comprehensive overview
Kubernetes a comprehensive overview
Gabriel Carro
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
Brendan Gregg
 
Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17
Rudy De Busscher
 
Ceph with CloudStack
Ceph with CloudStackCeph with CloudStack
Ceph with CloudStack
ShapeBlue
 
OpenStack Architecture
OpenStack ArchitectureOpenStack Architecture
OpenStack Architecture
Mirantis
 
Infrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfraInfrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfra
Tomislav Plavcic
 
[2018] 오픈스택 5년 운영의 경험
[2018] 오픈스택 5년 운영의 경험[2018] 오픈스택 5년 운영의 경험
[2018] 오픈스택 5년 운영의 경험
NHN FORWARD
 
OpenStack Networking
OpenStack NetworkingOpenStack Networking
OpenStack Networking
Ilya Shakhat
 
IBM MQ - High Availability and Disaster Recovery
IBM MQ - High Availability and Disaster RecoveryIBM MQ - High Availability and Disaster Recovery
IBM MQ - High Availability and Disaster Recovery
MarkTaylorIBM
 
Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18
CodeOps Technologies LLP
 
Spring Boot Tutorial | Microservices Spring Boot | Microservices Architecture...
Spring Boot Tutorial | Microservices Spring Boot | Microservices Architecture...Spring Boot Tutorial | Microservices Spring Boot | Microservices Architecture...
Spring Boot Tutorial | Microservices Spring Boot | Microservices Architecture...
Edureka!
 
OpenStack hands-on (All-in-One)
OpenStack hands-on (All-in-One)OpenStack hands-on (All-in-One)
OpenStack hands-on (All-in-One)
JeSam Kim
 
Let's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg MeetupLet's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg Meetup
Henning Jacobs
 
Red Hat OpenShift Container Platform Overview
Red Hat OpenShift Container Platform OverviewRed Hat OpenShift Container Platform Overview
Red Hat OpenShift Container Platform Overview
James Falkner
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes
VMware Tanzu
 
Velero search &amp; practice 20210609
Velero search &amp; practice 20210609Velero search &amp; practice 20210609
Velero search &amp; practice 20210609
KAI CHU CHUNG
 

What's hot (20)

Kubernetes security
Kubernetes securityKubernetes security
Kubernetes security
 
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
[OpenStack Days Korea 2016] Track1 - Monasca를 이용한 Cloud 모니터링
 
OpenStack Keystone with LDAP
OpenStack Keystone with LDAPOpenStack Keystone with LDAP
OpenStack Keystone with LDAP
 
infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
 
Kubernetes a comprehensive overview
Kubernetes   a comprehensive overviewKubernetes   a comprehensive overview
Kubernetes a comprehensive overview
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
 
Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17
 
Ceph with CloudStack
Ceph with CloudStackCeph with CloudStack
Ceph with CloudStack
 
OpenStack Architecture
OpenStack ArchitectureOpenStack Architecture
OpenStack Architecture
 
Infrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfraInfrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfra
 
[2018] 오픈스택 5년 운영의 경험
[2018] 오픈스택 5년 운영의 경험[2018] 오픈스택 5년 운영의 경험
[2018] 오픈스택 5년 운영의 경험
 
OpenStack Networking
OpenStack NetworkingOpenStack Networking
OpenStack Networking
 
IBM MQ - High Availability and Disaster Recovery
IBM MQ - High Availability and Disaster RecoveryIBM MQ - High Availability and Disaster Recovery
IBM MQ - High Availability and Disaster Recovery
 
Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18
 
Spring Boot Tutorial | Microservices Spring Boot | Microservices Architecture...
Spring Boot Tutorial | Microservices Spring Boot | Microservices Architecture...Spring Boot Tutorial | Microservices Spring Boot | Microservices Architecture...
Spring Boot Tutorial | Microservices Spring Boot | Microservices Architecture...
 
OpenStack hands-on (All-in-One)
OpenStack hands-on (All-in-One)OpenStack hands-on (All-in-One)
OpenStack hands-on (All-in-One)
 
Let's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg MeetupLet's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg Meetup
 
Red Hat OpenShift Container Platform Overview
Red Hat OpenShift Container Platform OverviewRed Hat OpenShift Container Platform Overview
Red Hat OpenShift Container Platform Overview
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes
 
Velero search &amp; practice 20210609
Velero search &amp; practice 20210609Velero search &amp; practice 20210609
Velero search &amp; practice 20210609
 

Similar to Working with PowerVC via its REST APIs

how to use openstack api
how to use openstack apihow to use openstack api
how to use openstack api
Liang Bo
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)
Maarten Mulders
 
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
PolarSeven Pty Ltd
 
MesosCon - Be a microservices hero
MesosCon - Be a microservices heroMesosCon - Be a microservices hero
MesosCon - Be a microservices hero
Dragos Dascalita Haut
 
DEVNET-1128 Cisco Intercloud Fabric NB Api's for Business & Providers
DEVNET-1128	Cisco Intercloud Fabric NB Api's for Business & ProvidersDEVNET-1128	Cisco Intercloud Fabric NB Api's for Business & Providers
DEVNET-1128 Cisco Intercloud Fabric NB Api's for Business & Providers
Cisco DevNet
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Puppet
 
Cloud APIs Overview Tucker
Cloud APIs Overview   TuckerCloud APIs Overview   Tucker
Cloud APIs Overview Tucker
Infrastructure 2.0
 
Building microservices sample application
Building microservices sample applicationBuilding microservices sample application
Building microservices sample application
Anil Allewar
 
.NET Core Apps: Design & Development
.NET Core Apps: Design & Development.NET Core Apps: Design & Development
.NET Core Apps: Design & Development
GlobalLogic Ukraine
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
Shubhra Kar
 
Automating Security in your IaC Pipeline
Automating Security in your IaC PipelineAutomating Security in your IaC Pipeline
Automating Security in your IaC Pipeline
Amazon Web Services
 
F5 Meetup presentation automation 2017
F5 Meetup presentation automation 2017F5 Meetup presentation automation 2017
F5 Meetup presentation automation 2017
Guy Brown
 
Making your Life Easier with MongoDB and Kafka (Robert Walters, MongoDB) Kafk...
Making your Life Easier with MongoDB and Kafka (Robert Walters, MongoDB) Kafk...Making your Life Easier with MongoDB and Kafka (Robert Walters, MongoDB) Kafk...
Making your Life Easier with MongoDB and Kafka (Robert Walters, MongoDB) Kafk...
HostedbyConfluent
 
Introduction to CloudStack API
Introduction to CloudStack APIIntroduction to CloudStack API
Introduction to CloudStack API
Krunal Jain
 
DEVNET-1136 Cisco ONE Enterprise Cloud Suite for Infrastructure Management.
DEVNET-1136	Cisco ONE Enterprise Cloud Suite for Infrastructure Management.DEVNET-1136	Cisco ONE Enterprise Cloud Suite for Infrastructure Management.
DEVNET-1136 Cisco ONE Enterprise Cloud Suite for Infrastructure Management.
Cisco DevNet
 
Integrating Ansible Tower with security orchestration and cloud management
Integrating Ansible Tower with security orchestration and cloud managementIntegrating Ansible Tower with security orchestration and cloud management
Integrating Ansible Tower with security orchestration and cloud management
Joel W. King
 
Cohesive Networks Support Docs: VNS3 version 3.5+ API Guide
Cohesive Networks Support Docs: VNS3 version 3.5+ API Guide Cohesive Networks Support Docs: VNS3 version 3.5+ API Guide
Cohesive Networks Support Docs: VNS3 version 3.5+ API Guide
Cohesive Networks
 
Infrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with GitInfrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with Git
Danilo Poccia
 
Migrate a on-prem platform to the public cloud with Java - SpringBoot and PCF
Migrate a on-prem platform to the public cloud with Java - SpringBoot and PCFMigrate a on-prem platform to the public cloud with Java - SpringBoot and PCF
Migrate a on-prem platform to the public cloud with Java - SpringBoot and PCF
Roy Braam
 
AWS as platform for scalable applications
AWS as platform for scalable applicationsAWS as platform for scalable applications
AWS as platform for scalable applications
Roman Gomolko
 

Similar to Working with PowerVC via its REST APIs (20)

how to use openstack api
how to use openstack apihow to use openstack api
how to use openstack api
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)
 
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
 
MesosCon - Be a microservices hero
MesosCon - Be a microservices heroMesosCon - Be a microservices hero
MesosCon - Be a microservices hero
 
DEVNET-1128 Cisco Intercloud Fabric NB Api's for Business & Providers
DEVNET-1128	Cisco Intercloud Fabric NB Api's for Business & ProvidersDEVNET-1128	Cisco Intercloud Fabric NB Api's for Business & Providers
DEVNET-1128 Cisco Intercloud Fabric NB Api's for Business & Providers
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
 
Cloud APIs Overview Tucker
Cloud APIs Overview   TuckerCloud APIs Overview   Tucker
Cloud APIs Overview Tucker
 
Building microservices sample application
Building microservices sample applicationBuilding microservices sample application
Building microservices sample application
 
.NET Core Apps: Design & Development
.NET Core Apps: Design & Development.NET Core Apps: Design & Development
.NET Core Apps: Design & Development
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
Automating Security in your IaC Pipeline
Automating Security in your IaC PipelineAutomating Security in your IaC Pipeline
Automating Security in your IaC Pipeline
 
F5 Meetup presentation automation 2017
F5 Meetup presentation automation 2017F5 Meetup presentation automation 2017
F5 Meetup presentation automation 2017
 
Making your Life Easier with MongoDB and Kafka (Robert Walters, MongoDB) Kafk...
Making your Life Easier with MongoDB and Kafka (Robert Walters, MongoDB) Kafk...Making your Life Easier with MongoDB and Kafka (Robert Walters, MongoDB) Kafk...
Making your Life Easier with MongoDB and Kafka (Robert Walters, MongoDB) Kafk...
 
Introduction to CloudStack API
Introduction to CloudStack APIIntroduction to CloudStack API
Introduction to CloudStack API
 
DEVNET-1136 Cisco ONE Enterprise Cloud Suite for Infrastructure Management.
DEVNET-1136	Cisco ONE Enterprise Cloud Suite for Infrastructure Management.DEVNET-1136	Cisco ONE Enterprise Cloud Suite for Infrastructure Management.
DEVNET-1136 Cisco ONE Enterprise Cloud Suite for Infrastructure Management.
 
Integrating Ansible Tower with security orchestration and cloud management
Integrating Ansible Tower with security orchestration and cloud managementIntegrating Ansible Tower with security orchestration and cloud management
Integrating Ansible Tower with security orchestration and cloud management
 
Cohesive Networks Support Docs: VNS3 version 3.5+ API Guide
Cohesive Networks Support Docs: VNS3 version 3.5+ API Guide Cohesive Networks Support Docs: VNS3 version 3.5+ API Guide
Cohesive Networks Support Docs: VNS3 version 3.5+ API Guide
 
Infrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with GitInfrastructure as Code: Manage your Architecture with Git
Infrastructure as Code: Manage your Architecture with Git
 
Migrate a on-prem platform to the public cloud with Java - SpringBoot and PCF
Migrate a on-prem platform to the public cloud with Java - SpringBoot and PCFMigrate a on-prem platform to the public cloud with Java - SpringBoot and PCF
Migrate a on-prem platform to the public cloud with Java - SpringBoot and PCF
 
AWS as platform for scalable applications
AWS as platform for scalable applicationsAWS as platform for scalable applications
AWS as platform for scalable applications
 

Recently uploaded

Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 

Recently uploaded (20)

Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 

Working with PowerVC via its REST APIs

  • 1. Managing PowerVC via REST APIs 1
  • 2. © 2016 IBM Corporation • Types of REST APIs : OpenStack, PowerVC Enhanced OpenStack and PowerVC supported APIs • Example PowerVC APIs: PowerVM, HMCs, and SCGs • PowerVC GUI uses REST APIs • http://www-01.ibm.com/support/knowledgecenter/api/content/nl/en- us/SSXK2N_1.3.2/com.ibm.powervc.standard.help.doc/powervc_pg_kickoff_hmc.html • Secured with https (TLS 1.2) • Can be used on any system running Python 2.7 (do not need PowerVC installed to run APIs) • Need a recent level of Python 2.7 version Overview
  • 3. © 2016 IBM Corporation Basic flow: Authenticate (PowerVC uses TLS 1.2) Use authentication token to make subsequent API calls Example: Display list of PowerVC Networks REST API client Keystone Neutron (Post) Authentication Request Authentication Response – includes the token needed for subsequent requests (Get) list of networks Using authorization token JSON based response A list of networks Working with REST APIs
  • 4. © 2016 IBM Corporation  The easiest way to get started is to observe the PowerVC UI as it makes API calls  Use a browser plugin like Firebug for Firefox or the Chrome Developers Toolkit Getting Started
  • 5. © 2016 IBM Corporation Example: logging in From the PowerVC GUI, log into PowerVC Make sure you have selected the Persist button to see all the requests. The login process sends a POST request to the PowerVC server as the first request Hover over request to see the URL Getting Started
  • 6. © 2016 IBM Corporation Select the Post tab to see the actual JSON data that is sent from the browser in the request to PowerVC Using Firebug you can see the source data or a more readable JSON version. This source data is exactly the same data you would use from your own custom client script or application! Getting Started
  • 7. © 2016 IBM Corporation From the Response tab you can see the entire raw JSON response These are the data your custom client script or application will need to process Getting Started
  • 8. © 2016 IBM Corporation You can also view the response in a more user-friendly JSON display format. Getting Started
  • 9. © 2016 IBM Corporation REST API – Creation of an LPAR  For creating an LPAR/VM you need: – An API token • After authenticating with user/password you get a token – The tenant • A tenant is a project. The terms project or tenant are interchangeable. • The default project is “ibm-default”, but since PowerVC 1.3.1 also other user defined projects are possible. – The IDs of: • The used network • The desired image • The Storage Connectivity Group – Details of the new LPAR, like name, size and so on …
  • 10. © 2016 IBM Corporation REST API – using curl – Get token  Create the following file auth.json with the correct user name and password: {"auth": {"scope": {"project": {"name": "ibm-default", "domain": {"name": "Default"} } }, "identity": {"methods": ["password"], "password": {"user": {"domain": {"name": "Default"}, "name": "userName", "password": "userPassword" } } } } }
  • 11. © 2016 IBM Corporation REST API – using curl – Get token  Use the file auth.json with the following curl command: # curl -1 -k -i -X POST https://<PowerVC URL>:5000/v3/auth/tokens -H "Accept: application/json" -H "Content-Type: application/json" -d @auth.json HTTP/1.1 201 Created Date: Fri, 15 Apr 2016 11:29:38 GMT Server: Apache X-Subject-Token: 35af31a38ca948788b771b5e8fbb0ddc Vary: X-Auth-Token x-openstack-request-id: req-a90f45bc-354e-4e76-8c2e-fda44508c7c1 Content-Length: 4858 Content-Type: application/json {"token": {"methods": ["password"], "roles": [{"id": "b7d2cade8fa1493a962ac7fb926324fe", "name": "admin"}], "expires_at": "2016-04-15T17:29:39.061651Z", "project": {"domain": {"id": "default", "name": "Default"}, "id": "1953082a91d54db8a51fc8a742df46c6", "name": "ibm-default"}, "catalog": [{"endpoints": [{"region_id": "RegionOne", "url": "https://cl- powervc.ibm-tce-cloud.com:35357/v3", "region": "RegionOne", "interface": "a …
  • 12. © 2016 IBM Corporation REST API – using curl – Get tenant  Get the tenant using the token … # curl -1 -k -i -X GET https://powervc:5000/v3/projects -H "X-Auth-Token:<Token>“ HTTP/1.1 200 OK Date: Fri, 15 Apr 2016 12:03:55 GMT Server: Apache Vary: X-Auth-Token x-openstack-request-id: req-caba8d80-e4a0-4b23-a5bf-2f250dcd6949 Content-Length: 725 Content-Type: application/json {"links": {"self": "https://cl-powervc.ibm-tce-cloud.com:5000/v3/projects", "previous": null, "next": null}, "projects": [{"is_domain": false, "description": "IBM Default Tenant", "links": {"self": "https://cl-powervc.ibm-tce- cloud.com:5000/v3/projects/1953082a91d54db8a51fc8a742df46c6"}, "enabled": true, "id": "1953082a91d54db8a51fc8a742df46c6", "parent_id": null, "domain_id": "default", "name": "ibm-default"}, {"is_domain": false, "description": "Service Tenant", "links": {"self": "https://cl-powervc.ibm-tce- cloud.com:5000/v3/projects/d8d34c62047647598eb3fc2caca25027"}, "enabled": true, "id": "d8d34c62047647598eb3fc2caca25027", "parent_id": null, "domain_id": "495548495c1d4cbb928a80a141c3b775", "name": "service"}]}
  • 13. © 2016 IBM Corporation Tipp: REST API – using curl – Get tenant – with JSON parser  To make the output better readable, remove the “-i” and add “| python - mjson.tool” # curl -1 -k -X GET https://powervc:5000/v3/projects -H "X-Auth-Token:<Token>“| python - mjson.tool % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 725 100 725 0 0 1942 0 --:--:-- --:--:-- --:--:-- 1943 { "links": { "next": null, "previous": null, "self": "https://cl-powervc.ibm-tce-cloud.com:5000/v3/projects" }, "projects": [ { "description": "IBM Default Tenant", "domain_id": "default", "enabled": true, "id": "1953082a91d54db8a51fc8a742df46c6",
  • 14. © 2016 IBM Corporation REST API – using curl – Get networks  Get the networks using the token … # curl -1 -k -i -X GET https://powervc:5000//powervc/openstack/network/v2.0/networks -H "X-Auth-Token: <Token>" -H "Content-Type: application/json“ HTTP/1.1 200 OK Date: Fri, 15 Apr 2016 12:08:59 GMT Server: Apache Content-Type: application/json; charset=UTF-8 Content-Length: 767 X-Openstack-Request-Id: req-be727fca-2bee-4f06-9a7b-aa577676ecaa Cache-control: no-cache Pragma: no-cache {"networks": [{"status": "ACTIVE", "subnets": ["749dbcf1-3f63-4e69-9233-c2f6cd38c0b6"], "name": "Cloud Network", "provider:physical_network": "default", "admin_state_up": true, "tenant_id": "1953082a91d54db8a51fc8a742df46c6", "mtu": null, "router:external": false, "shared": true, "provider:network_type": "vlan", "id": "c50d3a61-a2a5-43eb-9c6b- dcf38b4f1dd3", "provider:segmentation_id": 1}, {"status": "ACTIVE", "subnets": ["7b27af7b-3ac4-4bb0-94fe-87a5efd2017d"], "name": "9erNetwork", "provider:physical_network": "default", "admin_state_up": true, "tenant_id": "1953082a91d54db8a51fc8a742df46c6", "mtu": null, "router:external": false, "shared": true, "provider:network_type": "vlan", "id": "f9de96c4-c5eb-4f74-912d-43a658e88e92", "provider:segmentation_id": 2}]}
  • 15. © 2016 IBM Corporation REST API – using curl – Get images  Get the images using the token for the tenant … # curl -1 -k -i -X GET https://powervc:5000/powervc/openstack/compute/v2/<Tenant>/images -H "X-Auth-Token: <Token> " -H "Content-Type: application/json“ HTTP/1.1 200 OK Date: Fri, 15 Apr 2016 12:13:21 GMT Server: Apache Content-Type: application/json Content-Length: 4987 X-Compute-Request-Id: req-cd36fc90-7d0b-473f-b7fd-21c505b6326a Cache-control: no-cache Pragma: no-cache {"images": [{"id": "c3f2de51-385d-4ee7-8a2e-61ca0bf7c58a", "links": [{"href": "https://cl-powervc.ibm-tce- cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/images/c3f2de51-385d-4ee7-8a2e- 61ca0bf7c58a", "rel": "self"}, {"href": "https://cl-powervc.ibm-tce- cloud.com:8774/1953082a91d54db8a51fc8a742df46c6/images/c3f2de51-385d-4ee7-8a2e- 61ca0bf7c58a", "rel": "bookmark"}, {"href": "https://cl-powervc.ibm-tce- cloud.com:9292/images/c3f2de51-385d-4ee7-8a2e-61ca0bf7c58a", "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "SLES11CI"}, {"id": "a1ad5dfd-e990-4f07-bcb4-10a8a4e25c54", "links": [{"href": "https://cl-powervc.ibm-tce- cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/images/a1ad5dfd-e990-4f07-bcb4- 10a8a4e25c54", "rel": "self"}, {"href": "https://cl-powervc.ibm-tce- cloud.com:8774/1953082a91d54db8a51fc8a742df46c6/images/a1ad5dfd-e990-4f07-bcb4- …
  • 16. © 2016 IBM Corporation REST API – using curl – Get Storage Connectivity Group  Get the SCGs using the token for the tenant … # curl -1 -k -i -X GET https://powervc:5000/powervc/openstack/compute/v2/<Tenant>/storage-connectivity-groups -H "X-Auth-Token: <Token>" -H "Content-Type: application/json“ HTTP/1.1 200 OK Date: Fri, 15 Apr 2016 12:17:07 GMT Server: Apache Content-Type: application/json; charset=UTF-8 Content-Length: 749 X-Compute-Request-Id: req-56b63f94-534f-4853-bc06-8ddb361531e1 Cache-control: no-cache Pragma: no-cache {"storage_connectivity_groups": [{"display_name": "Any host, all VIOS", "id": "6a180ca0- b2a4-483d-a864-0c1f92294e21"}, {"display_name": "Any host in cl-cluster", "id": "be661942-4e87-4517-8678-5cbe3ff79b2b"}, {"display_name": "Belt", "id": "485ed115-5b6d- 429d-bf5c-782428699d9b"}, {"display_name": "vSCSI", "id": "b15e278d-ee5e-41bb-9ab9- 770955c8082a"}, {"display_name": "BB_vSCSI", "id": "5befa22d-5fd1-4f19-ab28- dc374e0e0b21"}, {"display_name": "auto-vscsi_npiv", "id": "a29ba01d-a7ae-47b8-8734- 90ddd769d1a3"}, {"display_name": "Braces", "id": "99bcb22f-c7c0-4020-b07e-af0451b5acdc"}, {"display_name": "vSCSI_NPIV", "id": "edc59fbe-e305-405e-959f-1d1785c55565"}, {"display_name": "auto-vscsi_vscsi", "id": "017a9f94-2cd1-4576-8969-e3203df955d0"}]}
  • 17. © 2016 IBM Corporation REST API – using curl – Deploy a VM  Use all the data to deploy a VM # curl -1 -k -i -X POST https://powervc:5000/powervc/openstack/compute/v2/<Tenant>/servers -H "X-Auth-Token: <Token>" -H "Content-Type: application/json" -d '{"server":{ "name": “MyName", "max_count": 1,"networkId":“<Network ID>", "imageRef": “<Image ID>", "networks":[{"uuid": “<Network ID>"}],"flavor": {"ram":1024,"vcpus":1,"disk": 30,"extra_specs": { "powervm:proc_units":"0.1", "powervm:storage_connectivity_group":“<Storage Connectivity Group ID>"}}}}‘ HTTP/1.1 202 Accepted Date: Fri, 15 Apr 2016 12:20:39 GMT Server: Apache Location: https://cl-powervc.ibm-tce- cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/servers/f312a9f0-2b96-4645-b588- a7d7b2473c71 Content-Type: application/json Content-Length: 474 X-Compute-Request-Id: req-2ace156a-0993-4cd9-8cd8-ce208fcd179d Cache-control: no-cache Pragma: no-cache {"server": {"security_groups": [{"name": "default"}], "OS-DCF:diskConfig": "MANUAL", "id": "f312a9f0-2b96-4645-b588-a7d7b2473c71", "links": [{"href": "https://cl-powervc.ibm- tce-cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/servers/f312a9f0-2b96-4645-b588- a7d7b2473c71", "rel": "self"}, {"href": "https://cl-powervc.ibm-tce- cloud.com:8774/1953082a91d54db8a51fc8a742df46c6/servers/f312a9f0-2b96-4645-b588- a7d7b2473c71", "rel": "bookmark"}], "adminPass": "73kgFCSZXEhW"}}
  • 18. © 2016 IBM Corporation REST API – using curl – List VMs
  • 19. © 2016 IBM Corporation REST API – using curl – List Volume, WWPN and Zoning for VM
  • 20. © 2016 IBM Corporation REST API – using curl – List Volume, WWPN and Zoning for VM
  • 21. © 2016 IBM Corporation REST API – using curl – List Volume, WWPN and Zoning for VM
  • 22. © 2016 IBM Corporation REST API – Using Python – Creation of an LPAR – API token – Get the token … If you did not specify user and password # openstack token issue --os-username=<User> Password: +------------+------------------------------------------------------------------+ | Field | Value | +------------+------------------------------------------------------------------+ | expires | 2016-07-19T19:46:46.961130Z | | id | c400003fc6a24c48b52abe52b7f9a51b | | project_id | 3c10a75d0cd14cb19c1567cccaf76991 | | user_id | 4b0d1b529006c03834a03106992f24c73a31c4b7537d91560e73973c63a685f8 | +------------+------------------------------------------------------------------+ – The token is valid for 4 hours – If you did not source anything and want another project (ex. marketing), use: # openstack token issue --os-username=<user> --os-auth-url=https://cl-powervc.ibm- tce-cloud.com:5000/v3/ --os-project-name=marketing --os-cacert=/etc/pki/tls/certs/ powervc.crt --os-user-domain-name=Default --os-project-domain-name=Default Password: +------------+-----------------------------------------------------------------+ | Field | Value | +------------+-----------------------------------------------------------------+ | expires | 2016-07-19T20:18:56.945144Z | | id | 4c90450a0879471694a4c10f772a2d68 | | project_id | 804682d760974ca9949d55da7efe9662 | | user_id | 4b0d1b529006c03834a03106992f24c73a31c4b7537d91560e73973c63a685f8| +------------+-----------------------------------------------------------------+
  • 23. © 2016 IBM Corporation REST API – Creation of an LPAR – Tenant  To get the tenant, the following script could be used <tenants>*): #!/usr/bin/python import httplib import json import os import sys def main(): token = raw_input("Please enter PowerVC token : ") print "PowerVC token used = "+token conn = httplib.HTTPSConnection('localhost') headers = {"X-Auth-Token":token, "Content-type":"application/json"} body = "" conn.request("GET", "/powervc/openstack/identity/v2.0/tenants", body, headers) conn.request("GET", "/powervc/openstack/identity/v3/projects", body, headers) response = conn.getresponse() raw_response = response.read() conn.close() json_data = json.loads(raw_response) print json.dumps(json_data, indent=4, sort_keys=True) if __name__ == "__main__": main()
  • 24. © 2016 IBM Corporation REST API – Creation of an LPAR – Tenant The output of the tenants script: # ./tenants Please enter PowerVC token : c192e0016c844d1c865238beb5994aac PowerVC token used = c192e0016c844d1c865238beb5994aac { "links": { "next": null, "previous": null, "self": "https://cl-powervc.ibm-tce-cloud.com/powervc/openstack/identity/v3/projects" }, "projects": [ { "description": "IBM Default Tenant", "domain_id": "default", "enabled": true, "id": "b8b4106dee504ed9b2882bf39db94486", "is_domain": false, …
  • 25. © 2016 IBM Corporation REST API – Creation of an LPAR – Network ID  To get the network IDs, the following script could be used <networks>*): #!/usr/bin/python import httplib import json import os import sys def main(): token = raw_input("Please enter PowerVC token : ") conn = httplib.HTTPSConnection('localhost') headers = {"X-Auth-Token":token, "Content-type":"application/json"} body = "" conn.request("GET", "/powervc/openstack/network/v2.0/networks", body, headers) response = conn.getresponse() raw_response = response.read() conn.close() json_data = json.loads(raw_response) print json.dumps(json_data, indent=4, sort_keys=True) if __name__ == "__main__": main()
  • 26. © 2016 IBM Corporation REST API – Creation of an LPAR – Network ID The output of the networks script: # ./networks Please enter PowerVC token : c192e0016c844d1c865238beb5994aac { "networks": [ { "admin_state_up": true, "id": "8e11a651-c019-4d87-a648-ab7e04842094", "mtu": null, "name": "Cloud Network", "provider:network_type": "vlan", "provider:physical_network": "default", "provider:segmentation_id": 1, "router:external": false, "shared": true, "status": "ACTIVE", "subnets": [ "2d395a1c-e25b-4ed7-b5b7-2c7fdb487c9b" ], "tenant_id": "b8b4106dee504ed9b2882bf39db94486" }, { "admin_state_up": true, "id": "a24cbb7d-65fb-43af-9750-dec63dd50389", "name": "9er Network", …
  • 27. © 2016 IBM Corporation REST API – Creation of an LPAR – Image ID  To get the image IDs, the following script could be used <images>*): #!/usr/bin/python import httplib import json import os import sys def main(): token = raw_input("Please enter PowerVC token : ") tenant_id = raw_input("Please enter PowerVC Tenant ID : ") conn = httplib.HTTPSConnection('localhost') headers = {"X-Auth-Token":token, "Content-type":"application/json"} body = "" conn.request("GET", "/powervc/openstack/compute/v2/"+tenant_id+"/images", body, headers) response = conn.getresponse() raw_response = response.read() conn.close() json_data = json.loads(raw_response) print json.dumps(json_data, indent=4, sort_keys=True) if __name__ == "__main__": main()
  • 28. © 2016 IBM Corporation REST API – Creation of an LPAR – Image ID The output of the images script: # ./images Please enter PowerVC token : c192e0016c844d1c865238beb5994aac Please enter PowerVC Tenant ID : b8b4106dee504ed9b2882bf39db94486 { "images": [ { "id": "8f0ca045-ddab-4d6d-8294-adbc0941e336", "links": [ { "href": "https://powervc:8774/v2/b8b4106dee504ed9b2882bf39db94486/images/8f0ca045- ddab-4d6d-8294-adbc0941e336", "rel": "self" }, { "href": "https://powervc:8774/b8b4106dee504ed9b2882bf39db94486/images/8f0ca045-ddab- 4d6d-8294-adbc0941e336", "rel": "bookmark" }, { "href": "https://powervc:9292/b8b4106dee504ed9b2882bf39db94486/images/8f0ca045-ddab- 4d6d-8294-adbc0941e336", "rel": "alternate", "type": "application/vnd.openstack.image" } ], "name": "AIX_71_TL3_Standard_Image_NPIV" }, …
  • 29. © 2016 IBM Corporation REST API – Creation of an LPAR – SCG ID  To get the IDs of the storage connectivity groups, the following script could be used <scg>*): #!/usr/bin/python import httplib import json import os import sys def main(): token = raw_input("Please enter PowerVC token : ") tenant_id = raw_input("Please enter PowerVC Tenant ID : ") conn = httplib.HTTPSConnection('localhost') headers = {"X-Auth-Token":token, "Content-type":"application/json"} body = "" conn.request("GET", "/powervc/openstack/compute/v2/"+tenant_id+"/storage-connectivity-groups", body, headers) response = conn.getresponse() raw_response = response.read() conn.close() json_data = json.loads(raw_response) print json.dumps(json_data, indent=4, sort_keys=True) if __name__ == "__main__": main()
  • 30. © 2016 IBM Corporation REST API – Creation of an LPAR – SCG ID The output of the scg script: # ./scg Please enter PowerVC token : eee5d529e2eb4f13a30ba32aafcc5601 Please enter PowerVC Tenant ID : 1953082a91d54db8a51fc8a742df46c6 { "storage_connectivity_groups": [ { "display_name": "Any host, all VIOS", "id": "6a180ca0-b2a4-483d-a864-0c1f92294e21" }, { "display_name": "Any host in cl-cluster", "id": "be661942-4e87-4517-8678-5cbe3ff79b2b" }, …
  • 31. © 2016 IBM Corporation REST API – Creation of an LPAR  The final creation script <create>*): #!/usr/bin/python import httplib import json import os import sys def main(): token = raw_input("Please enter PowerVC token : ") print "PowerVC token used = "+token tenant_id = raw_input("Please enter PowerVC Tenant ID : ") print "Tenant ID = "+tenant_id lpar_name = raw_input("Please enter the new LPAR name: ") print "LPAR Name = "+lpar_name network_id = raw_input("Please enter the ID for the network: ") print "Network ID = "+network_id image_id = raw_input("Please enter the ID for the image: ") print "Image ID = "+image_id scg_id = raw_input("Please enter the ID for the SCG: ") print "SCG = "+scg_id headers = {"Content-Type": "application/json"} conn = httplib.HTTPSConnection('localhost') headers = {"X-Auth-Token":token, "Content-type":"application/json"} …
  • 32. © 2016 IBM Corporation REST API – Creation of an LPAR  The final creation script <create>*): … body = { "server": { "name": lpar_name, "max_count": 1, "networkId": network_id, "imageRef": image_id, "networks": [ { "uuid": network_id } ], "flavor": { "ram": 1024, "vcpus": 1, "disk": 30, "extra_specs": { "powervm:proc_units": 0.1, "powervm:storage_connectivity_group": scg_id } } } } conn.request("POST", "/powervc/openstack/compute/v2/"+tenant_id+"/servers", json.dumps(body), headers) response = conn.getresponse() raw_response = response.read() conn.close() json_data = json.loads(raw_response) print json.dumps(json_data, indent=4, sort_keys=True) if __name__ == "__main__": main() To use a fixed IP, add the attribute “fixed_ip” in the “networks” section.
  • 33. © 2016 IBM Corporation REST API – Creation of an LPAR The output of the create script: # ./create Please enter PowerVC token : c192e0016c844d1c865238beb5994aac Please enter PowerVC Tenant ID : b8b4106dee504ed9b2882bf39db94486 Please enter the new LPAR name: aix123 Please enter the ID for the image: 8f0ca045-ddab-4d6d-8294-adbc0941e336 Please enter the ID for the network: 8e11a651-c019-4d87-a648-ab7e04842094 Please enter the ID for the SCG: 6a180ca0-b2a4-483d-a864-0c1f92294e21 { "server": { "OS-DCF:diskConfig": "MANUAL", "adminPass": "Lh8f8NhqB4iB", "id": "d7cb48e1-47f6-48c4-a939-08082cd26400", "links": [ { "href": "https://cl-powervc.ibm-tce- cloud.com:8774/v2/1953082a91d54db8a51fc8a742df46c6/servers/d7cb48e1-47f6-48c4-a939-08082cd26400", "rel": "self" }, …
  • 34. © 2016 IBM Corporation pvcmd commands  Benoit Creau also created ready to use commands using the REST API of PowerVC: – pvcmkvm – Create a virtual machine – pvcgrowlun – Extend a LUN  More Information could be found in GitHub: https://github.com/chmod666org/pvcmd or: http://chmod666.org/index.php/tips-and-tricks-for-powervc-1-2-3-pvid-ghostdev- clouddev-rest-api-growing-volumes-deleting-boot-volume-powervc-1-2-3-redbook/
  • 35. © 2016 IBM Corporation PowerVC – Metering  With PowerVC 1.3.1 metering was introduced. In this first version with metering, the following meters (meter name in brackets) are available: – Dedicated memory of an LPAR (total_memory) – Capacity Entitlement (total_vcpu) – Allocated disk space (total_volumes) – CPU usage on a host basis (compute.node.cpu.percent)  The default sampling interval is 10 minutes for total_memory, total_vcpu, total_volumes and 1 minute for compute.node.cpu.percent.  Metering data is stored for 14 days per default: # powervc-config metering meter_ttl Current value: 14 days, 0:00:00 Default value: 14 days, 0:00:00 To change it (for example to 30 days - 30*24=720) use: # powervc-config metering meter_ttl --set 720 --unit hr Setting metering_time_to_live to 720 hr
  • 36. © 2016 IBM Corporation PowerVC – Metering  To get metering data using “the curl method” do the following: – Source environment (for a specific project - example here ibm-default) # source /opt/ibm/powervc/powervcrc – Get token # openstack token issue +------------+------------------------------------------------------------------+ | Field | Value | +------------+------------------------------------------------------------------+ | expires | 2016-07-20T20:15:59.033226Z | | id | 8237ab6075454c408dbf291370af0246 | | project_id | 1953082a91d54db8a51fc8a742df46c6 | | user_id | 4b0d1b529006c03834a03106992f24c73a31c4b7537d91560e73973c63a685f8 | +------------+------------------------------------------------------------------+ – Examples how to get data: • Get all data for a given project for all users in that project (in JSON Format) # curl -1 -k -X GET "https://localhost:5000/powervc/openstack/metering/v2/samples?q.field=project_ id&q.value=<Project ID>" -H "X-Auth-Token:<Token ID>" | python -mjson.tool • Get all data for a given user for all projects that user belongs to (in JSON Format) # curl -1 -k -X GET "https://localhost:5000/powervc/openstack/metering/v2/samples?q.field=user_id& q.value=<User ID>" -H "X-Auth-Token:<Token ID>" | python -mjson.tool
  • 37. © 2016 IBM Corporation PowerVC – Metering – (more examples) … • Get CPU EC values for a given project for all users in that project (in JSON Format) # curl -1 -k -X GET "https://localhost:5000/powervc/openstack/metering/v2/meters/total_vcpu?q.field =project_id&q.value=<Project ID>" -H "X-Auth-Token:<Token ID>" | python - mjson.tool • Get host CPU utilization values for a given project for all users in that project (in JSON Format) # curl -1 -k -X GET "https://localhost:5000/powervc/openstack/metering/v2/meters/compute.node.cpu.p ercent?" -H "X-Auth-Token:<Token ID>" | python -mjson.tool – Output see next foil …
  • 38. © 2016 IBM Corporation PowerVC – Metering - Output [ { "id": "3b908cc2-4cc4-11e6-b6a0-6afdedb69202", "metadata": {}, "meter": "total_memory", "project_id": "804682d760974ca9949d55da7efe9662", "recorded_at": "2016-07-18T08:47:17.885101", "resource_id": "instances", "source": "openstack", "timestamp": "2016-07-18T08:47:17.800824", "type": "gauge",‘ "unit": "MB", "user_id": "b7f3a90cc35f00ce747b1b8162ad7e912f33660e2138840765b492390c06df5a", "volume": 1024.0 }, { "id": "3b9078ea-4cc4-11e6-b6a0-6afdedb69202", … ID of the sampling interval itself Name of the meter ID of the project. To find the project name, use: # openstack project list Timestamp Unit Value ID of the user. To find the user name, use: # openstack user list The output above is from “metering/v2/samples”. The output of a specific meter “metering/v2/meters/<specific meter>” has some other keywords, but shows the same amount of data.
  • 39. © 2016 IBM Corporation PowerVC – Metering - Output of a host [ { "counter_name": "compute.node.cpu.percent", "counter_type": "gauge", "counter_unit": "percent", "counter_volume": 13.0, "message_id": "5d541b86-4e6c-11e6-a197-6afdedb69202", "project_id": null, "recorded_at": "2016-07-20T11:23:21.090247", "resource_id": "8205E6B_061E6AR_8205E6B_061E6AR", "resource_metadata": { "event_type": "compute.metrics.update", "host": "compute.8205E6B_061E6AR", "source": "powervc_nova.virt.ibmpowervm.hmc.driver.PowerVMDriver" }, "source": "openstack", "timestamp": "2016-07-20T11:23:20.625730", "user_id": null }, … Timestamp Unit Value Type/model_serial of the host
  • 40. © 2016 IBM Corporation PowerVC – Metering - Output of a host  Per default, a query for data gives back a maximum of 100 entries. If you want more entries add a “?limit=<Number>” to the query.  Default example with 100 entries: # curl -1 -k -X GET "https://localhost:5000/powervc/openstack/metering/v2/meters/total_volumes?q.field=project _id&q.value=<Project ID>" -H "X-Auth-Token:<Token ID>" | python -mjson.tool | grep counter_name | wc -l % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 45100 100 45100 0 0 99k 0 --:--:-- --:--:-- --:--:-- 99k 100  Now for 1000 entries: # curl -1 -k -X GET "https://localhost:5000/powervc/openstack/metering/v2/meters/total_volumes?limit=1000 ?q.field=project_id&q.value=<Project ID>" -H "X-Auth-Token:<Token ID>" | python -mjson.tool | grep counter_name | wc -l % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 431k 100 431k 0 0 402k 0 0:00:01 0:00:01 --:--:-- 402k 1000
  • 41. © 2016 IBM Corporation For more information about metering see: 1. AIXpert Blog - PowerVC 1.3.1 Cloud Edition - Metering via REST API https://www.ibm.com/developerworks/community/blogs/aixpert/entry/PowerVC_1_3_1_Cloud_Edition_Metering_via_REST_ API?lang=en
  • 42. © 2016 IBM Corporation Technical Resources  PowerVC Knowledge Center: https://www.ibm.com/support/knowledgecenter/SSXK2N_1.3.2/com.ibm.powervc.standard.help. doc/powervc_hwandsw_reqs_hmc.html

Editor's Notes

  1. 1
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13
  7. 14
  8. 15
  9. 16
  10. 17
  11. 18
  12. 19
  13. 20
  14. 21
  15. 22
  16. 23
  17. 24
  18. 25
  19. 26
  20. 27
  21. 28
  22. 29
  23. 30
  24. 31
  25. 32
  26. 33
  27. 34
  28. 35
  29. 36
  30. 37
  31. 38
  32. 39
  33. 40
  34. 41
  35. 43