简体   繁体   中英

How to specify virtual machine name while vm deploy using ovf template in pyvmomi

I am using pyvmomi to to deploy virtual machine to vCenter using ovf template. By default it takes virtual machine name as specified in .ovf file. I am not able to figure out where in my code (ie while creating import specifications or in ImportVapp) i can specify the new virtual machine name to override that in .ovf file.

Here is code snippet:

 # Create import specifications
ovfManager = self.session.content.ovfManager
specParams = vim.OvfManager.CreateImportSpecParams()
importSpec = ovfManager.CreateImportSpec(
            ovfDescriptor, resourcePool, datastore, specParams)

# Create virtual machine 
lease = resourcePool.ImportVApp(importSpec.importSpec,
                                        datacenter.vmFolder, host)

Thanks for help.

在pyvmomi api文档中进行了大量搜索之后,我找到了解决方案:创建导入规范参数时,我们需要设置'entityName'属性。

specParams = vim.OvfManager.CreateImportSpecParams(entityName='new_linux_vm')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM