Open habakook opened 8 years ago
Hi, @habakook did you ever get a solution for your issue?
I am having this issue as well when creating a NIC for a Windows machine. When trying to assign a static ip, a NIC gets created but the static ip, netmask and gateway details I provide get ignored by vcenter. Any idea why static ip is not working?
Thanks!
Hi guys ,i am struggling to fix that ip address issue ,any updates on the above :)
@prziborowski any fix on this?
I haven't been able to hit this NotSupported exception. I hit a flurry of other issues, such as the dnsServerList should be IP addresses and not domain names and the hostName uses the VM name and depending on that name, it might not be valid as a hostName. (example case it is valid though). [And if the VM doesn't have tools installed, then it will get a different/confusing fault about being an UncustomizableGuest].
I didn't look into the Windows side since no sample is provided for that. When I tried the script on an ubuntu VM, after updating the dnsServerList and hostname, it worked fine and was configured as expected.
I found the solution. But I don't have it available now, because I left that company 8 months ago (they have the source code). Sorry, can't help you, but can assure you that it is doable.
vim.vm.customization.LinuxPrep()
vim.vm.customization.Sysprep()
and make sure you have the sysprep files. Have a look at this link https://communities.vmware.com/message/934733#934733 @uddyan92 @prziborowski @rreubenur I am also getting similar issue. I am doing it by connecting directly to an ESXi host instead of vcenter server. Do you think that may be the issue??
@shubham893 The guest customization is handled through vCenter Server, so if you try it directly to the ESXi host, I believe you'd get an error.
@prziborowski due to some issues i can not get vCenter server credentials, is there any other way to provide static ip address to vm? I am deploying vm by deploy_ovf.py file. But all deployed vm's have same ip address. So, is there any way to provide those vm different ip address by python script?
this is my solution,i hope it can help
def customeWin(customizationSpec, customeInfo):
guest_map = vim.vm.customization.AdapterMapping()
guest_map.adapter = vim.vm.customization.IPSettings()
guest_map.adapter.ip = vim.vm.customization.FixedIp()
guest_map.adapter.ip.ipAddress = customeInfo.ip # hard coded for now
guest_map.adapter.subnetMask = customeInfo.subnetMask # ditto
guest_map.adapter.gateway = customeInfo.gateway # ditto
guest_map.adapter.dnsServerList = customeInfo.dnsServerList # ditto
# DNS settings
globalip = vim.vm.customization.GlobalIPSettings()
globalip.dnsServerList = customeInfo.dnsServerList
# Hostname settings
ident = vim.vm.customization.Sysprep()
ident.guiUnattended = vim.vm.customization.GuiUnattended()
ident.guiUnattended.autoLogon = True # the machine does not auto-logon
ident.guiUnattended.password = vim.vm.customization.Password()
ident.guiUnattended.password.value = 'test@1234'
ident.guiUnattended.password.plainText = True # the password is not encrypted
ident.guiUnattended.timeZone = 210
ident.guiUnattended.autoLogonCount = 1
ident.userData = vim.vm.customization.UserData()
ident.userData.fullName = "My Name"
ident.userData.orgName = "Company"
ident.userData.computerName = vim.vm.customization.FixedName()
ident.userData.computerName.name = 'vmtest'
ident.userData.productId = ''
# ident.userData.productId = '489J6-VHDMP-X63PK-3K798-CPX3Y'
# join domain
ident.identification = vim.vm.customization.Identification()
# ident.identification.joinWorkgroup = ''
# ident.identification.joinDomain = ''
# ident.identification.domainAdmin = ''
# ident.identification.domainAdminPassword = vim.vm.customization.Password()
# ident.identification.domainAdminPassword.value=''
# ident.identification.domainAdminPassword.plainText = True
#
# create spec to change host IP address
# customspec = vim.vm.customization.Specification()
customizationSpec.nicSettingMap = [guest_map]
customizationSpec.globalIPSettings = globalip
customizationSpec.identity = ident
In addition to the above post, static ip assignment for windows works provided VMware Tools is running. Also at first the windows vm might get some random dhcp ip when powered ON and then eventually when sysprep runs, you should see the static IP on the NICs.
@shubham893 Hey did you find a work around for this? Even I am connecting directly to an ESXi
I haven't been able to hit this NotSupported exception. I hit a flurry of other issues, such as the dnsServerList should be IP addresses and not domain names and the hostName uses the VM name and depending on that name, it might not be valid as a hostName. (example case it is valid though). [And if the VM doesn't have tools installed, then it will get a different/confusing fault about being an UncustomizableGuest].
I didn't look into the Windows side since no sample is provided for that. When I tried the script on an ubuntu VM, after updating the dnsServerList and hostname, it worked fine and was configured as expected.
I use this way in Centos 7.x,it always except not valid param spec.identity.hostName.Did you solved it? Thanks
I have a VM with no NIC and it is powered off. When I execute the following code:
NIC gets created but on assigning IP it gets an error:
What am I missing? What am I doing wrong? How do I create a new NIC with static IP assigned?
Would much appreciate any help! @jm66 @Ctesias @rreubenur @thedeco @tianhao64 @snobear @ciorceri @sitle @bsherman @czee