Hi
could you please help me to find out the VLAN Id of the organization networks ( external and internal VLAN based) through VCO apis ( vcenter or vcloud director)
Thanks for your cooperation.
shay
Hi!
Not directly related to the vCO Plugin for vCD, but it might guide you in the proper direction:
http://communities.vmware.com/thread/416430?tstart=0
Cheers,
Joerg
Thanks Joerg, but i need to get Network information(VLAN ID) via Orchestrator workflows ( VCO) via vCenter Server plugin or vCloud Director plugins.
could any body help me to get this done?
Thanks for your kind cooperation.
Using the link I posted and some other examples here in the forums I put the solution together (see script below, I also attached the complete workflow).
Be aware that it is a draft, use at your own risk.
For the discussion: I didn't find another way to "translate" the vCD OrgNetwork Objects in vCenter dvPortgroups than searching for the name. That works only unique if you have only one vCenter.
Better would be to get the vCenter and the moref from vCenter, but I don't know if that is possible via the vCloud-API and the Plugin.
Cheers,
Joerg
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 resultSet = queryService.queryAllOrgNetworkRecords(params);var vlanOverview = "\n";while (resultSet != null) {var records = resultSet.getRecords();// only if you look for exactly one specific orgNetwork...//if (records.length != 1) throw "Not exactly one OrgNetwork found!";//record = records[0];for each (var record in records) { // loop through all ORG?NETWORKSvar networkRef = new VclReference();networkRef.href = record.href;networkRef.name = record.name;networkRef.type = record.type;var network = (vCDHost.getEntityByReference(VclFinderType.ORG_NETWORK, networkRef));if (network == null ) throw " Network not found";//System.debug(network.toXml());System.debug("==== processing " + network + "====");//Get dvPortgroup in vCEntervar orgNetworkName = network.getReference().name;var id = network.getReference().id.split(":")[3];System.debug("id: " + id);var xpath = "name[ends-with(.,'" + id + "')]";System.debug("searching for DVPortgroup with xpath: " + xpath);var portgroups = VcPlugin.getAllDistributedVirtualPortgroups(null , xpath);//xpath doesn't seem to work here , so we have to loop through resulting array and find the exact portgroupSystem.debug("portgroups: " + portgroups);var thePortgroups = new Array();for each (var portgroup in portgroups) {System.debug("portgroup.name: " + portgroup.name);//remove all NOT matching portgroupsvar pgname = portgroup.name;if (portgroup.name.lastIndexOf(id) > -1) thePortgroups.push(portgroup);}System.debug("thePortgroups: " + thePortgroups);if (thePortgroups.length > 1) throw "No unique Portgroup for " + id + " found!";if (thePortgroups.length == 1) {//get VLAN id for this portgroupvar thePortgroup = thePortgroups[0];var vlanId = thePortgroup.config.defaultPortConfig.vlan.vlanId;vlanOverview += "OrgNetwork: " + orgNetworkName + "\t\t vlanId: " + vlanId + "\n";}}resultSet = resultSet.getNextPage();}System.log(vlanOverview);