knife-vsphere
knife-vsphere copied to clipboard
vm vmdk add fails adding the 2nd extra disk on a vSAN datastore
Versions:
- Version of knife-vsphere: 2.0.0
- Version of chef:12.7.2
Platform Details
- Version of vSphere: 6.5.0 Build 5318154
- Version of ESXi: 6.5.0, 5310538
Scenario:
Adding more than 1 extra disk to an existing VM. That only happens when the VM is on a vSAN datastore.
Please paste the command and output (run with -VV). Don't forget to X out any passwords or sensitive information:
I believe I understand the problem and implemented a quick fix:
/usr/local/rvm/gems/ruby-2.4.1/wrappers/knife vsphere vm vmdk add syd01is-inf-ldap02.adm01.com 5 -c conf/knife_vm_conf_syd01np.rb
Datastore: vsanDatastore (137.20 TB(150851775627264) / 152.82 TB) Choosing: vsanDatastore Next vmdk name is => [vsanDatastore] syd01is-inf-ldap02.adm01.com/syd01is-inf-ldap02.adm01.com_1.vmdk Creating VMDK Capacity: 5 GB Disk: [vsanDatastore] syd01is-inf-ldap02.adm01.com/syd01is-inf-ldap02.adm01.com_1.vmdk Attaching VMDK to syd01is-inf-ldap02.adm01.com using SCSI controller 0 using SCSI ID 1 [root@slb01 deploy]#
/usr/local/rvm/gems/ruby-2.4.1/wrappers/knife vsphere vm vmdk add syd01is-inf-ldap02.adm01.com 5 -c conf/knife_vm_conf_syd01np.rb
Datastore: vsanDatastore (137.20 TB(150851746267136) / 152.82 TB) Choosing: vsanDatastore Next vmdk name is => [vsanDatastore] syd01is-inf-ldap02.adm01.com/syd01is-inf-ldap02.adm01.com_1.vmdk Attaching VMDK to syd01is-inf-ldap02.adm01.com using SCSI controller 0 using SCSI ID 2 ERROR: RbVmomi::Fault: GenericVmConfigFault: Failed to add disk 'scsi0:2'.
Expected Result:
I want the 2 vmdk disks added to the VM
Actual Result:
Failure to add the 2nd disk
when trying to add the 2nd extra vmdk disk to an existing VM, it looks like it can't parse the existing filenames that belong to the VM:
Adding first additional disk works (first additional disk is always VMNAME + "_1":
/usr/local/rvm/gems/ruby-2.4.1/wrappers/knife vsphere vm vmdk add syd01is-inf-ldap02.adm01.com 5 -c conf/knife_vm_conf_syd01np.rb
Datastore: vsanDatastore (137.20 TB(150851775627264) / 152.82 TB) Choosing: vsanDatastore Next vmdk name is => [vsanDatastore] syd01is-inf-ldap02.adm01.com/syd01is-inf-ldap02.adm01.com_1.vmdk Creating VMDK Capacity: 5 GB Disk: [vsanDatastore] syd01is-inf-ldap02.adm01.com/syd01is-inf-ldap02.adm01.com_1.vmdk Attaching VMDK to syd01is-inf-ldap02.adm01.com using SCSI controller 0 using SCSI ID 1 [root@slb01 deploy]#
Adding the second additional disk fails (VMNAME + "_2", it looks like it tries to add again VMNAME + "_1":
/usr/local/rvm/gems/ruby-2.4.1/wrappers/knife vsphere vm vmdk add syd01is-inf-ldap02.adm01.com 5 -c conf/knife_vm_conf_syd01np.rb
Datastore: vsanDatastore (137.20 TB(150851746267136) / 152.82 TB) Choosing: vsanDatastore Next vmdk name is => [vsanDatastore] syd01is-inf-ldap02.adm01.com/syd01is-inf-ldap02.adm01.com_1.vmdk Attaching VMDK to syd01is-inf-ldap02.adm01.com using SCSI controller 0 using SCSI ID 2 ERROR: RbVmomi::Fault: GenericVmConfigFault: Failed to add disk 'scsi0:2'.
I did a quick fix, that may not be completely consistent (file /usr/local/rvm/gems/ruby-2.4.1/gems/knife-vsphere-2.0.0/lib/chef/knife/vsphere_vm_vmdk_add.rb:
file: vsphere_vm_vmdk_add.rb
82 vm_files.keys.each do |vmFile|
83 vm_files[vmFile]['layoutEx.file'].each do |layout|
84 # if layout.name.match(/^\[#{vmdk_datastore.name}\] #{vmname}\/#{vmname}_([0-9]+).vmdk/)
85 if layout.name.match(/\/#{vmname}_([0-9]+).vmdk/)
86 num = Regexp.last_match(1)
I commented out the part where it parses the full file name, which includes the datastore name. I replaced it with a line of code that only parses the name of the file (not including the datastore name and directory).
I put some temporary outputs of layout.name so I realized instead of showing the VMname as the directory name, it displays something like a VM ID, when it is a vSAn datastore, which causes the failure during the parsing.
Parsing file [vsanDatastore] 5ebe6359-f005-b01b-1eff-0cc47a390c90/syn01is-inf-vspace01.adm01.com.vmx Parsing file [vsanDatastore] 5ebe6359-f005-b01b-1eff-0cc47a390c90/syn01is-inf-vspace01.adm01.com.nvram Parsing file [vsanDatastore] 5ebe6359-f005-b01b-1eff-0cc47a390c90/syn01is-inf-vspace01.adm01.com.vmsd Parsing file [vsanDatastore] 5ebe6359-f005-b01b-1eff-0cc47a390c90/syn01is-inf-vspace01.adm01.com.vmdk
Hey, thanks for the detailed output. I don't have vsan access where I am. Let me try a couple of things out and see if I can come to the same understanding as you of the problem.