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...
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.
Cna you share the procedure?
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)
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.
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?
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;
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?
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.
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;
Thanks... This was very useful.