Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Using Orchestrator, Finding a Specific vmkernel Port

$
0
0

Using Onyx, I got the following script to create a vmkernel port for vMotion.  I modified it to use it in a workflow.  The very last line refers to "vmk2" which is the vmkernel port created by vCenter and captured by Onyx.  It would be created a few lines above in the script.  My question is, how do I determine which vmkernel port was created (i.e. which vmk???)?  So instead of hardcoding in vmk2, I can use a variable string with the actual vmkernel port created earlier in the script.

 

---------------------Modified Onyx Script -------------------------------------------

// ------- Create New vSwitch and vMotion Portgroup -------

var config = new VcHostNetworkConfig();
config.vswitch = System.getModule("com.vmware.onyx").array(VcHostVirtualSwitchConfig, 1);
config.vswitch[0] = new VcHostVirtualSwitchConfig();
config.vswitch[0].changeOperation = "add";
config.vswitch[0].name = A_vSwitchName;
config.vswitch[0].spec = new VcHostVirtualSwitchSpec();
config.vswitch[0].spec.numPorts = 128;
config.vswitch[0].spec.bridge = new VcHostVirtualSwitchBondBridge();
config.vswitch[0].spec.bridge.nicDevice = System.getModule("com.vmware.onyx").array(String, A_upLinks.length);
config.vswitch[0].spec.bridge.nicDevice = A_upLinks;
config.portgroup = System.getModule("com.vmware.onyx").array(VcHostPortGroupConfig, 1);
config.portgroup[0] = new VcHostPortGroupConfig();
config.portgroup[0].changeOperation = "add";
config.portgroup[0].spec = new VcHostPortGroupSpec();
config.portgroup[0].spec.name = A_Portgroup;
config.portgroup[0].spec.vlanId = 0;
config.portgroup[0].spec.vswitchName = A_vSwitchName;
config.portgroup[0].spec.policy = new VcHostNetworkPolicy();
config.vnic = System.getModule("com.vmware.onyx").array(VcHostVirtualNicConfig, 1);
config.vnic[0] = new VcHostVirtualNicConfig();
config.vnic[0].changeOperation = "add";
config.vnic[0].portgroup = A_Portgroup;
config.vnic[0].spec = new VcHostVirtualNicSpec();
config.vnic[0].spec.ip = new VcHostIpConfig();
config.vnic[0].spec.ip.dhcp = false;
config.vnic[0].spec.ip.ipAddress = A_ipAddress;
config.vnic[0].spec.ip.subnetMask = A_subnetmask;

var managedObject = A_esxiHost.configManager.networkSystem;
managedObject.updateNetworkConfig(config, "modify");  // HostNetworkSystem

 

// ------- SelectVnicForNicType -------
var managedObject = A_esxiHost.configManager.virtualNicManager;
if (A_vMotionEnabled)
A_HostVirtualNicManager.selectVnicForNicType("vmotion", "vmk2");  // HostVirtualNicManager

--------------------------------------------------------------------------------------------------------


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>