From 3cd9526c8b396a10863090bc48c147ae783efd2a Mon Sep 17 00:00:00 2001 From: Arthur Lu <root@tronnet.net> Date: Tue, 11 Feb 2025 07:11:05 +0000 Subject: [PATCH] add node device path, add service and config templates --- app/app.go | 14 ++++++++++++++ configs/template.config.json | 13 +++++++++++++ init/proxmoxaas-fabric.service | 11 +++++++++++ 3 files changed, 38 insertions(+) create mode 100644 configs/template.config.json create mode 100644 init/proxmoxaas-fabric.service diff --git a/app/app.go b/app/app.go index b477de2..85bb623 100644 --- a/app/app.go +++ b/app/app.go @@ -80,6 +80,20 @@ func Run() { } }) + router.GET("/nodes/:node/devices", func(c *gin.Context) { + node := c.Param("node") + + host, err := cluster.GetHost(node) + + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err}) + return + } else { + c.JSON(http.StatusOK, gin.H{"devices": host.Devices}) + return + } + }) + router.GET("/nodes/:node/instances/:instance", func(c *gin.Context) { node := c.Param("node") vmid, err := strconv.ParseUint(c.Param("instance"), 10, 64) diff --git a/configs/template.config.json b/configs/template.config.json new file mode 100644 index 0000000..ec42b7e --- /dev/null +++ b/configs/template.config.json @@ -0,0 +1,13 @@ +{ + "listenPort": 80, + "pve": { + "url": "http://<proxmox host>/api2/json", + "token": { + "user": "proxmoxaas-api", + "realm": "pam", + "id": "token", + "uuid": "<secret-uuid>" + } + }, + "rebuildInterval": 60 +} \ No newline at end of file diff --git a/init/proxmoxaas-fabric.service b/init/proxmoxaas-fabric.service new file mode 100644 index 0000000..33d17d2 --- /dev/null +++ b/init/proxmoxaas-fabric.service @@ -0,0 +1,11 @@ +[Unit] +Description=proxmoxaas-fabric +After=network.target +[Service] +WorkingDirectory=/<path to dir> +ExecStart=/<path to dir>/proxmoxaas-fabric +Restart=always +RestartSec=10 +Type=simple +[Install] +WantedBy=default.target \ No newline at end of file