Correctly return servers installed on wings and their resource usage
This commit is contained in:
parent
b691b8f06f
commit
b448310a33
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/pterodactyl/wings/config"
|
"github.com/pterodactyl/wings/config"
|
||||||
"github.com/pterodactyl/wings/installer"
|
"github.com/pterodactyl/wings/installer"
|
||||||
"github.com/pterodactyl/wings/router/middleware"
|
"github.com/pterodactyl/wings/router/middleware"
|
||||||
|
"github.com/pterodactyl/wings/server"
|
||||||
"github.com/pterodactyl/wings/system"
|
"github.com/pterodactyl/wings/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,15 +29,20 @@ func getSystemInformation(c *gin.Context) {
|
||||||
// Returns all of the servers that are registered and configured correctly on
|
// Returns all of the servers that are registered and configured correctly on
|
||||||
// this wings instance.
|
// this wings instance.
|
||||||
func getAllServers(c *gin.Context) {
|
func getAllServers(c *gin.Context) {
|
||||||
servers := middleware.ExtractManager(c).All()
|
type serverItem struct {
|
||||||
var procData []serverProcData
|
*server.Configuration
|
||||||
for _, v := range servers {
|
Resources server.ResourceUsage `json:"resources"`
|
||||||
procData = append(procData, serverProcData{
|
|
||||||
ResourceUsage: v.Proc(),
|
|
||||||
Suspended: v.IsSuspended(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, procData)
|
|
||||||
|
servers := middleware.ExtractManager(c).All()
|
||||||
|
out := make([]serverItem, len(servers), len(servers))
|
||||||
|
for i, v := range servers {
|
||||||
|
out[i] = serverItem{
|
||||||
|
Configuration: v.Config(),
|
||||||
|
Resources: v.Proc(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new server on the wings daemon and begins the installation process
|
// Creates a new server on the wings daemon and begins the installation process
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
type EggConfiguration struct {
|
type EggConfiguration struct {
|
||||||
// The internal UUID of the Egg on the Panel.
|
// The internal UUID of the Egg on the Panel.
|
||||||
ID string
|
ID string `json:"id"`
|
||||||
|
|
||||||
// Maintains a list of files that are blacklisted for opening/editing/downloading
|
// Maintains a list of files that are blacklisted for opening/editing/downloading
|
||||||
// or basically any type of access on the server by any user. This is NOT the same
|
// or basically any type of access on the server by any user. This is NOT the same
|
||||||
|
@ -43,7 +43,6 @@ type Configuration struct {
|
||||||
Build environment.Limits `json:"build"`
|
Build environment.Limits `json:"build"`
|
||||||
CrashDetectionEnabled bool `default:"true" json:"enabled" yaml:"enabled"`
|
CrashDetectionEnabled bool `default:"true" json:"enabled" yaml:"enabled"`
|
||||||
Mounts []Mount `json:"mounts"`
|
Mounts []Mount `json:"mounts"`
|
||||||
Resources ResourceUsage `json:"resources"`
|
|
||||||
Egg EggConfiguration `json:"egg,omitempty"`
|
Egg EggConfiguration `json:"egg,omitempty"`
|
||||||
|
|
||||||
Container struct {
|
Container struct {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user