how to customization network when I create a new windows machine by clone from template.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 763
- PR merge metrics
- No merged PRs in 30d
Description
when i crate vm by templeate, if templete is Linux, the network can work, but windows templeate can't work . how to customization network when I create a new windows machine by clone from template.
below is my codes:
`
def get_customspec(self, vm_ip=None, vm_subnetmask=None, vm_gateway=None, vm_dns=None, vm_hostname=None,template=None):
# guest NIC settings
adaptermaps = []
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 = vm_ip
guest_map.adapter.subnetMask = vm_subnetmask
guest_map.adapter.gateway = vm_gateway
adaptermaps.append(guest_map)
# DNS settings
globalip = vim.vm.customization.GlobalIPSettings(dnsServerList=vm_dns)
ident = None
_host_name = "localhost"
# import pdb
# pdb.set_trace()
if 'windows' in template:
ident = vim.vm.customization.Sysprep()
ident.guiUnattended = vim.vm.customization.GuiUnattended()
ident.guiUnattended.autoLogon = False
ident.guiUnattended.password = vim.vm.customization.Password()
ident.guiUnattended.password.value = 'xxxxxx'
ident.guiUnattended.password.plainText = True
ident.userData = vim.vm.customization.UserData()
ident.userData.fullName = "Derek Chadwell"
ident.userData.orgName = "NetApp"
ident.userData.computerName = vim.vm.customization.FixedName()
ident.userData.computerName.name = _host_name
ident.identification = vim.vm.customization.Identification()
else:
ident = vim.vm.customization.LinuxPrep()
ident.domain = "baidu.com"
ident.hostName = vim.vm.customization.FixedName()
if vm_hostname:
print(vm_hostname)
ident.hostName.name = _host_name
customspec = vim.vm.customization.Specification()
customspec.nicSettingMap = adaptermaps
customspec.globalIPSettings = globalip
customspec.identity = ident
return customspec`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided get_customspec function and compare the Windows Sysprep identity path with the LinuxPrep path. Reproduce cloning a Windows template with the shown network values, then inspect whether the resulting VM receives the requested IP, subnet mask, gateway, and DNS settings; done means Windows cloning has working network customization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100