josenk / vagrant-vmware-esxi

A Vagrant plugin that adds a vmware ESXi provider support.
GNU General Public License v3.0
414 stars 109 forks source link

Wrong URL to the template VM #58

Closed saunuolis96 closed 6 years ago

saunuolis96 commented 6 years ago

I was following this page to run clones https://github.com/josenk/vagrant-vmware-esxi/wiki/How-to-clone_from_vm

#

Clone_from_vm test

# Vagrant.configure("2") do |config| config.vm.box = 'esxi_clone/dummy'

config.vm.synced_folder('.', '/vagrant', type: 'nfs', disabled: true) config.vm.synced_folder('.', '/Vagrantfiles', type: 'rsync', disabled: true)

config.vm.provider :vmware_esxi do |esxi| esxi.esxi_hostname = "XXX.XX.XX.XXX" esxi.esxi_username = "XXXXXX" esxi.esxi_password = 'XXXXXXXX' esxi.clone_from_vm = 'Templates/win2012R2_template' esxi.esxi_virtual_network = ["VM Network"] esxi.esxi_resource_pool = "/" esxi.local_allow_overwrite = 'True' end end

I get Error: Locator does not refer to an object.

And it is missing "/" and it is path value does not look correct: "ha-datacenter/host/HOSTNAME./Resources/"
I tried to change these values by providing full path to VM without luck: esxi.clone_from_vm esxi.esxi_resource_pool

Actual where the VM is stored is /vmfs/volumes/datastore1/win2012R2

vagrant --version: 2.1.4 vagrant-vmware-esxi (2.4.1, global)

Please help. Thanks, vagrant_error

Vaidas

josenk commented 6 years ago

The error is telling you that it cannot find the source.

According to your Vagrant file.

The Source: (The VM you are cloning) Templates is the name of a Resource Pool. win2012R2_template is the name of you guestVM.

Where did you store win2012R2_template? OVFtool doesn't care where on the filesystem it's stored. You can see that in vShpere.

saunuolis96 commented 6 years ago

I created Resource pool "Templates" and my Source VM Vagrant File is this:

config.vm.box = "win2012r2esxi2" config.vm.define "windows_server_2012_vmware_updated" config.vm.synced_folder('.', '/vagrant', type: 'nfs', disabled: true)

config.vm.provider :vmware_esxi do |esxi| esxi.esxi_hostname = 'XXXXXXXXX' esxi.esxi_username = 'XXXXX' esxi.esxi_password = 'XXXXXXX'

esxi.esxi_resource_pool = '/Templates'
esxi.guest_name = "win2012R2_template"
esxi.local_allow_overwrite = 'True'

end end

And actual Source VM location on ESX is :
/vmfs/volumes/datastore1/win2012R2-template

I do not get how OVF tool gets that path : "ha-datacenter/host/....." and how to change it.

josenk commented 6 years ago

/vmfs/volumes/datastore1/win2012R2-template <<--- This doesn't matter.

Open vShere. Verify that win2012R2-template exists in "Templates' Resource pool! If you don't see it there, it will NOT work. It must exist and be powered off.

Enable Debug, you'll get the ovftool full command line. Run ovftool it manually. If you cannot get it working manually, it will not work via the plugin.

https://github.com/josenk/vagrant-vmware-esxi/wiki/Debugging-the-plugin

the message "ha-datacenter/host/....." is ovftool's message to say its searching the infra. vi:// stands for Virtual Infrastructure and can be used for vSphere and vCenter... That is mis-leading you to the problem.

saunuolis96 commented 6 years ago

Thanks for quick reply!

win2012R2 is not in "Templates" resource pool. When I vagrant UP initially I can see VM appears in "Templates" resource pool but when VM changes state to "running" it just dissapears from Templates resource pool and looks like any other VM and resource pool becomes empty.

Then I do "vagrant halt" but it does not change anything.

Will run in debug mode to check logs.

saunuolis96 commented 6 years ago

Deploying Source VM: PS F:\Vagrant_box\esxi_test2_multi> vagrant up

