vmware / vmware/pyvmomi

HELP! I can't set Additional properties when deploy ova using pyvmomi.

Open
#850 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

networkObj = None
try:
content = si.RetrieveContent()
view = content.viewManager.CreateContainerView(content.rootFolder, [vim.HostSystem], True)
hostObj = [v for v in view.view]
view.Destroy()
for network in hostObj[0].network:
if network.name == networkName:
networkObj = network
except Exception as e:
log.error(e)
raise

networkMapping = vim.OvfManager.NetworkMapping(name=networkName, network=networkObj)
propertyMappingList = []

if propertyMappingDict:
    **for key in propertyMappingDict:
        propertyMappingList.append(vim.KeyValue(key=key, value=propertyMappingDict[key]))**

try:
    cisp = vim.OvfManager.CreateImportSpecParams(entityName=vmName, diskProvisioning=diskProvisioning,
                                                 networkMapping=[networkMapping], propertyMapping=propertyMappingList)
except Exception as e:
    log.error(e)
    raise

cisr = ovfManager.CreateImportSpec(ovf_handle.get_descriptor(), rp, ds, cisp)

if len(cisr.error):
    log.error("The following errors will prevent import of this OVA:")
    for error in cisr.error:
        log.error("%s" % error)
    raise Exception("cisr error.")

ovf_handle.set_spec(cisr)

lease = rp.ImportVApp(cisr.importSpec, dc.vmFolder)
while lease.state == vim.HttpNfcLease.State.initializing:
    log.info("Waiting for lease to be ready...")
    time.sleep(1)

if lease.state == vim.HttpNfcLease.State.error:
    log.info("Lease error: %s" % lease.error)
    raise Exception("Lease error: %s" % lease.error)
if lease.state == vim.HttpNfcLease.State.done:
    return 0

log.info("Starting deploy...")
try:
    ovf_handle.upload_disks(lease, host)
except Exception:
    raise
return 0

I refer the document esxi6.7 , I find propertyMapping is KeyValue[], then I fill the ovfkey into the list.
But it not work.
Can somebody help me ?
Thanks a lot.

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 at the CreateImportSpecParams call and the propertyMapping list shown in the issue, then inspect the OVF descriptor's property keys and the ImportSpec errors. Done means the additional properties are accepted during OVA deployment and their resulting values can be verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
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.