Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aac56e22b8 | ||
|
|
3c2eb0407c | ||
|
|
d776a86303 |
@@ -2,6 +2,8 @@
|
|||||||
- changing boot\_disk\_size in kvmvm
|
- changing boot\_disk\_size in kvmvm
|
||||||
- downsizing CPU and RAM in kvmvm
|
- downsizing CPU and RAM in kvmvm
|
||||||
- pfw recreation if public\_port\_end unspecified
|
- pfw recreation if public\_port\_end unspecified
|
||||||
|
- uninformative error message when retrying on 500
|
||||||
|
- hardcoded 3 minute timeout
|
||||||
|
|
||||||
### New datasources
|
### New datasources
|
||||||
- disk\_list
|
- disk\_list
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ package decort
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -140,12 +139,9 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|||||||
transCfg := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} //nolint:gosec
|
transCfg := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} //nolint:gosec
|
||||||
ret_config.cc_client = &http.Client{
|
ret_config.cc_client = &http.Client{
|
||||||
Transport: transCfg,
|
Transport: transCfg,
|
||||||
Timeout: Timeout180s,
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret_config.cc_client = &http.Client{
|
ret_config.cc_client = &http.Client{}
|
||||||
Timeout: Timeout180s, // time.Second * 30,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ret_config.auth_mode_code {
|
switch ret_config.auth_mode_code {
|
||||||
@@ -379,13 +375,15 @@ func (config *ControllerCfg) decortAPICall(method string, api_name string, url_v
|
|||||||
req.Header.Set("Authorization", fmt.Sprintf("bearer %s", config.jwt))
|
req.Header.Set("Authorization", fmt.Sprintf("bearer %s", config.jwt))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var resp *http.Response
|
||||||
|
var body []byte
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
resp, err := config.cc_client.Do(req)
|
resp, err = config.cc_client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err = ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -405,5 +403,6 @@ func (config *ControllerCfg) decortAPICall(method string, api_name string, url_v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", errors.New("number of retries exceeded")
|
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
|
||||||
|
resp.StatusCode, req.URL, params_str, body)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ package decort
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
// "net/url"
|
// "net/url"
|
||||||
@@ -96,6 +97,16 @@ func parseBootDiskId(disks []DiskRecord) uint {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func findBootDisk(disks []DiskRecord) (*DiskRecord, error) {
|
||||||
|
for _, d := range disks {
|
||||||
|
if d.Type == "B" {
|
||||||
|
return &d, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errors.New("boot disk not found")
|
||||||
|
}
|
||||||
|
|
||||||
// Parse the list of interfaces from compute/get response into a list of networks
|
// Parse the list of interfaces from compute/get response into a list of networks
|
||||||
// attached to this compute
|
// attached to this compute
|
||||||
func parseComputeInterfacesToNetworks(ifaces []InterfaceRecord) []interface{} {
|
func parseComputeInterfacesToNetworks(ifaces []InterfaceRecord) []interface{} {
|
||||||
@@ -148,8 +159,6 @@ func flattenCompute(d *schema.ResourceData, compFacts string) error {
|
|||||||
d.Set("cpu", model.Cpu)
|
d.Set("cpu", model.Cpu)
|
||||||
d.Set("ram", model.Ram)
|
d.Set("ram", model.Ram)
|
||||||
// d.Set("boot_disk_size", model.BootDiskSize) - bootdiskSize key in API compute/get is always zero, so we set boot_disk_size in another way
|
// d.Set("boot_disk_size", model.BootDiskSize) - bootdiskSize key in API compute/get is always zero, so we set boot_disk_size in another way
|
||||||
d.Set("boot_disk_size", parseBootDiskSize(model.Disks))
|
|
||||||
d.Set("boot_disk_id", parseBootDiskId(model.Disks)) // we may need boot disk ID in resize operations
|
|
||||||
d.Set("image_id", model.ImageID)
|
d.Set("image_id", model.ImageID)
|
||||||
d.Set("description", model.Desc)
|
d.Set("description", model.Desc)
|
||||||
d.Set("cloud_init", "applied") // NOTE: for existing compute we hard-code this value as an indicator for DiffSuppress fucntion
|
d.Set("cloud_init", "applied") // NOTE: for existing compute we hard-code this value as an indicator for DiffSuppress fucntion
|
||||||
@@ -162,6 +171,16 @@ func flattenCompute(d *schema.ResourceData, compFacts string) error {
|
|||||||
d.Set("started", false)
|
d.Set("started", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bootDisk, err := findBootDisk(model.Disks)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Set("boot_disk_size", bootDisk.SizeMax)
|
||||||
|
d.Set("boot_disk_id", bootDisk.ID) // we may need boot disk ID in resize operations
|
||||||
|
d.Set("sep_id", bootDisk.SepID)
|
||||||
|
d.Set("pool", bootDisk.Pool)
|
||||||
|
|
||||||
if len(model.Disks) > 0 {
|
if len(model.Disks) > 0 {
|
||||||
log.Debugf("flattenCompute: calling parseComputeDisksToExtraDisks for %d disks", len(model.Disks))
|
log.Debugf("flattenCompute: calling parseComputeDisksToExtraDisks for %d disks", len(model.Disks))
|
||||||
if err = d.Set("extra_disks", parseComputeDisksToExtraDisks(model.Disks)); err != nil {
|
if err = d.Set("extra_disks", parseComputeDisksToExtraDisks(model.Disks)); err != nil {
|
||||||
|
|||||||
@@ -75,6 +75,13 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
|
|||||||
urlValues.Add("desc", argVal.(string))
|
urlValues.Add("desc", argVal.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sepID, ok := d.GetOk("sep_id"); ok {
|
||||||
|
urlValues.Add("sepId", strconv.Itoa(sepID.(int)))
|
||||||
|
}
|
||||||
|
|
||||||
|
if pool, ok := d.GetOk("pool"); ok {
|
||||||
|
urlValues.Add("pool", pool.(string))
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
sshKeysVal, sshKeysSet := d.GetOk("ssh_keys")
|
sshKeysVal, sshKeysSet := d.GetOk("ssh_keys")
|
||||||
if sshKeysSet {
|
if sshKeysSet {
|
||||||
@@ -456,6 +463,22 @@ func resourceCompute() *schema.Resource {
|
|||||||
Description: "This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.",
|
Description: "This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "ID of SEP to create bootDisk on. Uses image's sepId if not set.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"pool": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "Pool to use if sepId is set, can be also empty if needed to be chosen by system.",
|
||||||
|
},
|
||||||
|
|
||||||
"extra_disks": {
|
"extra_disks": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user