vsphere-automation-sdk-java icon indicating copy to clipboard operation
vsphere-automation-sdk-java copied to clipboard

RetrievePropertiesEx returns token "0"

Open Fabio1988 opened this issue 1 year ago • 1 comments

  • [x] I am using the latest SDK version
  • [x] This API is compatible with my vCenter version (You can get this info from the API documentation )
  • [x] I have searched existing issues

Description

On asking for all virtual machines and using retrievePropertiesEx() it will return 100 objects and a token. using this token on continueRetrievePropertiesEx throws a Permission Denied Exception.

We tried the same with vmware govmomi and we receive 334 objects

Environment

  • SDK version: v8.0.2.1
  • Java version: openjdk 17.0.10 2024-01-16
  • vSphere version: vSphere 8.0

Steps or code snippet to reproduce

val propertyCollector = this.getServiceContent()?.propertyCollector
    ?: throw IllegalStateException("VMware Connection is open, but could not get property collector!")
val resultList = mutableListOf<ObjectContent>()
var retrieveResult = this.getPort()?.retrievePropertiesEx(propertyCollector, filters, options)
if (isResultEmpty(retrieveResult)) {
    // return the empty list
    return resultList
}
// add the current results, at this point, we know that retrieveResult is not null
resultList.addAll(retrieveResult!!.objects)
// continue the request to get remaining data chunks, if necessary
while (retrieveResult != null && retrieveResult.token != null) {
    // get the continuation token
    val token = retrieveResult.token
    // continue data fetching using the provided continuation token
    retrieveResult = this.getPort()?.continueRetrievePropertiesEx(propertyCollector, token)
    if (!isResultEmpty(retrieveResult)) {
        // again, at this point we know that retrieveResult is not empty
        resultList.addAll(retrieveResult!!.objects)
    }
}
return retrieveResult

Actual behavior

retrievePropertiesEx() returns 100 objects and a token of "0", and because of the token the continueRetrievePropertiesEx() is throwing an Permission Denied exception

Expected behavior

it should be possible to retrieve all 334 objects

Fabio1988 avatar Apr 02 '24 08:04 Fabio1988