* [pve-devel] [PATCH manager v2 1/2] ui: cloudinit: use cloudinit update api when regenerating images
@ 2024-11-07 14:40 Daniel Kral
2024-11-07 14:40 ` [pve-devel] [PATCH manager v2 2/2] ui: cloudinit: disallow unprivileged users to regenerate images Daniel Kral
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Kral @ 2024-11-07 14:40 UTC (permalink / raw)
To: pve-devel
Changes the behavior of the "Regenerate Image" button in the VM's
CloudInit tab from using the more expensive VM update API endpoint to
using the CloudInit update API endpoint.
Originally-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
Changes since v1 (as suggested by @Fiona):
- added this patch to reduce the needed permissions
- added a commit message to the applied patch
- no changes to the original patch hunk
This change has been taken from a previously unapplied commit [0]. I
have only applied the changes done to the button handler.
The rest of the original patch also touches the functionality of editing
the fields, which breaks the check if a cloudinit disk is present,
because the cloudinit_pending's response no longer includes the
CloudInit disk drive property itself and therefore will always show "No
CloudInit drive found". This change could be included in the future, but
is not part of my original patch's intention.
www/manager6/qemu/CloudInit.js | 32 +++++---------------------------
1 file changed, 5 insertions(+), 27 deletions(-)
diff --git a/www/manager6/qemu/CloudInit.js b/www/manager6/qemu/CloudInit.js
index 49519726..be902d43 100644
--- a/www/manager6/qemu/CloudInit.js
+++ b/www/manager6/qemu/CloudInit.js
@@ -82,38 +82,16 @@ Ext.define('PVE.qemu.CloudInit', {
text: gettext('Regenerate Image'),
handler: function() {
let view = this.up('grid');
- var eject_params = {};
- var insert_params = {};
- let disk = PVE.Parser.parseQemuDrive(view.ciDriveId, view.ciDrive);
- var storage = '';
- var stormatch = disk.file.match(/^([^:]+):/);
- if (stormatch) {
- storage = stormatch[1];
- }
- eject_params[view.ciDriveId] = 'none,media=cdrom';
- insert_params[view.ciDriveId] = storage + ':cloudinit';
-
- var failure = function(response, opts) {
- Ext.Msg.alert('Error', response.htmlStatus);
- };
Proxmox.Utils.API2Request({
- url: view.baseurl + '/config',
+ url: view.baseurl + '/cloudinit',
waitMsgTarget: view,
method: 'PUT',
- params: eject_params,
- failure: failure,
+ failure: function(response, opts) {
+ Ext.Msg.alert('Error', response.htmlStatus);
+ },
callback: function() {
- Proxmox.Utils.API2Request({
- url: view.baseurl + '/config',
- waitMsgTarget: view,
- method: 'PUT',
- params: insert_params,
- failure: failure,
- callback: function() {
- view.reload();
- },
- });
+ view.reload();
},
});
},
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] [PATCH manager v2 2/2] ui: cloudinit: disallow unprivileged users to regenerate images
2024-11-07 14:40 [pve-devel] [PATCH manager v2 1/2] ui: cloudinit: use cloudinit update api when regenerating images Daniel Kral
@ 2024-11-07 14:40 ` Daniel Kral
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kral @ 2024-11-07 14:40 UTC (permalink / raw)
To: pve-devel
Disables the "Regenerate image" button in the VM CloudInit tab for
users, which lack the necessary permission "VM.Config.CloudInit" for the
CloudInit update API endpoint.
This is a cosmetic change as the CloudInit update API endpoint would
fail because of insufficient permissions anyway.
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
Changes since v1:
- remove the now unnecessary permission "VM.Config.CDROM"
www/manager6/qemu/CloudInit.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/www/manager6/qemu/CloudInit.js b/www/manager6/qemu/CloudInit.js
index be902d43..ccad4916 100644
--- a/www/manager6/qemu/CloudInit.js
+++ b/www/manager6/qemu/CloudInit.js
@@ -120,7 +120,10 @@ Ext.define('PVE.qemu.CloudInit', {
}
});
- me.down('#savebtn').setDisabled(!found);
+ let caps = Ext.state.Manager.get('GuiCap');
+ let canRegenerateImage = !!caps.vms['VM.Config.Cloudinit'];
+ me.down('#savebtn').setDisabled(!found || !canRegenerateImage);
+
me.setDisabled(!found);
if (!found) {
me.getView().mask(gettext('No CloudInit Drive found'), ['pve-static-mask']);
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-07 14:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-07 14:40 [pve-devel] [PATCH manager v2 1/2] ui: cloudinit: use cloudinit update api when regenerating images Daniel Kral
2024-11-07 14:40 ` [pve-devel] [PATCH manager v2 2/2] ui: cloudinit: disallow unprivileged users to regenerate images Daniel Kral
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox