4.9.0
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -270,6 +270,13 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"ntp": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
143
internal/service/cloudapi/sep/available_sep_and_pools_list.go
Normal file
143
internal/service/cloudapi/sep/available_sep_and_pools_list.go
Normal 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(),
|
||||
}
|
||||
}
|
||||
74
internal/service/cloudapi/sep/flattens.go
Normal file
74
internal/service/cloudapi/sep/flattens.go
Normal 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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user