vmware / vmware/pyvmomi

Config the network when deploy ova file on VM ESXi 6.7

Open
#900 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

When deploying ova file, meet the error about 'host did not have any virtual network defined.'
This error message appeared on the latest 6.7 version of the VMware ESXi server.
So the content of this python script file(deploy_ova.py) has been improved to adapt it to the latest server.

 if args.network:
        net_name = get_network_list(si, dc, args.network)
        network = [vim.OvfManager.NetworkMapping(name='NAT', network=net_name)]
        ovfManager = si.content.ovfManager
        # CreateImportSpecParams can specify many useful things such as
        # diskProvisioning (thin/thick/sparse/etc)
        # networkMapping (to map to networks)
        # propertyMapping (descriptor specific properties)
        cisp = vim.OvfManager.CreateImportSpecParams(entityName='AutoServer', diskProvisioning='thin',networkMapping=network, ipAllocationPolicy='static',ipProtocol='IPv4')  # deploy disk type is thin, default is thick
        cisr = ovfManager.CreateImportSpec(ovf_handle.get_descriptor(),
                                           rp, ds, cisp)
    else:
        ovfManager = si.content.ovfManager
        # CreateImportSpecParams can specify many useful things such as
        # diskProvisioning (thin/thick/sparse/etc)
        # networkMapping (to map to networks)
        # propertyMapping (descriptor specific properties)
        cisp = vim.OvfManager.CreateImportSpecParams(entityName='AutoServer',diskProvisioning='thin')  # deploy disk type is thin, default is thick
        cisr = ovfManager.CreateImportSpec(ovf_handle.get_descriptor(),
                                           rp, ds, cisp)
def get_network_list(si, dc, networkName):
    """
     Get a network in the datacenter by its names.
     """
    viewManager = si.content.viewManager
    containerView = viewManager.CreateContainerView(dc, [vim.Network],
                                                    True)
    try:
        for rp in containerView.view:
            if rp.name == networkName:
                return rp
    finally:
        containerView.Destroy()
    raise Exception("Failed to find network %s in datacenter %s" %
                    (networkName, dc.name))

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 with deploy_ova.py and inspect the network handling around get_network_list and CreateImportSpecParams. Reproduce the OVA deployment against ESXi 6.7, then verify that the requested network is found and mapped without the “host did not have any virtual network defined” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.