Foreman deploy to vmware with a set boot order

In essence I am looking for a way to control the boot order of a VM.
Currently a standard deployed VM always defaults to HDD first before
Network , which is fine in normal operation, but is there a way to
manipulate the boot order when the host is in build status to first try the
network interfaces then CD then HDD ?

Using this as reference I would guess fog would be capable but not enough
in the content of it.
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2011654

And yes I do realize I could just change the boot order of the VM but it
defeats the reason I am asking it. I got the idea after seeing the lab0
post , I need to give customers access to deploying hosts but I do not want
to destroy the previous host and make a new one , but rather just re
provision the existing one , less hassle on the MAC address security we
run…

But something like what lab0 is would be great simple authentication
surface before it and our customers are good to go :stuck_out_tongue:

Definitely, I'd regard that as a bug. I remember libvirt and oVirt
create VMs with network first, so any VMware hosts we create should
follow the same pattern to enable re-deployment.

··· On 01/03/14 15:06, Jelle B wrote: > In essence I am looking for a way to control the boot order of a VM. > Currently a standard deployed VM always defaults to HDD first before > Network , which is fine in normal operation, but is there a way to > manipulate the boot order when the host is in build status to first try > the network interfaces then CD then HDD ? > > Using this as reference I would guess fog would be capable but not > enough in the content of it. > http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2011654 > > And yes I do realize I could just change the boot order of the VM but it > defeats the reason I am asking it. I got the idea after seeing the lab0 > post , I need to give customers access to deploying hosts but I do not > want to destroy the previous host and make a new one , but rather just > re provision the existing one , less hassle on the MAC address security > we run...


Dominic Cleal
Red Hat Engineering

I'm using a hook script which calls a powershell script that executes
PowerCLI commands to change boot order. I also change guest os type and
set the mac address to be static this way. Its not very pretty but its
been working for a few months now.

'create' hook script:

setup boot order so NIC is first

cmd_setboot="powershell C:\scripts\changeGuestBootOrder.ps1 -newserv
${newserv} -server $vsphere_server"
ssh foreman@powercli-server $cmd_setboot

Powershell script:

param(
[string] $newserv,
[string] $server
)

Add-PSSnapin VMware.VimAutomation.Core

if ( $server -eq 'qa' ) {
connect-viserver -server 10.10.10.101 -protocol https -user "username"
-password ******
}
elseif ( $server -eq 'prod-az' ) {
connect-viserver -server 192.168.10.101 -protocol https -user "username"
-password ******
}
elseif ( $server -eq 'prod-sc' ) {
connect-viserver -server 172.16.10.101 -protocol https -user "username"
-password *******
}

the VM to configure

$strVMName = $newserv

the device name of the NIC to which to boot

$strBootNICDeviceName = "Network adapter 1"

the device name of the hard disk to which to boot

$strBootHDiskDeviceName = "Hard disk 1"

get the .NET View object for the VM, with a couple of select properties

$viewVM = Get-View -ViewType VirtualMachine -Property Name,
Config.Hardware.Device -Filter @{"Name" = "^$strVMName$"}

get the VirtualEthernetCard device, and then grab its Key (DeviceKey,

used later)
$intNICDeviceKey = ($viewVM.Config.Hardware.Device | ?{$_.DeviceInfo.Label
-eq $strBootNICDeviceName}).Key

bootable NIC BootOption device, for use in setting BootOrder (the

corresponding VirtualEthernetCard device on the VM has PXE enabled, assumed)
$oBootableNIC = New-Object -TypeName
VMware.Vim.VirtualMachineBootOptionsBootableEthernetDevice -Property
@{"DeviceKey" = $intNICDeviceKey}

get the VirtualDisk device, then grab its Key (DeviceKey, used later)

$intHDiskDeviceKey = ($viewVM.Config.Hardware.Device |
?{$_.DeviceInfo.Label -eq $strBootHDiskDeviceName}).Key

bootable Disk BootOption device, for use in setting BootOrder (the

corresponding VirtualDisk device is bootable, assumed)
$oBootableHDisk = New-Object -TypeName
VMware.Vim.VirtualMachineBootOptionsBootableDiskDevice -Property
@{"DeviceKey" = $intHDiskDeviceKey}

bootable CDROM device (per the docs, the first CDROM with bootable media

found is used)
$oBootableCDRom = New-Object -Type
VMware.Vim.VirtualMachineBootOptionsBootableCdromDevice

create the VirtualMachineConfigSpec with which to change the VM's boot

order
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{
"BootOptions" = New-Object VMware.Vim.VirtualMachineBootOptions
-Property @{
## set the boot order in the spec as desired
BootOrder = $oBootableNIC, $oBootableHDisk
} ## end new-object
} ## end new-object

reconfig the VM to use the spec with the new BootOrder

$viewVM.ReconfigVM_Task($spec)

··· On Saturday, March 1, 2014 7:06:09 AM UTC-8, Jelle B wrote: > > In essence I am looking for a way to control the boot order of a VM. > Currently a standard deployed VM always defaults to HDD first before > Network , which is fine in normal operation, but is there a way to > manipulate the boot order when the host is in build status to first try the > network interfaces then CD then HDD ? > > Using this as reference I would guess fog would be capable but not enough > in the content of it. > > http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2011654 > > And yes I do realize I could just change the boot order of the VM but it > defeats the reason I am asking it. I got the idea after seeing the lab0 > post , I need to give customers access to deploying hosts but I do not want > to destroy the previous host and make a new one , but rather just re > provision the existing one , less hassle on the MAC address security we > run... > > But something like what lab0 is would be great simple authentication > surface before it and our customers are good to go :P > >

We can already do this for physical hosts and it's on the making for
Openstack, EC2 (waiting on Fog atm).

There is a very similar issue opened in the bug tracker already:
Feature #4317: Build button - Vmware provisioning - single click rebuild - Foreman please add your comments and
hopefully this'll get done quickly, it's an important issue in my opinion.

··· On Mon, Mar 3, 2014 at 11:46 AM, Dominic Cleal wrote:

On 01/03/14 15:06, Jelle B wrote:

In essence I am looking for a way to control the boot order of a VM.
Currently a standard deployed VM always defaults to HDD first before
Network , which is fine in normal operation, but is there a way to
manipulate the boot order when the host is in build status to first try
the network interfaces then CD then HDD ?

Using this as reference I would guess fog would be capable but not
enough in the content of it.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2011654

And yes I do realize I could just change the boot order of the VM but it
defeats the reason I am asking it. I got the idea after seeing the lab0
post , I need to give customers access to deploying hosts but I do not
want to destroy the previous host and make a new one , but rather just
re provision the existing one , less hassle on the MAC address security
we run…

Definitely, I’d regard that as a bug. I remember libvirt and oVirt
create VMs with network first, so any VMware hosts we create should
follow the same pattern to enable re-deployment.


Dominic Cleal
Red Hat Engineering


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


Daniel Lobato

@elobatoss
blog.daniellobato.me
daniellobato.me

GPG: http://keys.gnupg.net/pks/lookup?op=get&search=0x7A92D6DD38D6DE30