- From: <
>
- To:
- Subject: [chef-dev] Re: Re: [chef] Re: Re: Fwd: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re:
- Date: Wed, 9 Apr 2014 11:55:36 -0700 (PDT)
Hi Anna,
I’ve built a Portal for requesting VM’s by users. Basically, from a web
frontend, they choose what type of VM build to build (rhel ver, cpu, memory,
etc). This generates an approval email, where you click a link to build the
VM. The link brings up a page where you can select “Build VM”. The php
code is executing the chef vsphere plugin to clone a template to create the
VM.
It then runs configuration scripts on the VM, and 5 minutes later, you have a
working VM.
As far as the problems you have encountered:
1) I’m able to clone a VM using “-“ in the name. Here’s a snippet
from php VM clone:
$DATASTORE = chop(shell_exec("/usr/bin/knife vsphere datastore maxfree --regex
$resource_pool --vsuser $vuser --vspass $vspass"));
$BUILD_VM = "/usr/bin/knife vsphere vm clone $request_vm_name --vsuser $vuser
--vspass $vspass --resource-pool $resource_pool --datastore $DATASTORE
--folder
Templates --template $request_os --dest-folder '$FOLDER' --start --ccpu
$request_vm_cpus --cram $request_vm_memory --cspec 'DHCP v1' --format text
--verbose";
exec("$BUILD_VM",$retval,$ret);
2) I’m using VM names’ longer than 14 characters
3) In my template, it already has 2 VMDK’s, one for the OS, and another
for user VG. When I tried to use the knife vsphere esx plugin to clone a VM
it
wouldn’t add the second VMDK. Since using the vsphere plugin, it works fine.
4) If I try to add another VMDK, it works for top level folder, but not
sub-folders. Looking at the code.
def traverse_folders_for_vm(folder, vmname)
# not sure why @vm is necessary, but it returns class Array
# instead of class VirtualMachine without it... ugh
@vm = nil
folders = find_all_in_folder(folder, RbVmomi::VIM::Folder) <<<
folders
is empty when you used a sub folder
folders.each do |child|
traverse_folders_for_vm(child, vmname)
vms = find_all_in_folder(folder, RbVmomi::VIM::VirtualMachine)
vms.each do |vm|
if vm.name == vmname
5) Related to #4
Once it’s setup, it works great.
- [chef-dev] Re: Re: [chef] Re: Re: Fwd: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re:, anthony_cicone, 04/09/2014
Archive powered by MHonArc 2.6.16.