JavaSa
JavaSa

Reputation: 6241

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.

Upvotes: 0

Views: 451

Answers (1)

Rishabh Soni
Rishabh Soni

Reputation: 159

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.

Upvotes: 0

Related Questions