This commit is contained in:
2025-05-21 16:38:25 +03:00
parent 2c70109d2d
commit 9e68edb2b9
1034 changed files with 73925 additions and 3187 deletions

View File

@@ -55,6 +55,7 @@ import (
cb_node "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/node"
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
cb_stack "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/stack"
cb_user "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/user"
@@ -159,6 +160,7 @@ func newDataSourcesMap() map[string]*schema.Resource {
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
"decort_sep_and_pools_available_list": sep.DataSourceAvailableSEPAndPoolsList(),
"decort_cb_account": cb_account.DataSourceAccount(),
"decort_cb_account_list": cb_account.DataSourceAccountList(),
@@ -241,10 +243,12 @@ func newDataSourcesMap() map[string]*schema.Resource {
"decort_cb_rg_usage": cb_rg.DataSourceRgUsage(),
"decort_cb_sep_list": cb_sep.DataSourceSepList(),
"decort_cb_sep": cb_sep.DataSourceSep(),
"decort_cb_sep_and_pools_available_list": cb_sep.DataSourceAvailableSEPAndPoolsList(),
"decort_cb_sep_consumption": cb_sep.DataSourceSepConsumption(),
"decort_cb_sep_disk_list": cb_sep.DataSourceSepDiskList(),
"decort_cb_sep_config": cb_sep.DataSourceSepConfig(),
"decort_cb_sep_pool": cb_sep.DataSourceSepPool(),
"decort_cb_sep_template": cb_sep.DataSourceSepTemplate(),
"decort_cb_lb": cb_lb.DataSourceLB(),
"decort_cb_lb_list": cb_lb.DataSourceLBList(),
"decort_cb_lb_list_deleted": cb_lb.DataSourceLBListDeleted(),

View File

@@ -326,6 +326,10 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeFloat,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,

View File

@@ -49,6 +49,7 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} {
"acl": flattenRgAcl(acc.ACL),
"compute_features": acc.ComputeFeatures,
"created_time": acc.CreatedTime,
"desc": acc.Description,
"deleted_time": acc.DeletedTime,
"account_id": acc.ID,
"account_name": acc.Name,
@@ -176,6 +177,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -50,6 +50,7 @@ func flattenAccountRGList(argl *account.ListRG) []map[string]interface{} {
"resources": flattenAccRGResources(arg.Resources),
"created_by": arg.CreatedBy,
"created_time": arg.CreatedTime,
"desc": arg.Description,
"deleted_by": arg.DeletedBy,
"deleted_time": arg.DeletedTime,
"rg_id": arg.RGID,
@@ -314,6 +315,10 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,

View File

@@ -7,6 +7,7 @@ import (
func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
d.Set("dc_location", acc.DCLocation)
d.Set("desc", acc.Description)
// d.Set("resources", flattenAccResources(acc.Resources))
d.Set("ckey", acc.CKey)
d.Set("acl", flattenAccAcl(acc.ACL))
@@ -16,6 +17,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
d.Set("created_by", acc.CreatedBy)
d.Set("created_time", acc.CreatedTime)
d.Set("deactivation_time", acc.DeactivationTime)
d.Set("desc", acc.Description)
d.Set("deleted_by", acc.DeletedBy)
d.Set("deleted_time", acc.DeletedTime)
d.Set("displayname", acc.DisplayName)

View File

@@ -176,6 +176,7 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
if d.HasChange("enable") {
reqSwitch := account.DisableEnableRequest{
AccountID: accountId,
Reason: d.Get("reason").(string),
}
enable := d.Get("enable").(bool)
@@ -207,6 +208,11 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
updated = true
}
if d.HasChange("desc") {
req.Description = d.Get("desc").(string)
updated = true
}
if d.HasChange("resource_limits") {
resLimit := d.Get("resource_limits").([]interface{})[0]
resLimitConv := resLimit.(map[string]interface{})
@@ -394,10 +400,10 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "account name",
},
"username": {
"desc": {
Type: schema.TypeString,
Required: true,
Description: "username of owner the account",
Optional: true,
Description: "description",
},
"emailaddress": {
Type: schema.TypeString,
@@ -425,6 +431,11 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
},
},
},
"reason": {
Type: schema.TypeBool,
Optional: true,
Description: "reason for deactivation",
},
"restore": {
Type: schema.TypeBool,
Optional: true,

View File

@@ -105,6 +105,7 @@ func flattenBSGroupComputes(bsgcs bservice.ListGroupComputes) []map[string]inter
"ip_addresses": bsgc.IPAddresses,
"name": bsgc.Name,
"os_users": flattenBSGroupOSUsers(bsgc.OSUsers),
"chipset": bsgc.Chipset,
}
res = append(res, temp)
}
@@ -149,6 +150,10 @@ func dataSourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"chipset": {
Type: schema.TypeString,
Computed: true,
},
"os_users": {
Type: schema.TypeList,
Computed: true,

View File

@@ -100,6 +100,10 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData
req.ExtNets = res
}
if chipset, ok := d.GetOk("chipset"); ok {
req.Chipset = chipset.(string)
}
compgroupId, err := c.CloudAPI().BService().GroupAdd(ctx, req)
if err != nil {
return diag.FromErr(err)
@@ -172,6 +176,7 @@ func resourceBasicServiceGroupUpdate(ctx context.Context, d *schema.ResourceData
ServiceID: uint64(d.Get("service_id").(int)),
CompGroupID: uint64(d.Get("compgroup_id").(int)),
Count: int64(d.Get("comp_count").(int)),
Chipset: d.Get("chipset").(string),
Mode: d.Get("mode").(string),
}
@@ -414,6 +419,12 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"i440fx", "Q35"}, false),
Default: "i440fx",
},
///
"role": {
Type: schema.TypeString,
@@ -503,6 +514,10 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"chipset": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -101,11 +101,19 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Created time",
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
@@ -237,16 +245,24 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
// Computed: true,
// Description: "Login to access the disk",
// },
// "milestones": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Milestones",
// },
"milestones": {
Type: schema.TypeInt,
Computed: true,
Description: "Milestones",
},
"disk_name": {
Type: schema.TypeString,
Computed: true,
Description: "Name of disk",
},
"machine_id": {
Type: schema.TypeInt,
Computed: true,
},
"machine_name": {
Type: schema.TypeString,
Computed: true,
},
"order": {
Type: schema.TypeInt,
Computed: true,
@@ -278,7 +294,7 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Description: "Pool for disk location",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -300,27 +316,27 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_id": {
Type: schema.TypeInt,
Type: schema.TypeInt,
Computed: true,
},
"pool_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"role": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"self_volume_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"storage_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"volume_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
},
@@ -366,6 +382,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -434,6 +454,14 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Virtual Machine ID (Deprecated)",
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets

View File

@@ -163,6 +163,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
@@ -314,11 +318,15 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Machine name",
},
// "milestones": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Milestones",
// },
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
Description: "Milestones",
},
"disk_name": {
Type: schema.TypeString,
Computed: true,
@@ -355,7 +363,7 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Description: "Pool for disk location",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -387,27 +395,27 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_id": {
Type: schema.TypeInt,
Type: schema.TypeInt,
Computed: true,
},
"pool_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"role": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"self_volume_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"storage_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"volume_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
},
@@ -443,6 +451,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -511,6 +523,14 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Virtual Machine ID (Deprecated)",
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},

View File

@@ -303,7 +303,7 @@ func dataSourceDiskReplicationSchemaMake() map[string]*schema.Schema {
Description: "Pool for disk location",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -325,27 +325,27 @@ func dataSourceDiskReplicationSchemaMake() map[string]*schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_id": {
Type: schema.TypeInt,
Type: schema.TypeInt,
Computed: true,
},
"pool_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"role": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"self_volume_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"storage_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"volume_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
},

View File

@@ -149,11 +149,19 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
Description: "Created time",
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
@@ -300,11 +308,11 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Machine name",
},
// "milestones": {
// Type: schema.TypeInt,
// Computed: true,
// Description: "Milestones",
// },
"milestones": {
Type: schema.TypeInt,
Computed: true,
Description: "Milestones",
},
"disk_name": {
Type: schema.TypeString,
Computed: true,
@@ -341,7 +349,7 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
Description: "Pool for disk location",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -363,27 +371,27 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_id": {
Type: schema.TypeInt,
Type: schema.TypeInt,
Computed: true,
},
"pool_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"role": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"self_volume_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"storage_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"volume_id": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
},
@@ -429,6 +437,10 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -497,6 +509,14 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Virtual Machine ID (Deprecated)",
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},

View File

@@ -77,7 +77,9 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("acl", string(diskAcl))
// d.Set("boot_partition", disk.BootPartition)
d.Set("computes", flattenDiskComputes(disk.Computes))
d.Set("created_by", disk.CreatedBy)
d.Set("created_time", disk.CreatedTime)
d.Set("deleted_by", disk.DeletedBy)
d.Set("deleted_time", disk.DeletedTime)
d.Set("desc", disk.Description)
d.Set("destruction_time", disk.DestructionTime)
@@ -91,7 +93,9 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("iotune", flattenIOTune(disk.IOTune))
// d.Set("iqn", disk.IQN)
// d.Set("login", disk.Login)
// d.Set("milestones", disk.Milestones)
d.Set("machine_id", disk.MachineID)
d.Set("machine_name", disk.MachineName)
d.Set("milestones", disk.Milestones)
d.Set("disk_name", disk.Name)
d.Set("order", disk.Order)
d.Set("params", disk.Params)
@@ -110,6 +114,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("role", disk.Role)
d.Set("sep_id", disk.SepID)
d.Set("sep_type", disk.SepType)
d.Set("size_available", disk.SizeAvailable)
d.Set("size_max", disk.SizeMax)
d.Set("size_used", disk.SizeUsed)
d.Set("shareable", disk.Shareable)
@@ -118,6 +123,8 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
d.Set("updated_by", disk.UpdatedBy)
d.Set("updated_time", disk.UpdatedTime)
}
func flattenDiskReplication(rep disks.ItemReplication) []map[string]interface{} {
@@ -211,7 +218,9 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"account_name": disk.AccountName,
"acl": string(diskAcl),
"computes": flattenDiskComputes(disk.Computes),
"created_by": disk.CreatedBy,
"created_time": disk.CreatedTime,
"deleted_by": disk.DeletedBy,
"deleted_time": disk.DeletedTime,
"desc": disk.Description,
"destruction_time": disk.DestructionTime,
@@ -223,6 +232,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"iotune": flattenIOTune(disk.IOTune),
"machine_id": disk.MachineID,
"machine_name": disk.MachineName,
"milestones": disk.Milestones,
"disk_name": disk.Name,
"order": disk.Order,
"params": disk.Params,
@@ -238,6 +248,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"sep_id": disk.SepID,
"sep_type": disk.SepType,
"shareable": disk.Shareable,
"size_available": disk.SizeAvailable,
"size_max": disk.SizeMax,
"size_used": disk.SizeUsed,
"snapshots": flattenDiskSnapshotList(disk.Snapshots),
@@ -245,6 +256,8 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"tech_status": disk.TechStatus,
"type": disk.Type,
"vmid": disk.VMID,
"updated_by": disk.UpdatedBy,
"updated_time": disk.UpdatedTime,
}
res = append(res, temp)
}

View File

@@ -36,7 +36,6 @@ import (
"context"
"fmt"
"strconv"
"strings"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
@@ -47,7 +46,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
@@ -62,23 +60,9 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
return diag.Errorf("resourceDiskCreate: can't create Disk because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
}
haveGID, err := existGID(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !haveGID {
return diag.Errorf("resourceDiskCreate: can't create Disk because GID %d is not allowed or does not exist", d.Get("gid").(int))
}
req.AccountID = uint64(d.Get("account_id").(int))
req.GID = uint64(d.Get("gid").(int))
req.Name = d.Get("disk_name").(string)
req.Size = uint64(d.Get("size_max").(int))
if typeRaw, ok := d.GetOk("type"); ok {
req.Type = strings.ToUpper(typeRaw.(string))
} else {
req.Type = "D"
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.SEPID = uint64(sepId.(int))
@@ -210,14 +194,6 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
return diag.Errorf("resourceDiskUpdate: can't update Disk because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
}
haveGID, err := existGID(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !haveGID {
return diag.Errorf("resourceDiskUpdate: can't update Disk because GID %d is not allowed or does not exist", d.Get("gid").(int))
}
disk, err := utilityDiskCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
@@ -377,6 +353,14 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
//ForceNew: true,
Description: "The unique ID of the subscriber-owner of the disk",
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"disk_name": {
Type: schema.TypeString,
Required: true,
@@ -387,12 +371,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "Size in GB",
},
"gid": {
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
Description: "ID of the grid (platform)",
},
"pool": {
Type: schema.TypeString,
Optional: true,
@@ -411,13 +389,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Description of disk",
},
"type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"D", "B", "T"}, false),
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"detach": {
Type: schema.TypeBool,
Optional: true,
@@ -524,7 +495,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
},
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -585,6 +556,11 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Name of the device",
},
"gid": {
Type: schema.TypeInt,
Computed: true,
Description: "ID of the grid (platform)",
},
// "disk_path": {
// Type: schema.TypeString,
// Computed: true,
@@ -623,6 +599,14 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
// Computed: true,
// Description: "Milestones",
// },
"machine_id": {
Type: schema.TypeInt,
Computed: true,
},
"machine_name": {
Type: schema.TypeString,
Computed: true,
},
"order": {
Type: schema.TypeInt,
Computed: true,
@@ -638,6 +622,11 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "ID of the parent disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
// "passwd": {
// Type: schema.TypeString,
// Computed: true,
@@ -779,6 +768,14 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Virtual Machine ID (Deprecated)",
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets

View File

@@ -454,7 +454,7 @@ func resourceDiskReplicationSchemaMake() map[string]*schema.Schema {
Description: "ID of the pci slot to which the disk is connected",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,

View File

@@ -270,6 +270,13 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
},
},
},
"ntp": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
}
return res
}

View File

