UrielCh / proxmox-api

TypeScript Api for proxmox
56 stars 15 forks source link

Agent "exec-status" Error 400 Parameter verification failed. #11

Closed a1um1 closed 1 year ago

a1um1 commented 1 year ago

I got this error with exec-status

GET https://192.168.1.2:8006/api2/json/nodes/pve/qemu/102/agent/exec-status?pid=2688

return Error 400 Parameter verification failed.:

{\"errors\":{\"pid\":\"property is missing and it is not optional\"},\"data\":null}"

Replication problems

create agent exec and retrive pid and call agent exec-status should replicate an error but try to access that URL with browser will result like it's seem to be

UrielCh commented 1 year ago

I think the issue is now fixed, but I would like to test it first.

how did you get the pid ? is that the PID of a process inside the qemu ? is the agent able to list the running processes ?

a1um1 commented 1 year ago
  1. I retrive PID by using /agent/exec on qemu
  2. PID is process inside qemu
  3. Agent can retrive running process as normal via command or postman

    I think it's occured by parsing problem it's have this same problem with qemu rrddata and /agent/file-read method or anything that use GET query params

UrielCh commented 1 year ago

is that work on windows VM qemu? so it only works on the process starting via the agent?

have you a sample command I can exec in a windows QEMU agent to get its exec-status?

a1um1 commented 1 year ago
await agent.ping.$post()
const {pid} = await proxmox.nodes.$(query.node).qemu.$(query.vmID).agent.exec.$post({
command: `powershell.exe ping 127.0.0.1`,
})
const result = await proxmox.nodes.$(query.node).qemu.$(query.vmID).agent['exec-status'].$get({
pid:pid
})
UrielCh commented 1 year ago

The test is in progress, but I need to switch to another project; I'll be back in 30 minutes.

Your "powershell.exe ping 127.0.0.1" look more promising than my "echo hello" :)

UrielCh commented 1 year ago

I need to fix an offline remote server, which will take more time than expected. I will finish that within 12hours.

UrielCh commented 1 year ago

I do not have powershell.exe on my remote Windows :(

a1um1 commented 1 year ago

cmd.exe should do a job what windows version are you on

UrielCh commented 1 year ago

can you try v 0.4.1

extract from sample.ts:

            try {
                const mtd1 = theNode.qemu.$(qemu.vmid).agent.exec.$post;
                // const process = await exec.$post({ command: "powershell.exe ping 127.0.0.1" })
                const process = await mtd1({ command: "C:/Windows/System32/ping.exe 127.0.0.1" })
                console.log('pid:', process.pid)
                const getter = theNode.qemu.$(qemu.vmid).agent["exec-status"].$get;
                let exited = false;
                let waitcnd = 0;
                while (!exited) {
                    const status = await getter({ pid: process.pid })
                    console.log(++waitcnd + ' status:', status)
                    exited = !!status.exited;
                    await delay(500);
                }
                // { exited: 0 }
                // { exitcode: 0, exited: 1, out-data: 'stdout'}
            } catch (e) {
                console.log(e);
            }
a1um1 commented 1 year ago

v 0.4.1 is fixed this issues with every GET method so you can close this issue now Thank for supporting