[SOLVED] Unable to use api to configure cloud-int

Orisland

New Member
May 14, 2023
5
0
1
I want to adjust cloud-init settings through api to achieve automatic ip pre-allocation without using dhcp.
very strange.
I referred to the official API documentation for testing, but only this function seemed to throw an internal error that could not be handled.
I think there is nothing wrong with my authorization configuration, this is the first strange error I have encountered since testing the availability of multiple APIs.

Sorry my English is not that good, I used Google Translate.
api doc

I would be grateful if you could provide some relevant advice and guidance !

The following part is some configuration diagrams of the server. In order to show the configuration as comprehensively as possible, I took many screenshots.

1700126300960.png
1700126283983.png1700126417583.png1700126429051.png
 
Last edited:
The API you are using does not have any parameters to supply.

The variable vm.config.cloudinit refers to permissions you have to give to the user executing API. If you are using root its already assigned by default.

My guess is you created a user and attempted to provide permissions to execute this API? I am guessing that there is either a typo or some extra info in the permissions for this user. The failure is in the part of code which checks whether you have the privilege to execute the API, ie not the API call itself.

I'd go back and check your permissions/users, try with superuser as well. It could be a bug, but you need to provide a fuller report about your configuration:
exact API call
how its authenticated
what permissions are set
etc

PS it could be a bug in software, the best way to address it is for you to provide exact steps to reproduce it. I.e. create a new user, document every step that leads you to this error. You can post here, but if you want it to be tracked properly - utilize https://bugzilla.proxmox.com/

Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited:
The API you are using does not have any parameters to supply.

The variable vm.config.cloudinit refers to permissions you have to give to the user executing API. If you are using root its already assigned by default.

My guess is you created a user and attempted to provide permissions to execute this API? I am guessing that there is either a typo or some extra info in the permissions for this user. The failure is in the part of code which checks whether you have the privilege to execute the API, ie not the API call itself.

I'd go back and check your permissions/users, try with superuser as well. It could be a bug, but you need to provide a fuller report about your configuration:
exact API call
how its authenticated
what permissions are set
etc

PS it could be a bug in software, the best way to address it is for you to provide exact steps to reproduce it. I.e. create a new user, document every step that leads you to this error. You can post here, but if you want it to be tracked properly - utilize https://bugzilla.proxmox.com/

Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Thank you for your reply.
I am testing the API call, so I specially created a token with the all permissions for use.
So I can confirm that there are no issues related to insufficient permissions.
1700153560747.png
The way to verify the identity is to add the Authorization field in the header of the request, along with the created token with all permissions.
I'm not sure whether this error is caused by a problem with my configuration or a problem with proxmox itself, so I wanted to post here to ask related questions.
I tested many other APIs using this token, and only this one gave me an error.
1700152690864.png
Although this API does not have any input, there is this statement in the official API description.
1700153018849.png
The description clearly mentions ‘Regenerate and change cloudinit config drive.’
Is this a documentation error or is there some other reason?
Secondly, if there is really a problem with my access, I think a more reasonable access return result should not have internal errors like the second picture.

The screenshots I have given should contain all the information you need. If there is anything missing please leave a message and tell me and I will add the relevant information.
I want to make sure the problem is not with me before I use the website you gave me to report bugs.
 
Last edited:
The description clearly mentions ‘Regenerate and change cloudinit config drive.’
It means that if you have a cloudinit disk already created as part of the VM configuration, you can use this API to regenerate it. Keep in mind that cloudinit is a cdrom emulation. An ISO type disk is created and mounted as cdrom.

For example, if you use a custom userdata and make a change to file, you need to regenerate cloudinit ISO. So this API will "regenerate and change" it, as the documentation states:
Code:
pvesh set nodes/pve7demo1/qemu/103/cloudinit
generating cloud-init ISO

Same thing via curl:
Code:
curl --insecure --cookie "$(<cookie)" --header "$(<csrftoken)" -X PUT https://127.0.0.1:8006/api2/json/nodes/pve7demo1/qemu/103/cloudinit

The cookie was generated via:
Code:
curl --silent --insecure --data "username=root@pam&password=password" \
 https://127.0.0.1:8006/api2/json/access/ticket\
| jq --raw-output '.data.ticket' | sed 's/^/PVEAuthCookie=/' > cookie
curl --silent --insecure --data "username=root@pam&password=password" \
 https://127.0.0.1:8006/api2/json/access/ticket \
| jq --raw-output '.data.CSRFPreventionToken' | sed 's/^/CSRFPreventionToken:/' > csrftoken


Secondly, if there is really a problem with my access, I think a more reasonable access return result should not have internal errors like the second picture.
I agree. You should determine how you got to that error and report the steps to developers. As you can see above basic default access works.
The pam!test looks suspicious to me, but I am not an expert on that.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
I want to adjust cloud-init settings through api to achieve automatic ip pre-allocation without using dhcp.
Addressing your original goal, you would do it via:
https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/config

using ipconfig and other CI appropriate keys.
PVE knows when you change CI values of the _built_ in CI config, the CI disk will be regenerated on VM restart (cold start). You only need to call the API on which you were stuck if you are using customci

good luck


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Addressing your original goal, you would do it via:
https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/config

using ipconfig and other CI appropriate keys.
PVE knows when you change CI values of the _built_ in CI config, the CI disk will be regenerated on VM restart (cold start). You only need to call the API on which you were stuck if you are using customci

good luck


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Thank you for your attention and answers to this question!
Sorry for the long delay in replying, this is usually the only time I have time to deal with these issues.
The solution you gave me looks very reliable! Thank you so much!

But one problem is that if what this API can do is to regenerate the cloud-init driver, then when I use the API you mentioned to make modifications, I seem to have no way to regenerate it through the API. Because I have tested that the API that can generate the cloud-init driver is unavailable at this time. Does this mean I can't break away from using the web interface to manually generate the buttons standalone?

For testing, I regenerated an API and I didn't grant any permissions to the API at this time.
To my surprise, the problem did not turn out to be a permissions issue as I thought, but the same as the previous API that granted full permissions.
1700233854212.png
1700233988568.png
1700234005900.png
1700234050639.png
Then, after I tried to grant the new token the vm permissions it needed, the error message did not change.
1700234346307.png
1700234356608.png
This makes me think it's a bug, not a problem with my permissions or operations.
 
If I don't have the operation permission, the result returned by postman should be like this, instead of the strange error in the picture above.
1700234537139.png
 
I dont have the cycles to test your steps at this time. What I would do:
- confirm that you can use this API with user/password auth
- try to create a token without special characters, ie no !
- reproduce the issue with "curl"
- in either case report the bug in bugzilla, listing all steps you did. As you said, you should not be getting perl trace errors in ideal world.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: Orisland
I dont have the cycles to test your steps at this time. What I would do:
- confirm that you can use this API with user/password auth
- try to create a token without special characters, ie no !
- reproduce the issue with "curl"
- in either case report the bug in bugzilla, listing all steps you did. As you said, you should not be getting perl trace errors in ideal world.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Thanks for your active assistance, I will report this bug at https://bugzilla.proxmox.com/.;)
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!