@@ -107,6 +107,11 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Page size",
},
"ovs_bridge": {
Type: schema.TypeString,
Optional: true,
Description: "Name of the openVswitch bridge",
},
"items": {
Type: schema.TypeList,
Computed: true,

View File

@@ -24,6 +24,7 @@ func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
d.Set("net_name", e.Name)
d.Set("network", e.Network)
d.Set("network_id", e.NetworkID)
d.Set("ntp", e.NTP)
d.Set("pre_reservations_num", e.PreReservationsNum)
d.Set("prefix", e.Prefix)
d.Set("pri_vnf_dev_id", e.PriVNFDevID)

View File

@@ -46,11 +46,11 @@ func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData,
c := m.(*controller.ControllerCfg)
req := extnet.ListRequest{}
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
if accountID, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountID.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
if byID, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(byID.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
@@ -58,11 +58,11 @@ func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData,
if network, ok := d.GetOk("network"); ok {
req.Network = network.(string)
}
if vlan_id, ok := d.GetOk("vlan_id"); ok {
req.VLANID = uint64(vlan_id.(int))
if vlanID, ok := d.GetOk("vlan_id"); ok {
req.VLANID = uint64(vlanID.(int))
}
if vnfdev_id, ok := d.GetOk("vnfdev_id"); ok {
req.VNFDevID = uint64(vnfdev_id.(int))
if vnfDevID, ok := d.GetOk("vnfdev_id"); ok {
req.VNFDevID = uint64(vnfDevID.(int))
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
@@ -77,6 +77,10 @@ func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData,
req.Size = uint64(size.(int))
}
if ovsBridge, ok := d.GetOk("ovs_bridge"); ok {
req.OVSBridge = ovsBridge.(string)
}
log.Debugf("utilityExtnetListCheckPresence")
extnetList, err := c.CloudAPI().ExtNet().List(ctx, req)
if err != nil {

View File

@@ -58,6 +58,7 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
d.Set("sep_id", img.SepID)
d.Set("shared_with", img.SharedWith)
d.Set("size", img.Size)
d.Set("snapshot_id", img.SnapshotID)
d.Set("status", img.Status)
d.Set("tech_status", img.TechStatus)
d.Set("type", img.Type)

View File

@@ -169,7 +169,7 @@ func dataSourceImageExtendSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -198,6 +198,10 @@ func dataSourceImageExtendSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"snapshot_id": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,

View File

@@ -68,8 +68,8 @@ func resourceImageSchemaMake(sch map[string]*schema.Schema) map[string]*schema.S
sch["type"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, true),
Description: "Image type linux, windows or unknown",
}
sch["hot_resize"] = &schema.Schema{

View File

@@ -90,9 +90,6 @@ func resourceImageFromBlankComputeCreate(ctx context.Context, d *schema.Resource
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.SepID = uint64(sepId.(int))
}
if poolName, ok := d.GetOk("pool_name"); ok {
req.PoolName = poolName.(string)
}
@@ -302,8 +299,8 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, true),
Description: "Image type linux, windows or unknown",
},
"username": {
@@ -326,7 +323,6 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
@@ -457,7 +453,7 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -482,6 +478,10 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"snapshot_id": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,

View File

@@ -93,9 +93,6 @@ func resourceImageFromPlatformDiskCreate(ctx context.Context, d *schema.Resource
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.SepID = uint64(sepId.(int))
}
if poolName, ok := d.GetOk("pool_name"); ok {
req.PoolName = poolName.(string)
}
@@ -292,8 +289,8 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, true),
Description: "Image type linux, windows or unknown",
},
"architecture": {
Type: schema.TypeString,
@@ -322,7 +319,6 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
@@ -454,7 +450,7 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -479,6 +475,10 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"snapshot_id": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,

View File

@@ -357,6 +357,10 @@ func dataSourceK8sSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,

View File

@@ -240,6 +240,7 @@ func flattenK8sData(d *schema.ResourceData, cluster k8s.RecordK8S, masters []com
d.Set("k8sci_id", cluster.CIID)
d.Set("created_by", cluster.CreatedBy)
d.Set("created_time", cluster.CreatedTime)
d.Set("desc", cluster.Description)
d.Set("deleted_by", cluster.DeletedBy)
d.Set("deleted_time", cluster.DeletedTime)
d.Set("k8s_ci_name", cluster.K8CIName)
@@ -353,6 +354,7 @@ func flattenResourceK8sCP(d *schema.ResourceData, k8s k8s.RecordK8S, masters []c
d.Set("bservice_id", k8s.BServiceID)
d.Set("created_by", k8s.CreatedBy)
d.Set("created_time", k8s.CreatedTime)
d.Set("desc", k8s.Description)
d.Set("deleted_by", k8s.DeletedBy)
d.Set("deleted_time", k8s.DeletedTime)
d.Set("k8s_ci_name", k8s.K8CIName)
@@ -393,6 +395,7 @@ func flattenResourceK8s(d *schema.ResourceData, k8s k8s.RecordK8S, masters []com
d.Set("bservice_id", k8s.BServiceID)
d.Set("created_by", k8s.CreatedBy)
d.Set("created_time", k8s.CreatedTime)
d.Set("desc", k8s.Description)
d.Set("deleted_by", k8s.DeletedBy)
d.Set("deleted_time", k8s.DeletedTime)
d.Set("k8s_ci_name", k8s.K8CIName)

View File

@@ -359,7 +359,7 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -422,6 +422,10 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -966,10 +970,88 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"vgpus": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
Type: schema.TypeList,
Computed: true,
Description: "List of virtual GPUs",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"mode": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"profile_id": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"last_update_time": {
Type: schema.TypeInt,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
},
"pgpuid": {
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"last_claimed_by": {
Type: schema.TypeInt,
Computed: true,
},
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
},
"bus_number": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"virtual_image_id": {
@@ -988,6 +1070,22 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"loader_type": {
Type: schema.TypeString,
Computed: true,
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
}
}

View File

@@ -381,6 +381,22 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"loader_type": {
Type: schema.TypeString,
Computed: true,
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
}
}

View File

@@ -47,9 +47,9 @@ func flattenDisks(disks []compute.InfoDisk) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, disk := range disks {
temp := map[string]interface{}{
"bus_number": disk.BusNumber,
"disk_id": disk.ID,
"pci_slot": disk.PCISlot,
// "bus_number": disk.BusNumber,
"disk_id": disk.ID,
// "pci_slot": disk.PCISlot,
}
res = append(res, temp)
}
@@ -217,28 +217,32 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"need_reboot": compute.NeedReboot,
"numa_affinity": compute.NumaAffinity,
"numa_node_id": compute.NumaNodeId,
"pinned": compute.Pinned,
"preferred_cpu": compute.PreferredCPU,
"ram": compute.RAM,
"reference_id": compute.ReferenceID,
"registered": compute.Registered,
"res_name": compute.ResName,
"reserved_node_cpus": compute.ReservedNodeCpus,
"rg_id": compute.RGID,
"rg_name": compute.RGName,
"snap_sets": flattenSnapSets(compute.SnapSets),
"stateless_sep_id": compute.StatelessSepID,
"stateless_sep_type": compute.StatelessSepType,
"status": compute.Status,
"tags": flattenTags(compute.Tags),
"tech_status": compute.TechStatus,
"total_disk_size": compute.TotalDiskSize,
"updated_by": compute.UpdatedBy,
"updated_time": compute.UpdatedTime,
"user_managed": compute.UserManaged,
"vgpus": compute.VGPUs,
"vins_connected": compute.VINSConnected,
"virtual_image_id": compute.VirtualImageID,
// "pinned": compute.Pinned,
"preferred_cpu": compute.PreferredCPU,
"ram": compute.RAM,
"reference_id": compute.ReferenceID,
"registered": compute.Registered,
"res_name": compute.ResName,
"reserved_node_cpus": compute.ReservedNodeCpus,
"rg_id": compute.RGID,
"rg_name": compute.RGName,
"snap_sets": flattenSnapSets(compute.SnapSets),
"stateless_sep_id": compute.StatelessSepID,
"stateless_sep_type": compute.StatelessSepType,
"status": compute.Status,
"tags": flattenTags(compute.Tags),
"tech_status": compute.TechStatus,
"total_disk_size": compute.TotalDiskSize,
"updated_by": compute.UpdatedBy,
"updated_time": compute.UpdatedTime,
"user_managed": compute.UserManaged,
"vgpus": compute.VGPUs,
"vins_connected": compute.VINSConnected,
"virtual_image_id": compute.VirtualImageID,
"loader_type": compute.LoaderType,
"boot_type": compute.BootType,
"hot_resize": compute.HotResize,
"network_interface_naming": compute.NetworkInterfaceNaming,
}
res = append(res, temp)
}
@@ -250,17 +254,18 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"disk_name": bootDisk.Name,
"disk_id": bootDisk.ID,
"disk_type": bootDisk.Type,
"sep_id": bootDisk.SepID,
"shareable": bootDisk.Shareable,
"size_max": bootDisk.SizeMax,
"size_used": bootDisk.SizeUsed,
"pool": bootDisk.Pool,
"desc": bootDisk.Description,
"image_id": bootDisk.ImageID,
"size": bootDisk.SizeMax,
"disk_name": bootDisk.Name,
"disk_id": bootDisk.ID,
"disk_type": bootDisk.Type,
"sep_id": bootDisk.SepID,
"shareable": bootDisk.Shareable,
"size_max": bootDisk.SizeMax,
"size_used": bootDisk.SizeUsed,
"pool": bootDisk.Pool,
"desc": bootDisk.Description,
"image_id": bootDisk.ImageID,
"size": bootDisk.SizeMax,
"present_to": bootDisk.PresentTo,
}
res = append(res, temp)
@@ -301,6 +306,7 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
"image_id": disk.ImageID,
"size": disk.SizeMax,
"permanently": pernamentlyValue,
"present_to": disk.PresentTo,
}
res = append(res, temp)
indexDataDisks++
@@ -415,7 +421,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
if err := d.Set("os_users", parseOsUsers(computeRec.OSUsers)); err != nil {
return err
}
d.Set("pinned", computeRec.Pinned)
// d.Set("pinned", computeRec.Pinned)
d.Set("preferred_cpu", computeRec.PreferredCPU)
d.Set("ram", computeRec.RAM)
d.Set("reference_id", computeRec.ReferenceID)
@@ -434,9 +440,13 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
d.Set("updated_time", computeRec.UpdatedTime)
d.Set("user_managed", computeRec.UserManaged)
d.Set("vnc_password", computeRec.VNCPassword)
d.Set("vgpus", computeRec.VGPUs)
d.Set("vgpus", flattenVGPUs(computeRec.VGPUs))
d.Set("virtual_image_id", computeRec.VirtualImageID)
d.Set("virtual_image_name", computeRec.VirtualImageName)
d.Set("loader_type", computeRec.LoaderType)
d.Set("boot_type", computeRec.BootType)
d.Set("hot_resize", computeRec.HotResize)
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
d.Set("enabled", false)
if computeRec.Status == status.Enabled {
@@ -561,6 +571,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"role": disk.Role,
"sep_id": disk.SepID,
"shareable": disk.Shareable,
"size_available": disk.SizeAvailable,
"size_max": disk.SizeMax,
"size_used": disk.SizeUsed,
"snapshots": flattenSnapshots(disk.Snapshots),
@@ -660,7 +671,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("natable_vins_network", computeRec.NatableVINSNetwork)
d.Set("natable_vins_network_name", computeRec.NatableVINSNetworkName)
d.Set("os_users", flattenOsUsers(computeRec.OSUsers))
d.Set("pinned", computeRec.Pinned)
// d.Set("pinned", computeRec.Pinned)
d.Set("preferred_CPU", computeRec.PreferredCPU)
d.Set("ram", computeRec.RAM)
d.Set("reference_id", computeRec.ReferenceID)
@@ -680,10 +691,14 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("user_managed", computeRec.UserManaged)
d.Set("userdata", string(userdata))
d.Set("vnc_password", computeRec.VNCPassword)
d.Set("vgpus", computeRec.VGPUs)
d.Set("vgpus", flattenVGPUs(computeRec.VGPUs))
d.Set("virtual_image_id", computeRec.VirtualImageID)
d.Set("virtual_image_name", computeRec.VirtualImageName)
d.Set("pci_devices", flattenPCI(*pciList))
d.Set("loader_type", computeRec.LoaderType)
d.Set("boot_type", computeRec.BootType)
d.Set("hot_resize", computeRec.HotResize)
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
}
func flattenPCI(pciList compute.ListPCIDevices) []uint64 {
@@ -821,3 +836,34 @@ func flattenPCIDevice(deviceList []compute.ItemPCIDevice) []map[string]interface
}
return res
}
func flattenVGPUs(vgpus []compute.VGPUItem) []map[string]interface{} {
res := make([]map[string]interface{}, len(vgpus))
for i, vgpu := range vgpus {
res[i] = map[string]interface{}{
"id": int(vgpu.ID),
"gid": int(vgpu.GID),
"type": vgpu.Type,
"mode": vgpu.Mode,
"status": vgpu.Status,
"profile_id": vgpu.ProfileID,
"ram": int(vgpu.RAM),
"last_update_time": int(vgpu.LastUpdateTime),
"created_time": int(vgpu.CreatedTime),
"deleted_time": int(vgpu.DeletedTime),
"vmid": int(vgpu.VMID),
"pgpuid": int(vgpu.PGPuid),
"reference_id": vgpu.ReferenceID,
"account_id": int(vgpu.AccountID),
"rg_id": int(vgpu.RgID),
"last_claimed_by": int(vgpu.LastClaimedBy),
"pci_slot": int(vgpu.PCISlot),
"bus_number": int(vgpu.BusNumber),
"guid": int(vgpu.GUID),
}
}
return res
}

View File

