我正在使用 pyVmomi 从 vSphere 上的模板部署虚拟机,这很好,新虚拟机获取我作为参数发送的名称,但我希望 DNS 名称\主机名与虚拟机相同。
进行实际克隆时有没有办法设置主机名?
如果不是,在创建新 VM 后我该怎么做?
这是我正在使用的部分代码:
# RelocateSpec
relospec = vim.vm.RelocateSpec()
relospec.datastore = datastore
relospec.pool = resource_pool
# ConfigSpec
configSpec = vim.vm.ConfigSpec()
configSpec.annotation = "This is the annotation for this VM"
# CloneSpec
clonespec = vim.vm.CloneSpec()
clonespec.location = relospec
clonespec.powerOn = power_on
clonespec.config = configSpec
print ("cloning VM...")
task = template.Clone(folder=destfolder, name=vm_name, spec=clonespec)
wait_for_task(task)