make diskname optional
This commit is contained in:
parent
aee5ce47a2
commit
aa780c9d7e
1 changed files with 9 additions and 5 deletions
14
server.go
14
server.go
|
|
@ -94,9 +94,9 @@ func (m Memory) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Disk struct {
|
type Disk struct {
|
||||||
Storage string `json:"storage"`
|
Storage string `json:"storage"`
|
||||||
Name string `json:"name"`
|
Name *string `json:"name,omitempty"`
|
||||||
Size uint64 `json:"size"`
|
Size uint64 `json:"size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Disk) String() string {
|
func (d Disk) String() string {
|
||||||
|
|
@ -146,7 +146,7 @@ func (sc serverConfig) Server(node, id string) (s *Server, err error) {
|
||||||
}
|
}
|
||||||
case "bootdisk":
|
case "bootdisk":
|
||||||
if v, ok := sc[k].(string); ok {
|
if v, ok := sc[k].(string); ok {
|
||||||
s.Resources.Disk.Name = v
|
s.Resources.Disk.Name = &v
|
||||||
if val, ok := sc[v].(string); ok {
|
if val, ok := sc[v].(string); ok {
|
||||||
vals := strings.Split(val, ",")
|
vals := strings.Split(val, ",")
|
||||||
if len(vals) > 0 {
|
if len(vals) > 0 {
|
||||||
|
|
@ -416,8 +416,12 @@ func (c *ServerClient) updateConfig(ctx context.Context, s *Server, body httpbod
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ServerClient) resizeDisk(ctx context.Context, s *Server) (err error) {
|
func (c *ServerClient) resizeDisk(ctx context.Context, s *Server) (err error) {
|
||||||
|
diskName := ""
|
||||||
|
if s.Resources.Disk.Name != nil {
|
||||||
|
diskName = s.Resources.Disk.Name
|
||||||
|
}
|
||||||
body := httpbody{
|
body := httpbody{
|
||||||
"disk": s.Resources.Disk.Name,
|
"disk": diskName,
|
||||||
"size": s.Resources.Disk.String(),
|
"size": s.Resources.Disk.String(),
|
||||||
}
|
}
|
||||||
req, err := c.client.NewRequest(ctx, "PUT", fmt.Sprintf("/nodes/%s/qemu/%s/resize", s.Node, s.ID), body.Reader())
|
req, err := c.client.NewRequest(ctx, "PUT", fmt.Sprintf("/nodes/%s/qemu/%s/resize", s.Node, s.ID), body.Reader())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue