vmware / vmware/pyvmomi

clone from windows start network adapter failed

Open
#969 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs verification
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

I clone from windows template ,vm start but network adapter start failed,linux template is ok, what's wrong ? Thanks
image

edit nic

  device_change = []
  for device in vm.config.hardware.device:
      if isinstance(device, vim.vm.device.VirtualEthernetCard):
          nicspec = vim.vm.device.VirtualDeviceSpec()
          nicspec.operation = \
              vim.vm.device.VirtualDeviceSpec.Operation.edit
          nicspec.device = device
          nicspec.device.wakeOnLanEnabled = True
  
          network = pchelper.get_obj(
              content, [vim.dvs.DistributedVirtualPortgroup], network_name)
          dvs_port_connection = vim.dvs.PortConnection()
          dvs_port_connection.portgroupKey = network.key
          dvs_port_connection.switchUuid = \
              network.config.distributedVirtualSwitch.uuid
          nicspec.device.backing = \
              vim.vm.device.VirtualEthernetCard. \
                  DistributedVirtualPortBackingInfo()
          nicspec.device.backing.port = dvs_port_connection
  
          nicspec.device.connectable = \
              vim.vm.device.VirtualDevice.ConnectInfo()
          nicspec.device.connectable.startConnected = True
          nicspec.device.connectable.allowGuestControl = True
          nicspec.device.connectable.connected = True
          device_change.append(nicspec)
          break

clone

 clonespec = vim.vm.CloneSpec()
 clonespec.location = relospec
 clonespec.powerOn = power_on
 vmconf = vim.vm.ConfigSpec()
 vmconf.deviceChange = device_change
 clonespec.config = vmconf
 task = template.Clone(folder=destfolder, name=vm_name, spec=clonespec)
 self.wait_for_task(task)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Windows-template clone with the shown network-adapter edit and clone configuration, comparing it with the working Linux-template case. Inspect the adapter backing and connection settings in the clone specification; done means the cloned Windows VM starts with its network adapter connected.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.