VMware Cloud Community
brandong08
Enthusiast
Enthusiast
Jump to solution

Workflow to enable "Block All Ports" on a Port Group

I am trying to create a workflow to Block All Ports on a Port Group.  I think I have everything setup correctly but not sure what to put under the Scripting Tag.

This is what I have after editing an existing. 

// ------- ReconfigureDVPortgroup_Task -------

// General Settings:

var spec = new VcDVPortgroupConfigSpec();

spec.configVersion = dvPortgroup.config.configVersion; // retrieves configVersion to use during update

spec.name = dvPortgroupName;

// Policies - Misc:

defaultPortConfig.blocked = new VcBoolPolicy();

defaultPortConfig.blocked.inherited = false;

defaultPortConfig.blocked.value = blockAllPorts; // Shuts down all ports in the portgroup if set to true

task = dvPortgroup.reconfigureDVPortgroup_Task(spec);

1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Well, you can either pass dvPortgroupName  as a workflow input parameter, or you can comment out this line    spec.name = dvPortgroupName; 

View solution in original post

6 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

There is already out-of-the-box workflow that does so (plus other things) - Update distributed virtual port group (available under Library > vCenter > Networking > Distributed Virtual Port Group).

the corresponding setting is on workflow tab/group labelled Miscellaneous

0 Kudos
brandong08
Enthusiast
Enthusiast
Jump to solution

That is the one I am working from.  Trying to consolidate it so there is only one option.

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

The following should work:

// General Settings: 

var spec = new VcDVPortgroupConfigSpec(); 

spec.configVersion = dvPortgroup.config.configVersion; // retrieves configVersion to use during update 

spec.name = dvPortgroupName; 

 

// Policies - Misc: 

spec.defaultPortConfig = new VcVMwareDVSPortSetting();

spec.defaultPortConfig.blocked = new VcBoolPolicy(); 

spec.defaultPortConfig.blocked.inherited = false; 

spec.defaultPortConfig.blocked.value = blockAllPorts; // Shuts down all ports in the portgroup if set to true 

 

task = dvPortgroup.reconfigureDVPortgroup_Task(spec); 

0 Kudos
brandong08
Enthusiast
Enthusiast
Jump to solution

Still getting "Reference Error dvPortgroupName is not defined"

Thanks

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Well, you can either pass dvPortgroupName  as a workflow input parameter, or you can comment out this line    spec.name = dvPortgroupName; 

brandong08
Enthusiast
Enthusiast
Jump to solution

That worked.  Thanks for the help. 

0 Kudos