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

Autoselection of correct portgroup for deployment

$
0
0

I'm making an deployment workflow where the workflow itself decides several of the inputparameters for the actual deployment, based on presentation-inputs selections like "Security Zone", "Type of Enviroment", Required Redundant Storage etc.

 

Based on all of theese inputs, the scripts "knows" what cluster to deploy to (hardcoded). It automaticly then selects a host (at random) from that cluster, verifies it's state, and if it's in maintenance, it selects another one. It find's a suitable datastore of correct type, selects the one with the most free space, but also takes into concideration that datastores should not be filled above 80%. It then provisons the template, adds more ram (if selected), more cpu (if selected), adds additional harddrives, partitions then inside the VM etc etc.

 

The script works great and saves ut tons of time on deployment. But there is one annoying litte information I still have to provide, and that is the portgroup. I would like the script to select the portgroup based on just a VLAN ID given during the start of the workflow (presentation) because this would make the script more "selfservice" friendly and availlable to other people in the organization, and not just the vmware admins because they are the ones knowing what portgroups goes with wich hosts/clusters etc. The other parts of organizations like to focus more on placement into security zones and vlans, type of environment etc, not physical cluster placement, and virtual networking......

 

I have several clusters/hosts, some of wich are connected to vSwitches and some are connected to dvSwitches, and some connected to both, and I also have different dvSwitches. VLAN 600 could be part of several dvSwitches, but ofcourse under different PG-name for each dvswitch. It could be called "P_600" on one dvSwitch and PRD_MGMT on another dvSwitch for other clusters/hosts. And It's very easy to make selections during presentation indicating deployment to CLUSTER D1 and then by mistake or confusion (atleast for nonadmins) select PRD_MGMT instead of P_600, causing the deployment to hook up the network to a switch not visible to the host, causing the deployment to fail on jondomain operations etc. This is the reason for me wanting the script to do this part itself.

 

What I need is a piece of code using an cluster or a host as input, finding all switches to which this host is connected (both standard and distributed). Then loop through all portgroups on theese switches, and find a portgroup with the specified VLAN ID and return this portgroup as either VC:Network or VC:DistributedVirtualPortGroup based on what switch it was found in.  But I could find no way to do what I wanted using the default API's availlable.

 

I also tried to modify my wishes, and let some of the automation be "hardcoded" which would also work, just like the cluster's part (just not as fancy) and make a pice of code taking a specified hardcoded dvSwitch or vSwitch, loop trough all portgroups and find the portgroup with correct VLAN ID, returning it ito a VC:Network variable or a VC:DistributedVirtualPortGroup variable, but I couldn't get that to work either. Atleast not for dvSwitches, which is used for 90% of all deployments.... I just can't seem to find a working way to do this.

 

Anyone know how this could be done? In short, how do I loop through all portgroups on a dvswitch and return one with a specified VLAN ID? Any help appreciated!


Viewing all articles
Browse latest Browse all 6251

Trending Articles