diff --git a/app/routes/config.go b/app/routes/config.go index f951406..5c8fd28 100644 --- a/app/routes/config.go +++ b/app/routes/config.go @@ -13,6 +13,46 @@ import ( "github.com/go-viper/mapstructure/v2" ) +type VMPath struct { + Node string + Type string + VMID string +} + +// imported types from fabric + +type InstanceConfig struct { + Type fabric.InstanceType `json:"type"` + Name string `json:"name"` + Proctype string `json:"cpu"` + Cores uint64 `json:"cores"` + Memory uint64 `json:"memory"` + Swap uint64 `json:"swap"` + Volumes map[string]*fabric.Volume `json:"volumes"` + Nets map[string]*fabric.Net `json:"nets"` + Devices map[string]*fabric.Device `json:"devices"` + Boot fabric.BootOrder `json:"boot"` + // overrides + ProctypeSelect common.Select +} + +type GlobalConfig struct { + CPU struct { + Whitelist bool + } +} + +type UserConfig struct { + CPU struct { + Global []CPUConfig + Nodes map[string][]CPUConfig + } +} + +type CPUConfig struct { + Name string +} + func HandleGETConfig(c *gin.Context) { auth, err := common.GetAuth(c) if err == nil { @@ -155,29 +195,6 @@ func ExtractVMPath(c *gin.Context) (VMPath, error) { return vm_path, nil } -type VMPath struct { - Node string - Type string - VMID string -} - -// imported types from fabric - -type InstanceConfig struct { - Type fabric.InstanceType `json:"type"` - Name string `json:"name"` - Proctype string `json:"cpu"` - Cores uint64 `json:"cores"` - Memory uint64 `json:"memory"` - Swap uint64 `json:"swap"` - Volumes map[string]*fabric.Volume `json:"volumes"` - Nets map[string]*fabric.Net `json:"nets"` - Devices map[string]*fabric.Device `json:"devices"` - Boot fabric.BootOrder `json:"boot"` - // overrides - ProctypeSelect common.Select -} - func GetInstanceConfig(vm VMPath, auth common.Auth) (InstanceConfig, error) { config := InstanceConfig{} path := fmt.Sprintf("/cluster/%s/%s/%s", vm.Node, vm.Type, vm.VMID) @@ -208,23 +225,6 @@ func GetInstanceConfig(vm VMPath, auth common.Auth) (InstanceConfig, error) { return config, nil } -type GlobalConfig struct { - CPU struct { - Whitelist bool - } -} - -type UserConfig struct { - CPU struct { - Global []CPUConfig - Nodes map[string][]CPUConfig - } -} - -type CPUConfig struct { - Name string -} - func GetCPUTypes(vm VMPath, auth common.Auth) (common.Select, error) { cputypes := common.Select{ ID: "proctype", diff --git a/app/routes/index.go b/app/routes/index.go index 9741a13..d10e3af 100644 --- a/app/routes/index.go +++ b/app/routes/index.go @@ -10,6 +10,39 @@ import ( "github.com/go-viper/mapstructure/v2" ) +// used in constructing instance cards in index +type Node struct { + Node string `json:"node"` + Status string `json:"status"` +} + +// used in constructing instance cards in index +type InstanceCard struct { + VMID uint + Name string + Type string + Status string + Node string + NodeStatus string + ConfigPath string + ConsolePath string +} + +// used in retriving cluster tasks +type Task struct { + Type string + Node string + User string + ID string + VMID uint + Status string + EndTime uint +} + +type InstanceStatus struct { + Status string +} + func HandleGETIndex(c *gin.Context) { auth, err := common.GetAuth(c) if err == nil { // user should be authed, try to return index with population @@ -45,39 +78,6 @@ func HandleGETInstancesFragment(c *gin.Context) { } -// used in constructing instance cards in index -type Node struct { - Node string `json:"node"` - Status string `json:"status"` -} - -// used in constructing instance cards in index -type InstanceCard struct { - VMID uint - Name string - Type string - Status string - Node string - NodeStatus string - ConfigPath string - ConsolePath string -} - -// used in retriving cluster tasks -type Task struct { - Type string - Node string - User string - ID string - VMID uint - Status string - EndTime uint -} - -type InstanceStatus struct { - Status string -} - func GetClusterResources(auth common.Auth) (map[uint]InstanceCard, map[string]Node, error) { ctx := common.RequestContext{ Cookies: map[string]string{ diff --git a/web/html/index.html b/web/html/index.html index 48698f4..3854de9 100644 --- a/web/html/index.html +++ b/web/html/index.html @@ -35,7 +35,7 @@