[GH-ISSUE #10] use api how to write code running exec #12

Closed
opened 2026-02-26 17:32:05 +03:00 by kerem · 20 comments
Owner

Originally created by @haiwan-xm on GitHub (May 28, 2020).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-php/issues/10

hi boss.
how to write php code running api qm guest exec ..?

Originally created by @haiwan-xm on GitHub (May 28, 2020). Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-php/issues/10 hi boss. how to write php code running api qm guest exec ..?
kerem closed this issue 2026-02-26 17:32:05 +03:00
Author
Owner

@franklupo commented on GitHub (May 29, 2020):

Hi,

$client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data)

Best regards

<!-- gh-comment-id:635845752 --> @franklupo commented on GitHub (May 29, 2020): Hi, $client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data) Best regards
Author
Owner

@haiwan-xm commented on GitHub (May 29, 2020):

Hi,

$client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data)

Best regards

tks, boss. so if we use agent config ip address
we in promox shell set is qm guest exec 122 ip addr add 192.168.0.2/24 brd 192.168.0.255 dev eth0
so how to write php code from api running this set ip address?
ths boss give me guide. and happy weekend

<!-- gh-comment-id:635997499 --> @haiwan-xm commented on GitHub (May 29, 2020): > Hi, > > $client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data) > > Best regards tks, boss. so if we use agent config ip address we in promox shell set is qm guest exec 122 ip addr add 192.168.0.2/24 brd 192.168.0.255 dev eth0 so how to write php code from api running this set ip address? ths boss give me guide. and happy weekend
Author
Owner

@haiwan-xm commented on GitHub (Jun 8, 2020):

$client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data)

hi, boss we write code php runing error.
you see
image

<!-- gh-comment-id:640475801 --> @haiwan-xm commented on GitHub (Jun 8, 2020): > $client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data) hi, boss we write code php runing error. you see ![image](https://user-images.githubusercontent.com/45061573/84012996-ed5c3900-a9aa-11ea-889b-d3db3b260a7f.png)
Author
Owner

@franklupo commented on GitHub (Jun 8, 2020):

Hi,
the official documentation https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/exec not use encode.
With pvesh this command work?

pvesh create /nodes/{node}/qemu/{vmid}/agent/exec

best regards

<!-- gh-comment-id:640512232 --> @franklupo commented on GitHub (Jun 8, 2020): Hi, the official documentation https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/exec not use encode. With pvesh this command work? ```sh pvesh create /nodes/{node}/qemu/{vmid}/agent/exec ``` best regards
Author
Owner

@haiwan-xm commented on GitHub (Jun 8, 2020):

Hi,
the official documentation https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/exec not use encode.
With pvesh this command work?

pvesh create /nodes/{node}/qemu/{vmid}/agent/exec

best regards

qm guest exec --
we just don't know hot to use php running exec.

<!-- gh-comment-id:640696198 --> @haiwan-xm commented on GitHub (Jun 8, 2020): > Hi, > the official documentation [https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/exec](https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/%7Bnode%7D/qemu/%7Bvmid%7D/agent/exec) not use encode. > With pvesh this command work? > > ```shell > pvesh create /nodes/{node}/qemu/{vmid}/agent/exec > ``` > > best regards qm guest exec <VMID> -- <Commad inside VM> we just don't know hot to use php running exec.
Author
Owner

@haiwan-xm commented on GitHub (Jun 9, 2020):

Hi,
the official documentation https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/exec not use encode.
With pvesh this command work?

pvesh create /nodes/{node}/qemu/{vmid}/agent/exec

best regards

hi, boss. we just try use agent config host ip address.

<!-- gh-comment-id:641133561 --> @haiwan-xm commented on GitHub (Jun 9, 2020): > Hi, > the official documentation [https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/exec](https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/%7Bnode%7D/qemu/%7Bvmid%7D/agent/exec) not use encode. > With pvesh this command work? > > ```shell > pvesh create /nodes/{node}/qemu/{vmid}/agent/exec > ``` > > best regards hi, boss. we just try use agent config host ip address.
Author
Owner

@franklupo commented on GitHub (Jun 19, 2020):

Hi,
the official documentation https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/exec not use encode.
With pvesh this command work?

pvesh create /nodes/{node}/qemu/{vmid}/agent/exec

best regards

qm guest exec --
we just don't know hot to use php running exec.

Does it work in the shell manually?

<!-- gh-comment-id:646789252 --> @franklupo commented on GitHub (Jun 19, 2020): > > Hi, > > the official documentation [https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/exec](https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/%7Bnode%7D/qemu/%7Bvmid%7D/agent/exec) not use encode. > > With pvesh this command work? > > ```shell > > pvesh create /nodes/{node}/qemu/{vmid}/agent/exec > > ``` > > > > > > best regards > > qm guest exec -- > we just don't know hot to use php running exec. Does it work in the shell manually?
Author
Owner

@franklupo commented on GitHub (Jul 7, 2020):

news?

<!-- gh-comment-id:654987290 --> @franklupo commented on GitHub (Jul 7, 2020): news?
Author
Owner

@franklupo commented on GitHub (Sep 2, 2020):

Hi,
escape data using htmlspecialchars

<!-- gh-comment-id:685409134 --> @franklupo commented on GitHub (Sep 2, 2020): Hi, escape data using htmlspecialchars
Author
Owner

@haiwan-xm commented on GitHub (Sep 2, 2020):

Hi,
escape data using htmlspecialchars

tks, boss., so have give me a demo code running php exec config ip addres ?
tks

<!-- gh-comment-id:685413098 --> @haiwan-xm commented on GitHub (Sep 2, 2020): > Hi, > escape data using htmlspecialchars tks, boss., so have give me a demo code running php exec config ip addres ? tks
Author
Owner

@franklupo commented on GitHub (Sep 2, 2020):

$input_data1=  htmlspecialchars($input_data)
$client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data1)
<!-- gh-comment-id:685417506 --> @franklupo commented on GitHub (Sep 2, 2020): ```php $input_data1= htmlspecialchars($input_data) $client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data1) ```
Author
Owner

