vmware / vsphere-automation-sdk-python

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
739 stars 308 forks source link

Not able to create ticket for Web console for newly created VM #404

Closed karanpanchal-crest closed 6 months ago

karanpanchal-crest commented 7 months ago

Describe the bug

I have created a VM using the VSphere automation SDK Python. I can get a VM ID to connect. As a next step, I want to execute some commands on the newly created VM. For this task, I am trying to create a ticket using vcenter.vm.console.Tickets.create method.

Code I have written for creating the console ticket:

import requests
from vmware.vapi.vsphere.client import create_vsphere_client
from com.vmware.vcenter.vm.console_client import Tickets

session = requests.session()

vsphere_client = create_vsphere_client(
    server=server_ip,
    username=username,
    password=password, session=session)

create_spec = vsphere_client.vcenter.vm.console.Tickets.CreateSpec(type=Tickets.Type.WEBMKS)
console_ticket = vsphere_client.vcenter.vm.console.Tickets.create(vm=<vm_id>, spec = create_spec)

However, I am getting the below error when trying to create the console ticket using the above code.

com.vmware.vapi.std.errors_client.OperationNotFound: {messages : [LocalizableMessage(id='vapi.method.input.invalid.interface', default_message="Cannot find service 'com.vmware.vcenter.vm.console.tickets'.", args=['com.vmware.vcenter.vm.console.tickets'], params=None, localized=None)], data : None, error_type : None}

Reproduction steps

  1. Create a VM and try connecting the VM by getting the Web console URI.
  2. Execute the above code to get the web console ticket.

Expected behavior

A console ticket should be returned through which I should be able to connect to the VM and execute commands on the newly created VM.

Additional context

No response

karanpanchal-crest commented 7 months ago

@jobingeo Do you have any idea regarding this issue?

kunal-pmj commented 7 months ago

What is the vCenter Server Version?

Kindly note The feature was added in vCenter version : 7.0.0.2

karanpanchal-crest commented 7 months ago

@kunal-pmj Thanks for responding to my query I am using vSphere Client version 6.7.0.54000 Image 20-12-23 at 11 24 PM

How shall I get access to the newly created VM through this automation SDK? I want to execute interactive commands like changing the password of the VM, executing a process that asks for runtime input on CLI, etc. programmatically. Can you please guide me on how to achieve this requirement?

karanpanchal-crest commented 7 months ago

@kunal-pmj Can you please help me with the above question? Also, do you know if I can create a VM with IP assigned during creation? This will help me get SSH of the newly created VM to execute the commands.

karanpanchal-crest commented 7 months ago

@jobingeo Do you have any idea on my question above?

kunal-pmj commented 6 months ago

Hi @karanpanchal-crest

You are using an older version of the vCenter Server (6.7) with a new SDK 8.0U3 that is the reason for Operation not Found error.

You can deploy VM and configure IP address.