added server ref
This commit is contained in:
parent
b4a538849a
commit
78911eca56
4 changed files with 107 additions and 68 deletions
28
node.go
28
node.go
|
|
@ -25,15 +25,15 @@ const (
|
|||
)
|
||||
|
||||
type Node struct {
|
||||
Name string `json:"node"`
|
||||
Status NodeStatus `json:"status"`
|
||||
CPU float64 `json:"cpu"`
|
||||
MaxCPU float64 `json:"maxcpu"`
|
||||
Mem uint64 `json:"mem"`
|
||||
MaxMem uint64 `json:"maxmem"`
|
||||
Disk uint64 `json:"disk"`
|
||||
MaxDisk uint64 `json:"maxdisk"`
|
||||
serverList ServerList `json:"-"`
|
||||
Name string `json:"node"`
|
||||
Status NodeStatus `json:"status"`
|
||||
CPU float64 `json:"cpu"`
|
||||
MaxCPU float64 `json:"maxcpu"`
|
||||
Mem uint64 `json:"mem"`
|
||||
MaxMem uint64 `json:"maxmem"`
|
||||
Disk uint64 `json:"disk"`
|
||||
MaxDisk uint64 `json:"maxdisk"`
|
||||
serverList ServerRefList `json:"-"`
|
||||
}
|
||||
|
||||
func (n *Node) memFreePercent() float64 {
|
||||
|
|
@ -191,7 +191,7 @@ func (c *NodeClient) List(ctx context.Context) (nl NodeList, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (c *NodeClient) ListServers(ctx context.Context, n *Node) (sl ServerList, err error) {
|
||||
func (c *NodeClient) ListServers(ctx context.Context, n *Node) (sl ServerRefList, err error) {
|
||||
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("/nodes/%s/qemu", n.Name), nil)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -205,7 +205,7 @@ func (c *NodeClient) ListServers(ctx context.Context, n *Node) (sl ServerList, e
|
|||
return
|
||||
}
|
||||
|
||||
func (c *NodeClient) FindServer(ctx context.Context, name, id string) (s *Server, err error) {
|
||||
func (c *NodeClient) FindServer(ctx context.Context, name, id string) (s *ServerRef, err error) {
|
||||
nl, err := c.List(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -240,11 +240,11 @@ func (c *NodeClient) FindServer(ctx context.Context, name, id string) (s *Server
|
|||
return nil, ErrServerNotFound
|
||||
}
|
||||
|
||||
func (c *NodeClient) FindServerByName(ctx context.Context, name string) (s *Server, err error) {
|
||||
func (c *NodeClient) FindServerByName(ctx context.Context, name string) (s *ServerRef, err error) {
|
||||
return c.FindServer(ctx, name, "")
|
||||
}
|
||||
|
||||
func (c *NodeClient) FindServerByID(ctx context.Context, id string) (s *Server, err error) {
|
||||
func (c *NodeClient) FindServerByID(ctx context.Context, id string) (s *ServerRef, err error) {
|
||||
if id == "" {
|
||||
err = ErrEmptyID
|
||||
return
|
||||
|
|
@ -252,7 +252,7 @@ func (c *NodeClient) FindServerByID(ctx context.Context, id string) (s *Server,
|
|||
return c.FindServer(ctx, "", id)
|
||||
}
|
||||
|
||||
func (c *NodeClient) FindServerByURL(ctx context.Context, url string) (s *Server, err error) {
|
||||
func (c *NodeClient) FindServerByURL(ctx context.Context, url string) (s *ServerRef, err error) {
|
||||
_, _, id, err := ParseURL(url)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue