4.6.0
This commit is contained in:
@@ -14,6 +14,7 @@ func flattenResgroup(d *schema.ResourceData, rgData *rg.RecordRG) {
|
||||
d.Set("account_id", rgData.AccountID)
|
||||
d.Set("account_name", rgData.AccountName)
|
||||
d.Set("acl", flattenRgAcl(rgData.ACL))
|
||||
d.Set("compute_features", rgData.ComputeFeatures)
|
||||
d.Set("cpu_allocation_parameter", rgData.CPUAllocationParameter)
|
||||
d.Set("cpu_allocation_ratio", rgData.CPUAllocationRatio)
|
||||
d.Set("created_by", rgData.CreatedBy)
|
||||
@@ -387,6 +388,7 @@ func flattenRgList(rgl *rg.ListRG) []map[string]interface{} {
|
||||
"account_id": rg.AccountID,
|
||||
"account_name": rg.AccountName,
|
||||
"acl": flattenRgAcl(rg.ACL),
|
||||
"compute_features": rg.ComputeFeatures,
|
||||
"cpu_allocation_parameter": rg.CPUAllocationParameter,
|
||||
"cpu_allocation_ratio": rg.CPUAllocationRatio,
|
||||
"created_by": rg.CreatedBy,
|
||||
@@ -430,6 +432,8 @@ func flattenRgListVins(lv *rg.ListVINS) []map[string]interface{} {
|
||||
"deleted_by": vins.DeletedBy,
|
||||
"deleted_time": vins.DeletedTime,
|
||||
"external_ip": vins.ExternalIP,
|
||||
"extnet_id": vins.ExtnetId,
|
||||
"free_ips": vins.FreeIPs,
|
||||
"id": vins.ID,
|
||||
"name": vins.Name,
|
||||
"network": vins.Network,
|
||||
|
||||
@@ -160,6 +160,15 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
|
||||
|
||||
w := dc.Warnings{}
|
||||
|
||||
// compute_features is not set up during create request and is updated after create on purpose:
|
||||
// 1. to support configuration as final state in resource group,
|
||||
// 2. not to support compute_features inheritance from account.
|
||||
// other implementation may result in inconsistency between user configuration and state after rg creation.
|
||||
// note that call for compute features updated required even if compute_features is null in configuration, in order not ot inherit from account.
|
||||
if err := resourceRGChangeComputeFeatures(ctx, d, m); err != nil {
|
||||
w.Add(err)
|
||||
}
|
||||
|
||||
if _, ok := d.GetOk("access"); ok {
|
||||
if errs := resourceRGAccessGrant(ctx, d, m); len(errs) != 0 {
|
||||
for _, err := range errs {
|
||||
@@ -482,6 +491,12 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("compute_features") {
|
||||
if err := resourceRGChangeComputeFeatures(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return resourceResgroupRead(ctx, d, m)
|
||||
}
|
||||
|
||||
@@ -606,7 +621,7 @@ func resourceRGSetCPUAllocationParameter(ctx context.Context, d *schema.Resource
|
||||
|
||||
func resourceRGSetCPUAllocationRatio(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
cpuAllocationRatio := d.Get("cpu_allocation_ratio").(float64)
|
||||
log.Debugf("resourceRGSetCPUAllocationRatio: cpuAllocationRatio %f for rg id %d", cpuAllocationRatio, uint64(d.Get("rg_id").(int)))
|
||||
log.Debugf("resourceRGSetCPUAllocationRatio: cpuAllocationRatio %s for rg id %d", cpuAllocationRatio, uint64(d.Get("rg_id").(int)))
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
@@ -695,6 +710,32 @@ func resourceRGChangeEnable(ctx context.Context, d *schema.ResourceData, m inter
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceRGChangeComputeFeatures(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
rgId := uint64(d.Get("rg_id").(int))
|
||||
compFeaturesInterface := d.Get("compute_features").(*schema.Set).List()
|
||||
|
||||
compFeatures := make([]string, 0, len(compFeaturesInterface))
|
||||
for _, item := range compFeaturesInterface {
|
||||
compFeatures = append(compFeatures, item.(string))
|
||||
}
|
||||
|
||||
log.Debugf("resourceRGChangeComputeFeatures: compute_features %v for rg id %d", compFeatures, rgId)
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := rg.UpdateComputeFeaturesRequest{
|
||||
RGID: rgId,
|
||||
ComputeFeatures: compFeatures,
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().RG().UpdateComputeFeatures(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ResourceResgroup() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
@@ -55,6 +55,13 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"compute_features": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"cpu_allocation_parameter": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -841,6 +848,11 @@ func dataSourceRgListComputesSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Filter by extnet ID",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -1038,11 +1050,6 @@ func dataSourceRgListLbSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by account ID",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -1063,6 +1070,11 @@ func dataSourceRgListLbSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Filter by backend IP",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -1484,6 +1496,11 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Filter by lock status",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -1540,6 +1557,13 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"compute_features": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"cpu_allocation_parameter": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -1746,6 +1770,11 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Include deleted",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -1802,6 +1831,13 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"compute_features": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"cpu_allocation_parameter": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -1988,6 +2024,11 @@ func dataSourceRgListVinsSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Filter by ViNS ID",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -2036,6 +2077,14 @@ func dataSourceRgListVinsSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"free_ips": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -2364,6 +2413,15 @@ func resourceRgSchemaMake() map[string]*schema.Schema {
|
||||
Description: "flag to permanently delete resource group",
|
||||
},
|
||||
|
||||
"compute_features": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
ValidateFunc: validation.StringInSlice([]string{"hugepages", "numa", "cpupin", "vfnic"}, true),
|
||||
},
|
||||
},
|
||||
|
||||
"acl": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
|
||||
@@ -73,6 +73,10 @@ func utilityRgListCheckPresence(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 size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
@@ -78,6 +78,10 @@ func utilityRgListComputesCheckPresence(ctx context.Context, d *schema.ResourceD
|
||||
req.ExtNetID = uint64(extnet_id.(int))
|
||||
}
|
||||
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
@@ -72,6 +72,10 @@ func utilityRgListDeletedCheckPresence(ctx context.Context, d *schema.ResourceDa
|
||||
req.LockStatus = lock_status.(string)
|
||||
}
|
||||
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
@@ -54,10 +54,6 @@ func utilityRgListLbCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if account_id, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(account_id.(int))
|
||||
}
|
||||
|
||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
@@ -74,6 +70,10 @@ func utilityRgListLbCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
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))
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ func utilityRgListVinsCheckPresence(ctx context.Context, d *schema.ResourceData,
|
||||
req.VINSID = uint64(vins_id.(int))
|
||||
}
|
||||
|
||||
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