@@ -147,9 +147,11 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema {
},
"mac": {
Type: schema.TypeString,
Computed: true,
Description: "MAC address associated with this connection. MAC address is assigned automatically.",
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: networkSubresIPAddreDiffSupperss,
Description: "MAC address associated with this connection. MAC address is assigned automatically.",
},
"weight": {

View File

@@ -171,6 +171,11 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
reqInterface.IPAddr = ipaddr.(string)
}
macaddr, macSet := netInterfaceVal["mac"]
if macSet {
reqInterface.MAC = macaddr.(string)
}
interfaces = append(interfaces, reqInterface)
}
@@ -288,6 +293,38 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
log.Debugf("resourceComputeCreate: new simple Compute ID %d, name %s created", computeId, d.Get("name").(string))
updateReq := compute.UpdateRequest{}
loaderType, loaderTypeOk := d.GetOk("loader_type")
bootType, bootTypeOk := d.GetOk("boot_type")
hotResize, hotResizeOk := d.GetOk("hot_resize")
networkInterfaceNaming, networkInterfaceNamingOk := d.GetOk("network_interface_naming")
if loaderTypeOk {
updateReq.LoaderType = loaderType.(string)
}
if bootTypeOk {
updateReq.BootType = bootType.(string)
}
if hotResizeOk {
updateReq.HotResize = hotResize.(bool)
}
if networkInterfaceNamingOk {
updateReq.NetworkInterfaceNaming = networkInterfaceNaming.(string)
}
if loaderTypeOk || bootTypeOk || hotResizeOk || networkInterfaceNamingOk {
log.Debugf("resourceComputeCreate: change loaderType or bootType or hotResize or networkInterfaceNaming on ComputeID: %d", computeId)
updateReq.ComputeID = computeId
_, err := c.CloudAPI().Compute().Update(ctx, updateReq)
if err != nil {
warnings.Add(err)
}
}
if ars, ok := d.GetOk("pci_devices"); ok {
log.Debugf("resourceComputeCreate: add pci devices on ComputeID: %d", computeId)
addedPciDevices := ars.(*schema.Set).List()
@@ -920,7 +957,18 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if d.HasChanges("description", "name", "numa_affinity", "cpu_pin", "hp_backed", "chipset", "auto_start_w_node", "preferred_cpu") {
if d.HasChanges("description",
"name",
"numa_affinity",
"cpu_pin",
"hp_backed",
"chipset",
"auto_start_w_node",
"preferred_cpu",
"loader_type",
"boot_type",
"hot_resize",
"network_interface_naming") {
req := compute.UpdateRequest{
ComputeID: computeRec.ID,
}
@@ -956,6 +1004,22 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
req.HPBacked = d.Get("hp_backed").(bool)
req.AutoStart = d.Get("auto_start_w_node").(bool)
if d.HasChange("loader_type") {
req.LoaderType = d.Get("loader_type").(string)
}
if d.HasChange("boot_type") {
req.BootType = d.Get("boot_type").(string)
}
if d.HasChange("hot_resize") {
req.HotResize = d.Get("hot_resize").(bool)
}
if d.HasChange("network_interface_naming") {
req.NetworkInterfaceNaming = d.Get("network_interface_naming").(string)
}
// Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status.
// If STARTED, we need to stop it before update
var isStopRequired bool
@@ -1824,6 +1888,13 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"present_to": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
}
return rets
}
@@ -1941,6 +2012,13 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
),
Description: "Amount of RAM in MB to allocate to this compute instance.",
},
"boot_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, false),
Description: "Type of image upload.",
},
"image_id": {
Type: schema.TypeInt,
Optional: true,
@@ -2096,7 +2174,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeSet,
Optional: true,
MinItems: 1,
MaxItems: constants.MAX_NETWORKS_PER_COMPUTE,
Elem: &schema.Resource{
Schema: networkSubresourceSchemaMake(),
},
@@ -2171,6 +2248,19 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "If true - enable compute, else - disable",
},
"loader_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, false),
Description: "Type of image vm.",
},
"hot_resize": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Type of image vm.",
},
"pause": {
Type: schema.TypeBool,
Optional: true,
@@ -2230,6 +2320,13 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "compute purpose",
},
"network_interface_naming": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, false),
Description: "Name of netfowrk interface.",
},
"numa_affinity": {
Type: schema.TypeString,
Optional: true,
@@ -2481,10 +2578,88 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"vgpus": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
Type: schema.TypeList,
Computed: true,
Description: "List of virtual GPUs",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"mode": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"profile_id": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"last_update_time": {
Type: schema.TypeInt,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
},
"pgpuid": {
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"last_claimed_by": {
Type: schema.TypeInt,
Computed: true,
},
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
},
"bus_number": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"virtual_image_id": {

View File

@@ -98,14 +98,6 @@ func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceDa
if detach_set.Len() > 0 {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
stopReq := compute.StopRequest{
ComputeID: computeId,
Force: false,
}
_, err := c.CloudAPI().Compute().Stop(ctx, stopReq)
if err != nil {
return err
}
for _, diskId := range detach_set.List() {
req := compute.DiskDetachRequest{
@@ -120,14 +112,6 @@ func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceDa
}
}
req := compute.StartRequest{
ComputeID: computeId,
AltBootID: 0,
}
_, err = c.CloudAPI().Compute().Start(ctx, req)
if err != nil {
return err
}
}
attach_set := new_set.(*schema.Set).Difference(old_set.(*schema.Set))
@@ -180,7 +164,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
oldList := oldSet.(*schema.Set).List()
newList := newSet.(*schema.Set).List()
detachMap, changeIpMap, attachMap := differenceNetwork(oldList, newList)
detachMap, changeIpMap, changeMacMap, attachMap := differenceNetwork(oldList, newList)
apiErrCount := 0
var lastSavedError error
@@ -224,7 +208,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
needStart := false
if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 || hasDPDKnetwork(attachMap) {
if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 || hasDPDKnetwork(attachMap) || len(changeMacMap) != 0 {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
if err := utilityComputeStop(ctx, computeId, m); err != nil {
apiErrCount++
@@ -235,6 +219,24 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
}
}
log.Debugf("utilityComputeNetworksConfigure: changeMac set has %d items for Compute ID %s", len(changeMacMap), d.Id())
for _, netData := range changeMacMap {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
req := compute.ChangeMACRequest{
ComputeID: computeId,
NewMAC: netData["mac"].(string),
СurrentMAC: netData["old_mac"].(string),
}
_, err := c.CloudAPI().Compute().ChangeMAC(ctx, req)
if err != nil {
log.Errorf("utilityComputeNetworksConfigure: failed to change mac %s to %s from Compute ID %s: %s",
req.СurrentMAC, req.NewMAC, d.Id(), err)
apiErrCount++
lastSavedError = err
}
}
sort.Slice(attachMap, func(i, j int) bool {
weightI := attachMap[i]["weight"].(int)
weightJ := attachMap[j]["weight"].(int)
@@ -246,6 +248,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
}
return weightI < weightJ
})
log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", len(attachMap), d.Id())
for _, netData := range attachMap {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
@@ -259,6 +262,10 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
req.IPAddr = netData["ip_address"].(string)
}
if netData["mac"].(string) != "" {
req.MACAddr = netData["mac"].(string)
}
if req.NetType == "DPDK" {
req.MTU = uint64(netData["mtu"].(int))
}
@@ -378,9 +385,10 @@ func utilityComputeUpdatePciDevices(ctx context.Context, d *schema.ResourceData,
return nil
}
func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, attachMap []map[string]interface{}) {
func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, changeMacMap, attachMap []map[string]interface{}) {
attachMap = make([]map[string]interface{}, 0)
changeIpMap = make([]map[string]interface{}, 0)
changeMacMap = make([]map[string]interface{}, 0)
detachMap = make([]map[string]interface{}, 0)
for _, oldNetwork := range oldList {
oldMap := oldNetwork.(map[string]interface{})
@@ -388,15 +396,21 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
for _, newNetwork := range newList {
newMap := newNetwork.(map[string]interface{})
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(int) == 0) {
if (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != "") {
found = true
switch {
case (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != ""):
changeIpMap = append(changeIpMap, newMap)
found = true
break
} else if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(string) == "" {
fallthrough
case newMap["mac"] != oldMap["mac"] && newMap["mac"].(string) != "":
newMap["old_mac"] = oldMap["mac"]
changeMacMap = append(changeMacMap, newMap)
found = true
break
}
}
if found {
break
}
}
if found {
continue
@@ -410,12 +424,8 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
for _, oldNetwork := range oldList {
oldMap := oldNetwork.(map[string]interface{})
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(int) == 0) {
if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(string) == "" ||
((newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") &&
newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != "") {
found = true
break
}
found = true
break
}
}
if found {

View File

@@ -56,6 +56,7 @@ func flattenLocationsList(ll *locations.ListLocations) []map[string]interface{}
"id": l.ID,
"location_code": l.LocationCode,
"name": l.Name,
"sdn_support": l.SDNSupport,
}
res = append(res, temp)
}
@@ -169,6 +170,11 @@ func dataSourceLocationsListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Location name",
},
"sdn_support": {
Type: schema.TypeBool,
Computed: true,
Description: "support of SDN",
},
},
},
},

View File

@@ -355,10 +355,6 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"register_computes": {
Type: schema.TypeBool,
Computed: true,
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,

View File

@@ -202,10 +202,6 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"register_computes": {
Type: schema.TypeBool,
Computed: true,
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,

View File

@@ -199,10 +199,6 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"register_computes": {
Type: schema.TypeBool,
Computed: true,
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,

View File

@@ -106,7 +106,6 @@ func flattenResgroup(d *schema.ResourceData, details rg.RecordResourceGroup) err
d.Set("rg_id", details.ID)
d.Set("lock_status", details.LockStatus)
d.Set("milestones", details.Milestones)
d.Set("register_computes", details.RegisterComputes)
d.Set("res_types", details.ResTypes)
d.Set("secret", details.Secret)
d.Set("status", details.Status)
@@ -193,7 +192,6 @@ func flattenRg(d *schema.ResourceData, itemRg rg.RecordResourceGroup) {
d.Set("lock_status", itemRg.LockStatus)
d.Set("milestones", itemRg.Milestones)
d.Set("name", itemRg.Name)
d.Set("register_computes", itemRg.RegisterComputes)
d.Set("res_types", itemRg.ResTypes)
d.Set("resource_limits", flattenRgResourceLimits(itemRg.ResourceLimits))
d.Set("secret", itemRg.Secret)
@@ -245,7 +243,6 @@ func flattenRgList(rgl *rg.ListResourceGroups) []map[string]interface{} {
"lock_status": rg.LockStatus,
"milestones": rg.Milestones,
"name": rg.Name,
"register_computes": rg.RegisterComputes,
"resource_limits": flattenRgResourceLimits(rg.ResourceLimits),
"secret": rg.Secret,
"status": rg.Status,

File diff suppressed because it is too large Load Diff

View File

@@ -160,10 +160,6 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
req.ExtIP = extIp.(string)
}
if regComputes, ok := d.GetOk("register_computes"); ok {
req.RegisterComputes = regComputes.(bool)
}
apiResp, err := c.CloudAPI().RG().Create(ctx, req)
if err != nil {
return diag.FromErr(err)
@@ -404,7 +400,7 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter
return diag.FromErr(fmt.Errorf("resourceResgroupUpdate: RG ID %s: changing ext_net_id for existing RG is not allowed", d.Id()))
}
if d.HasChanges("name", "quota", "description", "register_computes", "uniq_pools") {
if d.HasChanges("name", "quota", "description", "uniq_pools") {
if err := utilityUpdateRG(ctx, d, m, rgData.ID); err != nil {
return diag.FromErr(err)
}
@@ -696,12 +692,6 @@ func ResourceRgSchemaMake() map[string]*schema.Schema {
Default: false,
Description: "Set to True if you want force delete non-empty RG",
},
"register_computes": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Register computes in registration system",
},
"restore": {
Type: schema.TypeBool,
Optional: true,

View File

@@ -129,11 +129,6 @@ func utilityUpdateRG(ctx context.Context, d *schema.ResourceData, m interface{},
req.Description = d.Get("description").(string)
}
if d.HasChange("register_computes") {
log.Debugf("resourceResgroupUpdate: register_computes specified - looking for deltas from the old settings.")
req.RegisterComputes = d.Get("register_computes").(bool)
}
if d.HasChange("uniq_pools") {
uniqPools := d.Get("uniq_pools").([]interface{})
if len(uniqPools) == 0 {

View File

@@ -0,0 +1,143 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Sergey Kisil, <svkisil@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package sep
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func DataSourceAvailableSEPAndPoolsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
sepList, err := utilityAvailableSEPAndPoolsListCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
flattenAvailableSEPList(d, sepList)
return nil
}
func dataSourceAvailableSEPListSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Required: true,
Description: "Account ID",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Resource group ID",
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
Description: "Number of available SEP entries",
},
"items": {
Type: schema.TypeList,
Computed: true,
Description: "List of available SEPs",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Computed: true,
Description: "SEP ID",
},
"sep_name": {
Type: schema.TypeString,
Computed: true,
Description: "SEP name",
},
"sep_type": {
Type: schema.TypeString,
Computed: true,
Description: "SEP type",
},
"pools": {
Type: schema.TypeList,
Computed: true,
Description: "List of pools in the SEP",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Pool name",
},
"types": {
Type: schema.TypeList,
Computed: true,
Description: "List of pool types",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"system": {
Type: schema.TypeBool,
Computed: true,
Description: "Is system pool",
},
},
},
},
},
},
},
}
}
func DataSourceAvailableSEPAndPoolsList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: DataSourceAvailableSEPAndPoolsListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAvailableSEPListSchemaMake(),
}
}

View File

@@ -0,0 +1,74 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Sergey Kisil, <svkisil@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package sep
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep"
)
func flattenAvailableSEPList(d *schema.ResourceData, sepList *sep.ListAvailableSEP) {
d.Set("items", flattenSEPDataList(sepList.Data))
d.Set("entry_count", sepList.EntryCount)
}
func flattenSEPDataList(sepDataList []sep.SEPData) []map[string]interface{} {
sh := make([]map[string]interface{}, 0)
for _, sepData := range sepDataList {
temp := map[string]interface{}{
"sep_id": sepData.SEPID,
"sep_name": sepData.SEPName,
"sep_type": sepData.SEPType,
"pools": flattenPoolList(sepData.Pools),
}
sh = append(sh, temp)
}
return sh
}
func flattenPoolList(pools []sep.Pool) []map[string]interface{} {
sh := make([]map[string]interface{}, 0)
for _, pool := range pools {
temp := map[string]interface{}{
"name": pool.Name,
"types": pool.Types,
"system": pool.System,
}
sh = append(sh, temp)
}
return sh
}

