[pve-devel] [PATCH v2 manager 3/4] ui: utils: add method to get VM data from resource store

Aaron Lauterer a.lauterer at proxmox.com
Tue Sep 1 16:30:45 CEST 2020


Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
---
v1 -> v2: fixed linter errors

 www/manager6/Utils.js | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index bf9ceda9..19227384 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1566,6 +1566,19 @@ Ext.define('PVE.Utils', { utilities: {
     constructor: function() {
 	var me = this;
 	Ext.apply(me, me.utilities);
-    }
+    },
+
+    getNodeVMs: function(nodename) {
+	let rstore = PVE.data.ResourceStore;
+	let vms = {};
+	rstore.data.items.forEach((item) => {
+	    if (!item.id.startsWith('qemu/')) { return; }
+	    let vmdata = item.data;
+	    if (vmdata.node !== nodename) { return; }
+
+	    vms[vmdata.vmid] = vmdata;
+	});
+	return vms;
+    },
 
 });
-- 
2.20.1






More information about the pve-devel mailing list