VMware Cloud Community
js40687
Contributor
Contributor

CreateCustomizationSpec

I am trying to automate VM deployment. I was looking at Windows VMs and using the PowerCli OSCustomization cmdlets but got stuck with the 2 NICs and having to put a default gateway on both NICs.

I then followed a post on here to use the sdk call which allows me to leave one blank, that worked a treat

I now want to do the same but for a Linux VM and am struggling to work out the Linux equivelant entries

Has anyone done this? or can point me at some VMware documentation that I am likely to be able to understand :smileyconfused:

Thanks

Jim

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership

Could you perhaps give some more details on what you did for the Windows VMs ?

What code did you use, and which parameters ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
js40687
Contributor
Contributor

Hi Luc, it was your post from last year

http://communities.vmware.com/thread/409321?start=0&tstart=0

I need to do a Linux one for the same reason, multiple NICs, need to drop the default gateway on one of them

I’m struggling converting this code to work for a Linux customization, struggling to find documentation that shows which parms are Windows and what additionally is required for Linux. Some are obviously Windows but.....

Reply
0 Kudos
LucD
Leadership
Leadership

Try something like this

$specMgr = Get-View CustomizationSpecManager

$item = New-Object VMware.Vim.CustomizationSpecItem

$item.Info = New-Object VMware.Vim.CustomizationSpecInfo
$item.Info.Name = "TestMultNICSDKLinux"
$item.Info.Description = "Testing with the SDK method"
$item.Info.Type = "Linux"

$item.Spec = New-Object VMware.Vim.CustomizationSpec

$item.Spec.globalIPSettings = New-Object VMware.Vim.CustomizationGlobalIPSettings

$item.Spec.identity = New-Object VMware.Vim.CustomizationLinuxPrep
$item.Spec.identity.domain = "mydomain.org"
$item.Spec.identity.hostname = New-Object VMware.Vim.CustomizationVirtualMachineName
$item.Spec.identity.hwClockUTC = $true
$item.Spec.identity.timeZone = "Europe/Brussels"
$item.Spec.Options = New-Object VMware.Vim.CustomizationLinuxOptions

1..2 | %{
 
$nic = New-Object VMware.Vim.CustomizationAdapterMapping
 
$nic.Adapter = New-Object VMware.Vim.CustomizationIPSettings
 
$nic.Adapter.ip = New-Object VMware.Vim.CustomizationFixedIp
 
$nic.Adapter.ip.ipAddress = "192.168.1.$_"
 
$nic.Adapter.subnetMask = "255.255.255.0"
 
if($_ -eq 1){
   
$nic.Adapter.Gateway = "192.168.1.254"
  }
 
$item.Spec.nicSettingMap += $nic
}

$specMgr.CreateCustomizationSpec($item)

Notice that the script will only assign a Gateway for the first NIC


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
js40687
Contributor
Contributor

Thanks Luc

Nearly there

The only thing I’m missing now is the Linux Location being set to Area of Europe Location of London

The New/Set OSCustomization states the TimeZone parameter is Windows only, I can create the Linux specification fine but get a default entry of Area Africa and Location Abidjan

How do I set that using the CustomizationSpecManager ?

Reply
0 Kudos
js40687
Contributor
Contributor

I did one last search after I sent the email below and found the answer

It is timeZone but needed to be in Linux format of Europe/London

Thanks for your help, as prompt as always ☺

From: SCOTT Jim (AXA-TECH-UK)

Sent: 25 July 2013 16:32

To: 'communities-emailer'

Subject: RE: New message: "CreateCustomizationSpec"

Thanks Luc

Nearly there

The only thing I’m missing now is the Linux Location being set to Area of Europe Location of London

The New/Set OSCustomization states the TimeZone parameter is Windows only, I can create the Linux specification fine but get a default entry of Area Africa and Location Abidjan

How do I set that using the CustomizationSpecManager ?

Reply
0 Kudos
LucD
Leadership
Leadership

Apparently I forgot to enter a value for TimeZone. I updated the code above.

Sorry about that, but good that you found what is required.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos