New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how can i use customize configuration when cloneing vm? #616
Comments
I'd also like to know how I cloud set the ip address when cloning |
it looks like you need to create a customization spec in vcenter and use the name of that created spec for reference. however this does not seem very dynamic, how would you chnage these settings at clone time? |
When you specify -customization=xxx govc appears to retrieve the customisation from vcenter and injects it into the cloneSpec that is passed to the cmd.VirtualMachine.Clone I patched the vm.clone command to allow for providing a fixed IP address, netmask and gateway on the command line which modifies the customisation object after it has been retrieved from vcenter, before cmd.VirtualMachine.Clone is called. Obviously the image you are cloning has to support using the customisation spec, and to be perfectly honest, the code is pretty ugly, has no tests, and is probably not very go-like, but it does what I needed it to do. Please let me know if you are interested in it. |
@mgherman could you please provide this code? |
+1 @mgherman please share :) |
So, this is the diff. You need to have the named customisation already provisioned within vmware, and then provide any / all of the overrides: custip, custgw and custmask which should then override the values in the customisation. Im sure there is a better way of doing this, but this was sufficient to get it working as a PoC in our environment. The cmdline flags i was using was something along the lines of:
|
build.sh is for creating releases. Just use 'go build ./govc' |
Can we create customSpec using govmomi ? I tried using the method, CreateCustomizationSpec in below file, but that gives error.
Error: The property identity has some dynamic data. How can we set the dynamic data ? |
any chance that @mgherman's code could be added to the cli? |
Yes, can you open a PR @mgherman ? I think it'd be fine to name those flags with the Can also avoid reflection: if len(customSpec.NicSettingMap) > 0 {
nic := customSpec.NicSettingMap[0].Adapter
if ip, ok := nic.Ip.(*types.CustomizationFixedIp); ok {
ip.IpAddress = "..."
}
nic.SubnetMask = "..."
nic.Gateway = []string{"..."}
} |
Maybe we should consider a new 'vm.customize' command rather than putting more into the clone command? Looks like it's possible to do so after cloning with the CustomizeVm_Task method.
|
It it resolved now ?? |
@mgherman did it |
Why was the issue closed? There is no PR yet from gherman's code, this (useful) feature has not been integrated into the govc cli? |
+1 I'd also like to customise |
+1 I'd also like to customise -ip, netmask, gateway, dns, disk, -net etc.. |
+1 it is a feature that is lacking |
+1 for this feature @mgherman tried your patch to clone.go and build the govc, running govc got error $./govc vm.clone -vm testvm -customization="test-spec" -custip="1.1.1.1" new-testvm ./govc: flag provided but not defined: -custip Am I missing something |
+1 for this feature.
|
+1 for this feature. |
+1 for this feature. I try @mgherman patch to clone.go and build govc success. When i run Anyone have the same problem? |
@pytimer i haven't tested the patch but if you're trying to deploy a Linux guest please be remember that...
(For reference: https://docs.ansible.com/ansible/latest/modules/vmware_guest_module.html#vmware-guest-module) |
@angystardust Thanks for you reply. I follow your said and install Perl package, customization spec is OK. Thanks. :-) |
@pytimer you were able to successfully user the patch? The ip was set? After applying the patch I'm seeing a After some debugging it appears that this is because If you were able to successfully use the patch though this gives me hope |
@dumez-k I update the latest version of govc clone code, you can see this pr: Add customSpec network configuration for govc vm.clone in my fork repository. it works ok for me. |
Hello, also a question about cloning VMs. Sometimes there are just about 10 lines - that is fine.
|
Has there been any update on this? It would be a huge help to have this feature. |
There is recent discussion here: #984 (comment) Still no development yet, but hoping to make it happen for the next release in the next few weeks. |
Fixes vmware#616 Fixes vmware#984 Closes vmware#1576
hi,
how can i use customize configuration file when cloneing vm? i want to set the hostname and ip use customize configuration file.
use "-customization=" ?
The text was updated successfully, but these errors were encountered: