Hello there. I'm brand new to orchestrator but not really new at all to powercli. What I've been trying to do over the past day or so is configure a workflow for brand new esx hosts as we don't have enterprise plus right now. The main issue I'm having is after my portgroup/vmkernel has been created I do not see a easy way to configure the nic load balancing policy. I can get it to change it to IP hash which is what we are using but I don't see a option to make certain nic's active, etc. Can anyone shed any light on this or have any existing workflows for this type of setup that will setup the MTU setting and everything all in one shot like you can via the GUI.
Thanks
Hi, and welcome to vCO 🙂
Onyx will help you to figure out the proper API calls for tasks you do via the normal client:
http://labs.vmware.com/flings/onyx.
Google for vCO onyx to find some articles and a demo video
Cheers,
Joerg
And you replied 1 min before I had the chance to do it
Ok so here is my question then since I am familiar with onyx but not with javascript much yet:
So the code below can I just use that with input variables or do I need something else special to make the code work? That is the vCO JavaScript output in Onyx.
// ------- UpdateVirtualNic -------
var nic = new VcHostVirtualNicSpec();
nic.ip = new VcHostIpConfig();
nic.ip.dhcp = false;
nic.ip.ipAddress = "0.0.0.0";
nic.ip.subnetMask = "255.255.252.0";
nic.mac = "";
nic.portgroup = "NFS";
nic.mtu = 9000;
nic.tsoEnabled = true;
managedObject.updateVirtualNic("vmk1", nic); // HostNetworkSystem
// ------- UpdatePortGroup -------
var portgrp = new VcHostPortGroupSpec();
portgrp.name = "NFS";
portgrp.vlanId = 24;
portgrp.vswitchName = "vSwitch0";
portgrp.policy = new VcHostNetworkPolicy();
portgrp.policy.security = new VcHostNetworkSecurityPolicy();
portgrp.policy.nicTeaming = new VcHostNicTeamingPolicy();
portgrp.policy.nicTeaming.policy = "loadbalance_ip";
portgrp.policy.nicTeaming.reversePolicy = true;
portgrp.policy.nicTeaming.notifySwitches = true;
portgrp.policy.nicTeaming.rollingOrder = false;
portgrp.policy.nicTeaming.failureCriteria = new VcHostNicFailureCriteria();
portgrp.policy.nicTeaming.failureCriteria.checkBeacon = false;
portgrp.policy.offloadPolicy = new VcHostNetOffloadCapabilities();
portgrp.policy.shapingPolicy = new VcHostNetworkTrafficShapingPolicy();
managedObject.updatePortGroup("NFS", portgrp); // HostNetworkSystem
you have to fill the "managedObject" variable with the HostNetworkSystem object from the ESX host.
So if you have an ESX host (type: HostSystem) as input parameter, get it via
var managedObject = host.configManager.networkSystem;
before doing the whole Onyx output.
Refer to the vSphere API reference to get there 🙂
And see this video: Using Onyx to speed-up Workflow development
Awesome thanks I'll check that out.
... actually... did you look at the library workflow "Update port group in standard virtual switch (nic teaming)" ?
Yea but it doesn't change the nic order and it also doesn't appear to set some of the options that I'm looking for correctly. I'll double check it again though.
Ah, ok.. just making sure... a lot of people miss those library workflows Sounds like you are on the right track to getting everything figured out!
Yea I thought the same thing of how odd it was for the workflow not to include MTU or other things that are kind of important lol. So I'll build out this workflow later when I get back from my dr's appointment and I'll show you what I get.
Thanks
Ok so here is my question now. For each of these onyx scripts I have managedObject.updateNetworkConfig(config, "modify"); // HostNetworkSystem, or managedObject.updateVirtualSwitch("vSwitch0", spec); // HostNetworkSystem depending on which part I am modifying. My question now is if I have a input setup for VC:HostSystem how do i relate these back to the ESX host they choose in the workflow? I'm just not sure how to take these managed objects and reference them to the right location.
For Instance:
// ------------- Add New NFS vmKernel ------------------
var managedObject = managedObject.updateNetworkConfig
var config = new VcHostNetworkConfig();
config.portgroup[0] = new VcHostPortGroupConfig();
config.portgroup[0].changeOperation = "add";
config.portgroup[0].spec = new VcHostPortGroupSpec();
config.portgroup[0].spec.name = "NFS";
config.portgroup[0].spec.vlanId = vlan;
config.portgroup[0].spec.vswitchName = "vSwitch0";
config.portgroup[0].spec.policy = new VcHostNetworkPolicy();
config.vnic[0] = new VcHostVirtualNicConfig();
config.vnic[0].changeOperation = "add";
config.vnic[0].portgroup = "NFS";
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 = ip_address;
config.vnic[0].spec.ip.subnetMask = subnet;
How do I reference the first line back to the actual right esx host so it performs correctly. This is the error I get which is to be expected right now:
TypeError: Cannot read property "updateNetworkConfig" from undefined (Workflow:Create NFS vmKernel Portgroup / Scriptable task (item1)#1)
Thanks
Would this be the correct way to do it? Host is a input character tied to VC:HostSystem
// ------------- Add New NFS vmKernel ------------------
var managedObject = Host;
var config = new VcHostNetworkConfig();
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 = "NFS";
config.portgroup[0].spec.vlanId = vlan;
config.portgroup[0].spec.vswitchName = "vSwitch0";
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 = "NFS";
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 = ip_address;
config.vnic[0].spec.ip.subnetMask = subnet;
managedObject.updateNetworkConfig(config, "modify"); // HostNetworkSystem
Using the following script code I'm getting the error listed:
Cannot set property "0.0" of null to "ch.dunes.vso.sdk.DynamicWrapper@66e23bb6 / DynamicWrapper (Instance) : [VcHostPortGroupConfig]-[class com.vmware.vim.vi4.HostPortGroupConfig] -- VALUE : com.vmware.vim.vi4.HostPortGroupConfig@1" (Workflow:Create NFS vmKernel Portgroup / Scriptable task (item1)#4)
// ------------- Add New NFS vmKernel ------------------
var managedObject = Host;
var config = new VcHostNetworkConfig();
config.portgroup[0] = new VcHostPortGroupConfig();
config.portgroup[0].changeOperation = "add";
config.portgroup[0].spec = new VcHostPortGroupSpec();
config.portgroup[0].spec.name = "NFS";
config.portgroup[0].spec.vlanId = vlan;
config.portgroup[0].spec.vswitchName = "vSwitch0";
config.portgroup[0].spec.policy = new VcHostNetworkPolicy();
config.vnic[0] = new VcHostVirtualNicConfig();
config.vnic[0].changeOperation = "add";
config.vnic[0].portgroup = "NFS";
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 = ip_address;
config.vnic[0].spec.ip.subnetMask = subnet;
task = managedObject.updateNetworkConfig(config, "modify"); // HostNetworkSystem
I'm sure I'm missing something simple if anyone can provide any insight.
Thanks