VMware Cloud Community
Subnet88
Enthusiast
Enthusiast
Jump to solution

Find External Network by name in VCD

Good day all,

Has anyone erer attempted to use VCO to find a list of external networks in VCD 1.5? I have been at it for a week now with no success and was hoping somebody might have a lead I can follow.

Looking forward to hearing from somebody...

0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Your action would look like this:

var providerNetworks = host.toAdminObject().getProviderNetworks();

for each (var providerNetwork in providerNetworks) {
     if (providerNetwork.name == externalNetworkName) return providerNetwork;
}
return null;

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

View solution in original post

0 Kudos
9 Replies
abirhasan
Enthusiast
Enthusiast
Jump to solution

Cna you share the procedure?

abirhasan 
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

I'm not sure what you mean by Share the procedure, but What I need to do is;

1) connect to the VCD Host

2)Retrieve a list of External Networks in the form of an Array/ Vcloud:ExternalNetworks format

I can currently Connect and rerieve a list of Orgs, Org Networks, and Org VDC's, but nothing at the root level (Provider VDC's and External Networks)

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

You should definitely use the query service to get the external networks. I cannot provide an example ATM but I think I  posted similar examples in this forum before.

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

I have used the Query service to find other items, but there is no VclQueryAdminExternalNetworkField  class or a VclQueryResultExternalNetwork Class

There is however a vclQueryRecordType.EXTERNALNETWORK attribute.

Any idea how I can query the above attribute?

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

This is not using the query service but can you please check if this action works for you ?

if (host != null) {
    return host.toAdminObject().getProviderNetworks();
}
else return null;

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

That worked perfectly! Thank you.

However I have one more issue that that brings up, How can I take that script and return a Single item of type Vcloud:ProviderNetwork that matches an External Network name provided as an input?

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Your action would look like this:

var providerNetworks = host.toAdminObject().getProviderNetworks();

for each (var providerNetwork in providerNetworks) {
     if (providerNetwork.name == externalNetworkName) return providerNetwork;
}
return null;

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
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Ans since I mentioned it you can also get the external networks using the query service

var queryService = vcdHost.toAdminObject().toAdminExtensionObject().getExtensionQueryService();

var expression = new VclExpression(VclQueryNetworkField.NAME, "*", VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);

var networks = new Array();

var resultSet = queryService.queryExternalNetworkRecords(params);
while (resultSet != null) {
    var records = resultSet.getRecords();
    for each (var record in records) {

        var networkRef = new VclReference();
        networkRef.href = record.href;
        networkRef.name = record.name;
        networkRef.type = record.type;
        var network = (vcdHost.getEntityByReference(VclFinderType.PROVIDER_NETWORK, networkRef));
        networks.push(network);
    }
    resultSet = resultSet.getNextPage();
}

return networks;

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
0 Kudos
abhishek2408
Contributor
Contributor
Jump to solution

Thanks... This was very useful.

0 Kudos