4.8.0
This commit is contained in:
@@ -150,6 +150,7 @@ func flattenVinsVNFDev(vd vins.VNFDev) []map[string]interface{} {
|
||||
"status": vd.Status,
|
||||
"tech_status": vd.TechStatus,
|
||||
"type": vd.Type,
|
||||
"vnc_password": vd.VNCPassword,
|
||||
"vins": vd.VINS,
|
||||
}
|
||||
res = append(res, temp)
|
||||
@@ -371,14 +372,12 @@ func flattenVinsListReservations(li vins.ListReservations) []map[string]interfac
|
||||
res := make([]map[string]interface{}, 0, len(li))
|
||||
for _, v := range li {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": v.ClientType,
|
||||
"description": v.Description,
|
||||
"domain_name": v.DomainName,
|
||||
"host_name": v.Hostname,
|
||||
"ip": v.IP,
|
||||
"mac": v.MAC,
|
||||
"type": v.Type,
|
||||
"vm_id": v.VMID,
|
||||
//TODO
|
||||
//"account_id": v.AccountID,
|
||||
"ip": v.IP,
|
||||
"mac": v.MAC,
|
||||
"type": v.Type,
|
||||
"vm_id": v.VMID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
@@ -38,14 +38,12 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func resourceStaticRouteCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
@@ -64,19 +62,6 @@ func resourceStaticRouteCreate(ctx context.Context, d *schema.ResourceData, m in
|
||||
Gateway: d.Get("gateway").(string),
|
||||
}
|
||||
|
||||
if computesIDS, ok := d.GetOk("compute_ids"); ok {
|
||||
ids := computesIDS.([]interface{})
|
||||
|
||||
res := make([]uint64, 10)
|
||||
|
||||
for _, id := range ids {
|
||||
computeId := uint64(id.(int))
|
||||
res = append(res, computeId)
|
||||
}
|
||||
|
||||
req.ComputeIds = res
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().VINS().StaticRouteAdd(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
@@ -108,30 +93,7 @@ func resourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m inte
|
||||
}
|
||||
|
||||
func resourceStaticRouteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceStaticRouteUpdate: called for static route id %s", d.Id())
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
if diags := checkParamsExistenceStaticRoute(ctx, d, c); diags != nil {
|
||||
return diags
|
||||
}
|
||||
|
||||
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
warnings := dc.Warnings{}
|
||||
if d.HasChange("compute_ids") {
|
||||
if errs := resourceStaticRouteChangeComputeIds(ctx, d, m, staticRouteData); len(errs) != 0 {
|
||||
for _, err := range errs {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return append(warnings.Get(), resourceStaticRouteRead(ctx, d, m)...)
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceStaticRouteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
@@ -158,61 +120,6 @@ func resourceStaticRouteDelete(ctx context.Context, d *schema.ResourceData, m in
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceStaticRouteChangeComputeIds(ctx context.Context, d *schema.ResourceData, m interface{}, staticRouteData *vins.ItemRoutes) []error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
var errs []error
|
||||
|
||||
vinsId := uint64(d.Get("vins_id").(int))
|
||||
|
||||
deletedIds := make([]uint64, 0)
|
||||
addedIds := make([]uint64, 0)
|
||||
|
||||
oldComputeIds, newComputeIds := d.GetChange("compute_ids")
|
||||
oldComputeIdsSlice := oldComputeIds.([]interface{})
|
||||
newComputeIdsSlice := newComputeIds.([]interface{})
|
||||
|
||||
for _, el := range oldComputeIdsSlice {
|
||||
if !isContainsIds(newComputeIdsSlice, el) {
|
||||
convertedEl := uint64(el.(int))
|
||||
deletedIds = append(deletedIds, convertedEl)
|
||||
}
|
||||
}
|
||||
|
||||
for _, el := range newComputeIdsSlice {
|
||||
if !isContainsIds(oldComputeIdsSlice, el) {
|
||||
convertedEl := uint64(el.(int))
|
||||
addedIds = append(addedIds, convertedEl)
|
||||
}
|
||||
}
|
||||
|
||||
if len(deletedIds) > 0 {
|
||||
req := vins.StaticRouteAccessRevokeRequest{
|
||||
VINSID: vinsId,
|
||||
RouteId: staticRouteData.ID,
|
||||
ComputeIds: deletedIds,
|
||||
}
|
||||
|
||||
if _, err := c.CloudBroker().VINS().StaticRouteAccessRevoke(ctx, req); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(addedIds) > 0 {
|
||||
req := vins.StaticRouteAccessGrantRequest{
|
||||
VINSID: vinsId,
|
||||
RouteId: staticRouteData.ID,
|
||||
ComputeIds: addedIds,
|
||||
}
|
||||
|
||||
if _, err := c.CloudBroker().VINS().StaticRouteAccessGrant(ctx, req); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
return errs
|
||||
}
|
||||
|
||||
func isContainsIds(els []interface{}, el interface{}) bool {
|
||||
convEl := el.(int)
|
||||
for _, elOld := range els {
|
||||
|
||||
@@ -341,6 +341,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "type",
|
||||
},
|
||||
"vnc_password": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vins": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -2509,6 +2513,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "type",
|
||||
},
|
||||
"vnc_password": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vins": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -3389,7 +3397,6 @@ func resourceStaticRouteSchemaMake() map[string]*schema.Schema {
|
||||
"compute_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user