From 85c9c4cc6dc05692a4465bbd202d8a5a1914db3a Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sat, 5 Apr 2025 00:18:43 +0000 Subject: [PATCH] add get instance config path --- src/routes/cluster.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/routes/cluster.js b/src/routes/cluster.js index b3c9db6..c0c6983 100644 --- a/src/routes/cluster.js +++ b/src/routes/cluster.js @@ -122,6 +122,36 @@ router.get(`/:node(${nodeRegexP})/pci`, async (req, res) => { } }); +/** + * GET - get basic resources for vm using the fabric format + * request: + * - node: string - vm host node id + * - type: string - vm type (lxc, qemu) + * - vmid: number - vm id number + * response: + * - 200: Fabric instance config + * - 401: {auth: false} + */ +router.get(`${basePath}`, async (req, res) => { + const params = { + node: req.params.node, + type: req.params.type, + vmid: req.params.vmid, + }; + + // check auth for specific instance + const vmpath = `/nodes/${params.node}/${params.type}/${params.vmid}`; + const auth = await checkAuth(req.cookies, res, vmpath); + if (!auth) { + return; + } + + // get current config + const instance = await global.pve.getInstance(params.node, params.vmid); + + res.status(200).send(instance); +}) + /** * POST - set basic resources for vm * request: