4.13.0
This commit is contained in:
@@ -25,6 +25,8 @@ func DataSourceRgAudits() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
DeprecationMessage: "This data source is deprecated and will be removed in version 4.14.0; use decort_cb_audit_list instead.",
|
||||
|
||||
ReadContext: dataSourceRgAuditsRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
|
||||
386
internal/service/cloudbroker/rg/old_schemas.go
Normal file
386
internal/service/cloudbroker/rg/old_schemas.go
Normal file
@@ -0,0 +1,386 @@
|
||||
package rg
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
)
|
||||
|
||||
func resourceRGV1() *schema.Resource {
|
||||
return &schema.Resource{Schema: resourceRgSchemaMakeV1()}
|
||||
}
|
||||
|
||||
func resourceRgSchemaMakeV1() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ValidateFunc: validation.IntAtLeast(1),
|
||||
Description: "Unique ID of the account, which this resource group belongs to.",
|
||||
},
|
||||
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Unique ID of the grid, where this resource group is deployed.",
|
||||
},
|
||||
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Name of this resource group. Names are case sensitive and unique within the context of a account.",
|
||||
},
|
||||
|
||||
"resource_limits": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
MaxItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"cu_c": {
|
||||
Type: schema.TypeFloat,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "MaxCPUCapacity",
|
||||
},
|
||||
"cu_d": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_dm": {
|
||||
Type: schema.TypeFloat,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "MaxVDiskCapacity",
|
||||
},
|
||||
"cu_i": {
|
||||
Type: schema.TypeFloat,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "MaxNumPublicIP",
|
||||
},
|
||||
"cu_m": {
|
||||
Type: schema.TypeFloat,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "MaxMemoryCapacity",
|
||||
},
|
||||
"gpu_units": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"storage_policy": {
|
||||
Type: schema.TypeSet,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"limit": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"owner": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "username - owner of this RG. Leave blank to set current user as owner",
|
||||
},
|
||||
|
||||
"def_net_type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "PUBLIC", "NONE"}, false),
|
||||
Description: "Type of the network, which this resource group will use as default for its computes - PRIVATE or PUBLIC or NONE.",
|
||||
},
|
||||
|
||||
"ipcidr": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Address of the netowrk inside the private network segment (aka ViNS) if def_net_type=PRIVATE",
|
||||
},
|
||||
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "User-defined text description of this resource group.",
|
||||
},
|
||||
|
||||
"ext_net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: 0,
|
||||
Description: "ID of the external network for default ViNS. Pass 0 if def_net_type=PUBLIC or no external connection required for the defult ViNS when def_net_type=PRIVATE",
|
||||
},
|
||||
|
||||
"ext_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "IP address on the external netowrk to request when def_net_type=PRIVATE and ext_net_id is not 0",
|
||||
},
|
||||
|
||||
"uniq_pools": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
|
||||
"access": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"user": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "User or group name to grant access",
|
||||
},
|
||||
"right": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Access rights to set, one of 'R', 'RCX' or 'ARCXDU'",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"def_net": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
MaxItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"net_type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "PUBLIC"}, false),
|
||||
Description: "Network type to set. Must be on of 'PRIVATE' or 'PUBLIC'.",
|
||||
},
|
||||
"net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: 0,
|
||||
Description: "Network segment ID. If netType is PUBLIC and netId is 0 then default external network segment will be selected. If netType is PRIVATE and netId=0, the first ViNS defined for this RG will be selected. Otherwise, netId identifies either existing external network segment or ViNS.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"cpu_allocation_parameter": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "set cpu allocation parameter",
|
||||
},
|
||||
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "set cpu allocation ratio",
|
||||
},
|
||||
|
||||
"enable": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
Description: "enable/disable rg",
|
||||
},
|
||||
"restore": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "restore deleted rg",
|
||||
},
|
||||
|
||||
"force": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "flag to force deleting resource group",
|
||||
},
|
||||
"permanently": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
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", "dpdk", "changemac", "trunk"}, true),
|
||||
},
|
||||
},
|
||||
"sdn_access_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "ID of the SDN access group",
|
||||
},
|
||||
"storage_policy": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"limit": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: -1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"acl": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"email": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"explicit": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"right": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"user_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the account, which this resource group belongs to.",
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"def_net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "ID of the default network for this resource group (if any).",
|
||||
},
|
||||
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"lock_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"resource_types": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"secret": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Current status of this resource group.",
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"vins": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
Description: "List of VINs deployed in this resource group.",
|
||||
},
|
||||
"vms": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
Description: "List of VM ids in this resource group.",
|
||||
},
|
||||
|
||||
"storage_policy_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
@@ -105,6 +105,10 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
|
||||
req.Owner = owner.(string)
|
||||
}
|
||||
|
||||
if enableDefaultGateway, ok := d.GetOkExists("enable_default_gateway"); ok {
|
||||
req.EnableDefaultGateway = enableDefaultGateway.(bool)
|
||||
}
|
||||
|
||||
if _, ok := d.GetOk("def_net"); !ok {
|
||||
if defNetType, ok := d.GetOk("def_net_type"); ok {
|
||||
if defNetType.(string) == "PRIVATE" {
|
||||
@@ -667,14 +671,14 @@ 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 %s for rg id %d", cpuAllocationRatio, uint64(d.Get("rg_id").(int)))
|
||||
cpuAllocationRatio := uint64(d.Get("cpu_allocation_ratio").(int))
|
||||
log.Debugf("resourceRGSetCPUAllocationRatio: cpuAllocationRatio %d for rg id %d", cpuAllocationRatio, uint64(d.Get("rg_id").(int)))
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
req := rg.SetCPUAllocationRatioRequest{
|
||||
RGID: uint64(d.Get("rg_id").(int)),
|
||||
Ratio: cpuAllocationRatio,
|
||||
Ratio: uint64(d.Get("cpu_allocation_ratio").(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().RG().SetCPUAllocationRatio(ctx, req)
|
||||
@@ -777,7 +781,7 @@ func resourceRGChangeComputeFeatures(ctx context.Context, d *schema.ResourceData
|
||||
|
||||
func ResourceResgroup() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
SchemaVersion: 2,
|
||||
|
||||
CreateContext: resourceResgroupCreate,
|
||||
ReadContext: resourceResgroupRead,
|
||||
@@ -812,5 +816,12 @@ func ResourceResgroup() *schema.Resource {
|
||||
},
|
||||
|
||||
Schema: resourceRgSchemaMake(),
|
||||
StateUpgraders: []schema.StateUpgrader{
|
||||
{
|
||||
Type: resourceRGV1().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceRGStateUpgradeV1,
|
||||
Version: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
@@ -1518,6 +1518,10 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"email": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"explicit": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -1557,7 +1561,7 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
@@ -1812,6 +1816,10 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"email": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"explicit": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -1851,7 +1859,7 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
@@ -2238,6 +2246,10 @@ func resourceRgSchemaMake() map[string]*schema.Schema {
|
||||
Description: "Name of this resource group. Names are case sensitive and unique within the context of a account.",
|
||||
},
|
||||
|
||||
"enable_default_gateway": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
"resource_limits": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
@@ -2395,7 +2407,7 @@ func resourceRgSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "set cpu allocation ratio",
|
||||
|
||||
15
internal/service/cloudbroker/rg/state_upgraders.go
Normal file
15
internal/service/cloudbroker/rg/state_upgraders.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceRGStateUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceRGStateUpgradeV1: upgrading state")
|
||||
if v, ok := rawState["cpu_allocation_ratio"]; ok && v != nil {
|
||||
rawState["cpu_allocation_ratio"] = int(v.(float64))
|
||||
}
|
||||
return rawState, nil
|
||||
}
|
||||
Reference in New Issue
Block a user