RUBY_PLATFORM: x64-mingw32 Testing esxi connectivity ==> windows_server_2012_vmware_updated: --- ESXi version : VMware ESXi 6.0.0 build-3620759 Bringing machine 'windows_server_2012_vmware_updated' up with 'vmware_esxi' provider... ==> windows_server_2012_vmware_updated: Virtual Machine will be built. VMware ovftool 4.3.0 (build-7948156) ==> windows_server_2012_vmware_updated: --- Avail DS vols : ["datastore1"] ==> windows_server_2012_vmware_updated: --- WARNING : esxi_disk_store not set, using "--- Least Used ---" ==> windows_server_2012_vmware_updated: --- Avail Networks : ["VM Network", "Management Network", "VM Network 2"] ==> windows_server_2012_vmware_updated: --- WARNING : esxi_virtual_network[0] not set, using VM Network ==> windows_server_2012_vmware_updated: --- --- ESXi Summary --- ==> windows_server_2012_vmware_updated: --- ESXi host : XXX.XX.XX.XXX ==> windows_server_2012_vmware_updated: --- Virtual Network : ["VM Network"] ==> windows_server_2012_vmware_updated: --- Disk Store : datastore1 ==> windows_server_2012_vmware_updated: --- Resource Pool : /Templates ==> windows_server_2012_vmware_updated: --- --- Guest Summary --- ==> windows_server_2012_vmware_updated: --- VM Name : win2012R2-template ==> windows_server_2012_vmware_updated: --- Box : win2012r2esxi2 ==> windows_server_2012_vmware_updated: --- Box Ver : 0 ==> windows_server_2012_vmware_updated: --- Memsize (MB) : 2048 ==> windows_server_2012_vmware_updated: --- CPUS : 2 ==> windows_server_2012_vmware_updated: --- Guest OS type : windows7server64guest ==> windows_server_2012_vmware_updated: --- Allow Overwrite : True ==> windows_server_2012_vmware_updated: --- --- Guest Build --- ovftool command: ovftool --noSSLVerify --overwrite --powerOffTarget --acceptAllEulas -dm=thin -ds="datastore1" --name="win2012R2-template" "F:/v agrant_real/boxes/win2012R2esxi2/0/vmware_desktop/ZZZZ_win2012R2-template.vmx" vi://ESX_USERNAME:**@XXX.XX.XX.XXX/Templates Opening VMX source: F:/vagrant_real/boxes/win2012R2esxi2/0/vmware_desktop/ZZZZ_win2012R2-template.vmx Opening VI target: vi://ESX_USERNAME@XXX.XX.XX.XXX:443/Templates Deploying to VI: vi://ESX_USERNAME@XXX.XX.XX.XXX:443/Templates Transfer Completed Completed successfully ==> windows_server_2012_vmware_updated: --- Keeping file : F:/vagrant_real/boxes/win2012R2esxi2/0/vmware_desktop/ZZZZ_win2012R2-template.vmx ==> windows_server_2012_vmware_updated: --- VMID : 165 orig vmx: .encoding = "UTF-8" config.version = "8" virtualHW.version = "9" pciBridge0.present = "TRUE" svga.present = "TRUE" pciBridge4.present = "TRUE" pciBridge4.virtualDev = "pcieESX_USERNAMEPort" pciBridge4.functions = "8" pciBridge5.present = "TRUE" pciBridge5.virtualDev = "pcieESX_USERNAMEPort" pciBridge5.functions = "8" pciBridge6.present = "TRUE" pciBridge6.virtualDev = "pcieESX_USERNAMEPort" pciBridge6.functions = "8" pciBridge7.present = "TRUE" pciBridge7.virtualDev = "pcieESX_USERNAMEPort" pciBridge7.functions = "8" vmci0.present = "TRUE" hpet0.present = "TRUE" floppy0.present = "FALSE" svga.vramSize = "8388608" numvcpus = "2" memSize = "2048" powerType.suspend = "soft" tools.upgrade.policy = "upgradeAtPowerCycle" scsi0.virtualDev = "lsisas1068" scsi0.present = "TRUE" ide1:0.startConnected = "FALSE" ide1:0.allowGuestConnectionControl = "FALSE" ide1:0.deviceType = "atapi-cdrom" ide1:0.fileName = "CD/DVD drive 0" ide1:0.present = "TRUE" scsi0:0.deviceType = "scsi-hardDisk" scsi0:0.fileName = "win2012R2-template.vmdk" scsi0:0.present = "TRUE" displayName = "win2012R2-template" guestOS = "other" toolScripts.afterPowerOn = "TRUE" toolScripts.afterResume = "TRUE" toolScripts.beforeSuspend = "TRUE" toolScripts.beforePowerOff = "TRUE" tools.syncTime = "TRUE" uuid.bios = "65 54 d5 f6 ...." uuid.location = "as 5a d0 ....." vc.uuid = "30 2b....." nvram = "packer-vmware-iso.nvram" virtualhw.productcompatibility = "hosted"

