diff --git a/models/model/host.go b/models/model/host.go index 575d865c..d4a06628 100644 --- a/models/model/host.go +++ b/models/model/host.go @@ -51,6 +51,7 @@ func (host *Host) ToVerboseDTO() body.HostVerboseRead { Enabled: host.Enabled, Schedulable: host.Schedulable, DeactivatedUntil: host.DeactivatedUntil, + LastSeenAt: host.LastSeenAt, RegisteredAt: host.RegisteredAt, } } diff --git a/routers/api/v2/hosts.go b/routers/api/v2/hosts.go index 850c328b..97b38a1d 100644 --- a/routers/api/v2/hosts.go +++ b/routers/api/v2/hosts.go @@ -56,7 +56,7 @@ func VerboseListHosts(c *gin.Context) { return } - hostInfo, err := service.V2().System().ListHosts() + hostInfo, err := service.V2().System().ListAllHosts() if err != nil { context.ServerError(err, fmt.Errorf("failed to get host info")) } diff --git a/service/v2/api/api_client.go b/service/v2/api/api_client.go index f3ee9d94..cae6f12a 100644 --- a/service/v2/api/api_client.go +++ b/service/v2/api/api_client.go @@ -2,6 +2,8 @@ package api import ( "context" + "time" + "github.com/kthcloud/go-deploy/dto/v2/body" configModels "github.com/kthcloud/go-deploy/models/config" "github.com/kthcloud/go-deploy/models/model" @@ -18,7 +20,6 @@ import ( userOpts "github.com/kthcloud/go-deploy/service/v2/users/opts" vmK8sService "github.com/kthcloud/go-deploy/service/v2/vms/k8s_service" vmOpts "github.com/kthcloud/go-deploy/service/v2/vms/opts" - "time" ) type Deployments interface { @@ -195,6 +196,7 @@ type System interface { RegisterNode(params *body.HostRegisterParams) error ListHosts() ([]model.Host, error) + ListAllHosts() ([]model.Host, error) GetZone(name string) *configModels.Zone ListZones(opts ...systemOpts.ListOpts) ([]configModels.Zone, error) diff --git a/service/v2/system/host_service.go b/service/v2/system/host_service.go index f6079b6c..36b4780d 100644 --- a/service/v2/system/host_service.go +++ b/service/v2/system/host_service.go @@ -14,3 +14,13 @@ func (c *Client) ListHosts() ([]model.Host, error) { return hosts, nil } + +// ListAllHosts gets a list of all hosts +func (c *Client) ListAllHosts() ([]model.Host, error) { + hosts, err := host_repo.New().List() + if err != nil { + return nil, err + } + + return hosts, nil +}