VMware Cloud Community
Subnet88
Enthusiast
Enthusiast
Jump to solution

orgvdcnetwork.toAdminObject() not returning correct value

Good day,

When I run the orgvdcnetwork.toAdminObject() method, I recieve the error "Resource not found". In the error message, it includes the href that is not found. It appears that "admin" is written twide in this url. Is there a way to get around this?

The error is also present on the action System.getModule("com.vmware.library.vCloud.operation").toAdminObjectOrgVdcNetwork()

'https://vCloudCell.local/api/admin/admin/network/50599c9b-2576-4b7f-b5a4-a068b37350be'

Reply
0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee
Jump to solution

It is indeed odd that you get an admin url in an non admin object.

I found my way with getting directly the admin Org VDC Networks from the query service:

var queryService = host.getQueryService();
var expression = new VclExpression(VclQueryOrgVdcNetworkField.NAME, Network_Name, VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var oNetworks = new Array();
var resultSet = queryService.queryRecords(VclQueryRecordType.ADMINORGNETWORK, params);
while (resultSet != null)  {
    var records = resultSet.getRecords(new VclQueryResultAdminOrgNetworkRecord());
    System.log(records.length + " Org VDC Network record(s) found");
    for each (var record in records) {
        var onetRef = new VclReference();
        onetRef.href = record.href;
        onetRef.name = record.name;
        onetRef.type = record.type;
           oNetworks.push(host.getEntityByReference(VclFinderType.ADMIN_ORG_VDC_NETWORK, onetRef));
    }
    resultSet = resultSet.getNextPage();
}
adminOrgVdcNetwork = oNetworks[0];

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

View solution in original post

Reply
0 Kudos
7 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

I have just run the following

adminOrgVdcNetwork = orgVdcNetwork.toAdminObject();

And it worked as expected. I have normal URLs.

I really wonder how you can get 2 admin in the URL. :smileyconfused:

A work around would be to get the first one URL, add /admin and then use getEntityByReference but this would be an ugly work around and not solve the main issue you have that can certainly affect you in other workflows.

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
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

I have confirmed that I get 2 admin in the URL from two diffrent VCO servers running VCD plugin v5.1.538. I have also confirmed that I see this on two different VCD environments.

The host connection is connecting to the SYSTEM org, if that helps at all.

Christophe, What version of the VCD plugin are you running?

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

vCloud Director 5.1.538 and system org.

I would suggest opening a support request at GSS. Maybe they can find what is wrong from your logs.

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
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

AH HA!   I think I have figured out my problem. I was retrieving the OrgVDCNetwork via the query service using the query below.  This is where the extra admin was coming from. If I manually specify an OrgVDCNetwork I only get one /admin and all is right with the world.   Any thoughts why this is retrieving the Admin object?

Inputs: Network_Name(string), host(vcloud:host)

var queryService = host.getQueryService();
var expression = new VclExpression(VclQueryOrgVdcNetworkField.NAME, Network_Name, VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var oNetworks = new Array();
var resultSet = queryService.queryRecords(VclQueryRecordType.ORGVDCNETWORK, params);
while (resultSet != null)  {
    var records = resultSet.getRecords(new VclQueryResultOrgVdcNetworkRecord());
    System.log(records.length + " Org VDC Network record(s) found");
    for each (var record in records) {
        var onetRef = new VclReference();
        onetRef.href = record.href;
        onetRef.name = record.name;
        onetRef.type = record.type;
       oNetworks.push(host.getEntityByReference(VclFinderType.ORG_VDC_NETWORK, onetRef));
    }
    resultSet = resultSet.getNextPage();
}
OrgVDCNetwork = oNetworks[0]
Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

It is indeed odd that you get an admin url in an non admin object.

I found my way with getting directly the admin Org VDC Networks from the query service:

var queryService = host.getQueryService();
var expression = new VclExpression(VclQueryOrgVdcNetworkField.NAME, Network_Name, VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var oNetworks = new Array();
var resultSet = queryService.queryRecords(VclQueryRecordType.ADMINORGNETWORK, params);
while (resultSet != null)  {
    var records = resultSet.getRecords(new VclQueryResultAdminOrgNetworkRecord());
    System.log(records.length + " Org VDC Network record(s) found");
    for each (var record in records) {
        var onetRef = new VclReference();
        onetRef.href = record.href;
        onetRef.name = record.name;
        onetRef.type = record.type;
           oNetworks.push(host.getEntityByReference(VclFinderType.ADMIN_ORG_VDC_NETWORK, onetRef));
    }
    resultSet = resultSet.getNextPage();
}
adminOrgVdcNetwork = oNetworks[0];

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
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

Thanks. Should I open a bug with GSS for the Admin URL in a non admin object?

This is the code I think I will stick with for now, which turns the href into a non admin object, unless this is likely to break.

var queryService = host.getQueryService();
var expression = new VclExpression(VclQueryOrgVdcNetworkField.NAME, Network_Name, VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var oNetworks = new Array();
var resultSet = queryService.queryRecords(VclQueryRecordType.ORGVDCNETWORK, params);
while (resultSet != null)  {
    var records = resultSet.getRecords(new VclQueryResultOrgVdcNetworkRecord());
    System.log(records.length + " Org VDC Network record(s) found");
    for each (var record in records) {
        var onetRef = new VclReference();
        onetRef.href = record.href.replace('/admin', '');
        onetRef.name = record.name;
        onetRef.type = record.type;
System.log(onetRef.href)
System.log(record.name)
System.log(record.type)
       oNetworks.push(host.getEntityByReference(VclFinderType.ORG_VDC_NETWORK, onetRef));
    }
    resultSet = resultSet.getNextPage();
}
OrgVDCNetwork = oNetworks[0]

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Yes please open a GSS support request. I am curious to know the answer.

Your code works, no doubt but if the above is a bug it will break in the next version, mine shouldn't :smileydevil:

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
Reply
0 Kudos