How to change vm name through pysphere

418 views Asked by At

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.

1

There are 1 answers

0
Rishabh Soni On

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.