4.10.2
This commit is contained in:
@@ -457,6 +457,22 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"devicename": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1148,6 +1164,22 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"loader_meta_iso": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"device_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"path": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"os_version": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -225,28 +225,28 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"numa_affinity": compute.NumaAffinity,
|
||||
"numa_node_id": compute.NumaNodeId,
|
||||
"os_version": compute.OSVersion,
|
||||
// "pinned": compute.Pinned,
|
||||
"preferred_cpu": compute.PreferredCPU,
|
||||
"qemu_guest": flattenQemuQuest(compute.QemuQuest),
|
||||
"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,
|
||||
"pinned": compute.PinnedToStack,
|
||||
"preferred_cpu": compute.PreferredCPU,
|
||||
"qemu_guest": flattenQemuQuest(compute.QemuQuest),
|
||||
"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,
|
||||
//TODO
|
||||
// "virtual_image_id": compute.VirtualImageID,
|
||||
"loader_type": compute.LoaderType,
|
||||
@@ -289,10 +289,6 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
|
||||
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(disksList))
|
||||
|
||||
if len(disksBlocks) == 0 {
|
||||
return res
|
||||
}
|
||||
|
||||
sort.Slice(disksList, func(i, j int) bool {
|
||||
return disksList[i].ID < disksList[j].ID
|
||||
})
|
||||
@@ -304,9 +300,19 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
||||
continue
|
||||
}
|
||||
|
||||
pernamentlyValue := disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool)
|
||||
var pernamentlyValue bool
|
||||
if indexDataDisks < len(disksBlocks) {
|
||||
if diskBlock, ok := disksBlocks[indexDataDisks].(map[string]interface{}); ok {
|
||||
if perm, exists := diskBlock["permanently"]; exists {
|
||||
if permBool, ok := perm.(bool); ok {
|
||||
pernamentlyValue = permBool
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
temp := map[string]interface{}{
|
||||
"devicename": disk.DeviceName,
|
||||
"disk_name": disk.Name,
|
||||
"disk_id": disk.ID,
|
||||
"disk_type": disk.Type,
|
||||
@@ -318,9 +324,15 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
||||
"desc": disk.Description,
|
||||
"image_id": disk.ImageID,
|
||||
"size": disk.SizeMax,
|
||||
"permanently": pernamentlyValue,
|
||||
"present_to": disk.PresentTo,
|
||||
"storage_policy_id": disk.StoragePolicyID,
|
||||
"to_clean": disk.ToClean,
|
||||
"created_by": disk.CreatedBy,
|
||||
"created_time": disk.CreatedTime,
|
||||
"deleted_by": disk.DeletedBy,
|
||||
"deleted_time": disk.DeletedTime,
|
||||
"updated_time": disk.UpdatedTime,
|
||||
"permanently": pernamentlyValue,
|
||||
}
|
||||
res = append(res, temp)
|
||||
indexDataDisks++
|
||||
@@ -439,7 +451,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.PinnedToStack)
|
||||
d.Set("preferred_cpu", computeRec.PreferredCPU)
|
||||
d.Set("ram", computeRec.RAM)
|
||||
d.Set("reference_id", computeRec.ReferenceID)
|
||||
@@ -467,6 +479,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
||||
d.Set("hot_resize", computeRec.HotResize)
|
||||
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
|
||||
d.Set("zone_id", computeRec.ZoneID)
|
||||
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
|
||||
|
||||
d.Set("enabled", false)
|
||||
if computeRec.Status == status.Enabled {
|
||||
@@ -486,6 +499,16 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
||||
return nil
|
||||
}
|
||||
|
||||
func flattenLoaderMetaIso(loaderMetaIso compute.LoaderMetaIso) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"device_name": loaderMetaIso.DeviceName,
|
||||
"path": loaderMetaIso.Path,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenACL(acl compute.RecordACL) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
@@ -565,7 +588,10 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
|
||||
"boot_partition": disk.BootPartition,
|
||||
"bus_number": disk.BusNumber,
|
||||
"created_time": disk.CreatedTime,
|
||||
"created_by": disk.CreatedBy,
|
||||
"deleted_time": disk.DeletedTime,
|
||||
"deleted_by": disk.DeletedBy,
|
||||
"devicename": disk.DeviceName,
|
||||
"description": disk.Description,
|
||||
"destruction_time": disk.DestructionTime,
|
||||
"disk_path": disk.DiskPath,
|
||||
@@ -601,6 +627,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
|
||||
"tech_status": disk.TechStatus,
|
||||
"type": disk.Type,
|
||||
"to_clean": disk.ToClean,
|
||||
"updated_time": disk.UpdatedTime,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -726,6 +753,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
d.Set("hot_resize", computeRec.HotResize)
|
||||
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
|
||||
d.Set("zone_id", computeRec.ZoneID)
|
||||
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
|
||||
d.Set("os_version", computeRec.OSVersion)
|
||||
}
|
||||
|
||||
|
||||
@@ -944,41 +944,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("pin_to_stack") {
|
||||
oldPin, newPin := d.GetChange("pin_to_stack")
|
||||
if !newPin.(bool) {
|
||||
req := compute.UnpinFromStackRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().Compute().UnpinFromStack(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
if !oldPin.(bool) {
|
||||
if !d.Get("started").(bool) {
|
||||
return diag.Errorf("Cannot pin to stack a VM, that is not started")
|
||||
}
|
||||
reqToStart := compute.StartRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
_, err := c.CloudAPI().Compute().Start(ctx, reqToStart)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
req := compute.PinToStackRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
req.AutoStart = d.Get("auto_start_w_node").(bool)
|
||||
_, err = c.CloudAPI().Compute().PinToStack(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status.
|
||||
var isStopRequired bool
|
||||
if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu", "hot_resize") && d.Get("started").(bool) {
|
||||
@@ -1810,7 +1775,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
req := compute.StopRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
@@ -1821,6 +1785,34 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("pin_to_stack") || d.HasChange("started") {
|
||||
newPin := d.Get("pin_to_stack")
|
||||
if !newPin.(bool) && d.HasChange("pin_to_stack") {
|
||||
req := compute.UnpinFromStackRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().Compute().UnpinFromStack(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
if newPin.(bool) {
|
||||
if !d.Get("started").(bool) {
|
||||
return diag.Errorf("Cannot pin to stack a VM, that is not started")
|
||||
}
|
||||
|
||||
req := compute.PinToStackRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
req.AutoStart = d.Get("auto_start_w_node").(bool)
|
||||
_, err = c.CloudAPI().Compute().PinToStack(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we may reuse dataSourceComputeRead here as we maintain similarity
|
||||
// between Compute resource and Compute data source schemas
|
||||
|
||||
@@ -1900,32 +1892,6 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
|
||||
c := m.(*controller.ControllerCfg)
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
if start, ok := d.GetOk("started"); ok {
|
||||
if start.(bool) {
|
||||
req := compute.StopRequest{ComputeID: computeId}
|
||||
log.Debugf("resourceComputeDelete: stoping Compute ID %d", computeId)
|
||||
if _, err := c.CloudAPI().Compute().Stop(ctx, req); err != nil {
|
||||
diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pciList, ok := d.GetOk("pci_devices")
|
||||
|
||||
if d.Get("permanently").(bool) && ok {
|
||||
pciDevices := pciList.(*schema.Set).List()
|
||||
for _, v := range pciDevices {
|
||||
pciID := v.(int)
|
||||
req := compute.DetachPCIDeviceRequest{
|
||||
ComputeID: computeId,
|
||||
DeviceID: uint64(pciID),
|
||||
}
|
||||
_, err := c.CloudAPI().Compute().DetachPCIDevice(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
req := compute.DeleteRequest{
|
||||
ComputeID: computeId,
|
||||
Permanently: d.Get("permanently").(bool),
|
||||
@@ -2022,6 +1988,30 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"devicename": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"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,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
@@ -2154,6 +2144,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -2841,6 +2832,22 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"loader_meta_iso": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"device_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"path": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
@@ -2867,6 +2874,10 @@ func ResourceCompute() *schema.Resource {
|
||||
if diff.HasChanges("pin_to_stack") {
|
||||
diff.SetNewComputed("pinned")
|
||||
}
|
||||
if diff.HasChanges("image_id") {
|
||||
diff.SetNewComputed("boot_disk")
|
||||
diff.SetNewComputed("boot_image_id")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
|
||||
@@ -135,14 +135,6 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"cpu_allocation_parameter": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -243,6 +235,14 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"cpu_allocation_parameter": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"uniq_pools": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -250,6 +250,10 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"sdn_access_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"storage_policy_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
|
||||
@@ -20,9 +20,8 @@ func flattenAccessSEPPools(accessSEPPools stpolicy.ListAccessSEPPools) []map[str
|
||||
res := make([]map[string]interface{}, 0, len(accessSEPPools))
|
||||
for _, asp := range accessSEPPools {
|
||||
temp := map[string]interface{}{
|
||||
"sep_id": asp.SEPID,
|
||||
//TODO
|
||||
//"name": asp.Name,
|
||||
"sep_id": asp.SEPID,
|
||||
"sep_name": asp.Name,
|
||||
"pool_names": asp.PoolNames,
|
||||
}
|
||||
|
||||
|
||||
@@ -170,6 +170,10 @@ func dataSourceStoragePolicyListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"sep_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user