some improvements
This commit is contained in:
parent
501d579a90
commit
d6c9b69b9c
3 changed files with 24 additions and 3 deletions
|
|
@ -6,6 +6,15 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type IPConfigs []*IPConfig
|
||||||
|
|
||||||
|
func (c IPConfigs) Get(index int) *IPConfig {
|
||||||
|
if len(c)-1 >= index {
|
||||||
|
return c[index]
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type IPConfig struct {
|
type IPConfig struct {
|
||||||
IPv4CIDR string
|
IPv4CIDR string
|
||||||
IPv4Gateway string
|
IPv4Gateway string
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,15 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type NetworkDevices []*NetworkDevice
|
||||||
|
|
||||||
|
func (c NetworkDevice) Get(index int) *NetworkDevice {
|
||||||
|
if len(c)-1 >= index {
|
||||||
|
return c[index]
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type NetworkDevice struct {
|
type NetworkDevice struct {
|
||||||
Type string
|
Type string
|
||||||
MACAddress string
|
MACAddress string
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ type Server struct {
|
||||||
Node string
|
Node string
|
||||||
Status ServerStatus `json:"status"`
|
Status ServerStatus `json:"status"`
|
||||||
Resources Resources
|
Resources Resources
|
||||||
NetDevices []*NetworkDevice
|
NetDevices NetworkDevices
|
||||||
IPConfig []*IPConfig
|
IPConfig IPConfigs
|
||||||
Nameserver Nameserver
|
Nameserver Nameserver
|
||||||
SearchDomain string
|
SearchDomain string
|
||||||
UserData *UserData
|
UserData *UserData
|
||||||
|
|
@ -217,7 +217,7 @@ func (o ServerTemplateOpts) body() httpbody {
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ServerClient) CreateFromTemplate(ctx context.Context, opts ServerTemplateOpts) (t *Task, err error) {
|
func (c *ServerClient) CreateFromTemplate(ctx context.Context, opts ServerTemplateOpts) (t *Task, url string, err error) {
|
||||||
err = opts.Validate()
|
err = opts.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
@ -234,6 +234,9 @@ func (c *ServerClient) CreateFromTemplate(ctx context.Context, opts ServerTempla
|
||||||
body["newid"] = nextid
|
body["newid"] = nextid
|
||||||
if tempnode != opts.TargetNode {
|
if tempnode != opts.TargetNode {
|
||||||
body["target"] = opts.TargetNode
|
body["target"] = opts.TargetNode
|
||||||
|
url = NewURL(opts.TargetNode, nextid)
|
||||||
|
} else {
|
||||||
|
url = NewURL(tempnode, nextid)
|
||||||
}
|
}
|
||||||
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("/nodes/%s/qemu/%s/clone", tempnode, id), body.Reader())
|
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("/nodes/%s/qemu/%s/clone", tempnode, id), body.Reader())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue