VMware Cloud Community
BrettJowett
Contributor
Contributor

VCD External Network Creation Workflow

Hi All,

I am looking for assistance with the create external network workflow with the VCloud director plugin.

Basically I am looking for a way to figure out what the portgroup Moref would be of the underlying DVS portgroup.

I can find this information if I manually log into the vCenter API and browse the the DVS portgroup in question. However I was wondering if there is a way to find this information in the form of a workflow or action?

Apologies if this is already available I am relatively new to VCO and still finding my feet.

Regards

Brett

0 Kudos
4 Replies
BrettJowett
Contributor
Contributor

Hi All,

Just to add further information I have found the following discussion created by Zeppa on the 10/10/2012.A big thanks to him/her as I believe this is on the right track.

How to obtain VDS Portrgroup MoRef from name?

I have created scriptable task with Zeppa's script in and customised it to meet my requirements

Input:

Name                         Type                   

vcdHost:                    vCloud:Host

portGroupName          string

Output

Name                        Type

resultSet                    String

var queryService = vcdHost.getQueryService();

expression = new VclExpression(VclQueryPortgroupField.NAME, portGroupName, VclExpressionType.EQUALS);

filter = new VclFilter(expression);

params = new VclQueryParams();

params.setFilter(filter);

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

while (resultSet != null) {

    var records = resultSet.getRecords(new VclQueryResultPortgroupRecord());

    System.log(records.length + "I have found something!!");  

    for each (var record in records) {

        if (record.name == portGroupName {

            record2 = record.moref;

            }

   }

    resultSet = resultSet.getNextPage();

}

System.log(resultSet)

When I run the workflow I am getting a null value returned I am just starting out with VCO and Javascript and figuring out what is happening within the script is a bit beyond me at this time.

So any assistance would be appreciated.

Regards

Brett

0 Kudos
BrettJowett
Contributor
Contributor

Hi All,

Can anyone help out with this?

Regards

Brett

0 Kudos
qc4vmware
Virtuoso
Virtuoso

I see a syntax error which vRO should have squawked about.  The line:

if (record.name == portGroupName {


should be:


if (record.name == portGroupName) {


Its missing the closing paren around the expression.

0 Kudos
qc4vmware
Virtuoso
Virtuoso

Here is a doctored up script.  You'll need an output named "morefList" that is an array of type string.  This script works.  You can compare it to what you came up with.  You'll see where I tweaked things just a little and added some extra logging for debugging.

var queryService = vcdHost.getQueryService();

expression = new VclExpression(VclQueryPortgroupField.NAME, portGroupName, VclExpressionType.EQUALS);

filter = new VclFilter(expression);

params = new VclQueryParams();

params.setFilter(filter);

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

var morefList = new Array();

while (resultSet != null) {

    var records = resultSet.getRecords(new VclQueryResultPortgroupRecord());

    System.log(records.length + " - I have found something!!"); 

    for each (var record in records) {

  System.log("Processing Portgroup with name: " + record.name + ",moref: " + record.moref);

        if (record.name == portGroupName) {

            morefList.push(record.moref);

            }

   }

    resultSet = resultSet.getNextPage();

}

System.log(morefList);

0 Kudos