View File

@@ -0,0 +1,63 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Sergey Kisil, <svkisil@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package sep
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sep"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAvailableSEPAndPoolsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*sep.ListAvailableSEP, error) {
c := m.(*controller.ControllerCfg)
req := sep.ListAvailableSEPAndPoolsRequest{}
if AccountID, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(AccountID.(int))
}
if RGID, ok := d.GetOk("rg_id"); ok {
req.RGID = RGID.(uint64)
}
log.Debugf("utilityAvailableSEPAndPoolsListCheckPresence: load sep and pools list")
sepList, err := c.CloudAPI().SEP().ListAvailableSEPAndPools(ctx, req)
if err != nil {
return nil, err
}
return sepList, nil
}

View File

@@ -99,6 +99,11 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"status": {
Type: schema.TypeString,
Optional: true,
Description: "sort by status",
},
"page": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -78,6 +78,10 @@ func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m
req.SortBy = sortBy.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}

View File

@@ -18,6 +18,7 @@ func flattenResourceAccount(d *schema.ResourceData, acc *account.RecordAccount)
d.Set("created_by", acc.CreatedBy)
d.Set("created_time", acc.CreatedTime)
d.Set("deactivation_time", acc.DeactivationTime)
d.Set("desc", acc.Description)
d.Set("deleted_by", acc.DeletedBy)
d.Set("deleted_time", acc.DeletedTime)
d.Set("displayname", acc.DisplayName)
@@ -46,6 +47,7 @@ func flattenDataAccount(d *schema.ResourceData, acc *account.RecordAccount) {
d.Set("created_by", acc.CreatedBy)
d.Set("created_time", acc.CreatedTime)
d.Set("deactivation_time", acc.DeactivationTime)
d.Set("desc", acc.Description)
d.Set("deleted_by", acc.DeletedBy)
d.Set("deleted_time", acc.DeletedTime)
d.Set("displayname", acc.DisplayName)
@@ -71,6 +73,7 @@ func flattenAccountRGList(argl *account.ListRG) []map[string]interface{} {
"resources": flattenAccRGResources(arg.Resources),
"created_by": arg.CreatedBy,
"created_time": arg.CreatedTime,
"desc": arg.Description,
"deleted_by": arg.DeletedBy,
"deleted_time": arg.DeletedTime,
"rg_id": arg.ID,
@@ -204,6 +207,7 @@ func flattenListDeleted(al *account.ListAccounts) []map[string]interface{} {
"created_by": acc.CreatedBy,
"created_time": acc.CreatedTime,
"deactivation_time": acc.DeactivationTime,
"desc": acc.Description,
"deleted_by": acc.DeletedBy,
"deleted_time": acc.DeletedTime,
"displayname": acc.DisplayName,
@@ -240,6 +244,7 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} {
"created_by": acc.CreatedBy,
"created_time": acc.CreatedTime,
"deactivation_time": acc.DeactivationTime,
"desc": acc.Description,
"deleted_by": acc.DeletedBy,
"deleted_time": acc.DeletedTime,
"displayname": acc.DisplayName,

View File

@@ -55,6 +55,10 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interf
Username: d.Get("username").(string),
}
if desc, ok := d.GetOk("desc"); ok {
req.Description = desc.(string)
}
if emailaddress, ok := d.GetOk("emailaddress"); ok {
req.EmailAddress = emailaddress.(string)
}
@@ -196,6 +200,7 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interf
if !d.Get("enable").(bool) {
_, err := c.CloudBroker().Account().Disable(ctx, account.DisableRequest{
AccountID: accountId,
Reason: d.Get("reason").(string),
})
if err != nil {
@@ -239,6 +244,8 @@ func resourceAccountDelete(ctx context.Context, d *schema.ResourceData, m interf
req := account.DeleteRequest{
AccountID: accountData.ID,
Permanently: d.Get("permanently").(bool),
Name: d.Get("account_name").(string),
Reason: d.Get("reason").(string),
}
_, err = c.CloudBroker().Account().Delete(ctx, req)
@@ -277,6 +284,7 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
if d.Get("restore").(bool) {
_, err := c.CloudBroker().Account().Restore(ctx, account.RestoreRequest{
AccountID: accountId,
Reason: d.Get("reason").(string),
})
if err != nil {
@@ -308,7 +316,7 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if d.HasChanges("account_name", "send_access_emails", "uniq_pools", "resource_limits") {
if d.HasChanges("account_name", "send_access_emails", "uniq_pools", "resource_limits", "desc") {
if err := utilityAccountUpdate(ctx, d, m); err != nil {
return diag.FromErr(err)
}

View File

@@ -17,6 +17,11 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "username of owner the account",
},
"desc": {
Type: schema.TypeString,
Optional: true,
Description: "description",
},
"emailaddress": {
Type: schema.TypeString,
Optional: true,
@@ -72,6 +77,11 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
},
Description: "Share images with account",
},
"reason": {
Type: schema.TypeBool,
Optional: true,
Description: "reason for restore or deactivation",
},
"restore": {
Type: schema.TypeBool,
Optional: true,
@@ -138,7 +148,7 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"hugepages", "numa", "cpupin", "vfnic"}, true),
ValidateFunc: validation.StringInSlice([]string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac"}, true),
},
},
"account_id": {
@@ -576,6 +586,10 @@ func dataSourceAccountListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeFloat,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
@@ -1214,6 +1228,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeFloat,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
@@ -1710,6 +1728,10 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
@@ -1973,6 +1995,10 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,

View File

@@ -218,6 +218,10 @@ func utilityAccountUpdate(ctx context.Context, d *schema.ResourceData, m interfa
req.Name = d.Get("account_name").(string)
}
if d.HasChange("desc") {
req.Description = d.Get("desc").(string)
}
if d.HasChange("send_access_emails") {
req.SendAccessEmails = d.Get("send_access_emails").(bool)
}

View File

@@ -52,6 +52,7 @@ func flattenAudit(d *schema.ResourceData, au *audit.RecordAudit) {
d.Set("tags", au.Tags)
d.Set("timestamp", au.Timestamp)
d.Set("timestamp_end", au.TimestampEnd)
d.Set("ttl", au.TTL)
d.Set("user", au.User)
}
@@ -59,12 +60,19 @@ func flattenAuditList(au *audit.ListAudits) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(au.Data))
for _, item := range au.Data {
temp := map[string]interface{}{
"call": item.Call,
"guid": item.GUID,
"responsetime": item.ResponseTime,
"status_code": item.StatusCode,
"timestamp": item.Timestamp,
"user": item.User,
"args": item.Args,
"call": item.Call,
"guid": item.GUID,
"kwargs": item.Kwargs,
"remote_addr": item.RemoteAddr,
"result": item.Result,
"responsetime": item.ResponseTime,
"status_code": item.StatusCode,
"tags": item.Tags,
"timestamp": item.Timestamp,
"timestamp_end": item.TimestampEnd,
"ttl": item.TTL,
"user": item.User,
}
res = append(res, temp)
}
@@ -76,14 +84,15 @@ func flattenLinkedJobs(ljl *audit.ListLinkedJobs) []map[string]interface{} {
linkedJobs := *ljl
for _, item := range linkedJobs {
temp := map[string]interface{}{
"cmd": item.CMD,
"guid": item.GUID,
"nid": item.NID,
"state": item.State,
"time_create": item.TimeCreate,
"time_start": item.TimeStart,
"time_stop": item.TimeStop,
"timeout": item.Timeout,
"cmd": item.CMD,
"guid": item.GUID,
"nid": item.NID,
"physical_node": item.PhysicalNode,
"state": item.State,
"time_create": item.TimeCreate,
"time_start": item.TimeStart,
"time_stop": item.TimeStop,
"timeout": item.Timeout,
}
res = append(res, temp)
}

View File

@@ -54,6 +54,10 @@ func dataSourceAuditSchemaMake() map[string]*schema.Schema {
Type: schema.TypeFloat,
Computed: true,
},
"ttl": {
Type: schema.TypeString,
Computed: true,
},
"user": {
Type: schema.TypeString,
Computed: true,
@@ -103,12 +107,16 @@ func dataSourceAuditListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "page number",
},
"request_id": {
Type: schema.TypeString,
Optional: true,
Description: "request id",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -138,6 +146,34 @@ func dataSourceAuditListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"ttl": {
Type: schema.TypeString,
Computed: true,
},
"args": {
Type: schema.TypeString,
Computed: true,
},
"kwargs": {
Type: schema.TypeString,
Computed: true,
},
"result": {
Type: schema.TypeString,
Computed: true,
},
"timestamp_end": {
Type: schema.TypeFloat,
Computed: true,
},
"remote_addr": {
Type: schema.TypeString,
Computed: true,
},
"tags": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
@@ -177,6 +213,10 @@ func dataSourceLinkedJobsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "nid",
},
"physical_node": {
Type: schema.TypeBool,
Computed: true,
},
"state": {
Type: schema.TypeString,
Computed: true,

View File

@@ -70,6 +70,9 @@ func utilityAuditListCheckPresence(ctx context.Context, d *schema.ResourceData,
if Page, ok := d.GetOk("page"); ok {
req.Page = uint64(Page.(int))
}
if RequestID, ok := d.GetOk("request_id"); ok {
req.RequestID = RequestID.(string)
}
if Size, ok := d.GetOk("size"); ok {
req.Size = uint64(Size.(int))
}

View File

@@ -15,7 +15,9 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("acl", string(diskAcl))
d.Set("boot_partition", disk.BootPartition)
d.Set("computes", flattenDiskComputes(disk.Computes))
d.Set("created_by", disk.CreatedBy)
d.Set("created_time", disk.CreatedTime)
d.Set("deleted_by", disk.DeletedBy)
d.Set("deleted_time", disk.DeletedTime)
d.Set("desc", disk.Description)
d.Set("destruction_time", disk.DestructionTime)
@@ -29,6 +31,8 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("iotune", flattenIOTune(disk.IOTune))
d.Set("iqn", disk.IQN)
d.Set("login", disk.Login)
d.Set("machine_id", disk.MachineID)
d.Set("machine_name", disk.MachineName)
d.Set("milestones", disk.Milestones)
d.Set("disk_name", disk.Name)
d.Set("order", disk.Order)
@@ -49,6 +53,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("sep_id", disk.SEPID)
d.Set("sep_type", disk.SEPType)
d.Set("shareable", disk.Shareable)
d.Set("size_available", disk.SizeAvailable)
d.Set("size_max", disk.SizeMax)
d.Set("size_used", disk.SizeUsed)
d.Set("snapshots", flattendDiskSnapshotList(disk.Snapshots))
@@ -56,6 +61,8 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
d.Set("updated_by", disk.UpdatedBy)
d.Set("updated_time", disk.UpdatedTime)
}
func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusReplication string) {
@@ -176,7 +183,9 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"acl": string(diskAcl),
"boot_partition": disk.BootPartition,
"computes": flattenDiskComputes(disk.Computes),
"created_by": disk.CreatedBy,
"created_time": disk.CreatedTime,
"deleted_by": disk.DeletedBy,
"deleted_time": disk.DeletedTime,
"desc": disk.Description,
"destruction_time": disk.DestructionTime,
@@ -210,6 +219,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"role": disk.Role,
"sep_id": disk.SEPID,
"sep_type": disk.SEPType,
"size_available": disk.SizeAvailable,
"size_max": disk.SizeMax,
"size_used": disk.SizeUsed,
"snapshots": flattendDiskSnapshotList(disk.Snapshots),
@@ -217,6 +227,8 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"tech_status": disk.TechStatus,
"type": disk.Type,
"vmid": disk.VMID,
"updated_by": disk.UpdatedBy,
"updated_time": disk.UpdatedTime,
}
res = append(res, temp)
}

View File

@@ -2,6 +2,7 @@ package disks
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/ic"
@@ -14,15 +15,10 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro
var errs []error
accountID := uint64(d.Get("account_id").(int))
gid := uint64(d.Get("gid").(int))
if err := ic.ExistAccount(ctx, accountID, c); err != nil {
errs = append(errs, err)
}
if err := ic.ExistGID(ctx, gid, c); err != nil {
errs = append(errs, err)
}
return dc.ErrorsToDiagnostics(errs)
}

View File

@@ -58,20 +58,14 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
req := disks.CreateRequest{
AccountID: uint64(d.Get("account_id").(int)),
GID: uint64(d.Get("gid").(int)),
Name: d.Get("disk_name").(string),
Size: uint64(d.Get("size_max").(int)),
Type: d.Get("type").(string),
}
if desc, ok := d.GetOk("desc"); ok {
req.Description = desc.(string)
}
if ssdSize, ok := d.GetOk("ssd_size"); ok {
req.SSDSize = uint64(ssdSize.(int))
}
if iops, ok := d.GetOk("iops"); ok {
req.IOPS = uint64(iops.(int))
}

View File

@@ -2,7 +2,6 @@ package disks
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func dataSourceDiskSchemaMake() map[string]*schema.Schema {
@@ -43,10 +42,18 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
@@ -154,6 +161,14 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"machine_id": {
Type: schema.TypeInt,
Computed: true,
},
"machine_name": {
Type: schema.TypeString,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
@@ -187,7 +202,7 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -266,6 +281,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -326,6 +345,14 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets
@@ -435,10 +462,18 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
@@ -591,7 +626,7 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -670,6 +705,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -730,6 +769,14 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -830,10 +877,18 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
@@ -986,7 +1041,7 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1065,6 +1120,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -1125,6 +1184,14 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -1505,7 +1572,7 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Description: "Pool for disk location",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1796,22 +1863,18 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Required: true,
//ForceNew: true,
},
"gid": {
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"disk_name": {
Type: schema.TypeString,
Required: true,
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"D", "B", "T"}, false),
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"desc": {
Type: schema.TypeString,
Optional: true,
@@ -1821,9 +1884,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Required: true,
},
"ssd_size": {
Type: schema.TypeInt,
Optional: true,
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"iops": {
Type: schema.TypeInt,
@@ -1922,6 +1986,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"disk_id": {
Type: schema.TypeInt,
Computed: true,
@@ -2020,11 +2088,18 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"machine_id": {
Type: schema.TypeInt,
Computed: true,
},
"machine_name": {
Type: schema.TypeString,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"order": {
Type: schema.TypeInt,
Computed: true,
@@ -2046,7 +2121,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -2169,6 +2244,14 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets
@@ -2367,7 +2450,7 @@ func dataSourceDiskReplicationSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -2741,7 +2824,7 @@ func resourceDiskReplicationSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,

View File

@@ -85,6 +85,7 @@ func flattenRecordExtnet(d *schema.ResourceData, recNet *extnet.RecordExtNet) {
d.Set("milestones", recNet.Milestones)
d.Set("name", recNet.Name)
d.Set("network_id", recNet.NetworkID)
d.Set("ntp", recNet.NTP)
d.Set("ovs_bridge", recNet.OVSBridge)
d.Set("pre_reservations_num", recNet.PreReservationsNum)
d.Set("pri_vnfdev_id", recNet.PriVNFDevID)

View File

@@ -516,6 +516,13 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
},
},
},
"ntp": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
}
}

View File

@@ -41,7 +41,6 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/ic"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
)
@@ -53,12 +52,6 @@ func resourceCDROMImageCreate(ctx context.Context, d *schema.ResourceData, m int
URL: d.Get("url").(string),
}
if err := ic.ExistGID(ctx, uint64(d.Get("gid").(int)), c); err != nil {
return diag.FromErr(err)
}
req.GID = uint64(d.Get("gid").(int))
drivers := []string{}
for _, driver := range d.Get("drivers").([]interface{}) {
drivers = append(drivers, driver.(string))

View File

@@ -354,41 +354,47 @@ func resourceImageChangeAccess(ctx context.Context, d *schema.ResourceData, m in
oldSet, newSet := d.GetChange("accounts")
revokeAccess := (oldSet.(*schema.Set).Difference(newSet.(*schema.Set))).List()
if len(revokeAccess) > 0 {
revokeAccounts := make([]uint64, 0, len(revokeAccess))
revokeAccounts := make([]int64, 0, len(revokeAccess))
if newSet.(*schema.Set).Len() == 0 {
revokeAccounts = append(revokeAccounts, -1)
} else if len(revokeAccess) > 0 {
for _, accountId := range revokeAccess {
revokeAccounts = append(revokeAccounts, uint64(accountId.(int)))
revokeAccounts = append(revokeAccounts, accountId.(int64))
}
req := image.RevokeAccessRequest{
ImageID: imageId,
AccountIDs: revokeAccounts,
}
}
_, err := c.CloudBroker().Image().RevokeAccess(ctx, req)
if err != nil {
return err
}
req := image.RevokeAccessRequest{
ImageID: imageId,
AccountIDs: revokeAccounts,
}
_, err := c.CloudBroker().Image().RevokeAccess(ctx, req)
if err != nil {
return err
}
addedAccess := (newSet.(*schema.Set).Difference(oldSet.(*schema.Set))).List()
if len(addedAccess) > 0 {
grantAccounts := make([]uint64, 0, len(addedAccess))
grantAccounts := make([]int64, 0, len(addedAccess))
if newSet.(*schema.Set).Len() == 0 {
grantAccounts = append(grantAccounts, -1)
} else if len(addedAccess) > 0 {
for _, accountId := range addedAccess {
grantAccounts = append(grantAccounts, uint64(accountId.(int)))
grantAccounts = append(grantAccounts, accountId.(int64))
}
req := image.GrantAccessRequest{
ImageID: imageId,
AccountIDs: grantAccounts,
}
_, err := c.CloudBroker().Image().GrantAccess(ctx, req)
if err != nil {
return err
}
}
// req := image.GrantAccessRequest{
// ImageID: imageId,
// AccountIDs: grantAccounts,
// }
// _, err := c.CloudBroker().Image().GrantAccess(ctx, req)
// if err != nil {
// return err
// }
return nil
}
@@ -399,9 +405,9 @@ func resourceImageSetAccess(ctx context.Context, d *schema.ResourceData, m inter
imageId, _ := strconv.ParseUint(d.Id(), 10, 64)
accounts := d.Get("accounts").([]interface{})
accountIDs := make([]uint64, 0, len(accounts))
accountIDs := make([]int64, 0, len(accounts))
for _, accountId := range accounts {
accountIDs = append(accountIDs, uint64(accountId.(int)))
accountIDs = append(accountIDs, accountId.(int64))
}
req := image.GrantAccessRequest{

View File

@@ -74,9 +74,6 @@ func resourceImageFromBlankComputeCreate(ctx context.Context, d *schema.Resource
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.SepID = uint64(sepId.(int))
}
if poolName, ok := d.GetOk("pool_name"); ok {
req.PoolName = poolName.(string)
}

View File

@@ -76,9 +76,6 @@ func resourceImageFromPlatformDiskCreate(ctx context.Context, d *schema.Resource
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.SepID = uint64(sepId.(int))
}
if poolName, ok := d.GetOk("pool_name"); ok {
req.PoolName = poolName.(string)
}

View File

@@ -574,7 +574,7 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
Description: "pool for image create",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -832,7 +832,7 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema {
Description: "pool for image create",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -930,11 +930,6 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "URL where to download ISO from",
},
"gid": {
Type: schema.TypeInt,
Required: true,
Description: "grid (platform) ID where this template should be create in",
},
"drivers": {
Type: schema.TypeList,
Optional: true,
@@ -1068,6 +1063,10 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Boot type of image bios or uefi",
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
@@ -1128,7 +1127,7 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1200,11 +1199,6 @@ func resourceImageSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "path to image file",
},
"gid": {
Type: schema.TypeInt,
Required: true,
Description: "grid (platform) ID where this template should be create in",
},
"boot_type": {
Type: schema.TypeString,
Required: true,
@@ -1365,6 +1359,10 @@ func resourceImageSchemaMake() map[string]*schema.Schema {
},
},
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
@@ -1424,7 +1422,7 @@ func resourceImageSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1669,7 +1667,7 @@ func resourceVirtualImageSchemaMake() map[string]*schema.Schema {
Description: "pool for image create",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1763,8 +1761,8 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
"image_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, true),
Description: "Image type linux, windows or unknown",
},
"username": {
@@ -1787,7 +1785,6 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
@@ -1966,7 +1963,7 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -2037,8 +2034,8 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
"image_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, true),
Description: "Image type linux, windows or unknown",
},
"architecture": {
Type: schema.TypeString,
@@ -2067,7 +2064,6 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
@@ -2245,7 +2241,7 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,

View File

@@ -36,8 +36,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/ic"
)
func SyncCreateRequest(ctx context.Context, d *schema.ResourceData, m interface{}, url string) (image.SyncCreateRequest, error) {
@@ -100,14 +98,6 @@ func CreateRequest(ctx context.Context, d *schema.ResourceData, m interface{}, u
ImageType: d.Get("image_type").(string),
}
c := m.(*controller.ControllerCfg)
if err := ic.ExistGID(ctx, uint64(d.Get("gid").(int)), c); err != nil {
return req, err
}
req.GID = uint64(d.Get("gid").(int))
if _, ok := d.GetOk("drivers"); ok {
drivers := []string{}
for _, driver := range d.Get("drivers").([]interface{}) {

View File

@@ -50,6 +50,7 @@ func flattenResourceK8sCP(d *schema.ResourceData, k8s k8s.RecordK8S, masters []c
d.Set("bservice_id", k8s.BServiceID)
d.Set("created_by", k8s.CreatedBy)
d.Set("created_time", k8s.CreatedTime)
d.Set("desc", k8s.Description)
d.Set("deleted_by", k8s.DeletedBy)
d.Set("deleted_time", k8s.DeletedTime)
d.Set("k8s_ci_name", k8s.K8CIName)
@@ -91,6 +92,7 @@ func flattenK8sData(d *schema.ResourceData, cluster *k8s.RecordK8S, masters []co
d.Set("created_time", cluster.CreatedTime)
d.Set("deleted_by", cluster.DeletedBy)
d.Set("deleted_time", cluster.DeletedTime)
d.Set("desc", cluster.Description)
d.Set("k8s_id", cluster.ID)
d.Set("k8s_ci_name", cluster.K8CIName)
d.Set("k8s_groups", flattenK8sGroups(cluster.K8SGroups, masters, workers))

View File

@@ -51,12 +51,12 @@ func dataSourceComputeListDeletedRead(ctx context.Context, d *schema.ResourceDat
result := computeList
if d.Get("ignore_k8s").(bool) {
// matches automatically generated names like "s234-g2134-c1" etc
result = matchComputes(computeList)
result = matchDeletedComputes(computeList)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenComputeList(result))
d.Set("items", flattenDeletedComputeList(result))
d.Set("entry_count", computeList.EntryCount)
return nil

View File

@@ -75,7 +75,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
d.Set("need_reboot", computeRec.NeedReboot)
d.Set("numa_node_id", computeRec.NumaNodeId)
d.Set("os_users", flattenOSUsers(computeRec.OSUsers))
d.Set("pinned", computeRec.Pinned)
d.Set("pinned", computeRec.PinnedToStack)
d.Set("preferred_cpu", computeRec.PreferredCPU)
d.Set("reference_id", computeRec.ReferenceID)
d.Set("registered", computeRec.Registered)
@@ -95,10 +95,14 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
d.Set("user_data", string(userData))
d.Set("user_managed", computeRec.UserManaged)
d.Set("vnc_password", computeRec.VNCPassword)
d.Set("vgpus", computeRec.VGPUs)
d.Set("vgpus", flattenVGPUs(computeRec.VGPUs))
d.Set("virtual_image_id", computeRec.VirtualImageID)
d.Set("virtual_image_name", computeRec.VirtualImageName)
d.Set("pci_devices", flattenPCI(*pciList))
d.Set("loader_type", computeRec.LoaderType)
d.Set("boot_type", computeRec.BootType)
d.Set("hot_resize", computeRec.HotResize)
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
return nil
}
@@ -249,6 +253,7 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
"size_used": disk.SizeUsed,
"size_max": disk.SizeMax,
"permanently": pernamentlyValue,
"present_to": disk.PresentTo,
}
res = append(res, temp)
indexDataDisks++
@@ -289,73 +294,164 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
devices, _ := json.Marshal(computeItem.Devices)
userData, _ := json.Marshal(computeItem.Userdata)
temp := map[string]interface{}{
"acl": flattenListACLInterface(computeItem.ACL),
"account_id": computeItem.AccountID,
"account_name": computeItem.AccountName,
"affinity_label": computeItem.AffinityLabel,
"affinity_rules": flattenListRules(computeItem.AffinityRules),
"affinity_weight": computeItem.AffinityWeight,
"anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules),
"arch": computeItem.Arch,
"auto_start_w_node": computeItem.AutoStart,
"chipset": computeItem.Chipset,
"cd_image_id": computeItem.CdImageId,
"boot_order": computeItem.BootOrder,
"bootdisk_size": computeItem.BootDiskSize,
"clone_reference": computeItem.CloneReference,
"clones": computeItem.Clones,
"computeci_id": computeItem.ComputeCIID,
"cpus": computeItem.CPUs,
"created_by": computeItem.CreatedBy,
"created_time": computeItem.CreatedTime,
"custom_fields": string(customFields),
"deleted_by": computeItem.DeletedBy,
"deleted_time": computeItem.DeletedTime,
"desc": computeItem.Description,
"devices": string(devices),
"disks": flattenDisks(computeItem.Disks),
"driver": computeItem.Driver,
"gid": computeItem.GID,
"guid": computeItem.GUID,
"hp_backed": computeItem.HPBacked,
"compute_id": computeItem.ID,
"cpu_pin": computeItem.CPUPin,
"image_id": computeItem.ImageID,
"interfaces": flattenInterfaces(computeItem.Interfaces),
"lock_status": computeItem.LockStatus,
"manager_id": computeItem.ManagerID,
"manager_type": computeItem.ManagerType,
"migrationjob": computeItem.MigrationJob,
"milestones": computeItem.Milestones,
"name": computeItem.Name,
"need_reboot": computeItem.NeedReboot,
"numa_affinity": computeItem.NumaAffinity,
"numa_node_id": computeItem.NumaNodeId,
"os_users": flattenOSUsers(computeItem.OSUsers),
"pinned": computeItem.Pinned,
"preferred_cpu": computeItem.PreferredCPU,
"ram": computeItem.RAM,
"reference_id": computeItem.ReferenceID,
"registered": computeItem.Registered,
"res_name": computeItem.ResName,
"reserved_node_cpus": computeItem.ReservedNodeCpus,
"rg_id": computeItem.RGID,
"rg_name": computeItem.RGName,
"snap_sets": flattenSnapSets(computeItem.SnapSets),
"stack_id": computeItem.StackID,
"stateless_sep_id": computeItem.StatelessSEPID,
"stateless_sep_type": computeItem.StatelessSEPType,
"status": computeItem.Status,
"tags": flattenTags(computeItem.Tags),
"tech_status": computeItem.TechStatus,
"total_disk_size": computeItem.TotalDiskSize,
"updated_by": computeItem.UpdatedBy,
"updated_time": computeItem.UpdatedTime,
"user_data": string(userData),
"user_managed": computeItem.UserManaged,
"vgpus": computeItem.VGPUs,
"vins_connected": computeItem.VINSConnected,
"virtual_image_id": computeItem.VirtualImageID,
"acl": flattenListACLInterface(computeItem.ACL),
"account_id": computeItem.AccountID,
"account_name": computeItem.AccountName,
"affinity_label": computeItem.AffinityLabel,
"affinity_rules": flattenListRules(computeItem.AffinityRules),
"affinity_weight": computeItem.AffinityWeight,
"anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules),
"arch": computeItem.Arch,
"auto_start_w_node": computeItem.AutoStart,
"chipset": computeItem.Chipset,
"cd_image_id": computeItem.CdImageId,
"boot_order": computeItem.BootOrder,
"bootdisk_size": computeItem.BootDiskSize,
"clone_reference": computeItem.CloneReference,
"clones": computeItem.Clones,
"computeci_id": computeItem.ComputeCIID,
"cpus": computeItem.CPUs,
"created_by": computeItem.CreatedBy,
"created_time": computeItem.CreatedTime,
"custom_fields": string(customFields),
"deleted_by": computeItem.DeletedBy,
"deleted_time": computeItem.DeletedTime,
"desc": computeItem.Description,
"devices": string(devices),
"disks": flattenDisks(computeItem.Disks),
"driver": computeItem.Driver,
"gid": computeItem.GID,
"guid": computeItem.GUID,
"hp_backed": computeItem.HPBacked,
"compute_id": computeItem.ID,
"cpu_pin": computeItem.CPUPin,
"image_id": computeItem.ImageID,
"interfaces": flattenInterfaces(computeItem.Interfaces),
"lock_status": computeItem.LockStatus,
"manager_id": computeItem.ManagerID,
"manager_type": computeItem.ManagerType,
"migrationjob": computeItem.MigrationJob,
"milestones": computeItem.Milestones,
"nid": computeItem.NID,
"name": computeItem.Name,
"need_reboot": computeItem.NeedReboot,
"numa_affinity": computeItem.NumaAffinity,
"numa_node_id": computeItem.NumaNodeId,
"os_users": flattenOSUsers(computeItem.OSUsers),
"pinned": computeItem.PinnedToStack,
"preferred_cpu": computeItem.PreferredCPU,
"ram": computeItem.RAM,
"reference_id": computeItem.ReferenceID,
"registered": computeItem.Registered,
"res_name": computeItem.ResName,
"reserved_node_cpus": computeItem.ReservedNodeCpus,
"rg_id": computeItem.RGID,
"rg_name": computeItem.RGName,
"snap_sets": flattenSnapSets(computeItem.SnapSets),
"stack_id": computeItem.StackID,
"stack_name": computeItem.StackName,
"stateless_sep_id": computeItem.StatelessSEPID,
"stateless_sep_type": computeItem.StatelessSEPType,
"status": computeItem.Status,
"tags": flattenTags(computeItem.Tags),
"tech_status": computeItem.TechStatus,
"total_disk_size": computeItem.TotalDiskSize,
"updated_by": computeItem.UpdatedBy,
"updated_time": computeItem.UpdatedTime,
"user_data": string(userData),
"user_managed": computeItem.UserManaged,
"vgpus": computeItem.VGPUs,
"vins_connected": computeItem.VINSConnected,
"virtual_image_id": computeItem.VirtualImageID,
"loader_type": computeItem.LoaderType,
"boot_type": computeItem.BootType,
"hot_resize": computeItem.HotResize,
"network_interface_naming": computeItem.NetworkInterfaceNaming,
}
res = append(res, temp)
}
return res
}
func flattenDeletedComputeList(computes *compute.ListDeletedComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(computes.Data))
for _, computeItem := range computes.Data {
customFields, _ := json.Marshal(computeItem.CustomFields)
devices, _ := json.Marshal(computeItem.Devices)
userData, _ := json.Marshal(computeItem.Userdata)
temp := map[string]interface{}{
"acl": flattenListACLInterface(computeItem.ACL),
"account_id": computeItem.AccountID,
"account_name": computeItem.AccountName,
"affinity_label": computeItem.AffinityLabel,
"affinity_rules": flattenListRules(computeItem.AffinityRules),
"affinity_weight": computeItem.AffinityWeight,
"anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules),
"arch": computeItem.Arch,
"auto_start_w_node": computeItem.AutoStart,
"chipset": computeItem.Chipset,
"cd_image_id": computeItem.CdImageId,
"boot_order": computeItem.BootOrder,
"bootdisk_size": computeItem.BootDiskSize,
"clone_reference": computeItem.CloneReference,
"clones": computeItem.Clones,
"computeci_id": computeItem.ComputeCIID,
"cpus": computeItem.CPUs,
"created_by": computeItem.CreatedBy,
"created_time": computeItem.CreatedTime,
"custom_fields": string(customFields),
"deleted_by": computeItem.DeletedBy,
"deleted_time": computeItem.DeletedTime,
"desc": computeItem.Description,
"devices": string(devices),
"disks": flattenDisks(computeItem.Disks),
"driver": computeItem.Driver,
"gid": computeItem.GID,
"guid": computeItem.GUID,
"hp_backed": computeItem.HPBacked,
"compute_id": computeItem.ID,
"cpu_pin": computeItem.CPUPin,
"image_id": computeItem.ImageID,
"interfaces": flattenInterfaces(computeItem.Interfaces),
"lock_status": computeItem.LockStatus,
"manager_id": computeItem.ManagerID,
"manager_type": computeItem.ManagerType,
"migrationjob": computeItem.MigrationJob,
"milestones": computeItem.Milestones,
"name": computeItem.Name,
"need_reboot": computeItem.NeedReboot,
"numa_affinity": computeItem.NumaAffinity,
"numa_node_id": computeItem.NumaNodeId,
"os_users": flattenOSUsers(computeItem.OSUsers),
"pinned": computeItem.PinnedToStack,
"preferred_cpu": computeItem.PreferredCPU,
"ram": computeItem.RAM,
"reference_id": computeItem.ReferenceID,
"registered": computeItem.Registered,
"res_name": computeItem.ResName,
"reserved_node_cpus": computeItem.ReservedNodeCpus,
"rg_id": computeItem.RGID,
"rg_name": computeItem.RGName,
"snap_sets": flattenSnapSets(computeItem.SnapSets),
"stack_id": computeItem.StackID,
"stack_name": computeItem.StackName,
"stateless_sep_id": computeItem.StatelessSEPID,
"stateless_sep_type": computeItem.StatelessSEPType,
"status": computeItem.Status,
"tags": flattenTags(computeItem.Tags),
"tech_status": computeItem.TechStatus,
"total_disk_size": computeItem.TotalDiskSize,
"updated_by": computeItem.UpdatedBy,
"updated_time": computeItem.UpdatedTime,
"user_data": string(userData),
"user_managed": computeItem.UserManaged,
"vgpus": computeItem.VGPUs,
"vins_connected": computeItem.VINSConnected,
"virtual_image_id": computeItem.VirtualImageID,
"loader_type": computeItem.LoaderType,
"boot_type": computeItem.BootType,
"hot_resize": computeItem.HotResize,
"network_interface_naming": computeItem.NetworkInterfaceNaming,
}
res = append(res, temp)
}
@@ -431,9 +527,9 @@ func flattenDisks(disks []compute.InfoDisk) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, disk := range disks {
temp := map[string]interface{}{
"bus_number": disk.BusNumber,
"disk_id": disk.ID,
"pci_slot": disk.PCISlot,
// "bus_number": disk.BusNumber,
"disk_id": disk.ID,
// "pci_slot": disk.PCISlot,
}
res = append(res, temp)
}
@@ -657,7 +753,7 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
d.Set("numa_affinity", compFacts.NumaAffinity)
d.Set("numa_node_id", compFacts.NumaNodeId)
d.Set("os_users", flattenOSUsers(compFacts.OSUsers))
d.Set("pinned", compFacts.Pinned)
d.Set("pinned", compFacts.PinnedToStack)
d.Set("preferred_cpu", compFacts.PreferredCPU)
d.Set("ram", compFacts.RAM)
d.Set("reference_id", compFacts.ReferenceID)
@@ -679,10 +775,14 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
d.Set("user_data", string(userData))
d.Set("user_managed", compFacts.UserManaged)
d.Set("vnc_password", compFacts.VNCPassword)
d.Set("vgpus", compFacts.VGPUs)
d.Set("vgpus", flattenVGPUs(compFacts.VGPUs))
d.Set("virtual_image_id", compFacts.VirtualImageID)
d.Set("virtual_image_name", compFacts.VirtualImageName)
d.Set("pci_devices", flattenPCI(*pciList))
d.Set("loader_type", compFacts.LoaderType)
d.Set("boot_type", compFacts.BootType)
d.Set("hot_resize", compFacts.HotResize)
d.Set("network_interface_naming", compFacts.NetworkInterfaceNaming)
//extra fields setting
bootDisk := findBootDisk(compFacts.Disks)
if bootDisk != nil {
@@ -771,6 +871,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
"role": disk.Role,
"sep_id": disk.SEPID,
"shareable": disk.Shareable,
"size_available": disk.SizeAvailable,
"size_max": disk.SizeMax,
"size_used": disk.SizeUsed,
"snapshots": flattendDiskSnapshotList(disk.Snapshots),
@@ -837,3 +938,34 @@ func flattendDiskSnapshotList(sl compute.ListDetailedSnapshots) []interface{} {
return res
}
func flattenVGPUs(vgpus []compute.VGPUItem) []map[string]interface{} {
res := make([]map[string]interface{}, len(vgpus))
for i, vgpu := range vgpus {
res[i] = map[string]interface{}{
"id": int(vgpu.ID),
"gid": int(vgpu.GID),
"type": vgpu.Type,
"mode": vgpu.Mode,
"status": vgpu.Status,
"profile_id": vgpu.ProfileID,
"ram": int(vgpu.RAM),
"last_update_time": int(vgpu.LastUpdateTime),
"created_time": int(vgpu.CreatedTime),
"deleted_time": int(vgpu.DeletedTime),
"vmid": int(vgpu.VMID),
"pgpuid": int(vgpu.PGPuid),
"reference_id": vgpu.ReferenceID,
"account_id": int(vgpu.AccountID),
"rg_id": int(vgpu.RgID),
"last_claimed_by": int(vgpu.LastClaimedBy),
"pci_slot": int(vgpu.PCISlot),
"bus_number": int(vgpu.BusNumber),
"guid": int(vgpu.GUID),
}
}
return res
}

File diff suppressed because it is too large Load Diff

View File

@@ -121,6 +121,11 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
reqInterface.IPAddr = ipaddr.(string)
}
macaddr, macSet := netInterfaceVal["mac"]
if macSet {
reqInterface.MAC = macaddr.(string)
}
interfacesX86 = append(interfacesX86, reqInterface)
}
createReqX86.Interfaces = interfacesX86
@@ -242,6 +247,38 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
log.Debugf("resourceComputeCreate: new simple Compute ID %d, name %s created", computeId, d.Get("name").(string))
updateReq := compute.UpdateRequest{}
loaderType, loaderTypeOk := d.GetOk("loader_type")
bootType, bootTypeOk := d.GetOk("boot_type")
hotResize, hotResizeOk := d.GetOk("hot_resize")
networkInterfaceNaming, networkInterfaceNamingOk := d.GetOk("network_interface_naming")
if loaderTypeOk {
updateReq.LoaderType = loaderType.(string)
}
if bootTypeOk {
updateReq.BootType = bootType.(string)
}
if hotResizeOk {
updateReq.HotResize = hotResize.(bool)
}
if networkInterfaceNamingOk {
updateReq.NetworkInterfaceNaming = networkInterfaceNaming.(string)
}
if loaderTypeOk || bootTypeOk || hotResizeOk || networkInterfaceNamingOk {
log.Debugf("resourceComputeCreate: change loaderType or bootType or hotResize or networkInterfaceNaming on ComputeID: %d", computeId)
updateReq.ComputeID = computeId
_, err := c.CloudBroker().Compute().Update(ctx, updateReq)
if err != nil {
warnings.Add(err)
}
}
if ars, ok := d.GetOk("pci_devices"); ok {
log.Debugf("resourceComputeCreate: add pci devices on ComputeID: %d", computeId)
addedPciDevices := ars.(*schema.Set).List()
@@ -352,9 +389,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
}
} else if ok && !start.(bool) {
req := compute.StopRequest{ComputeID: computeId}
if depresent, ok := d.Get("depresent").(bool); ok {
req.Depresent = depresent
}
log.Debugf("resourceComputeCreate: stoping Compute ID %d after completing its resource configuration", computeId)
if _, err := c.CloudBroker().Compute().Stop(ctx, req); err != nil {
warnings.Add(err)
@@ -713,7 +747,18 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if d.HasChanges("description", "name", "numa_affinity", "cpu_pin", "hp_backed", "chipset", "auto_start_w_node", "preferred_cpu") {
if d.HasChanges("description",
"name",
"numa_affinity",
"cpu_pin",
"hp_backed",
"chipset",
"auto_start_w_node",
"preferred_cpu",
"loader_type",
"boot_type",
"hot_resize",
"network_interface_naming") {
if err := utilityComputeUpdate(ctx, d, m); err != nil {
return diag.FromErr(err)
}
@@ -874,7 +919,7 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
func ResourceCompute() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 2,
CustomizeDiff: func(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error {
if diff.HasChanges() || diff.HasChanges("chipset", "pin_to_stack", "auto_start_w_node", "libvirt_settings", "network", "affinity_rules", "anti_affinity_rules",
@@ -911,5 +956,12 @@ func ResourceCompute() *schema.Resource {
},
Schema: resourceComputeSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceComputeResourceV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourceCompueteStateUpgradeV1,
Version: 1,
},
},
}
}

View File

@@ -391,7 +391,7 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -466,6 +466,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"size_available": {
Type: schema.TypeFloat,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
@@ -789,7 +793,7 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
},
},
"pinned": {
Type: schema.TypeBool,
Type: schema.TypeInt,
Computed: true,
},
"preferred_cpu": {
@@ -918,10 +922,88 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"vgpus": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
Type: schema.TypeList,
Computed: true,
Description: "List of virtual GPUs",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"mode": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"profile_id": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"last_update_time": {
Type: schema.TypeInt,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
},
"pgpuid": {
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"last_claimed_by": {
Type: schema.TypeInt,
Computed: true,
},
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
},
"bus_number": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"virtual_image_id": {
@@ -949,6 +1031,22 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"loader_type": {
Type: schema.TypeString,
Computed: true,
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
}
return res
}
@@ -985,6 +1083,11 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Find by tech status",
},
"stack_name": {
Type: schema.TypeString,
Optional: true,
Description: "Find by node name.",
},
"status": {
Type: schema.TypeString,
Optional: true,
@@ -1462,6 +1565,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"nid": {
Type: schema.TypeInt,
Computed: true,
},
"numa_affinity": {
Type: schema.TypeString,
Computed: true,
@@ -1495,7 +1602,7 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
},
},
"pinned": {
Type: schema.TypeBool,
Type: schema.TypeInt,
Computed: true,
},
"preferred_cpu": {
@@ -1567,6 +1674,11 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"stack_name": {
Type: schema.TypeString,
Computed: true,
Description: "Find by node name.",
},
"stateless_sep_id": {
Type: schema.TypeInt,
Computed: true,
@@ -1634,6 +1746,22 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"loader_type": {
Type: schema.TypeString,
Computed: true,
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
@@ -1848,6 +1976,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"chipset": {
Type: schema.TypeString,
Computed: true,
},
"cd_image_id": {
Type: schema.TypeInt,
Computed: true,
@@ -1948,6 +2080,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"bus_number": {
Type: schema.TypeInt,
Computed: true,
},
"conn_id": {
Type: schema.TypeInt,
Computed: true,
@@ -1984,6 +2120,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"mtu": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
@@ -2032,6 +2172,42 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
},
},
},
"libvirt_settings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"guid": {
Type: schema.TypeString,
Computed: true,
},
"txmode": {
Type: schema.TypeString,
Computed: true,
},
"ioeventfd": {
Type: schema.TypeString,
Computed: true,
},
"event_idx": {
Type: schema.TypeString,
Computed: true,
},
"queues": {
Type: schema.TypeInt,
Computed: true,
},
"rx_queue_size": {
Type: schema.TypeInt,
Computed: true,
},
"tx_queue_size": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"target": {
Type: schema.TypeString,
Computed: true,
@@ -2111,10 +2287,6 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
},
},
"pinned": {
Type: schema.TypeBool,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
@@ -2125,6 +2297,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
@@ -2183,6 +2359,11 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"stack_name": {
Type: schema.TypeString,
Computed: true,
Description: "Find by node name.",
},
"stateless_sep_id": {
Type: schema.TypeInt,
Computed: true,
@@ -2250,6 +2431,22 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"loader_type": {
Type: schema.TypeString,
Computed: true,
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
@@ -3001,12 +3198,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Optional text description of this compute instance.",
},
"depresent": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "whether to depresent compute disks from node or not",
},
"started": {
Type: schema.TypeBool,
Optional: true,
@@ -3044,7 +3235,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeSet,
Optional: true,
MinItems: 1,
MaxItems: constants.MAX_NETWORKS_PER_COMPUTE,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"net_type": {
@@ -3067,9 +3257,11 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Description: "Optional IP address to assign to this connection. This IP should belong to the selected network and free for use.",
},
"mac": {
Type: schema.TypeString,
Computed: true,
Description: "MAC address associated with this connection. MAC address is assigned automatically.",
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: networkSubresIPAddreDiffSupperss,
Description: "MAC address associated with this connection. MAC address is assigned automatically.",
},
"weight": {
Type: schema.TypeInt,
@@ -3288,6 +3480,13 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Disk ID",
},
"present_to": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"shareable": {
Type: schema.TypeBool,
Computed: true,
@@ -3306,7 +3505,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
"extra_disks": {
Type: schema.TypeSet,
Optional: true,
MaxItems: constants.MAX_EXTRA_DISKS_PER_COMPUTE,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
@@ -3507,6 +3705,33 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
},
Description: "ID of the connected pci devices",
},
"loader_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, false),
Description: "Type of image vm.",
},
"boot_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, false),
Description: "Type of image upload.",
},
"hot_resize": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Type of image vm.",
},
"network_interface_naming": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, false),
Description: "Name of netfowrk interface.",
},
// Computed properties
"account_id": {
Type: schema.TypeInt,
@@ -3858,7 +4083,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Description: "Guest OS users provisioned on this compute instance.",
},
"pinned": {
Type: schema.TypeBool,
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
@@ -3950,10 +4175,88 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"vgpus": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
Type: schema.TypeList,
Computed: true,
Description: "List of virtual GPUs",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"mode": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"profile_id": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"last_update_time": {
Type: schema.TypeInt,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
},
"pgpuid": {
Type: schema.TypeInt,
Computed: true,
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"last_claimed_by": {
Type: schema.TypeInt,
Computed: true,
},
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
},
"bus_number": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"virtual_image_id": {

View File

@@ -0,0 +1,20 @@
package kvmvm
import (
"context"
log "github.com/sirupsen/logrus"
)
func resourceCompueteStateUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
log.Debug("resourceCompueteStateUpgradeV1: upgrading state")
if oldVal, ok := rawState["pinned"].(bool); ok {
if !oldVal {
rawState["pinned"] = -1
} else {
rawState["pinned"] = 0
}
}
return rawState, nil
}

View File

@@ -100,9 +100,6 @@ func utilityComputeStarted(ctx context.Context, d *schema.ResourceData, m interf
if force, ok := d.Get("force_stop").(bool); ok {
req.Force = force
}
if depresent, ok := d.Get("depresent").(bool); ok {
req.Depresent = depresent
}
if _, err := c.CloudBroker().Compute().Stop(ctx, req); err != nil {
return err
}
@@ -267,10 +264,6 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
Force: false,
}
if depresent, ok := d.Get("depresent").(bool); ok {
stopReq.Depresent = depresent
}
_, err := c.CloudBroker().Compute().Stop(ctx, stopReq)
if err != nil {
return err
@@ -474,19 +467,6 @@ func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceDa
if detach_set.Len() > 0 {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
stopReq := compute.StopRequest{
ComputeID: computeId,
Force: false,
}
if depresent, ok := d.Get("depresent").(bool); ok {
stopReq.Depresent = depresent
}
_, err := c.CloudBroker().Compute().Stop(ctx, stopReq)
if err != nil {
return err
}
for _, diskId := range detach_set.List() {
req := compute.DiskDetachRequest{
@@ -501,14 +481,6 @@ func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceDa
}
}
req := compute.StartRequest{
ComputeID: computeId,
AltBootID: 0,
}
_, err = c.CloudBroker().Compute().Start(ctx, req)
if err != nil {
return err
}
}
attach_set := new_set.(*schema.Set).Difference(old_set.(*schema.Set))
@@ -601,7 +573,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
oldList := oldSet.(*schema.Set).List()
newList := newSet.(*schema.Set).List()
detachMap, changeIpMap, attachMap := differenceNetwork(oldList, newList)
detachMap, changeIpMap, changeMacMap, attachMap := differenceNetwork(oldList, newList)
apiErrCount := 0
var lastSavedError error
@@ -649,7 +621,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
addedLibvirtSettings := (newLibvirtSet.(*schema.Set).Difference(oldLibvirtSet.(*schema.Set))).List()
libvirtSettingsMap := addAttachedNetwork(addedLibvirtSettings, newLibvirtSet.(*schema.Set).List(), attachMap)
if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 || len(libvirtSettingsMap) > 0 || hasDPDKnetwork(attachMap) {
if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 || len(libvirtSettingsMap) > 0 || hasDPDKnetwork(attachMap) || len(changeMacMap) > 0 {
if err := utilityComputeStop(ctx, d, m); err != nil {
apiErrCount++
lastSavedError = err
@@ -659,6 +631,24 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
}
}
log.Debugf("utilityComputeNetworksConfigure: changeMac set has %d items for Compute ID %s", len(changeMacMap), d.Id())
for _, netData := range changeMacMap {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
req := compute.ChangeMACRequest{
ComputeID: computeId,
NewMAC: netData["mac"].(string),
СurrentMAC: netData["old_mac"].(string),
}
_, err := c.CloudBroker().Compute().ChangeMAC(ctx, req)
if err != nil {
log.Errorf("utilityComputeNetworksConfigure: failed to change mac %s to %s from Compute ID %s: %s",
req.СurrentMAC, req.NewMAC, d.Id(), err)
apiErrCount++
lastSavedError = err
}
}
sort.Slice(attachMap, func(i, j int) bool {
weightI := attachMap[i]["weight"].(int)
weightJ := attachMap[j]["weight"].(int)
@@ -687,6 +677,10 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
req.IPAddr = netData["ip_address"].(string)
}
if netData["mac"].(string) != "" {
req.MACAddr = netData["mac"].(string)
}
_, err := c.CloudBroker().Compute().NetAttach(ctx, req)
if err != nil {
log.Errorf("utilityComputeNetworksConfigure: failed to attach net ID %d of type %s to Compute ID %s: %s",
@@ -758,9 +752,10 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
return nil
}
func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, attachMap []map[string]interface{}) {
func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, changeMacMap, attachMap []map[string]interface{}) {
attachMap = make([]map[string]interface{}, 0)
changeIpMap = make([]map[string]interface{}, 0)
changeMacMap = make([]map[string]interface{}, 0)
detachMap = make([]map[string]interface{}, 0)
for _, oldNetwork := range oldList {
oldMap := oldNetwork.(map[string]interface{})
@@ -768,15 +763,21 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
for _, newNetwork := range newList {
newMap := newNetwork.(map[string]interface{})
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(int) == 0) {
if (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != "") {
found = true
switch {
case (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != ""):
changeIpMap = append(changeIpMap, newMap)
found = true
break
} else if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(string) == "" {
fallthrough
case newMap["mac"] != oldMap["mac"] && newMap["mac"].(string) != "":
newMap["old_mac"] = oldMap["mac"]
changeMacMap = append(changeMacMap, newMap)
found = true
break
}
}
if found {
break
}
}
if found {
continue
@@ -790,12 +791,8 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap,
for _, oldNetwork := range oldList {
oldMap := oldNetwork.(map[string]interface{})
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(int) == 0) {
if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(string) == "" ||
((newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "VINS") &&
newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(string) != "") {
found = true
break
}
found = true
break
}
}
if found {
@@ -871,6 +868,23 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
if d.HasChange("chipset") {
req.Chipset = d.Get("chipset").(string)
}
if d.HasChange("loader_type") {
req.LoaderType = d.Get("loader_type").(string)
}
if d.HasChange("boot_type") {
req.BootType = d.Get("boot_type").(string)
}
if d.HasChange("hot_resize") {
req.HotResize = d.Get("hot_resize").(bool)
}
if d.HasChange("network_interface_naming") {
req.NetworkInterfaceNaming = d.Get("network_interface_naming").(string)
}
req.CPUPin = d.Get("cpu_pin").(bool)
req.HPBacked = d.Get("hp_backed").(bool)
req.AutoStart = d.Get("auto_start_w_node").(bool)
@@ -902,9 +916,7 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
ComputeID: computeId,
Force: false,
}
if depresent, ok := d.Get("depresent").(bool); ok {
stopReq.Depresent = depresent
}
if _, err := c.CloudBroker().Compute().Stop(ctx, stopReq); err != nil {
return err
}
@@ -1368,9 +1380,6 @@ func utilityComputeRollback(ctx context.Context, d *schema.ResourceData, m inter
ComputeID: computeId,
Force: false,
}
if depresent, ok := d.Get("depresent").(bool); ok {
req.Depresent = depresent
}
_, err := c.CloudBroker().Compute().Stop(ctx, req)
if err != nil {
@@ -1531,9 +1540,6 @@ func utilityComputeUpdateImage(ctx context.Context, d *schema.ResourceData, m in
ComputeID: computeId,
Force: false,
}
if depresent, ok := d.Get("depresent").(bool); ok {
stopReq.Depresent = depresent
}
if forceStop, ok := d.GetOk("force_stop"); ok {
stopReq.Force = forceStop.(bool)
}
@@ -1608,9 +1614,6 @@ func utilityComputeStop(ctx context.Context, d *schema.ResourceData, m interface
Force: true,
}
req.ComputeID = uint64(d.Get("compute_id").(int))
if depresent, ok := d.Get("depresent").(bool); ok {
req.Depresent = depresent
}
log.Debugf("utilityComputeStop: stopping compute %d", req.ComputeID)
_, err := c.CloudBroker().Compute().Stop(ctx, req)

View File

@@ -72,6 +72,9 @@ func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.Resource
if stackID, ok := d.GetOk("stack_id"); ok {
req.StackID = stackID.(uint64)
}
if stackName, ok := d.GetOk("stack_name"); ok {
req.StackName = stackName.(string)
}
if imageID, ok := d.GetOk("image_id"); ok {
req.ImageID = imageID.(uint64)
}

View File

@@ -34,13 +34,14 @@ package kvmvm
import (
"context"
"regexp"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/compute"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityDataComputeListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListComputes, error) {
func utilityDataComputeListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListDeletedComputes, error) {
c := m.(*controller.ControllerCfg)
req := compute.ListDeletedRequest{}
@@ -88,3 +89,12 @@ func utilityDataComputeListDeletedCheckPresence(ctx context.Context, d *schema.R
return listComputes, nil
}
func matchDeletedComputes(computeList *compute.ListDeletedComputes) *compute.ListDeletedComputes {
matched, _ := regexp.Compile(`[a-zA-Z]+\\d+-[a-zA-Z]+\\d+-[a-zA-Z]+\\d+`)
result := computeList.FilterFunc(func(ic compute.ItemDeletedCompute) bool {
res := matched.Match([]byte(ic.Name))
return !res
})
return &result
}

View File

@@ -31,7 +31,6 @@ func flattenResgroup(d *schema.ResourceData, rgData *rg.RecordRG) {
d.Set("lock_status", rgData.LockStatus)
d.Set("milestones", rgData.Milestones)
d.Set("name", rgData.Name)
d.Set("register_computes", rgData.RegisterComputes)
d.Set("resource_limits", flattenRgResourceLimits(rgData.ResourceLimits))
d.Set("resource_types", rgData.ResTypes)
d.Set("secret", rgData.Secret)
@@ -405,7 +404,6 @@ func flattenRgList(rgl *rg.ListRG) []map[string]interface{} {
"lock_status": rg.LockStatus,
"milestones": rg.Milestones,
"name": rg.Name,
"register_computes": rg.RegisterComputes,
"resource_limits": flattenRgResourceLimits(rg.ResourceLimits),
"secret": rg.Secret,
"status": rg.Status,
@@ -476,7 +474,6 @@ func flattenResourceRG(d *schema.ResourceData, rgData *rg.RecordRG) {
d.Set("rg_name", rgData.Name)
d.Set("resource_limits", flattenRgResourceLimits(rgData.ResourceLimits))
d.Set("description", rgData.Description)
d.Set("register_computes", rgData.RegisterComputes)
d.Set("uniq_pools", rgData.UniqPools)
d.Set("cpu_allocation_parameter", rgData.CPUAllocationParameter)
d.Set("cpu_allocation_ratio", rgData.CPUAllocationRatio)

View File

@@ -1,148 +1,147 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package rg
type ResourceLimits struct {
CUC float64 `json:"CU_C"`
CUD float64 `json:"CU_D"`
CUI float64 `json:"CU_I"`
CUM float64 `json:"CU_M"`
CUNP float64 `json:"CU_NP"`
GpuUnits float64 `json:"gpu_units"`
}
type ResgroupRecord struct {
ACLs []AccountAclRecord `json:"acl"`
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
CreatedBy string `json:"createdBy"`
CreatedTime uint64 `json:"createdTime"`
DefaultNetID int `json:"def_net_id"`
DefaultNetType string `json:"def_net_type"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
Decsription string `json:"desc"`
GridID int `json:"gid"`
GUID int `json:"guid"`
ID uint `json:"id"`
LockStatus string `json:"lockStatus"`
Milestones int `json:"milestones"`
Name string `json:"name"`
RegisterComputes bool `json:"registerComputes"`
ResourceLimits ResourceLimits `json:"resourceLimits"`
Secret string `json:"secret"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime uint64 `json:"updatedTime"`
Vins []int `json:"vins"`
Computes []int `json:"vms"`
}
type ResgroupListResp []ResgroupRecord
type ResgroupUpdateParam struct {
RgId int `json:"rgId"`
Name string `json:"name"`
Desc string `json:"decs"`
Ram int `json:"maxMemoryCapacity"`
Disk int `json:"maxVDiskCapacity"`
Cpu int `json:"maxCPUCapacity"`
NetTraffic int `json:"maxNetworkPeerTransfer"`
}
type AccountAclRecord struct {
IsExplicit bool `json:"explicit"`
Guid string `json:"guid"`
Rights string `json:"right"`
Status string `json:"status"`
Type string `json:"type"`
UgroupID string `json:"userGroupId"`
CanBeDeleted bool `json:"canBeDeleted"`
}
type ResgroupGetResp struct {
ACLs []UserAclRecord `json:"ACLs"`
Usage UsageRecord `json:"Resources"`
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
GridID int `json:"gid"`
CreatedBy string `json:"createdBy"`
CreatedTime uint64 `json:"createdTime"`
DefaultNetID int `json:"def_net_id"`
DefaultNetType string `json:"def_net_type"`
DeletedBy string `json:"deletedBy"`
DeletedTime uint64 `json:"deletedTime"`
Desc string `json:"desc"`
ID uint `json:"id"`
LockStatus string `json:"lockStatus"`
Name string `json:"name"`
Quota QuotaRecord `json:"resourceLimits"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime uint64 `json:"updatedTime"`
Vins []int `json:"vins"`
Computes []int `json:"vms"`
Ignored map[string]interface{} `json:"-"`
}
type UserAclRecord struct {
IsExplicit bool `json:"explicit"`
Rights string `json:"right"`
Status string `json:"status"`
Type string `json:"type"`
UgroupID string `json:"userGroupId"`
// CanBeDeleted bool `json:"canBeDeleted"`
}
type QuotaRecord struct { // this is how quota is reported by /api/.../rg/get
Cpu float64 `json:"CU_C"` // CPU count in pcs
Ram float64 `json:"CU_M"` // RAM volume in MB, it is STILL reported as FLOAT
Disk float64 `json:"CU_D"` // Disk capacity in GB
ExtIPs float64 `json:"CU_I"` // Ext IPs count
ExtTraffic float64 `json:"CU_NP"` // Ext network traffic
GpuUnits float64 `json:"gpu_units"` // GPU count
}
type ResourceRecord struct { // this is how actual usage is reported by /api/.../rg/get
Cpu int `json:"cpu"`
Disk int `json:"disksize"`
ExtIPs int `json:"extips"`
ExtTraffic int `json:"exttraffic"`
Gpu int `json:"gpu"`
Ram int `json:"ram"`
}
type UsageRecord struct {
Current ResourceRecord `json:"Current"`
Reserved ResourceRecord `json:"Reserved"`
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package rg
type ResourceLimits struct {
CUC float64 `json:"CU_C"`
CUD float64 `json:"CU_D"`
CUI float64 `json:"CU_I"`
CUM float64 `json:"CU_M"`
CUNP float64 `json:"CU_NP"`
GpuUnits float64 `json:"gpu_units"`
}
type ResgroupRecord struct {
ACLs []AccountAclRecord `json:"acl"`
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
CreatedBy string `json:"createdBy"`
CreatedTime uint64 `json:"createdTime"`
DefaultNetID int `json:"def_net_id"`
DefaultNetType string `json:"def_net_type"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
Decsription string `json:"desc"`
GridID int `json:"gid"`
GUID int `json:"guid"`
ID uint `json:"id"`
LockStatus string `json:"lockStatus"`
Milestones int `json:"milestones"`
Name string `json:"name"`
ResourceLimits ResourceLimits `json:"resourceLimits"`
Secret string `json:"secret"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime uint64 `json:"updatedTime"`
Vins []int `json:"vins"`
Computes []int `json:"vms"`
}
type ResgroupListResp []ResgroupRecord
type ResgroupUpdateParam struct {
RgId int `json:"rgId"`
Name string `json:"name"`
Desc string `json:"decs"`
Ram int `json:"maxMemoryCapacity"`
Disk int `json:"maxVDiskCapacity"`
Cpu int `json:"maxCPUCapacity"`
NetTraffic int `json:"maxNetworkPeerTransfer"`
}
type AccountAclRecord struct {
IsExplicit bool `json:"explicit"`
Guid string `json:"guid"`
Rights string `json:"right"`
Status string `json:"status"`
Type string `json:"type"`
UgroupID string `json:"userGroupId"`
CanBeDeleted bool `json:"canBeDeleted"`
}
type ResgroupGetResp struct {
ACLs []UserAclRecord `json:"ACLs"`
Usage UsageRecord `json:"Resources"`
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
GridID int `json:"gid"`
CreatedBy string `json:"createdBy"`
CreatedTime uint64 `json:"createdTime"`
DefaultNetID int `json:"def_net_id"`
DefaultNetType string `json:"def_net_type"`
DeletedBy string `json:"deletedBy"`
DeletedTime uint64 `json:"deletedTime"`
Desc string `json:"desc"`
ID uint `json:"id"`
LockStatus string `json:"lockStatus"`
Name string `json:"name"`
Quota QuotaRecord `json:"resourceLimits"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime uint64 `json:"updatedTime"`
Vins []int `json:"vins"`
Computes []int `json:"vms"`
Ignored map[string]interface{} `json:"-"`
}
type UserAclRecord struct {
IsExplicit bool `json:"explicit"`
Rights string `json:"right"`
Status string `json:"status"`
Type string `json:"type"`
UgroupID string `json:"userGroupId"`
// CanBeDeleted bool `json:"canBeDeleted"`
}
type QuotaRecord struct { // this is how quota is reported by /api/.../rg/get
Cpu float64 `json:"CU_C"` // CPU count in pcs
Ram float64 `json:"CU_M"` // RAM volume in MB, it is STILL reported as FLOAT
Disk float64 `json:"CU_D"` // Disk capacity in GB
ExtIPs float64 `json:"CU_I"` // Ext IPs count
ExtTraffic float64 `json:"CU_NP"` // Ext network traffic
GpuUnits float64 `json:"gpu_units"` // GPU count
}
type ResourceRecord struct { // this is how actual usage is reported by /api/.../rg/get
Cpu int `json:"cpu"`
Disk int `json:"disksize"`
ExtIPs int `json:"extips"`
ExtTraffic int `json:"exttraffic"`
Gpu int `json:"gpu"`
Ram int `json:"ram"`
}
type UsageRecord struct {
Current ResourceRecord `json:"Current"`
Reserved ResourceRecord `json:"Reserved"`
}

View File

@@ -129,10 +129,6 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
req.ExtIP = extIp.(string)
}
if regComputes, ok := d.GetOk("register_computes"); ok {
req.RegisterComputes = regComputes.(bool)
}
if uniqPools, ok := d.GetOk("uniq_pools"); ok {
uniqPools := uniqPools.([]interface{})
@@ -418,11 +414,6 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter
doGeneralUpdate = true
}
if d.HasChange("register_computes") {
req.RegisterComputes = d.Get("register_computes").(bool)
doGeneralUpdate = true
}
if d.HasChange("uniq_pools") {
uniqPools := d.Get("uniq_pools").([]interface{})
if len(uniqPools) == 0 {

View File

@@ -119,10 +119,6 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"register_computes": {
Type: schema.TypeBool,
Computed: true,
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,
@@ -1621,10 +1617,6 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"register_computes": {
Type: schema.TypeBool,
Computed: true,
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,
@@ -1895,10 +1887,6 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"register_computes": {
Type: schema.TypeBool,
Computed: true,
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,
@@ -2292,14 +2280,6 @@ func resourceRgSchemaMake() map[string]*schema.Schema {
Description: "IP address on the external netowrk to request when def_net_type=PRIVATE and ext_net_id is not 0",
},
"register_computes": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
// Default: false,
Description: "Register computes in registration system",
},
"uniq_pools": {
Type: schema.TypeList,
Computed: true,
@@ -2395,7 +2375,7 @@ func resourceRgSchemaMake() map[string]*schema.Schema {
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"hugepages", "numa", "cpupin", "vfnic"}, true),
ValidateFunc: validation.StringInSlice([]string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac"}, true),
},
},

View File

@@ -0,0 +1,72 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Sergey Kisil, <svkisil@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package sep
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func DataSourceAvailableSEPAndPoolsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
sepList, err := utilityAvailableSEPAndPoolsListCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
flattenAvailableSEPList(d, sepList)
return nil
}
func DataSourceAvailableSEPAndPoolsList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: DataSourceAvailableSEPAndPoolsListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAvailableSEPListSchemaMake(),
}
}

View File

@@ -0,0 +1,71 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package sep
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceSepTemplateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
sepTemplate, err := utilitySepTemplateCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("sep_template", sepTemplate)
return nil
}
func DataSourceSepTemplate() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceSepTemplateRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceSepTemplateSchemaMake(),
}
}

View File

@@ -147,3 +147,39 @@ func flattenSepConsumptionPools(bp *sep.RecordConsumption) []map[string]interfac
}
return sh
}
func flattenAvailableSEPList(d *schema.ResourceData, sepList *sep.ListAvailableSEP) {
d.Set("items", flattenSEPDataList(sepList.Data))
d.Set("entry_count", sepList.EntryCount)
}
func flattenSEPDataList(sepDataList []sep.SEPData) []map[string]interface{} {
sh := make([]map[string]interface{}, 0)
for _, sepData := range sepDataList {
temp := map[string]interface{}{
"sep_id": sepData.SEPID,
"sep_name": sepData.SEPName,
"sep_type": sepData.SEPType,
"pools": flattenPoolList(sepData.Pools),
}
sh = append(sh, temp)
}
return sh
}
func flattenPoolList(pools []sep.Pool) []map[string]interface{} {
sh := make([]map[string]interface{}, 0)
for _, pool := range pools {
temp := map[string]interface{}{
"name": pool.Name,
"types": pool.Types,
"system": pool.System,
}
sh = append(sh, temp)
}
return sh
}

View File

@@ -1,6 +1,9 @@
package sep
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func dataSourceSepCSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
@@ -101,6 +104,27 @@ func dataSourceSepConfigSchemaMake() map[string]*schema.Schema {
}
}
func dataSourceSepTemplateSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"hitachi", "dorado", "tatlin", "shared", "local", "des"}, false),
Description: "type of sep",
},
"lang": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"ru", "en"}, false),
Description: "language",
},
"sep_template": {
Type: schema.TypeString,
Computed: true,
},
}
}
func dataSourceSepConsumptionSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_id": {
@@ -698,3 +722,74 @@ func resourceSepConfigSchemaMake() map[string]*schema.Schema {
},
}
}
func dataSourceAvailableSEPListSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Required: true,
Description: "Account ID",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Resource group ID",
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
Description: "Number of available SEP entries",
},
"items": {
Type: schema.TypeList,
Computed: true,
Description: "List of available SEPs",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Computed: true,
Description: "SEP ID",
},
"sep_name": {
Type: schema.TypeString,
Computed: true,
Description: "SEP name",
},
"sep_type": {
Type: schema.TypeString,
Computed: true,
Description: "SEP type",
},
"pools": {
Type: schema.TypeList,
Computed: true,
Description: "List of pools in the SEP",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Pool name",
},
"types": {
Type: schema.TypeList,
Computed: true,
Description: "List of pool types",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"system": {
Type: schema.TypeBool,
Computed: true,
Description: "Is system pool",
},
},
},
},
},
},
},
}
}