new vmx: .encoding = "UTF-8" config.version = "8" virtualHW.version = "9" pciBridge0.present = "TRUE" svga.present = "TRUE" pciBridge4.present = "TRUE" pciBridge4.virtualDev = "pcieESX_USERNAMEPort" pciBridge4.functions = "8" pciBridge5.present = "TRUE" pciBridge5.virtualDev = "pcieESX_USERNAMEPort" pciBridge5.functions = "8" pciBridge6.present = "TRUE" pciBridge6.virtualDev = "pcieESX_USERNAMEPort" pciBridge6.functions = "8" pciBridge7.present = "TRUE" pciBridge7.virtualDev = "pcieESX_USERNAMEPort" pciBridge7.functions = "8" vmci0.present = "TRUE" hpet0.present = "TRUE" floppy0.present = "FALSE" svga.vramSize = "8388608" numvcpus = "2" memsize = "2048" powerType.suspend = "soft" tools.upgrade.policy = "upgradeAtPowerCycle" scsi0.virtualDev = "lsisas1068" scsi0.present = "TRUE" ide1:0.startConnected = "FALSE" ide1:0.allowGuestConnectionControl = "FALSE" ide1:0.deviceType = "atapi-cdrom" ide1:0.fileName = "CD/DVD drive 0" ide1:0.present = "TRUE" scsi0:0.deviceType = "scsi-hardDisk" scsi0:0.fileName = "win2012R2-template.vmdk" scsi0:0.present = "TRUE" displayName = "win2012R2-template" guestOS = "windows7server64guest" toolScripts.afterPowerOn = "TRUE" toolScripts.afterResume = "TRUE" toolScripts.beforeSuspend = "TRUE" toolScripts.beforePowerOff = "TRUE" tools.syncTime = "TRUE" uuid.bios = " e0 40 ...." uuid.location = "93 4a ........." vc.uuid = "30 df ...." nvram = "packer-vmware-iso.nvram" virtualhw.productcompatibility = "hosted" ethernet0.networkName = "VM Network" ethernet0.virtualDev = "e1000" ethernet0.present = "TRUE" ethernet0.addressType = "generated"

==> windows_server_2012_vmware_updated: --- VM has been Powered On... ip1 (pri): ip2 (alt): ==> windows_server_2012_vmware_updated: --- Waiting for state "running" ip1 (pri): ip2 (alt): ip1 (pri): ip2 (alt): ip1 (pri): ip2 (alt): ip1 (pri): ip2 (alt): ip1 (pri): ip2 (alt): ip1 (pri): ip2 (alt): ip1 (pri): ip2 (alt): ip1 (pri): ip2 (alt): ip1 (pri): ip2 (alt): ip1 (pri): ip2 (alt): Get IP alt method, uptime: 129 ip1 (pri): ip2 (alt):XX.XX.XX.XX Using cached guest IP address Get local IP address for NFS. (pri) nfs_host_ip: XXX.XX.XX.XX ==> windows_server_2012_vmware_updated: --- Success, state is now "running" num adapters: 1, vm.network.count: 0 Get IP alt method, uptime: 129 ip1 (pri): ip2 (alt):XX.XX.XX.XX Using cached guest IP address Get IP alt method, uptime: 129 ip1 (pri): ip2 (alt):XX.XX.XX.XX

