VMware Cloud Community
vedaniks
Enthusiast
Enthusiast

ResourceConfig.getStatus does not exist. Is there any other way to get collection status of a resource object?

I want to remove the resource objects from the inventory explorer of my adapter which has collection status as RESOURCE_STATUS_NO_DATA_RECEIVING. Since vROPs does not immediately remove them, they are getting accumulated and causing a slowdown of the system.

not_receiving.JPG

What I'm thinking of doing is checking the collection status of each resource and if it is RESOURCE_STATUS_NO_DATA_RECEIVING, I'll set the collection state as RESOURCE_STATE_NOT_EXISTING which will be removed by vROPS according to this (VMware Knowledge Base).

But when I'm getting the ResourceConfig using getMonitoringResource(ResourceKey), It is just giving me the collection state of the resource using ResourceConfig.getState() but not the status.

The function to get status as mentioned in documentation (vrealize-operations-manager-SDK-70-programming-guide) does not exist which is ResourceConfig.getStatus().

Is there any way I can get the status of resource object? Or any other way I can tackle the problem I'm facing?

I thought of getting resource status for object type Process using ResourceDto object but I could not create the ResourceDto object for the Process Object type.

I'm using vROps SDK version 7.0

Reply
0 Kudos
6 Replies
RobertMesropyan
VMware Employee
VMware Employee

Hello

Try to mark object/resource as "Not Existing" by removing it from discovery result - you don't need to set RESOURCE_STATUS_NO_DATA_RECEIVING from adapter code.

Reply
0 Kudos
vedaniks
Enthusiast
Enthusiast

Hi RobertMesropyan,

Thank you for your response.

I think you mean, loop through all the resources from DiscoveryResult.getResources(String adapterKind) and then remove some of them which are not satisfying some condition.

But, under what condition should I remove the object/resource from discovery result?

There are VMs on which users login, run some processes and after they log out, the processes are still shown in inventory explorer in with RESOURCE_STATUS_NO_DATA_RECEIVING as can be seen in the image attached in question.

If I am missing something please correct me.

Thanks!

Reply
0 Kudos
RobertMesropyan
VMware Employee
VMware Employee

Hi, for your case this code sample is more suitable, please try it:

               ResourceConfig resourceConfig = adapterCache.getMonitoringResource(resourceKey);

                if(resourceConfig == null) {

                    resourceConfig = adapterCache.getStoppedResource(resourceKey);

                }

                if(resourceConfig != null) {

                    changeResourceState(resourceConfig, DiscoveryResult.StateChangeEnum.NOTEXIST);

                }

               ResourceConfig resourceConfig = adapterCache.getMonitoringResource(resourceKey);
                if(resourceConfig == null) {
                    resourceConfig = adapterCache.getStoppedResource(resourceKey);
                }
                if(resourceConfig != null) {
                    changeResourceState(resourceConfig, DiscoveryResult.StateChangeEnum.NOTEXIST);
                }
Reply
0 Kudos
vedaniks
Enthusiast
Enthusiast

Hello RobertMesropyan,

From what I can gather by looking the code, I think here you are getting ResourceConfig of "Stopped Resource" and then marking it NOTEXIST.

Then shouldn't the code snippet be like this:

ResourceConfig resourceConfig = adapterCache.getMonitoringResource(resourceKey);

if(resourceConfig == null) {

     resourceConfig = adapterCache.getStoppedResource(resourceKey);

     if(resourceConfig != null) {

          changeResourceState(resourceConfig, DiscoveryResult.StateChangeEnum.NOTEXIST);

     }

}

Since, otherwise all the resources state will be marked as NOTEXIST? or is it the case that the line

ResourceConfig resourceConfig = adapterCache.getMonitoringResource(resourceKey);

gives ResourceConfig of objects which has stopped collecting?

Please explain if I'm wrong.

Also if you can share any sources for reading about ResourceConfig, AdapterCache, etc will be very helpful.

Thanks!

Reply
0 Kudos
RobertMesropyan
VMware Employee
VMware Employee

Hello, yes, are correct - I just tried to show you the main idea.

Wiht regards to "Also if you can share any sources for reading about ResourceConfig, AdapterCache, etc will be very helpful." - all SDK related staff can be found under https://code.vmware.com/group/sdk/8.0/vrealize-operations, it's cannot be shared in public area.

Reply
0 Kudos
vedaniks
Enthusiast
Enthusiast

This did not work. I was not able to get anything by using getStoppedResource. I had deleted one VM to check if that will get caught in getStoppedResource but to no success.

Can you suggest some other approach?

I had tried :

ResourceStatus resStatus = adapterStatus.getResourceStatus(resConfig.getResourceId());

to get the collection status of the resource but every time I'm getting collection status as RESOURCE_STATUS_NONE.

Note: I'm trying the above things when I'm creating resources for the adapter.

Reply
0 Kudos