View File

@@ -0,0 +1,63 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Sergey Kisil, <svkisil@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package sep
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAvailableSEPAndPoolsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*sep.ListAvailableSEP, error) {
c := m.(*controller.ControllerCfg)
req := sep.ListAvailableSEPAndPoolsRequest{}
if AccountID, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(AccountID.(int))
}
if RGID, ok := d.GetOk("rg_id"); ok {
req.RGID = RGID.(uint64)
}
log.Debugf("utilityAvailableSEPAndPoolsListCheckPresence: load sep and pools list")
sepList, err := c.CloudBroker().SEP().ListAvailableSEPAndPools(ctx, req)
if err != nil {
return nil, err
}
return sepList, nil
}

View File

@@ -0,0 +1,59 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package sep
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilitySepTemplateCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) {
c := m.(*controller.ControllerCfg)
req := sep.GetTemplateRequest{
SepType: d.Get("sep_type").(string),
Language: d.Get("lang").(string),
}
log.Debugf("utilitySepTemplateCheckPresence: load sep template")
sepTemplate, err := c.CloudBroker().SEP().GetTemplate(ctx, req)
if err != nil {
return "", err
}
return sepTemplate, nil
}

View File

@@ -1237,6 +1237,11 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"status": {
Type: schema.TypeString,
Optional: true,
Description: "sort by status",
},
"page": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -66,6 +66,9 @@ func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}