HERE I CAN SEE THAT BOX IS UNDER TEMPLATES Resource Pool

PS F:\Vagrant_box\esxi_test2_multi> vagrant halt

RUBY_PLATFORM: x64-mingw32 Testing esxi connectivity ==> windows_server_2012_vmware_updated: --- ESXi version : VMware ESXi 6.0.0 build-3620759 Get IP alt method, uptime: 249 ip1 (pri): ip2 (alt):XX.XX.XX.XX Using cached guest IP address Get local IP address for NFS. (pri) nfs_host_ip: XXX.XX.XXX.X Using cached guest IP address ==> windows_server_2012_vmware_updated: --- Starting graceful shutdown... Get IP alt method, uptime: 269 ip1 (pri): ip2 (alt): ==> windows_server_2012_vmware_updated: --- Waiting for state "powered_off" ==> windows_server_2012_vmware_updated: --- Success, state is now "powered_off"

Here ESX Source VM looks like one of other VM on ESX and Resource Pool is empty

====================================================================================

=========================================================================================

Trying to clone VM: PS F:\Vagrant_box\esxi_test2_multi\test1> vagrant up

RUBY_PLATFORM: x64-mingw32 Testing esxi connectivity ==> default: --- ESXi version : VMware ESXi 6.0.0 build-3620759 Bringing machine 'default' up with 'vmware_esxi' provider... ==> default: Virtual Machine will be built. VMware ovftool 4.3.0 (build-7948156) ovftool command: ovftool --noSSLVerify --overwrite --X:useMacNaming=false --powerOffTarget --noDisks --targetType=vmx --X:logLevel=info --X:logFil e=C:/Users/vmeistin/AppData/Local/Temp/d20180924-59356-bixhro/ovftool.log --acceptAllEulas vi://ESX_USERNAME:**@XXX.XX.XX.XXX/Templates/win2012R2templ ate C:/Users/vmeistin/AppData/Local/Temp/d20180924-59356-bixhro Opening VI source: vi://ESX_USERNAME@XXX.XX.XX.XXX:443/Templates/win2012R2template Error: Locator does not refer to an object: vi://ESX_USERNAME@XXX.XX.XX.XXX:443ha-datacenter/host/HOSTNAME./Resources/Templates/win2012R2template Completed with errors There was an OVF Tool error. Unable to access Templates/win2012R2template PS F:\Vagrant_box\esxi_test2_multi\test1>

josenk commented 6 years ago

Thanks for the logs.

It shows you create the guestVM named "win2012R2-template". Then, you try to clone it using the name "win2012R2template". (missing dash '-')

Are they identical in your Vagrantfiles?

saunuolis96 commented 6 years ago

So initially the name in my both files was with underscore '_', but when in running in debug mode I saw dash '-' in the name. So I updated my both files and removed underscore from name in case some code is not happy with underscores. Then redeployed the source VM with new name and tried to make a clone.

But still does not work.

josenk commented 6 years ago

Try running the ovftool command manually. If it doesn't work, you cannot expect it to work within this plugin.

BTW: Be VERY careful with your hostnames. (Vagrant uses the guestname as the hostname). The underscore '_' is NOT allowed and you are mixing upper and lower cases.

https://en.wikipedia.org/wiki/Hostname "The Internet standards (Requests for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the minus sign ('-')."

saunuolis96 commented 6 years ago

If I try the same OVFtool command I see when running plugin in debug mode I get the same output.

I read ovftool help:

where:

searchTerm: Is a specification of a resource pool, host system, or cluster (see syntax for source locator). When connected directly to an ESX host, this must be left empty.

I think I can not construct a proper query . I tried a few without luck.

josenk commented 6 years ago

Have you corrected your GuestVM names? They are not consistent.

Try rebooting your ESXi host.

If you cannot get ovftool working, you cannot expect it work within the plugin. You may want to open a support ticket with VMware.

josenk commented 6 years ago

abandoned