VMware Horizon Community
access360
Enthusiast
Enthusiast
Jump to solution

Single image, dozens of VLANs

I've been retooling a clients View Horizon 5.2 install for the last few months.  The basics are this: a VDI cluster in a centrally located data-center and relatively low latency extended LANs to branch offices.  Speeds not my concern thankfully, but they do have lots of branch offices connected via extended VLANs from the data-center.  Whoever set them up originally thought that creating a different master snapshot for each VLAN was the way to go when it comes to re-composing the dozens of pools.  Needless to say it kinda negates the ease of maintaining a single image when you have multiple snapshots that have to be taken with the correct network vlan assigned to them.

I've already got the PowerCli set to run based on location specific prefix variables of the VMs and set the network location from that.  Perfect - for me anyway.  I won't be handing this back to a VMware expert, so I'm trying to automate as much as I can.  I'm not convinced that using QuickPrep as opposed to SysPrep is the answer - which would allow me to run a PS script to the machines, and sysprep's ability to 'run once' doesn't work because, well, VM Power Cli isn't installed on the virtuals.

I realize that once the pools are re-deployed properly, there should be very few reasons to actually re-compose the pools using Sysprep - the client should simply be refreshing which will keep all of my VMs properties the same, just update the OS.  But in the interests of making more work for myself, can anyone suggest a way to call a PS script to run using a custom Customization Specifications Manager script that I can link to the pools in the View Admin console?

If there isn't a solid way to do it, I'm thinking I might just leave a bunch of PS scripts on the desktop of the vCenter server that can be run against whatever location / vlan needs to have the networks adjusted for.  If I set my GM to do all the AD joining on the management network when a recompose is done, and then simply leave instructions to manually call the relevant location PS script on the vCenter server to set the VLANs after the linked clones are all made, that will work too - but I'd love to not have to worry about it and have it run post clone / customization so it can be set and forgotten about.

If it was my full time job to maintain this, I'd just run the PS as needed - when needed, but it's not, and I want to make things as simple for my client to deploy new sites or recompose a pool without worrying about what vlan they end up on.

This is what I have right now:

#This script is for users of VMWare View Horizon and requires the VIToolkit for Windows

#When you run the script it will prompt you to authenticate

#$VCServer should be the server that you want the VIToolkit to connect to in order to get information about the users VM

$VCServer = 'vcenterFQDN'

#Check for the VMware.VimAutomation.Core snapin and add load it if necessary

$snapins = Get-PSSnapin | where {$_.Name -match "VMware*"} | select name

if ($snapins.name -notcontains "VMware.VimAutomation.Core"){Add-PSSnapin VMware.VimAutomation.Core}

#collect the credentals needed to connect to the VDI servers

$cred = Get-Credential

$pw = $cred.GetNetworkCredential()

#connect to the VI server with the supplied credentials

Connect-VIServer -Server $VCServer -Credential $cred -Protocol https

# Connects a virtual network adapter of the VM to network VLAN - eg:

# $vlan = Get-VirtualSwitch -Distributed -Name 'dvSwitch-name' | Get-VirtualPortGroup -Name  'vlan or portgroup name'

#

# Filter based on VDI Location Prefix

# Uncomment the $Location variable to filer by location prefix

# Uncomment the $vlan variable to apply the VLAN to the correct VM location variable.

# Follow simple formatting to add additioal locations and VLANs as required.

################################################################################

##########                                                           ###########

##########      USE EXTREME CAUTION WHEN USING GLOBAL VARIABLES      ###########

##########      VMPowerCli will move ALL network locations of the    ###########

##########      location variable regardless of VM state & session   ###########

##########                                                           ###########

################################################################################

#$location = "LOC1*"

#$vlan = "VLAN1000 - location1"

#$location = "LOC2*"

#$vlan = "VLAN1001 - location2"

#$location = "LOC3*"

#$vlan = "VLAN1026 - location3"

#$location = "LOC4*"

#$vlan = "VLAN1027 - location4"

#$location = "LOC5*"

#$vlan = "VLAN1024 - location5"

$location = "TEST1*"

$vlan = "VLAN1000 - location1"

Get-VM $location | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $vlan

The variables can be adjusted from a single script, or I make many copies and hard code them in for the 'simplicity factor.'

Any suggestions or other ways to approach this would be welcome.

Cheers,

A

0 Kudos
1 Solution

Accepted Solutions
mittim12
Immortal
Immortal
Jump to solution

The new version of Horizon View allows you to set vlans at a pool level now.  This new feature may simplify your task even more and reduce the need for a script. You can review this link for a write up on the feature,http://myvirtualcloud.net/?p=4730

View solution in original post

0 Kudos
2 Replies
mittim12
Immortal
Immortal
Jump to solution

The new version of Horizon View allows you to set vlans at a pool level now.  This new feature may simplify your task even more and reduce the need for a script. You can review this link for a write up on the feature,http://myvirtualcloud.net/?p=4730

0 Kudos
access360
Enthusiast
Enthusiast
Jump to solution

Hmm.  It's good to know that that option is available.  I won't have pools with multiple VLANs, but still a good option for larger pools.  The problem I have is having so many Pools with single VLANs attached to each.  Organized, but lots of mistakes for a junior admin to make should they ever re-compose instead of refresh a pool.  I like the idea of the automatic association of this network name being associated with a pool, but I'm a little concerned that if existing pools 'automagically' retain their network names, and new pools don't, I might be introducing a difficult to trace issue if full documentation isn't read.  I'm gonna have to ponder this.  It makes complete sense from an View Admin perpective, but might not from a Windows Admin who is running the View deployment.  My PS can easily be edited and run on the required pools with a filtered variable, where as the View config file has to be populated and either modified or re-polled if new pools are created.  lol - I guess it's a bit of a crap shoot anyway you look at it.  What would really be nice is if View 5.2.x or higher simply puts a little drop down that lets you choose the network name / vlan - then my concerns are all gone!

I'll post back with what I end up going with - and my reasons for whatever I choose.

Thanks for the useful info!  Love that VMware admins are happy to share their knowledge.

0 Kudos