This commit is contained in:
2026-09-21 11:51:12 +03:00
parent 9cd93e4277
commit 2b229a84fb
240 changed files with 7735 additions and 3166 deletions

View File

@@ -58,6 +58,8 @@ func DataSourceAccountAuditsList() *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: dataSourceAccountAuditsListRead,
Timeouts: &schema.ResourceTimeout{

View File

@@ -0,0 +1,309 @@
package account
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceAccountV1() *schema.Resource {
return &schema.Resource{Schema: resourceAccountSchemaMakeV1()}
}
func resourceAccountSchemaMakeV1() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_name": {
Type: schema.TypeString,
Required: true,
Description: "account name",
},
"username": {
Type: schema.TypeString,
Required: true,
Description: "username of owner the account",
},
"desc": {
Type: schema.TypeString,
Optional: true,
Description: "description",
},
"emailaddress": {
Type: schema.TypeString,
Optional: true,
Description: "email",
},
"default_zone_id": {
Type: schema.TypeInt,
Optional: true,
Description: "email",
},
"send_access_emails": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "if true send emails when a user is granted access to resources",
},
"zone_ids": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"uniq_pools": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"users": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"user_id": {
Type: schema.TypeString,
Required: true,
},
"access_type": {
Type: schema.TypeString,
Required: true,
},
},
},
},
"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",
},
"available_templates": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
Description: "Share images with account",
},
"restore": {
Type: schema.TypeBool,
Optional: true,
Description: "restore a deleted account",
},
"permanently": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "whether to completely delete the account",
},
"enable": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "enable/disable 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,
},
"cu_d": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_dm": {
Type: schema.TypeFloat,
Optional: true,
Computed: true,
},
"cu_i": {
Type: schema.TypeFloat,
Optional: true,
Computed: true,
},
"cu_m": {
Type: schema.TypeFloat,
Optional: true,
Computed: true,
},
"gpu_units": {
Type: schema.TypeFloat,
Optional: true,
Computed: true,
},
"storage_policy": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"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,
Required: true,
},
},
},
},
"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),
},
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"dc_location": {
Type: schema.TypeString,
Computed: true,
},
"acl": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"emails": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"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,
},
},
},
},
"company": {
Type: schema.TypeString,
Computed: true,
},
"companyurl": {
Type: schema.TypeString,
Computed: true,
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deactivation_time": {
Type: schema.TypeFloat,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"displayname": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"resource_types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
"version": {
Type: schema.TypeInt,
Computed: true,
},
"vins": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
}
}

View File

@@ -209,7 +209,7 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interf
}
if cpuAllocationRatio, ok := d.GetOk("cpu_allocation_ratio"); ok {
cpuAllocationRatio := cpuAllocationRatio.(float64)
cpuAllocationRatio := uint64(cpuAllocationRatio.(int))
req := account.SetCPUAllocationRatioRequest{
AccountID: accountId,
@@ -450,7 +450,7 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
func ResourceAccount() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CreateContext: resourceAccountCreate,
ReadContext: resourceAccountRead,
@@ -470,5 +470,12 @@ func ResourceAccount() *schema.Resource {
},
Schema: resourceAccountSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceAccountV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourceAccountStateUpgradeV1,
Version: 1,
},
},
}
}

View File

@@ -77,7 +77,7 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
Description: "set cpu allocation parameter",
},
"cpu_allocation_ratio": {
Type: schema.TypeFloat,
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "set cpu allocation ratio",
@@ -596,7 +596,7 @@ func dataSourceAccountListDeletedSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"cpu_allocation_ratio": {
Type: schema.TypeFloat,
Type: schema.TypeInt,
Computed: true,
},
"created_by": {
@@ -1342,7 +1342,7 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"cpu_allocation_ratio": {
Type: schema.TypeFloat,
Type: schema.TypeInt,
Computed: true,
},
"created_by": {
@@ -2234,7 +2234,7 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"cpu_allocation_ratio": {
Type: schema.TypeFloat,
Type: schema.TypeInt,
Computed: true,
},
"created_by": {

View File

@@ -0,0 +1,15 @@
package account
import (
"context"
log "github.com/sirupsen/logrus"
)
func resourceAccountStateUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
log.Debug("resourceAccountStateUpgradeV1: upgrading state")
if v, ok := rawState["cpu_allocation_ratio"]; ok && v != nil {
rawState["cpu_allocation_ratio"] = int(v.(float64))
}
return rawState, nil
}

View File

@@ -117,7 +117,7 @@ func utilityAccountCPURatioUpdate(ctx context.Context, d *schema.ResourceData, m
accountId, _ := strconv.ParseUint(d.Id(), 10, 64)
cpuAllocacationRatio := d.Get("cpu_allocation_ratio").(float64)
cpuAllocacationRatio := uint64(d.Get("cpu_allocation_ratio").(int))
_, err := c.CloudBroker().Account().SetCPUAllocationRatio(ctx, account.SetCPUAllocationRatioRequest{
AccountID: accountId,