VMware Cloud Community
SandorBihary
Contributor
Contributor

VR OPS API bug?

Hi All!

I would like to push external data into the VR OPS over rest APi.

However, I have some trouble to achieve that.

I am able to get the token and establish a connection. That part works fine.

Also, I can create adapter/instances, etc…

The problem begins after that. The freshly created resource just disappear after a few minutes.

I am able to feed in data and the API call returns with response code 200. However, after a few minutes I got this:

{"message":"No such Resource - 3eefd2d5-9ed5-4b6c-8242-9216910110f6.","httpStatusCode":404,"apiErrorCode":404}

If I add new metrics/properties to an existing resource it work fine. I can only see this with freshly create ones.

Does anyone has any idea what I am doing wrong? Or is it a bug?

See the screenshots and the code snippets below:

load = {

  "description" : "Sanyi Metrics",

  "resourceKey" : {

    "name" : "SanyiResourceKeyTEST1",

    "adapterKindKey" : "sanyi3",

    "resourceKindKey" : "sanyiresneiTEST1",

    "resourceIdentifiers" : [ {

      "identifierType" : {

        "name" : "EntityName",

        "dataType" : "STRING",

        "isPartOfUniqueness" : True

      },

      "value" : "SanyiResourceKeyTEST1"

    }]

                },

  "credentialInstanceId" : None,

  "resourceStatusStates" : [ ],

  "dtEnabled" : True

}

<Response [201]>

{"description":"Sanyi Metrics","resourceKey":{"name":"SanyiResourceKeyTEST1","adapterKindKey":"sanyi3","resourceKindKey":"sanyiresneiTEST1","resourceIdentifiers":[{"identifierType":{"name":"EntityName","dataType":"STRING","isPartOfUniqueness":true},"value":"SanyiResourceKeyTEST1"}]},"resourceStatusStates":[],"dtEnabled":true,"badges":[],"relatedResources":[],"links":[{"href":"/suite-api/api/resources/3eefd2d5-9ed5-4b6c-8242-9216910110f6","rel":"SELF","name":"linkToSelf"},{"href":"/suite-api/api/resources/3eefd2d5-9ed5-4b6c-8242-9216910110f6/relationships","rel":"RELATED","name":"relationsOfResource"},{"href":"/suite-api/api/resources/3eefd2d5-9ed5-4b6c-8242-9216910110f6/properties","rel":"RELATED","name":"propertiesOfResource"},{"href":"/suite-api/api/alerts?resourceId=3eefd2d5-9ed5-4b6c-8242-9216910110f6","rel":"RELATED","name":"alertsOfResource"},{"href":"/suite-api/api/symptoms?resourceId=3eefd2d5-9ed5-4b6c-8242-9216910110f6","rel":"RELATED","name":"symptomsOfResource"},{"href":"/suite-api/api/resources/3eefd2d5-9ed5-4b6c-8242-9216910110f6/statkeys","rel":"RELATED","name":"statKeysOfResource"},{"href":"/suite-api/api/resources/3eefd2d5-9ed5-4b6c-8242-9216910110f6/stats/latest","rel":"RELATED","name":"latestStatsOfResource"},{"href":"/suite-api/api/resources/3eefd2d5-9ed5-4b6c-8242-9216910110f6/properties","rel":"RELATED","name":"latestPropertiesOfResource"},{"href":"/suite-api/api/credentials/","rel":"RELATED","name":"credentialsOfResource"}],"identifier":"3eefd2d5-9ed5-4b6c-8242-9216910110f6"}

def vra_post(vrafqdn,token,payload):

    url = "https://{}/suite-api/api/resources/3eefd2d5-9ed5-4b6c-8242-9216910110f6/properties".format(vrafqdn)

    #params = '{"adapterKindKey": "sanyi"}'

    #print(payload)

    #print(url)

    headers = {

        'accept': "application/json",

        'content-type': "application/json",

        'X-vRealizeOps-API-use-unsupported': 'true',

        'Authorization': 'vRealizeOpsToken {}'.format(token)

        }

    response = requests.request("POST", url, data=json.dumps(payload),  headers=headers, verify=False)

    print(response)

    print(response.text)

prop = {

  "property-content" : [ {

    "statKey" : "sanyi1|sanaylability",

    "timestamps" : [ 1550657306000],

    "values" : [ "UP" ],

    "others" : [ ],

    "otherAttributes" : { }

  }, {

    "statKey" : "sanyiconfig|sanyinum|sanyiprocesses",

    "timestamps" : [ 1550657306000 ],

    "data" : [ 93.0 ],

    "others" : [ ],

    "otherAttributes" : { }

  } ]

}

First few call:

<Response [200]>

Error after a few minutes:

<Response [404]>

{"message":"No such Resource - 3eefd2d5-9ed5-4b6c-8242-9216910110f6.","httpStatusCode":404,"apiErrorCode":404}

vrops1.jpgvrops2.jpgvrops3.jpg,

Tags (1)
Reply
0 Kudos
3 Replies
SandorBihary
Contributor
Contributor

Hi All!

Does anyone has any comment? I would really appreciate any hints or advice:)

Thanks!

Sandor

Reply
0 Kudos
RobertMesropyan
VMware Employee
VMware Employee

Hi Sandor

It looks that your installed adapter mark these objects as "not existing" and delete them. Can you try with other adapter/resource kinds?

Reply
0 Kudos
SandorBihary
Contributor
Contributor

Hi Robert,

I have tried to add customer metrics to a VM. It works well.

What adapter/resource kinds do you mean exactly?

The documentation says I have to use OPENAPI adapter kind. (I created the adapter beforehand, so it's exists)

POST /api/events/adapterkinds/{adapterKind}

Push a single Event into the system with associating an adapter kind as the event source.
If the adapter kind specified is not present in the system, it will be created dynamically. However, if the adapter kind specified already exists, then it must be of OPENAPI adapter kind type.
Also the API sanitizes the Push Adapter Kind key by removing invalid characters (e.g.: Embedded HTML & JS)

So, if you could clarify what resource/adapterkind I should create, I would really appreciate that:)

Best,

Sandor

Reply
0 Kudos