Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
739289fbb8 | ||
|
|
c89574c3e6 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@ examples/
|
||||
url_scrapping/
|
||||
terraform-provider-decort*
|
||||
.vscode/
|
||||
.DS_Store
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
## Version 4.3.6
|
||||
## Version 4.3.8
|
||||
|
||||
## Bugfix
|
||||
- Fixed bug with disks resize error
|
||||
- Fixed bugs with restore and newCreate after destroy
|
||||
|
||||
|
||||
2
Makefile
2
Makefile
@@ -7,7 +7,7 @@ ZIPDIR = ./zip
|
||||
BINARY=${NAME}
|
||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||
MAINPATH = ./cmd/decort/
|
||||
VERSION=4.3.6
|
||||
VERSION=4.3.8
|
||||
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||
|
||||
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||
|
||||
2
go.mod
2
go.mod
@@ -9,7 +9,7 @@ require (
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
golang.org/x/net v0.12.0
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.3
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.10
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
4
go.sum
4
go.sum
@@ -339,5 +339,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.3 h1:Rt5tE4EZcUr4ONK9u/XYe2mG1CC37xLUnNuCLYKDwYs=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.3/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.10 h1:LnnOxO8QxSaIfetrzivmRf7qBZJkiakHD0FJLYYAvv8=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.10/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||
|
||||
@@ -54,7 +54,7 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceAccountRead: called for account with ID: %v", d.Id())
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
|
||||
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
@@ -67,22 +67,23 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
switch acc.Status {
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceAccountCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceAccountCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
||||
case status.Deleted:
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
req := account.RestoreRequest{
|
||||
AccountID: id,
|
||||
}
|
||||
// req := account.RestoreRequest{
|
||||
// AccountID: id,
|
||||
// }
|
||||
|
||||
_, err := c.CloudAPI().Account().Restore(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().Account().Restore(ctx, req)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Disabled:
|
||||
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
||||
case status.Confirmed:
|
||||
@@ -142,7 +143,8 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
switch acc.Status {
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceAccountCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceAccountCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
||||
case status.Deleted:
|
||||
|
||||
@@ -83,7 +83,7 @@ func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m i
|
||||
func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceBasicServiceRead")
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
|
||||
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
@@ -104,29 +104,30 @@ func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m int
|
||||
case status.Disabling:
|
||||
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
|
||||
case status.Deleted:
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
restoreReq := bservice.RestoreRequest{
|
||||
ServiceID: id,
|
||||
}
|
||||
enableReq := bservice.EnableRequest{
|
||||
ServiceID: id,
|
||||
}
|
||||
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
// restoreReq := bservice.RestoreRequest{
|
||||
// ServiceID: id,
|
||||
// }
|
||||
// enableReq := bservice.EnableRequest{
|
||||
// ServiceID: id,
|
||||
// }
|
||||
|
||||
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
_, err = c.CloudAPI().BService().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err = c.CloudAPI().BService().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Deleting:
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceBasicServiceCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceBasicServiceCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
|
||||
case status.Restoring:
|
||||
@@ -224,7 +225,8 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
|
||||
case status.Deleting:
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceBasicServiceCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceBasicServiceCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
|
||||
case status.Restoring:
|
||||
|
||||
@@ -142,7 +142,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
|
||||
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||
@@ -157,23 +157,24 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
case status.Destroyed, status.Purged:
|
||||
d.Set("disk_id", 0)
|
||||
d.SetId("")
|
||||
return resourceDiskCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceDiskCreate(ctx, d, m)
|
||||
case status.Deleted:
|
||||
hasChangeState = true
|
||||
req := disks.RestoreRequest{
|
||||
DiskID: disk.ID,
|
||||
}
|
||||
// hasChangeState = true
|
||||
// req := disks.RestoreRequest{
|
||||
// DiskID: disk.ID,
|
||||
// }
|
||||
|
||||
if reason, ok := d.GetOk("reason"); ok {
|
||||
req.Reason = reason.(string)
|
||||
} else {
|
||||
req.Reason = "Terraform automatic restore"
|
||||
}
|
||||
// if reason, ok := d.GetOk("reason"); ok {
|
||||
// req.Reason = reason.(string)
|
||||
// } else {
|
||||
// req.Reason = "Terraform automatic restore"
|
||||
// }
|
||||
|
||||
_, err := c.CloudAPI().Disks().Restore(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().Disks().Restore(ctx, req)
|
||||
// if err != nil {
|
||||
// warnings.Add(err)
|
||||
// }
|
||||
case status.Assigned:
|
||||
case status.Modeled:
|
||||
return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status)
|
||||
@@ -227,7 +228,8 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
case status.Destroyed, status.Purged:
|
||||
d.Set("disk_id", 0)
|
||||
d.SetId("")
|
||||
return resourceDiskCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceDiskCreate(ctx, d, m)
|
||||
case status.Deleted:
|
||||
hasChangeState = true
|
||||
req := disks.RestoreRequest{
|
||||
|
||||
@@ -144,7 +144,8 @@ func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
case status.Created:
|
||||
case status.Destroyed, status.Purged:
|
||||
d.SetId("")
|
||||
return resourceImageCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceImageCreate(ctx, d, m)
|
||||
}
|
||||
|
||||
flattenImage(d, img)
|
||||
@@ -233,7 +234,8 @@ func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
case status.Created:
|
||||
case status.Destroyed, status.Purged:
|
||||
d.SetId("")
|
||||
return resourceImageCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceImageCreate(ctx, d, m)
|
||||
}
|
||||
|
||||
if d.HasChange("name") {
|
||||
|
||||
@@ -205,31 +205,32 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
case status.Created:
|
||||
case status.Deleting:
|
||||
case status.Deleted:
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
restoreReq := k8s.RestoreRequest{
|
||||
K8SID: id,
|
||||
}
|
||||
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
// restoreReq := k8s.RestoreRequest{
|
||||
// K8SID: id,
|
||||
// }
|
||||
|
||||
_, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
enableReq := k8s.DisableEnableRequest{
|
||||
K8SID: id,
|
||||
}
|
||||
// enableReq := k8s.DisableEnableRequest{
|
||||
// K8SID: id,
|
||||
// }
|
||||
|
||||
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceK8sCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceK8sCreate(ctx, d, m)
|
||||
case status.Enabling:
|
||||
case status.Enabled:
|
||||
case status.Disabling:
|
||||
@@ -388,7 +389,8 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceK8sCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceK8sCreate(ctx, d, m)
|
||||
case status.Enabling:
|
||||
case status.Enabled:
|
||||
case status.Disabling:
|
||||
|
||||
@@ -204,31 +204,32 @@ func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
case status.Created:
|
||||
case status.Deleting:
|
||||
case status.Deleted:
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
restoreReq := k8s.RestoreRequest{
|
||||
K8SID: id,
|
||||
}
|
||||
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
// restoreReq := k8s.RestoreRequest{
|
||||
// K8SID: id,
|
||||
// }
|
||||
|
||||
_, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
enableReq := k8s.DisableEnableRequest{
|
||||
K8SID: id,
|
||||
}
|
||||
// enableReq := k8s.DisableEnableRequest{
|
||||
// K8SID: id,
|
||||
// }
|
||||
|
||||
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceK8sCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceK8sCreate(ctx, d, m)
|
||||
case status.Enabling:
|
||||
case status.Enabled:
|
||||
case status.Disabling:
|
||||
@@ -387,7 +388,8 @@ func resourceK8sCPUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceK8sCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceK8sCreate(ctx, d, m)
|
||||
case status.Enabling:
|
||||
case status.Enabled:
|
||||
case status.Disabling:
|
||||
|
||||
@@ -496,7 +496,7 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
log.Debugf("resourceComputeRead: called for Compute name %s, RG ID %d",
|
||||
d.Get("name").(string), d.Get("rg_id").(int))
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
|
||||
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
@@ -507,23 +507,24 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
|
||||
switch computeRec.Status {
|
||||
case status.Deleted:
|
||||
restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID}
|
||||
enableReq := compute.EnableRequest{ComputeID: computeRec.ID}
|
||||
// restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID}
|
||||
// enableReq := compute.EnableRequest{ComputeID: computeRec.ID}
|
||||
|
||||
_, err := c.CloudAPI().Compute().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().Compute().Restore(ctx, restoreReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
_, err = c.CloudAPI().Compute().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err = c.CloudAPI().Compute().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceComputeCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceComputeCreate(ctx, d, m)
|
||||
case status.Disabled:
|
||||
log.Debugf("The compute is in status: %s, troubles may occur with update. Please, enable compute first.", computeRec.Status)
|
||||
case status.Redeploying:
|
||||
@@ -642,7 +643,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceComputeCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceComputeCreate(ctx, d, m)
|
||||
case status.Disabled:
|
||||
log.Debugf("The compute is in status: %s, may troubles can be occured with update. Please, enable compute first.", computeRec.Status)
|
||||
case status.Redeploying:
|
||||
|
||||
@@ -128,7 +128,7 @@ func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBRead")
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
|
||||
lbRec, err := utilityLBCheckPresence(ctx, d, m)
|
||||
if lbRec == nil {
|
||||
@@ -145,25 +145,26 @@ func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
case status.Created:
|
||||
case status.Deleting:
|
||||
case status.Deleted:
|
||||
lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
restoreReq := lb.RestoreRequest{LBID: lbId}
|
||||
enableReq := lb.DisableEnableRequest{LBID: lbId}
|
||||
// lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
// restoreReq := lb.RestoreRequest{LBID: lbId}
|
||||
// enableReq := lb.DisableEnableRequest{LBID: lbId}
|
||||
|
||||
_, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
_, err = c.CloudAPI().LB().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
// _, err = c.CloudAPI().LB().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Destroying:
|
||||
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceLBCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceLBCreate(ctx, d, m)
|
||||
case status.Enabled:
|
||||
case status.Enabling:
|
||||
case status.Disabling:
|
||||
@@ -276,7 +277,8 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceLBCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceLBCreate(ctx, d, m)
|
||||
case status.Enabled:
|
||||
case status.Enabling:
|
||||
case status.Disabling:
|
||||
|
||||
@@ -256,7 +256,7 @@ func resourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
log.Debugf("resourceResgroupRead: called for RG name %s, account ID %d",
|
||||
d.Get("name").(string), d.Get("account_id").(int))
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
|
||||
rgData, err := utilityResgroupCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
@@ -272,24 +272,25 @@ func resourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
case status.Created:
|
||||
case status.Enabled:
|
||||
case status.Deleted:
|
||||
restoreReq := rg.RestoreRequest{RGID: rgData.ID}
|
||||
enableReq := rg.EnableRequest{RGID: rgData.ID}
|
||||
// restoreReq := rg.RestoreRequest{RGID: rgData.ID}
|
||||
// enableReq := rg.EnableRequest{RGID: rgData.ID}
|
||||
|
||||
_, err := c.CloudAPI().RG().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().RG().Restore(ctx, restoreReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
_, err = c.CloudAPI().RG().Enable(ctx, enableReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
// _, err = c.CloudAPI().RG().Enable(ctx, enableReq)
|
||||
// if err != nil {
|
||||
// return diag.FromErr(err)
|
||||
// }
|
||||
|
||||
hasChanged = true
|
||||
// hasChanged = true
|
||||
case status.Deleting:
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceResgroupCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceResgroupCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
case status.Disabled:
|
||||
case status.Disabling:
|
||||
@@ -369,7 +370,8 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter
|
||||
case status.Deleting:
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceResgroupCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceResgroupCreate(ctx, d, m)
|
||||
case status.Destroying:
|
||||
case status.Disabled:
|
||||
case status.Disabling:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,8 +34,8 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
@@ -47,8 +47,9 @@ func dataSourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(vins.ID, 10))
|
||||
flattenVinsData(d, *vins)
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
flattenVinsData(d, vins)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -640,7 +641,7 @@ func rulesSchemaMake() map[string]*schema.Schema {
|
||||
}
|
||||
}
|
||||
|
||||
func configSchrmaMake() map[string]*schema.Schema {
|
||||
func natConfigSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"net_mask": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -678,7 +679,7 @@ func natSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: configSchrmaMake(),
|
||||
Schema: natConfigSchemaMake(),
|
||||
},
|
||||
},
|
||||
"devices": {
|
||||
@@ -768,7 +769,6 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||
},
|
||||
|
||||
"vnf_dev": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -776,10 +776,6 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Schema: vnfDevSchemaMake(),
|
||||
},
|
||||
},
|
||||
"_ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -797,6 +793,14 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Schema: vinsComputeSchemaMake(),
|
||||
},
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"default_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -808,6 +812,14 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Schema: qosSchemaMake(),
|
||||
},
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -874,6 +886,14 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"user_managed": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -49,7 +49,7 @@ func dataSourceVinsExtNetListRead(ctx context.Context, d *schema.ResourceData, m
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsExtNetList(extNetList))
|
||||
|
||||
d.Set("entry_count", extNetList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -92,6 +92,10 @@ func DataSourceVinsExtNetListchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -49,7 +49,7 @@ func dataSourceVinsIpListRead(ctx context.Context, d *schema.ResourceData, m int
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsIpList(ips))
|
||||
|
||||
d.Set("entry_count", ips.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -96,6 +96,10 @@ func DataSourceVinsIpListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -49,6 +49,8 @@ func dataSourceVinsNatRuleListRead(ctx context.Context, d *schema.ResourceData,
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsNatRuleList(natRules))
|
||||
d.Set("entry_count", natRules.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -99,6 +101,10 @@ func DataSourceVinsNatRuleListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -49,7 +49,7 @@ func flattenMGMT(mgmt vins.RecordMGMT) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenResources(resources *vins.RecordResources) []map[string]interface{} {
|
||||
func flattenResources(resources vins.RecordResources) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"cpu": resources.CPU,
|
||||
@@ -65,7 +65,7 @@ func flattenConfig(config vins.RecordVNFConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"mgmt": flattenMGMT(config.MGMT),
|
||||
"resources": flattenResources(&config.Resources),
|
||||
"resources": flattenResources(config.Resources),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
@@ -84,8 +84,7 @@ func flattenQOS(qos vins.QOS) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenInterfaces(interfaces []vins.ItemVNFInterface) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
|
||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
||||
for _, vnfInterface := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"conn_id": vnfInterface.ConnID,
|
||||
@@ -141,7 +140,7 @@ func flattenVNFDev(vnfDev vins.RecordVNFDev) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenComputes(computes vins.ListVINSComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computes))
|
||||
for _, compute := range computes {
|
||||
temp := map[string]interface{}{
|
||||
"compute_id": compute.ID,
|
||||
@@ -154,7 +153,7 @@ func flattenComputes(computes vins.ListVINSComputes) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenReservations(reservations vins.ListReservations) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(reservations))
|
||||
for _, reservation := range reservations {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": reservation.ClientType,
|
||||
@@ -275,9 +274,9 @@ func flattenGW(gw vins.RecordGW) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRules(rules vins.ListNATRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, rule := range rules.Data {
|
||||
func flattenRules(rules vins.ListNATRulesConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(rules))
|
||||
for _, rule := range rules {
|
||||
tmp := map[string]interface{}{
|
||||
"rule_id": rule.ID,
|
||||
"local_ip": rule.LocalIP,
|
||||
@@ -343,9 +342,9 @@ func flattenVNFS(vnfs vins.RecordVNFs) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRuleBlock(rules vins.ListNATRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, rule := range rules.Data {
|
||||
func flattenRuleBlock(rules vins.ListNATRulesConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(rules))
|
||||
for _, rule := range rules {
|
||||
tmp := map[string]interface{}{
|
||||
"int_ip": rule.LocalIP,
|
||||
"int_port": rule.LocalPort,
|
||||
@@ -359,15 +358,18 @@ func flattenRuleBlock(rules vins.ListNATRules) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVins(d *schema.ResourceData, vins vins.RecordVINS) {
|
||||
func flattenVins(d *schema.ResourceData, vins *vins.RecordVINS) {
|
||||
d.Set("vins_id", vins.ID)
|
||||
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||
d.Set("_ckey", vins.CKey)
|
||||
d.Set("account_id", vins.AccountID)
|
||||
d.Set("account_name", vins.AccountName)
|
||||
d.Set("computes", flattenComputes(vins.Computes))
|
||||
d.Set("created_by", vins.CreatedBy)
|
||||
d.Set("created_time", vins.CreatedTime)
|
||||
d.Set("default_gw", vins.DefaultGW)
|
||||
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||
d.Set("deleted_by", vins.DeletedBy)
|
||||
d.Set("deleted_time", vins.DeletedTime)
|
||||
d.Set("desc", vins.Description)
|
||||
d.Set("gid", vins.GID)
|
||||
d.Set("guid", vins.GUID)
|
||||
@@ -384,21 +386,26 @@ func flattenVins(d *schema.ResourceData, vins vins.RecordVINS) {
|
||||
d.Set("rg_name", vins.RGName)
|
||||
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
|
||||
d.Set("status", vins.Status)
|
||||
d.Set("updated_by", vins.UpdatedBy)
|
||||
d.Set("updated_time", vins.UpdatedTime)
|
||||
d.Set("user_managed", vins.UserManaged)
|
||||
d.Set("vnfs", flattenVNFS(vins.VNFs))
|
||||
d.Set("vxlan_id", vins.VXLANID)
|
||||
d.Set("nat_rule", flattenRuleBlock(vins.VNFs.NAT.Config.Rules))
|
||||
}
|
||||
|
||||
func flattenVinsData(d *schema.ResourceData, vins vins.RecordVINS) {
|
||||
func flattenVinsData(d *schema.ResourceData, vins *vins.RecordVINS) {
|
||||
d.Set("vins_id", vins.ID)
|
||||
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||
d.Set("_ckey", vins.CKey)
|
||||
d.Set("account_id", vins.AccountID)
|
||||
d.Set("account_name", vins.AccountName)
|
||||
d.Set("computes", flattenComputes(vins.Computes))
|
||||
d.Set("created_by", vins.CreatedBy)
|
||||
d.Set("created_time", vins.CreatedTime)
|
||||
d.Set("default_gw", vins.DefaultGW)
|
||||
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||
d.Set("deleted_by", vins.DeletedBy)
|
||||
d.Set("deleted_time", vins.DeletedTime)
|
||||
d.Set("desc", vins.Description)
|
||||
d.Set("gid", vins.GID)
|
||||
d.Set("guid", vins.GUID)
|
||||
@@ -415,14 +422,16 @@ func flattenVinsData(d *schema.ResourceData, vins vins.RecordVINS) {
|
||||
d.Set("rg_name", vins.RGName)
|
||||
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
|
||||
d.Set("status", vins.Status)
|
||||
d.Set("updated_by", vins.UpdatedBy)
|
||||
d.Set("updated_time", vins.UpdatedTime)
|
||||
d.Set("user_managed", vins.UserManaged)
|
||||
d.Set("vnfs", flattenVNFS(vins.VNFs))
|
||||
d.Set("vxlan_id", vins.VXLANID)
|
||||
}
|
||||
|
||||
func flattenVinsAudits(auidts vins.ListAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, audit := range auidts {
|
||||
func flattenVinsAudits(audits vins.ListAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(audits))
|
||||
for _, audit := range audits {
|
||||
temp := map[string]interface{}{
|
||||
"call": audit.Call,
|
||||
"response_time": audit.ResponseTime,
|
||||
@@ -437,7 +446,7 @@ func flattenVinsAudits(auidts vins.ListAudits) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenVinsExtNetList(extNetList *vins.ListExtNets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(extNetList.Data))
|
||||
for _, extNet := range extNetList.Data {
|
||||
temp := map[string]interface{}{
|
||||
"default_gw": extNet.DefaultGW,
|
||||
@@ -454,7 +463,7 @@ func flattenVinsExtNetList(extNetList *vins.ListExtNets) []map[string]interface{
|
||||
}
|
||||
|
||||
func flattenVinsIpList(ips *vins.ListIPs) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(ips.Data))
|
||||
for _, ip := range ips.Data {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": ip.ClientType,
|
||||
@@ -472,7 +481,7 @@ func flattenVinsIpList(ips *vins.ListIPs) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(vl.Data))
|
||||
for _, v := range vl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": v.AccountID,
|
||||
@@ -498,7 +507,7 @@ func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenVinsNatRuleList(natRules *vins.ListNATRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(natRules.Data))
|
||||
for _, natRule := range natRules.Data {
|
||||
temp := map[string]interface{}{
|
||||
"id": natRule.ID,
|
||||
|
||||
@@ -129,8 +129,10 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
req.Description = desc.(string)
|
||||
}
|
||||
req.PreReservationsNum = uint(d.Get("pre_reservations_num").(int))
|
||||
|
||||
if preReservationsNum, ok := d.GetOk("pre_reservations_num"); ok {
|
||||
req.PreReservationsNum = uint64(preReservationsNum.(int))
|
||||
}
|
||||
|
||||
id, err := c.CloudAPI().VINS().CreateInRG(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -141,7 +143,6 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
req := vins.CreateInAccountRequest{
|
||||
Name: d.Get("name").(string),
|
||||
AccountID: uint64(accountId.(int)),
|
||||
PreReservationsNum: uint64(d.Get("pre_reservations_num").(int)),
|
||||
}
|
||||
|
||||
if gid, ok := d.GetOk("gid"); ok {
|
||||
@@ -153,7 +154,10 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
req.Description = desc.(string)
|
||||
}
|
||||
|
||||
if preReservationsNum, ok := d.GetOk("pre_reservations_num"); ok {
|
||||
req.PreReservationsNum = uint64(preReservationsNum.(int))
|
||||
}
|
||||
|
||||
id, err := c.CloudAPI().VINS().CreateInAccount(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -214,15 +218,15 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
defer resourceVinsRead(ctx, d, m)
|
||||
return warnings.Get()
|
||||
|
||||
return append(warnings.Get(), resourceVinsRead(ctx, d, m)...)
|
||||
}
|
||||
|
||||
func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
vinsData, err := utilityVinsCheckPresence(ctx, d, m)
|
||||
vinsData, err := utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
@@ -236,18 +240,19 @@ func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
case status.Destroyed:
|
||||
d.Set("vins_id", 0)
|
||||
d.SetId("")
|
||||
return resourceVinsCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceVinsCreate(ctx, d, m)
|
||||
case status.Deleted:
|
||||
hasChangeState = true
|
||||
// hasChangeState = true
|
||||
|
||||
req := vins.RestoreRequest{
|
||||
VINSID: vinsData.ID,
|
||||
}
|
||||
// req := vins.RestoreRequest{
|
||||
// VINSID: vinsData.ID,
|
||||
// }
|
||||
|
||||
_, err := c.CloudAPI().VINS().Restore(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
// _, err := c.CloudAPI().VINS().Restore(ctx, req)
|
||||
// if err != nil {
|
||||
// warnings.Add(err)
|
||||
// }
|
||||
case status.Modeled:
|
||||
return diag.Errorf("ViNS are in status: %s, please, contact support for more information", vinsData.Status)
|
||||
case status.Created:
|
||||
@@ -282,14 +287,14 @@ func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
}
|
||||
|
||||
if hasChangeState {
|
||||
vinsData, err = utilityVinsCheckPresence(ctx, d, m)
|
||||
vinsData, err = utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
flattenVins(d, *vinsData)
|
||||
flattenVins(d, vinsData)
|
||||
|
||||
return warnings.Get()
|
||||
}
|
||||
@@ -366,7 +371,7 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
vinsData, err := utilityVinsCheckPresence(ctx, d, m)
|
||||
vinsData, err := utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
@@ -379,7 +384,8 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
switch vinsData.Status {
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return resourceVinsCreate(ctx, d, m)
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceVinsCreate(ctx, d, m)
|
||||
case status.Deleted:
|
||||
hasChangeState = true
|
||||
|
||||
@@ -425,7 +431,7 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
|
||||
if hasChangeState {
|
||||
vinsData, err = utilityVinsCheckPresence(ctx, d, m)
|
||||
vinsData, err = utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
@@ -631,8 +637,7 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
defer resourceVinsRead(ctx, d, m)
|
||||
return warnings.Get()
|
||||
return append (warnings.Get(), resourceVinsRead(ctx, d, m)...)
|
||||
}
|
||||
|
||||
func resourceVinsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
@@ -658,7 +663,7 @@ func extNetSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"ext_net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Default: 0,
|
||||
Default: -1,
|
||||
Optional: true,
|
||||
},
|
||||
"ext_net_ip": {
|
||||
@@ -674,6 +679,7 @@ func ipSchemaMake() map[string]*schema.Schema {
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string {"DHCP", "VIP", "EXCLUDE"}, false),
|
||||
},
|
||||
"ip_addr": {
|
||||
Type: schema.TypeString,
|
||||
@@ -823,7 +829,6 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
|
||||
rets["vins_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -44,8 +44,13 @@ import (
|
||||
|
||||
func utilityDataVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.RecordVINS, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.GetRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
req := vins.GetRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
vins, err := c.CloudAPI().VINS().Get(ctx, req)
|
||||
@@ -56,17 +61,3 @@ func utilityDataVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
return vins, nil
|
||||
}
|
||||
|
||||
func utilityVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.RecordVINS, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
vinsId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req := vins.GetRequest{
|
||||
VINSID: vinsId,
|
||||
}
|
||||
|
||||
vins, err := c.CloudAPI().VINS().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vins, nil
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,6 +34,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
@@ -42,8 +43,13 @@ import (
|
||||
|
||||
func utilityVinsAuditsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (vins.ListAudits, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.AuditsRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
req := vins.AuditsRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
audits, err := c.CloudAPI().VINS().Audits(ctx, req)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,6 +34,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
@@ -46,6 +47,13 @@ func utilityVinsExtNetListCheckPresence(ctx context.Context, d *schema.ResourceD
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
extNetList, err := c.CloudAPI().VINS().ExtNetList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,6 +34,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
@@ -42,8 +43,13 @@ import (
|
||||
|
||||
func utilityVinsIpListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListIPs, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.IPListRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
req := vins.IPListRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
ips, err := c.CloudAPI().VINS().IPList(ctx, req)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,6 +34,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
@@ -42,8 +43,13 @@ import (
|
||||
|
||||
func utilityVinsNatRuleListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListNATRules, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.NATRuleListRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
req := vins.NATRuleListRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
natRuleList, err := c.CloudAPI().VINS().NATRuleList(ctx, req)
|
||||
|
||||
Reference in New Issue
Block a user