some fixes

This commit is contained in:
ston1th 2020-06-04 20:24:46 +02:00
commit 07f48d4369

View file

@ -55,11 +55,11 @@ func (s *Server) body() (httpbody, error) {
}
func (s *Server) InstanceID() string {
return s.String()
return NewURL("", s.Node, s.ID)
}
func (s *Server) String() string {
return NewURL(s.Node, s.ID)
func (s *Server) K8sID(pool string) string {
return NewURL(pool, "", s.ID)
}
type Resources struct {
@ -166,7 +166,7 @@ func (c *ServerClient) NextID(ctx context.Context) (id string, err error) {
func (c *ServerClient) getConfig(ctx context.Context, node, id string) (cfg serverConfig, err error) {
cfg = make(serverConfig)
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("/nodes/%s/qemu/%s/config", node, id), nil)
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("/nodes/%s/qemu/%s/config?current=1", node, id), nil)
if err != nil {
return
}
@ -261,10 +261,12 @@ func (c *ServerClient) CreateFromTemplate(ctx context.Context, opts ServerTempla
}
body := opts.body()
body["newid"] = nextid
node := opts.TemplateNode
if opts.TargetNode != "" && opts.TemplateNode != opts.TargetNode {
node = opts.TargetNode
body["target"] = opts.TargetNode
}
url = NewURL(opts.Pool, nextid)
url = NewURL(opts.Pool, node, nextid)
req, err := c.client.NewRequest(ctx, "POST", fmt.Sprintf("/nodes/%s/qemu/%s/clone", opts.TemplateNode, opts.TemplateID), body.Reader())
if err != nil {
return