4.10.0
This commit is contained in:
@@ -93,6 +93,7 @@ func flattenResourceLBBackend(d *schema.ResourceData, b *lb.ItemBackend, lbId in
|
||||
}
|
||||
|
||||
func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
|
||||
d.Set("account_id", lb.AccountID)
|
||||
d.Set("ha_mode", lb.HAMode)
|
||||
d.Set("ckey", lb.CKey)
|
||||
d.Set("meta", flattens.FlattenMeta(lb.Meta))
|
||||
@@ -121,6 +122,7 @@ func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
|
||||
d.Set("tech_status", lb.TechStatus)
|
||||
d.Set("user_managed", lb.UserManaged)
|
||||
d.Set("vins_id", lb.VINSID)
|
||||
d.Set("zone_id", lb.ZoneID)
|
||||
}
|
||||
|
||||
func flattenNode(node lb.Node) []map[string]interface{} {
|
||||
@@ -253,6 +255,7 @@ func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
|
||||
"updated_time": lb.UpdatedTime,
|
||||
"user_managed": lb.UserManaged,
|
||||
"vins_id": lb.VINSID,
|
||||
"zone_id": lb.ZoneID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
@@ -67,6 +67,9 @@ func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
req.Description = desc.(string)
|
||||
}
|
||||
if zoneID, ok := d.GetOk("zone_id"); ok {
|
||||
req.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
if haMode, ok := d.GetOk("ha_mode"); ok {
|
||||
req.HighlyAvailable = haMode.(bool)
|
||||
}
|
||||
@@ -303,6 +306,12 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("zone_id") {
|
||||
if err := resourceLbChangeZoneID(ctx, d, lbRec.ID, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("sysctl_params") {
|
||||
if err := resourceLbChangeSysctlParams(ctx, d, lbRec.ID, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -436,6 +445,46 @@ func resourceLbChangeHaMode(ctx context.Context, d *schema.ResourceData, lbId ui
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLbChangeZoneID(ctx context.Context, d *schema.ResourceData, lbId uint64, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
start := d.Get("start").(bool)
|
||||
|
||||
if start {
|
||||
reqStop := lb.StopRequest{
|
||||
LBID: uint64(d.Get("lb_id").(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().LB().Stop(ctx, reqStop)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
req := lb.MigrateToZoneRequest{
|
||||
LBID: uint64(d.Get("lb_id").(int)),
|
||||
ZoneID: uint64(d.Get("zone_id").(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().LB().MigrateToZone(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if start {
|
||||
reqStart := lb.StartRequest{
|
||||
LBID: uint64(d.Get("lb_id").(int)),
|
||||
}
|
||||
|
||||
_, err = c.CloudBroker().LB().Start(ctx, reqStart)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLbChangeStart(ctx context.Context, d *schema.ResourceData, lbId uint64, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
start := d.Get("start").(bool)
|
||||
|
||||
@@ -43,6 +43,10 @@ func dsLBSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"ha_mode": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -51,6 +55,11 @@ func dsLBSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"meta": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -456,6 +465,10 @@ func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"backends": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -473,6 +486,10 @@ func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"server_default_settings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -885,6 +902,10 @@ func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"backend_haip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -1258,6 +1279,11 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
|
||||
Reference in New Issue
Block a user