Quantcast
Channel: VMware Communities : All Content - VMware View
Viewing all articles
Browse latest Browse all 9103

Single image, dozens of VLANs

$
0
0

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


Viewing all articles
Browse latest Browse all 9103

Trending Articles



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