4.6.0
This commit is contained in:
@@ -108,6 +108,8 @@ func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
|
||||
d.Set("gid", lb.GID)
|
||||
d.Set("guid", lb.GUID)
|
||||
d.Set("lb_id", lb.ID)
|
||||
d.Set("manager_id", lb.ManagerId)
|
||||
d.Set("manager_type", lb.ManagerType)
|
||||
d.Set("image_id", lb.ImageID)
|
||||
d.Set("milestones", lb.Milestones)
|
||||
d.Set("name", lb.Name)
|
||||
@@ -117,6 +119,7 @@ func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
|
||||
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
|
||||
d.Set("status", lb.Status)
|
||||
d.Set("tech_status", lb.TechStatus)
|
||||
d.Set("user_managed", lb.UserManaged)
|
||||
d.Set("vins_id", lb.VINSID)
|
||||
}
|
||||
|
||||
@@ -235,8 +238,11 @@ func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
|
||||
"gid": lb.GID,
|
||||
"guid": lb.GUID,
|
||||
"lb_id": lb.ID,
|
||||
"manager_id": lb.ManagerId,
|
||||
"manager_type": lb.ManagerType,
|
||||
"milestones": lb.Milestones,
|
||||
"name": lb.Name,
|
||||
"part_k8s": lb.PartK8s,
|
||||
"primary_node": flattenNode(lb.PrimaryNode),
|
||||
"rg_id": lb.RGID,
|
||||
"rg_name": lb.RGName,
|
||||
@@ -245,6 +251,7 @@ func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
|
||||
"tech_status": lb.TechStatus,
|
||||
"updated_by": lb.UpdatedBy,
|
||||
"updated_time": lb.UpdatedTime,
|
||||
"user_managed": lb.UserManaged,
|
||||
"vins_id": lb.VINSID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
@@ -34,9 +34,10 @@ package lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||
"strconv"
|
||||
|
||||
"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"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -69,6 +70,22 @@ func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
if haMode, ok := d.GetOk("ha_mode"); ok {
|
||||
req.HighlyAvailable = haMode.(bool)
|
||||
}
|
||||
if sysctlParams, ok := d.GetOk("sysctl_params"); ok {
|
||||
syscrlSliceMaps := sysctlParams.([]map[string]string)
|
||||
res := make([]map[string]interface{}, 0, len(syscrlSliceMaps))
|
||||
for _, syscrlMap := range syscrlSliceMaps {
|
||||
tempMap := make(map[string]interface{})
|
||||
for k, v := range syscrlMap {
|
||||
if intVal, err := strconv.Atoi(v); err == nil {
|
||||
tempMap[k] = intVal
|
||||
continue
|
||||
}
|
||||
tempMap[k] = v
|
||||
}
|
||||
res = append(res, tempMap)
|
||||
}
|
||||
req.SysctlParams = res
|
||||
}
|
||||
|
||||
lbId, err := c.CloudBroker().LB().Create(ctx, req)
|
||||
if err != nil {
|
||||
@@ -286,6 +303,12 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("sysctl_params") {
|
||||
if err := resourceLbChangeSysctlParams(ctx, d, lbRec.ID, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("start") {
|
||||
if err := resourceLbChangeStart(ctx, d, lbRec.ID, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -323,6 +346,31 @@ func resourceLbEnable(ctx context.Context, lbId uint64, m interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func resourceLbChangeSysctlParams(ctx context.Context, d *schema.ResourceData, lbId uint64, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
syscrlSliceMaps := d.Get("sysctl_params").([]map[string]string)
|
||||
res := make([]map[string]interface{}, 0, len(syscrlSliceMaps))
|
||||
for _, syscrlMap := range syscrlSliceMaps {
|
||||
tempMap := make(map[string]interface{})
|
||||
for k, v := range syscrlMap {
|
||||
if intVal, err := strconv.Atoi(v); err == nil {
|
||||
tempMap[k] = intVal
|
||||
continue
|
||||
}
|
||||
tempMap[k] = v
|
||||
}
|
||||
res = append(res, tempMap)
|
||||
}
|
||||
|
||||
req := lb.UpdateSysctParamsRequest{
|
||||
LBID: lbId,
|
||||
SysctlParams: res,
|
||||
}
|
||||
_, err := c.CloudBroker().LB().UpdateSysctlParams(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func resourceLbDisable(ctx context.Context, lbId uint64, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
@@ -429,6 +477,9 @@ func resourceLbChangeRestart(ctx context.Context, d *schema.ResourceData, lbId u
|
||||
req := lb.RestartRequest{
|
||||
LBID: lbId,
|
||||
}
|
||||
if safe, ok := d.GetOk("safe"); ok {
|
||||
req.Safe = safe.(bool)
|
||||
}
|
||||
|
||||
if _, err := c.CloudBroker().LB().Restart(ctx, req); err != nil {
|
||||
return err
|
||||
|
||||
@@ -274,6 +274,14 @@ func dsLBSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -366,6 +374,10 @@ func dsLBSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"user_managed": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -412,6 +424,11 @@ func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Filter by BackIP",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -663,6 +680,14 @@ func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"lb_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -675,6 +700,10 @@ func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"part_k8s": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"primary_node": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -763,6 +792,10 @@ func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"user_managed": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -824,6 +857,11 @@ func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -1075,6 +1113,14 @@ func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"lb_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1087,6 +1133,10 @@ func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"part_k8s": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"primary_node": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -1175,6 +1225,10 @@ func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"user_managed": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1222,7 +1276,6 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"enable": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -1231,6 +1284,11 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
"safe": {
|
||||
Type: schema.TypeBool,
|
||||
Default: true,
|
||||
Optional: true,
|
||||
},
|
||||
"restore": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -1243,7 +1301,17 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"sysctl_params": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Description: "Custom sysctl values for Load Balancer instance. Applied on boot",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeMap,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
},
|
||||
"ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -1467,6 +1535,14 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -1551,6 +1627,10 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"user_managed": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,10 @@ func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m i
|
||||
req.IncludeDeleted = includedeleted.(bool)
|
||||
}
|
||||
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
@@ -74,6 +74,10 @@ func utilityLBListDeletedCheckPresence(ctx context.Context, d *schema.ResourceDa
|
||||
req.BackIP = back_ip.(string)
|
||||
}
|
||||
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user