I'm trying to learn how to use orchestrator and I thought a good project would be to create a workflow that allows you to create a vlan for an esx host.
What I would like to do further with this is to create a vlan on a bunch of hosts at a time, like say: for this folder of esx hosts, create the vlan id on it if it doesn't exist.
Any tips on how to add a vlan to an esx host?
Sorry, I meant, can I use the vmware api to create a portgroup with a specific vlan ID for the main vswitch of an esx host.
Create an VLAN on your physical switch.
After that assign an new Portgroup an an vswitch with the new created VLAN.
Hi. I solved it by creating an action element. Decided I'd share the main part for others.
var vlanName = "VLAN"+vlanID; // vlanID is a number input to the action
var myPortGroupSpec = new VcHostPortGroupSpec();
myPortGroupSpec.name = vlanName;
myPortGroupSpec.vlanId = vlanID;
myPortGroupSpec.vswitchName = defaultSwitch; // default switch is calculated above
var myVcHostNetworkPolicy = new VcHostNetworkPolicy() ;
myPortGroupSpec.policy = myVcHostNetworkPolicy;
System.log("------ getting ManagedObjectReference --> HostNetworkSystem -
var vimHost = VcPlugin.allVimHosts;
var netSys = VcPlugin.convertToVimManagedObject(vimHost, host.configManager.networkSystem);
System.log("------run add port group: " + vlanName + " -
System.log("Successfully created portgroup!");
System.log("Portgroup already exists!");
Thanks for sharing!
You beat me to the punch. I thought you wanted a new vswitch instead of a new port group and had started working on that.