In this post we will learn how to install Management Packs in vROPs via API.
For vCenter we don’t have to install any management pack as its shipped with vROPs by default and we just have to create vCenter credentials and configure adapter. Below steps can be followed to configure VC adapter.
1: Obtain Session Token: vROPs session token is obtained via POST call.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Method: POST URL: https://<vrops-fqdn>/suite-api/api/auth/token/acquire Headers: Content-Type : application\json Accept : application\json Auth: No Auth Body: { "username" : "vROPs-User", "password" : "Password" } |
Sample Output:
1 2 3 4 5 6 |
{ "token": "dd05ef7a-2019-4742-89b0-831460a8ca5a::1068428f-05a6-4bb8-b2c8-75aa7a7214bf", "validity": 1582804658913, "expiresAt": "Thursday, February 27, 2020 11:57:38 AM UTC", "roles": [] } |
The token id obtained in output is passed as “Authorization: vRealizeOpsToken token_value” header in all subsequent GET and POST calls.
2: Obtain Collector ID: By default, for a distributed vROPs deployment, collector-id of master node is 1 and replica node is 2. But we can fetch collector id via API call as well. Collector ID is needed when configuring various adapters.
1 2 3 4 5 6 7 8 9 |
Method: GET URL: https://<vrops-fqdn>/suite-api/api/collectors Headers: Content-Type : application/json Accept : application/json Authorization: vRealizeOpsToken {{vROPS-Token}} |
Sample Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
{ "collector": [ { "name": "vRealize Operations Manager Collector-192.168.101.121", "state": "UP", "hostName": "192.168.101.121", "local": true, "lastHeartbeat": 1583070848188, "id": "1", "uuId": "0b704d79-c88a-4886-aa3a-337c3872d6d7", "nodeIdentifier": "8dd35e5d-c99e-4783-827c-1f791f62a68a" }, { "name": "vRealize Operations Manager Collector-192.168.101.122", "state": "UP", "hostName": "192.168.101.122", "local": true, "lastHeartbeat": 1583070888547, "id": "2", "uuId": "0c4ca9c1-6ab6-4a7d-a4e7-3fe0d89ac666", "nodeIdentifier": "8d0e926f-2881-41b2-9f6e-f8a74a75a023" } ] } |
3: Configure vCenter Adapter: Before configuring adapters, we need to add credential for the solution first. Below payload used for VC adapter configuration, creates VC credentials and configures adapter in one shot.
Note: To get information about types of adapter that can be configured in vROPs, you can use below GET call.
GET https://<vrops-fqdn>/suite-api/api/adapterkinds
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
Method: POST URL: https://<vrops-fqdn>/suite-api/api/adapters Headers: Content-Type : application/json Accept : application/json Authorization: vRealizeOpsToken {{vROPS-Token}} Payload: { "name":"VC Adapter Instance", "description":"vCenter Adapter Instance", "collectorId":"1", "adapterKindKey":"VMWARE", "resourceIdentifiers":[ { "name":"AUTODISCOVERY", "value":"true" }, { "name":"PROCESSCHANGEEVENTS", "value":"true" }, { "name":"VCURL", "value":"vcenter.mgmt.vmw" } ], "credential":{ "id":null, "name":"VC-Credential-Global", "adapterKindKey":"VMWARE", "credentialKindKey":"PRINCIPALCREDENTIAL", "fields":[ { "name":"USER", "value":"administrator@vsphere.local" }, { "name":"PASSWORD", "value":"Password" } ] } } |
Sample Output: From response output, grab the adapter uuid as it will be used in subsequent calls. Adapter uuid corresponds to field “id” in output.
Note: Below output is a trimmed output. The actual output is a slightly big json which we need to pass in next API call.
1 2 3 4 5 6 7 8 9 10 11 12 |
{ "resourceKey":{ "name":"VC Adapter Instance", "adapterKindKey":"VMWARE", "resourceKindKey":"VMwareAdapter Instance", "description":"vCenter Adapter Instance", "collectorId":1, "credentialInstanceId":"06047080-eaf9-403a-b02c-4bec1c345bb6", "monitoringInterval":5, "id":"81454a3a-c526-400c-a8aa-e647d3f7e1ae" } } |
4: Patch vCenter Adapter: In this step we tell vROPS to start trusting certs returned by vCenter. For this we will pass the entire payload json in body which we obtained as output of step 3.
1 2 3 4 5 6 7 8 9 |
Method: PATCH URL: https://<vrops-fqdn>/suite-api/api/adapters Payload: { full response output json obtained in step 3 } |
5: Start Collecting data from vCenter: Use adapter id from step-3 in below call.
1 2 3 |
Method: PUT URL: https://<vrops-fqdn>/suite-api/api/adapters/<vCenter-Adapter-ID>/monitoringstate/start |
I hope you enjoyed reading this post. Feel free to share this on social media if it is worth sharing 🙂