官术网_书友最值得收藏!

Importing data with a REST API

What if there is information we would like to import into vRealize Operations but there is no solution available? This is fine as vRealize Operations supports multiple ways to import any data we like, but it will require some scripting if it's a regular import.

Prior to vRealize Operations 6.0 in 5.x, we had the HTTP POST adapter and the TEXT adapter. Both could import data into vCenter Operations Manager 5.x. In vRealize Operations 6.6, we still have access to the HTTP POST adapter; this adapter has remained unchanged from vCenter Operations Manager 5.x for legacy support, and any current scripts importing data that is configured should still work using this adapter.

The new and preferred way to import our own data is through the new vRealize Operations REST API. This is a highly-functional API. Most GUI tasks can also be done through the API if required. The vRealize Operations nodes we have deployed all have a detailed REST guide built in; this can be found by navigating to https://<vRealizeOperations_FQDN/IP>/suite-api/docs/rest/index.html. Here we can find sample code and information on all the rest functions. If you currently don't have anything importing via the HTTP POST adapter, it would be highly recommended that anything new be done through the new REST API, or as its commonly referred to, the Suite API solution.

The Suite API is the only officially supported API for vRealize Operations. As you might have seen in the previous screenshot, the Suite API is broken down into two parts:

  • Public API
  • Internal API
Note: The Internal API may not be supported in future releases. Use it at your own risk.

In this example, we will be importing a Recommendation into vRealize Operations using the REST API:

  1. Open your favorite REST tool. Anything that can make standard REST calls will work, like curl in Linux or even a browser with the right plugins. In this example, I'm using Postman.
  2. Select POST as the method, and type the https://<vRealizeOperations_FQDN_OR_IP/suite-api/api/recommendations URL.
    • Create authorization for requests by supplying a username and password for vRealize Operations
  1. Create an application/XML header:
  1. Paste the following code in the body of the request:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ops:recommendation xmlns:ops="http://webservice.vmware.com/vRealizeOpsMgr/1.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ops:description>My REST imported recommendation (USR)</ops:description>
</ops:recommendation>

In Postman the request body would look similar to this:

For reference, the JSON for the above XML code would be as follows:

{
"description" : " My REST imported recommendation (USR)",
"others" : [ ],
"otherAttributes" : {
}
}
  1. After posting this to vRealize Operations, navigate to the Recommendations section within the UI. You should see the imported recommendation listed:

This is a very basic example of what can be achieved if there is no official solution for the data we would like to import. Most of what people want to import will be IT-related in some way, but vRealize Operations is definitely not limited to computer data; we can import data on weather, power usage, parcel deliveries, and anything we can apply relationships and metrics to.

主站蜘蛛池模板: 澜沧| 富源县| 桦南县| 鄂托克前旗| 普定县| 宁城县| 北碚区| 威信县| 石狮市| 陇西县| 上虞市| 南部县| 廊坊市| 西充县| 商南县| 黎城县| 海城市| 德江县| 永寿县| 灵寿县| 杭锦旗| 丹阳市| 抚州市| 鹤山市| 梓潼县| 景谷| 滦南县| 黔南| 朝阳区| 乌兰县| 毕节市| 南雄市| 黄冈市| 洛阳市| 北票市| 德化县| 山丹县| 灌南县| 柞水县| 云和县| 集安市|