[chef-dev] Re: Re: Re: [chef] Re: Re: Fwd: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re:


Chronological Thread 
  • From: Anna Redding < >
  • To: "< >" < >
  • Cc: " " < >,
  • Subject: [chef-dev] Re: Re: Re: [chef] Re: Re: Fwd: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re:
  • Date: Wed, 9 Apr 2014 15:05:33 -0500

Anthony
Thank you for the examples and feedback. 

Here are some questions I have:
1a.  What version of  the following are you using? 
     - vCenter / ESXi
     - Chef server ;  Chef client
     - Ruby

1b.  Are you authorized to run commands on the ESXi hosts themselves? 
(We have to enable ssh to login to esxi host and more importantly, we do not have authorization to run anything on the host itself...this vmkfstools and knife-wax were not viable options for us to use). 

2.  Please confirm that when you provide a response to the $request_vm_name variable, you are providing a value that contains a '-' such as:
      abc1annavm-devenv
(Note: I intentionally made this longer than14 characters)

When I used names such as abc1annavm-devenv, my command
fails with 'VM not found' error. I tried everything under the sun and finally removed the '-' and it worked.  There should be an email from me to the community with more detail that I sent back when I was struggling through that issue. 

Regarding the use of VM name longer than 14 characters, the only time I have a problem with this is when I create the additional VMDKs. When I used abc1annavm-devenv, the 'knife vsphere vm vmdk add abc1annavm-devenv  2  --folder VMbuildout ...' 
fails with 'VM not found'.  Again, I trod everything but it would not work until I
changed it to 'abc1annavmdev'. 

And RE: your #4 - yes, I cannot use subfolders either, has to be at top level to work. 

NOTE:  I'm thinking the problem has to do with the actual tie between vcenter and knife-vsphere.  The problem we are seeing is not with the actual vm 'hostname' having a  '-'  or being more than 14 characters. It is the name vcenter uses for the folder construct. I find it quite suspect that all three issues I have are related to the folder structure as vcenter sees it but only when knife-vsphere tries to 'locate' something ...
a - knife-vsphere cannot locate a VM who's VM folder name on the datastore has a '-' in the name
b - knife-vsphere cannot locate a VM who's VM folder name on the datastore has more than 14 characters in the name 
c - knife-vsphere cannot locate a VM datastore if it is not located at the top level of the vcenter datacenter construct.

But yet, knife-sphere can bootstrap a VM and chef-client can process a runlist on a VM with a hostname that  has a '-' and more than 14 characters. 


3.  You are using a Template that already has additional vmdk's allocated. 
Once this is established, and you use knife-vsphere to add another VMDK, are you:
     - allocating it on the same datastore as the VMs primary vmdk (where OS exists) or any other datastore that already has a folder created with the folder name equal to the VM name?
 
When I execute the "knife vsphere vm vmdk add abc1annavmdev  2 ..." and point to the same datastore as the VMs primary vmdk, it fails saying  abc1annavmdev already exists. 

When I execute command and point to a different datastore so that it is the 'first' piece associated with abc1annavmdev, it creates the vmdk but fails to attach to the VM spitting out a deviceInfo error. 

When I execute command and point to a same datastore that i just created a vmdk on, it fails saying  abc1annavmdev already exists. 

===

I think it would be a good test for me to change my template so it has a secondary vmdk created/attached and then run my script to clone it and  see if that makes any difference to the issues I have encountered.  That seems to be the only difference between your scenario and mine shy of potential software versions. 

Again, thanks for giving me the details. Let me know the responses to my questions and I will go test the process with a second vmdk already attached to my  template and then try to run my script to clone and add VMDKs.  

Thanks!!!
Anna


Sent from my iPhone
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.



Archive powered by MHonArc 2.6.16.

§