VMware Cloud Community
Mururam
Contributor
Contributor

Not able to retrieve vcloud director host sys admin user reference

i am trying to retrieve vcloud director host system admin user reference for using this user for performing automation tasks.

But resultset is not retrievable with below code. Is there any other way to retrieve Sys Admin User reference?


var expressionUser = new VclExpression(VclQueryAdminUserField.NAME, host.getUsername(), VclExpressionType.EQUALS);

var filter = new VclFilter(expressionUser);
var params = new VclQueryParams();

params.setFilter(filter);

var users = new Array();

var resultSet = queryService.queryRecords(VclQueryRecordType.ADMINUSER, params);

while (resultSet != null)  {
    var records = resultSet.getRecords(new VclQueryResultAdminUserRecord());
    System.log(records.length + " Admin User record found");
    for each (var record in records) {
        var userRef = new VclReference();

    System.log(record.href + " href");
    System.log(record.name + " name");
    System.log(record.type + " type");

        userRef.href = record.href;
        userRef.name = record.name;
  userRef.type = record.type;

       users.push(host.getEntityByReference(VclFinderType.USER, userRef));
    }
    resultSet = resultSet.getNextPage();
}

Reply
0 Kudos
2 Replies
cdecanini_
VMware Employee
VMware Employee

I have tested your code and it works perfectly for me on 5.1.

How is configured your vCloud plug-in ? is it set to system org ? Is the user system org admin ?

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Mururam
Contributor
Contributor

Thank you. It was found to be a configuration issue in the environment.

Reply
0 Kudos