简体   繁体   中英

How to change vm name through pysphere

I'm using the Pysphere API written in python in order to manage VM operations.

My question is, how do I change the machine name after it was already cloned.

The API is here and here .

As i understood, vm is already created/cloned. So basically you want to change the vm configuration.You need to create a configuration spec(vm name in your case).

context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_NONE
print opArg
sI = connect.SmartConnect(host='',
             user='',
             pwd='',
             port=443,
             sslContext=context)
content = sI.content
objView = content.viewManager.CreateContainerView(content.rootFolder,[vim.VirtualMachine],True)
vmList = objView.view
for vm in vmList:
    vm_obj = vm

And then you pass your spec as-

vm_obj.ReconfigVM_Task(spec=your_spec)

I worked on VMWare a long time ago. I hope this is still helpful.

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