@haiwan-xm commented on GitHub (Sep 2, 2020):

$input_data1=  htmlspecialchars($input_data)
$client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data1)

tks, boss, let me test

<!-- gh-comment-id:685418488 --> @haiwan-xm commented on GitHub (Sep 2, 2020): > ``` > $input_data1= htmlspecialchars($input_data) > $client->getNodes()->get("pve1")->getQemu()->get(100)->getAgent()->getExec()->exec($command, $input_data1) > ``` tks, boss, let me test
Author
Owner

@haiwan-xm commented on GitHub (Sep 2, 2020):

and we have a new trouble. how to use qemu agent config vm ip address.
for example. centos. if we use exec command set ip address , later reboot config loss. we want let ip config write eth config.
tks , wish give me guide.

<!-- gh-comment-id:685419737 --> @haiwan-xm commented on GitHub (Sep 2, 2020): and we have a new trouble. how to use qemu agent config vm ip address. for example. centos. if we use exec command set ip address , later reboot config loss. we want let ip config write eth config. tks , wish give me guide.
Author
Owner

@franklupo commented on GitHub (Sep 2, 2020):

I have no idea.
I think the Proxmox VE forum can help you.

<!-- gh-comment-id:685422577 --> @franklupo commented on GitHub (Sep 2, 2020): I have no idea. I think the Proxmox VE forum can help you.
Author
Owner

@haiwan-xm commented on GitHub (Sep 2, 2020):

I have no idea.
I think the Proxmox VE forum can help you.

him let me write all operating system config shell. later call shell running .

<!-- gh-comment-id:685423965 --> @haiwan-xm commented on GitHub (Sep 2, 2020): > I have no idea. > I think the Proxmox VE forum can help you. him let me write all operating system config shell. later call shell running .
Author
Owner

@franklupo commented on GitHub (Sep 2, 2020):

I do not understand

<!-- gh-comment-id:685425634 --> @franklupo commented on GitHub (Sep 2, 2020): I do not understand
Author
Owner

@haiwan-xm commented on GitHub (Sep 3, 2020):

I do not understand

this depends on the distribution/OS you're running in the VM, since they have different implementations (networkmanager, systemd-networkd. /etc/network/interfaces, and so on..)

cloud-init can be used to configure networking for VMs though, which would work simpler..

otherwise you can try writing scripts for each distro to configure network, and call that script with arguments via qm guest exec

<!-- gh-comment-id:686340640 --> @haiwan-xm commented on GitHub (Sep 3, 2020): > I do not understand this depends on the distribution/OS you're running in the VM, since they have different implementations (networkmanager, systemd-networkd. /etc/network/interfaces, and so on..) cloud-init can be used to configure networking for VMs though, which would work simpler.. otherwise you can try writing scripts for each distro to configure network, and call that script with arguments via `qm guest exec`
Author
Owner

@franklupo commented on GitHub (Sep 4, 2020):

You will have to make specific scripts for each OS.

<!-- gh-comment-id:687193351 --> @franklupo commented on GitHub (Sep 4, 2020): You will have to make specific scripts for each OS.
Author
Owner

@haiwan-xm commented on GitHub (Sep 23, 2020):

You will have to make specific scripts for each OS.

hi , boss
this exec($command, $input_data1) how to write.
have wish give me guide?
eg: set ip address or df or ifconfig

<!-- gh-comment-id:697252090 --> @haiwan-xm commented on GitHub (Sep 23, 2020): > You will have to make specific scripts for each OS. hi , boss this exec($command, $input_data1) how to write. have wish give me guide? eg: set ip address or df or ifconfig
Author
Owner

@franklupo commented on GitHub (Sep 23, 2020):

you have to look at the guide of Proxmox VE

<!-- gh-comment-id:697324334 --> @franklupo commented on GitHub (Sep 23, 2020): you have to look at the guide of Proxmox VE
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cv4pve-api-php#12
No description provided.