Need help to run API to enable data collection from a Jumpbox VM. I read NSX 6.2 API document example 14-1 but not working. The VMID is "7" based on vim-cmd
CLI output. My run below script.
POST https://x.x.x.x/api/1.0/eventcontrol/vm/virtualMachineId/request
Request Body:
<perVmConfig>
<actions>
<action>
<type>per_vm_config</type>
<value>enabled</value>
</action>
</actions>
</perVmConfig>
The error I got is below.
<?xml version="1.0" encoding="UTF-8"?>
<error>
<details>Can not query for entry client id : 7</details>
<errorCode>9022</errorCode>
<moduleName>actionable-information</moduleName>
</error>
Can anyone help me what value of virtual machine ID to be used on the above script? Thanks
I think it's possible that you need to get the syntax from the NSX central CLI since that's where the API POST is directed.
SSH into the NSX manager and do the following
Find the cluster id for the cluster that owns the host which the VM is running on
nsxmgr > show cluster all
Find the HOST-ID for the host that the VM is running on
nsxmgr > show cluster CLUSTER-ID
Find the VM-ID for the VM running on the host
nsxmgr > show host HOST-ID
This should give you the vm-id in the format that NSX manager API can consume. Then replace virtualMachineId with whatever you get from that output.
I can't test this out right now, but let me know if that works for you.
Normally the VM Id will be in the format vm-xxx
The easy way to find the VMID is via NSX Manager central CLI
Let me know what exactly u type in the VMID field.
this is the POST URLs:
https://192.168.0.250/api/1.0/eventcontrol/vm/vm-7/request
https://192.168.0.250/api/1.0/eventcontrol/vm/7/request
none of the above post script works.
[root@dc1-esx2:~] vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
4 WEB-SVR2 [DC1-ESX2-Local] WEB-SVR2/WEB-SVR2.vmx windows7_64Guest vmx-11
7 Jumpbox [DC1-ESX2-Local] XP1/XP1.vmx winXPProGuest vmx-11
The output shows VMID 7 for Jumpbox. Any idea?
thanks
I think it's possible that you need to get the syntax from the NSX central CLI since that's where the API POST is directed.
SSH into the NSX manager and do the following
Find the cluster id for the cluster that owns the host which the VM is running on
nsxmgr > show cluster all
Find the HOST-ID for the host that the VM is running on
nsxmgr > show cluster CLUSTER-ID
Find the VM-ID for the VM running on the host
nsxmgr > show host HOST-ID
This should give you the vm-id in the format that NSX manager API can consume. Then replace virtualMachineId with whatever you get from that output.
I can't test this out right now, but let me know if that works for you.
Thanks buddy. I realised this too. Lesson learned that VMID value is different between ESXi and NSX.