4.11.0
This commit is contained in:
@@ -78,7 +78,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
|
||||
d.Set("need_reboot", computeRec.NeedReboot)
|
||||
d.Set("numa_node_id", computeRec.NumaNodeId)
|
||||
d.Set("os_users", flattenOSUsers(computeRec.OSUsers))
|
||||
d.Set("pinned", computeRec.PinnedToStack)
|
||||
d.Set("pinned", computeRec.PinnedToNode)
|
||||
d.Set("preferred_cpu", computeRec.PreferredCPU)
|
||||
d.Set("ram", computeRec.RAM)
|
||||
d.Set("reference_id", computeRec.ReferenceID)
|
||||
@@ -88,9 +88,9 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
|
||||
d.Set("rg_name", computeRec.RGName)
|
||||
d.Set("rg_id", computeRec.RGID)
|
||||
d.Set("snap_sets", flattenSnapSets(computeRec.SnapSets))
|
||||
d.Set("stack_id", computeRec.StackID)
|
||||
d.Set("stack_name", computeRec.StackName)
|
||||
d.Set("started", computeRec.TechStatus == "STARTED")
|
||||
d.Set("node_id", computeRec.NodeID)
|
||||
d.Set("node_name", computeRec.NodeName)
|
||||
d.Set("stateless_sep_id", computeRec.StatelessSEPID)
|
||||
d.Set("stateless_sep_type", computeRec.StatelessSEPType)
|
||||
d.Set("status", computeRec.Status)
|
||||
@@ -100,11 +100,9 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
|
||||
d.Set("updated_time", computeRec.UpdatedTime)
|
||||
d.Set("user_data", string(userData))
|
||||
d.Set("user_managed", computeRec.UserManaged)
|
||||
d.Set("read_only", computeRec.ReadOnly)
|
||||
d.Set("vnc_password", computeRec.VNCPassword)
|
||||
d.Set("vgpus", flattenVGPUs(computeRec.VGPUs))
|
||||
//TODO
|
||||
// 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)
|
||||
@@ -286,6 +284,8 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
|
||||
"delete_by": disk.DeletedBy,
|
||||
"delete_time": disk.DeletedTime,
|
||||
"update_time": disk.UpdatedTime,
|
||||
"cache": disk.Cache,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
}
|
||||
res = append(res, temp)
|
||||
indexDataDisks++
|
||||
@@ -327,79 +327,78 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
devices, _ := json.Marshal(computeItem.Devices)
|
||||
userData, _ := json.Marshal(computeItem.Userdata)
|
||||
temp := map[string]interface{}{
|
||||
"acl": flattenListACLInterface(computeItem.ACL),
|
||||
"account_id": computeItem.AccountID,
|
||||
"account_name": computeItem.AccountName,
|
||||
"affinity_label": computeItem.AffinityLabel,
|
||||
"affinity_rules": flattenListRules(computeItem.AffinityRules),
|
||||
"affinity_weight": computeItem.AffinityWeight,
|
||||
"anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules),
|
||||
"arch": computeItem.Arch,
|
||||
"auto_start_w_node": computeItem.AutoStart,
|
||||
"chipset": computeItem.Chipset,
|
||||
"cd_image_id": computeItem.CdImageId,
|
||||
"boot_order": computeItem.BootOrder,
|
||||
"boot_image_id": computeItem.BootImageID,
|
||||
"bootdisk_size": computeItem.BootDiskSize,
|
||||
"clone_reference": computeItem.CloneReference,
|
||||
"clones": computeItem.Clones,
|
||||
"computeci_id": computeItem.ComputeCIID,
|
||||
"cpus": computeItem.CPUs,
|
||||
"created_by": computeItem.CreatedBy,
|
||||
"created_time": computeItem.CreatedTime,
|
||||
"custom_fields": string(customFields),
|
||||
"deleted_by": computeItem.DeletedBy,
|
||||
"deleted_time": computeItem.DeletedTime,
|
||||
"desc": computeItem.Description,
|
||||
"devices": string(devices),
|
||||
"disks": flattenDisks(computeItem.Disks),
|
||||
"driver": computeItem.Driver,
|
||||
"gid": computeItem.GID,
|
||||
"guid": computeItem.GUID,
|
||||
"hp_backed": computeItem.HPBacked,
|
||||
"compute_id": computeItem.ID,
|
||||
"cpu_pin": computeItem.CPUPin,
|
||||
"interfaces": flattenInterfaces(computeItem.Interfaces),
|
||||
"live_migration_job_id": computeItem.LiveMigrationJobID,
|
||||
"lock_status": computeItem.LockStatus,
|
||||
"manager_id": computeItem.ManagerID,
|
||||
"manager_type": computeItem.ManagerType,
|
||||
"migrationjob": computeItem.MigrationJob,
|
||||
"milestones": computeItem.Milestones,
|
||||
"nid": computeItem.NID,
|
||||
"name": computeItem.Name,
|
||||
"need_reboot": computeItem.NeedReboot,
|
||||
"numa_affinity": computeItem.NumaAffinity,
|
||||
"numa_node_id": computeItem.NumaNodeId,
|
||||
"os_users": flattenOSUsers(computeItem.OSUsers),
|
||||
"os_version": computeItem.OSVersion,
|
||||
"pinned": computeItem.PinnedToStack,
|
||||
"preferred_cpu": computeItem.PreferredCPU,
|
||||
"qemu_guest": flattenQemuQuest(computeItem.QemuQuest),
|
||||
"ram": computeItem.RAM,
|
||||
"reference_id": computeItem.ReferenceID,
|
||||
"registered": computeItem.Registered,
|
||||
"res_name": computeItem.ResName,
|
||||
"reserved_node_cpus": computeItem.ReservedNodeCpus,
|
||||
"rg_id": computeItem.RGID,
|
||||
"rg_name": computeItem.RGName,
|
||||
"snap_sets": flattenSnapSets(computeItem.SnapSets),
|
||||
"stack_id": computeItem.StackID,
|
||||
"stack_name": computeItem.StackName,
|
||||
"stateless_sep_id": computeItem.StatelessSEPID,
|
||||
"stateless_sep_type": computeItem.StatelessSEPType,
|
||||
"status": computeItem.Status,
|
||||
"tags": flattenTags(computeItem.Tags),
|
||||
"tech_status": computeItem.TechStatus,
|
||||
"total_disk_size": computeItem.TotalDiskSize,
|
||||
"updated_by": computeItem.UpdatedBy,
|
||||
"updated_time": computeItem.UpdatedTime,
|
||||
"user_data": string(userData),
|
||||
"user_managed": computeItem.UserManaged,
|
||||
"vgpus": computeItem.VGPUs,
|
||||
"vins_connected": computeItem.VINSConnected,
|
||||
//TODO
|
||||
// "virtual_image_id": computeItem.VirtualImageID,
|
||||
"acl": flattenListACLInterface(computeItem.ACL),
|
||||
"account_id": computeItem.AccountID,
|
||||
"account_name": computeItem.AccountName,
|
||||
"affinity_label": computeItem.AffinityLabel,
|
||||
"affinity_rules": flattenListRules(computeItem.AffinityRules),
|
||||
"affinity_weight": computeItem.AffinityWeight,
|
||||
"anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules),
|
||||
"arch": computeItem.Arch,
|
||||
"auto_start_w_node": computeItem.AutoStart,
|
||||
"chipset": computeItem.Chipset,
|
||||
"cd_image_id": computeItem.CdImageId,
|
||||
"boot_order": computeItem.BootOrder,
|
||||
"boot_image_id": computeItem.BootImageID,
|
||||
"bootdisk_size": computeItem.BootDiskSize,
|
||||
"clone_reference": computeItem.CloneReference,
|
||||
"clones": computeItem.Clones,
|
||||
"computeci_id": computeItem.ComputeCIID,
|
||||
"cpus": computeItem.CPUs,
|
||||
"created_by": computeItem.CreatedBy,
|
||||
"created_time": computeItem.CreatedTime,
|
||||
"custom_fields": string(customFields),
|
||||
"deleted_by": computeItem.DeletedBy,
|
||||
"deleted_time": computeItem.DeletedTime,
|
||||
"desc": computeItem.Description,
|
||||
"devices": string(devices),
|
||||
"disks": flattenDisks(computeItem.Disks),
|
||||
"driver": computeItem.Driver,
|
||||
"gid": computeItem.GID,
|
||||
"guid": computeItem.GUID,
|
||||
"hp_backed": computeItem.HPBacked,
|
||||
"compute_id": computeItem.ID,
|
||||
"cpu_pin": computeItem.CPUPin,
|
||||
"interfaces": flattenInterfaces(computeItem.Interfaces),
|
||||
"live_migration_job_id": computeItem.LiveMigrationJobID,
|
||||
"lock_status": computeItem.LockStatus,
|
||||
"manager_id": computeItem.ManagerID,
|
||||
"manager_type": computeItem.ManagerType,
|
||||
"migrationjob": computeItem.MigrationJob,
|
||||
"milestones": computeItem.Milestones,
|
||||
"nid": computeItem.NID,
|
||||
"name": computeItem.Name,
|
||||
"need_reboot": computeItem.NeedReboot,
|
||||
"numa_affinity": computeItem.NumaAffinity,
|
||||
"numa_node_id": computeItem.NumaNodeId,
|
||||
"os_users": flattenOSUsers(computeItem.OSUsers),
|
||||
"os_version": computeItem.OSVersion,
|
||||
"pinned": computeItem.PinnedToNode,
|
||||
"preferred_cpu": computeItem.PreferredCPU,
|
||||
"qemu_guest": flattenQemuQuest(computeItem.QemuQuest),
|
||||
"ram": computeItem.RAM,
|
||||
"reference_id": computeItem.ReferenceID,
|
||||
"registered": computeItem.Registered,
|
||||
"res_name": computeItem.ResName,
|
||||
"reserved_node_cpus": computeItem.ReservedNodeCpus,
|
||||
"rg_id": computeItem.RGID,
|
||||
"rg_name": computeItem.RGName,
|
||||
"snap_sets": flattenSnapSets(computeItem.SnapSets),
|
||||
"node_id": computeItem.NodeID,
|
||||
"node_name": computeItem.NodeName,
|
||||
"stateless_sep_id": computeItem.StatelessSEPID,
|
||||
"stateless_sep_type": computeItem.StatelessSEPType,
|
||||
"status": computeItem.Status,
|
||||
"tags": flattenTags(computeItem.Tags),
|
||||
"tech_status": computeItem.TechStatus,
|
||||
"total_disk_size": computeItem.TotalDiskSize,
|
||||
"updated_by": computeItem.UpdatedBy,
|
||||
"updated_time": computeItem.UpdatedTime,
|
||||
"user_data": string(userData),
|
||||
"user_managed": computeItem.UserManaged,
|
||||
"read_only": computeItem.ReadOnly,
|
||||
"vgpus": computeItem.VGPUs,
|
||||
"vins_connected": computeItem.VINSConnected,
|
||||
"loader_type": computeItem.LoaderType,
|
||||
"boot_type": computeItem.BootType,
|
||||
"hot_resize": computeItem.HotResize,
|
||||
@@ -419,78 +418,74 @@ func flattenDeletedComputeList(computes *compute.ListDeletedComputes) []map[stri
|
||||
devices, _ := json.Marshal(computeItem.Devices)
|
||||
userData, _ := json.Marshal(computeItem.Userdata)
|
||||
temp := map[string]interface{}{
|
||||
"acl": flattenListACLInterface(computeItem.ACL),
|
||||
"account_id": computeItem.AccountID,
|
||||
"account_name": computeItem.AccountName,
|
||||
"affinity_label": computeItem.AffinityLabel,
|
||||
"affinity_rules": flattenListRules(computeItem.AffinityRules),
|
||||
"affinity_weight": computeItem.AffinityWeight,
|
||||
"anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules),
|
||||
"arch": computeItem.Arch,
|
||||
"auto_start_w_node": computeItem.AutoStart,
|
||||
"chipset": computeItem.Chipset,
|
||||
"cd_image_id": computeItem.CdImageId,
|
||||
"boot_order": computeItem.BootOrder,
|
||||
"bootdisk_size": computeItem.BootDiskSize,
|
||||
"boot_image_id": computeItem.BootImageID,
|
||||
"clone_reference": computeItem.CloneReference,
|
||||
"clones": computeItem.Clones,
|
||||
"computeci_id": computeItem.ComputeCIID,
|
||||
"cpus": computeItem.CPUs,
|
||||
"created_by": computeItem.CreatedBy,
|
||||
"created_time": computeItem.CreatedTime,
|
||||
"custom_fields": string(customFields),
|
||||
"deleted_by": computeItem.DeletedBy,
|
||||
"deleted_time": computeItem.DeletedTime,
|
||||
"desc": computeItem.Description,
|
||||
"devices": string(devices),
|
||||
"disks": flattenDisks(computeItem.Disks),
|
||||
"driver": computeItem.Driver,
|
||||
"gid": computeItem.GID,
|
||||
"guid": computeItem.GUID,
|
||||
"hp_backed": computeItem.HPBacked,
|
||||
"compute_id": computeItem.ID,
|
||||
"cpu_pin": computeItem.CPUPin,
|
||||
//TODO
|
||||
// "image_id": computeItem.ImageID,
|
||||
"interfaces": flattenInterfaces(computeItem.Interfaces),
|
||||
"lock_status": computeItem.LockStatus,
|
||||
"manager_id": computeItem.ManagerID,
|
||||
"manager_type": computeItem.ManagerType,
|
||||
"migrationjob": computeItem.MigrationJob,
|
||||
"milestones": computeItem.Milestones,
|
||||
"name": computeItem.Name,
|
||||
"need_reboot": computeItem.NeedReboot,
|
||||
"numa_affinity": computeItem.NumaAffinity,
|
||||
"numa_node_id": computeItem.NumaNodeId,
|
||||
"os_users": flattenOSUsers(computeItem.OSUsers),
|
||||
"os_version": computeItem.OSVersion,
|
||||
"pinned": computeItem.PinnedToStack,
|
||||
"preferred_cpu": computeItem.PreferredCPU,
|
||||
"ram": computeItem.RAM,
|
||||
"reference_id": computeItem.ReferenceID,
|
||||
"registered": computeItem.Registered,
|
||||
"res_name": computeItem.ResName,
|
||||
"reserved_node_cpus": computeItem.ReservedNodeCpus,
|
||||
"rg_id": computeItem.RGID,
|
||||
"rg_name": computeItem.RGName,
|
||||
"snap_sets": flattenSnapSets(computeItem.SnapSets),
|
||||
"stack_id": computeItem.StackID,
|
||||
"stack_name": computeItem.StackName,
|
||||
"stateless_sep_id": computeItem.StatelessSEPID,
|
||||
"stateless_sep_type": computeItem.StatelessSEPType,
|
||||
"status": computeItem.Status,
|
||||
"tags": flattenTags(computeItem.Tags),
|
||||
"tech_status": computeItem.TechStatus,
|
||||
"total_disk_size": computeItem.TotalDiskSize,
|
||||
"updated_by": computeItem.UpdatedBy,
|
||||
"updated_time": computeItem.UpdatedTime,
|
||||
"user_data": string(userData),
|
||||
"user_managed": computeItem.UserManaged,
|
||||
"vgpus": computeItem.VGPUs,
|
||||
"vins_connected": computeItem.VINSConnected,
|
||||
//TODO
|
||||
// "virtual_image_id": computeItem.VirtualImageID,
|
||||
"acl": flattenListACLInterface(computeItem.ACL),
|
||||
"account_id": computeItem.AccountID,
|
||||
"account_name": computeItem.AccountName,
|
||||
"affinity_label": computeItem.AffinityLabel,
|
||||
"affinity_rules": flattenListRules(computeItem.AffinityRules),
|
||||
"affinity_weight": computeItem.AffinityWeight,
|
||||
"anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules),
|
||||
"arch": computeItem.Arch,
|
||||
"auto_start_w_node": computeItem.AutoStart,
|
||||
"chipset": computeItem.Chipset,
|
||||
"cd_image_id": computeItem.CdImageId,
|
||||
"boot_order": computeItem.BootOrder,
|
||||
"bootdisk_size": computeItem.BootDiskSize,
|
||||
"boot_image_id": computeItem.BootImageID,
|
||||
"clone_reference": computeItem.CloneReference,
|
||||
"clones": computeItem.Clones,
|
||||
"computeci_id": computeItem.ComputeCIID,
|
||||
"cpus": computeItem.CPUs,
|
||||
"created_by": computeItem.CreatedBy,
|
||||
"created_time": computeItem.CreatedTime,
|
||||
"custom_fields": string(customFields),
|
||||
"deleted_by": computeItem.DeletedBy,
|
||||
"deleted_time": computeItem.DeletedTime,
|
||||
"desc": computeItem.Description,
|
||||
"devices": string(devices),
|
||||
"disks": flattenDisks(computeItem.Disks),
|
||||
"driver": computeItem.Driver,
|
||||
"gid": computeItem.GID,
|
||||
"guid": computeItem.GUID,
|
||||
"hp_backed": computeItem.HPBacked,
|
||||
"compute_id": computeItem.ID,
|
||||
"cpu_pin": computeItem.CPUPin,
|
||||
"interfaces": flattenInterfaces(computeItem.Interfaces),
|
||||
"lock_status": computeItem.LockStatus,
|
||||
"manager_id": computeItem.ManagerID,
|
||||
"manager_type": computeItem.ManagerType,
|
||||
"migrationjob": computeItem.MigrationJob,
|
||||
"milestones": computeItem.Milestones,
|
||||
"name": computeItem.Name,
|
||||
"need_reboot": computeItem.NeedReboot,
|
||||
"numa_affinity": computeItem.NumaAffinity,
|
||||
"numa_node_id": computeItem.NumaNodeId,
|
||||
"os_users": flattenOSUsers(computeItem.OSUsers),
|
||||
"os_version": computeItem.OSVersion,
|
||||
"pinned": computeItem.PinnedToNode,
|
||||
"preferred_cpu": computeItem.PreferredCPU,
|
||||
"ram": computeItem.RAM,
|
||||
"reference_id": computeItem.ReferenceID,
|
||||
"registered": computeItem.Registered,
|
||||
"res_name": computeItem.ResName,
|
||||
"reserved_node_cpus": computeItem.ReservedNodeCpus,
|
||||
"rg_id": computeItem.RGID,
|
||||
"rg_name": computeItem.RGName,
|
||||
"snap_sets": flattenSnapSets(computeItem.SnapSets),
|
||||
"node_id": computeItem.NodeID,
|
||||
"node_name": computeItem.NodeName,
|
||||
"stateless_sep_id": computeItem.StatelessSEPID,
|
||||
"stateless_sep_type": computeItem.StatelessSEPType,
|
||||
"status": computeItem.Status,
|
||||
"tags": flattenTags(computeItem.Tags),
|
||||
"tech_status": computeItem.TechStatus,
|
||||
"total_disk_size": computeItem.TotalDiskSize,
|
||||
"updated_by": computeItem.UpdatedBy,
|
||||
"updated_time": computeItem.UpdatedTime,
|
||||
"user_data": string(userData),
|
||||
"user_managed": computeItem.UserManaged,
|
||||
"vgpus": computeItem.VGPUs,
|
||||
"vins_connected": computeItem.VINSConnected,
|
||||
"loader_type": computeItem.LoaderType,
|
||||
"boot_type": computeItem.BootType,
|
||||
"hot_resize": computeItem.HotResize,
|
||||
@@ -574,6 +569,7 @@ func flattenDisks(disks []compute.InfoDisk) []map[string]interface{} {
|
||||
// "bus_number": disk.BusNumber,
|
||||
"disk_id": disk.ID,
|
||||
// "pci_slot": disk.PCISlot,
|
||||
"sep_id": disk.SepID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -690,7 +686,7 @@ func flattenPCIDevice(deviceList []compute.ItemPCIDevice) []map[string]interface
|
||||
"device_id": dev.ID,
|
||||
"name": dev.Name,
|
||||
"rg_id": dev.RGID,
|
||||
"stack_id": dev.StackID,
|
||||
"node_id": dev.NodeID,
|
||||
"status": dev.Status,
|
||||
"system_name": dev.SystemName,
|
||||
}
|
||||
@@ -809,7 +805,7 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
|
||||
d.Set("numa_affinity", compFacts.NumaAffinity)
|
||||
d.Set("numa_node_id", compFacts.NumaNodeId)
|
||||
d.Set("os_users", flattenOSUsers(compFacts.OSUsers))
|
||||
d.Set("pinned", compFacts.PinnedToStack)
|
||||
d.Set("pinned", compFacts.PinnedToNode)
|
||||
d.Set("preferred_cpu", compFacts.PreferredCPU)
|
||||
d.Set("qemu_guest", flattenQemuQuest(compFacts.QemuQuest))
|
||||
d.Set("ram", compFacts.RAM)
|
||||
@@ -820,8 +816,8 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
|
||||
d.Set("rg_id", compFacts.RGID)
|
||||
d.Set("rg_name", compFacts.RGName)
|
||||
d.Set("snap_sets", flattenSnapSets(compFacts.SnapSets))
|
||||
d.Set("stack_id", compFacts.StackID)
|
||||
d.Set("stack_name", compFacts.StackName)
|
||||
d.Set("node_id", compFacts.NodeID)
|
||||
d.Set("node_name", compFacts.NodeName)
|
||||
d.Set("stateless_sep_id", compFacts.StatelessSEPID)
|
||||
d.Set("stateless_sep_type", compFacts.StatelessSEPType)
|
||||
d.Set("status", compFacts.Status)
|
||||
@@ -831,11 +827,9 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
|
||||
d.Set("updated_time", compFacts.UpdatedTime)
|
||||
d.Set("user_data", string(userData))
|
||||
d.Set("user_managed", compFacts.UserManaged)
|
||||
d.Set("read_only", compFacts.ReadOnly)
|
||||
d.Set("vnc_password", compFacts.VNCPassword)
|
||||
d.Set("vgpus", flattenVGPUs(compFacts.VGPUs))
|
||||
//TODO
|
||||
// d.Set("virtual_image_id", compFacts.VirtualImageID)
|
||||
// d.Set("virtual_image_name", compFacts.VirtualImageName)
|
||||
d.Set("pci_devices", flattenPCI(*pciList))
|
||||
d.Set("loader_type", compFacts.LoaderType)
|
||||
d.Set("boot_type", compFacts.BootType)
|
||||
@@ -872,6 +866,7 @@ func parseComputeInterfacesToNetworks(networks []interface{}, ifaces compute.Lis
|
||||
elem["ip_address"] = value.IPAddress
|
||||
elem["mac"] = value.MAC
|
||||
elem["mtu"] = value.MTU
|
||||
elem["net_mask"] = value.NetMask
|
||||
elem["sdn_interface_id"] = value.SDNInterfaceID
|
||||
elem["weight"] = flattenNetworkWeight(networks, value.NetID, value.NetType)
|
||||
elem["enabled"] = value.Enabled
|
||||
@@ -900,6 +895,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
|
||||
"ckey": disk.CKey,
|
||||
"meta": flattens.FlattenMeta(disk.Meta),
|
||||
"account_id": disk.AccountID,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"boot_partition": disk.BootPartition,
|
||||
"bus_number": disk.BusNumber,
|
||||
"created_time": disk.CreatedTime,
|
||||
|
||||
@@ -73,8 +73,8 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.Pool = pool.(string)
|
||||
}
|
||||
|
||||
if stackID, ok := d.GetOk("stack_id"); ok {
|
||||
createReqX86.StackID = uint64(stackID.(int))
|
||||
if nodeID, ok := d.GetOk("node_id"); ok {
|
||||
createReqX86.NodeID = uint64(nodeID.(int))
|
||||
}
|
||||
|
||||
if ipaType, ok := d.GetOk("ipa_type"); ok {
|
||||
@@ -85,6 +85,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.BootDisk = uint64(bootSize.(int))
|
||||
}
|
||||
|
||||
if bootDiskCache, ok := d.GetOk("boot_disk_cache"); ok {
|
||||
createReqX86.BootDiskCache = bootDiskCache.(string)
|
||||
}
|
||||
|
||||
if IS, ok := d.GetOk("is"); ok {
|
||||
createReqX86.IS = IS.(string)
|
||||
}
|
||||
@@ -93,6 +97,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
|
||||
if bootDiskBLKDiscard, ok := d.GetOk("boot_disk_blk_discard"); ok {
|
||||
createReqX86.BootDiskBLKDiscard = bootDiskBLKDiscard.(bool)
|
||||
}
|
||||
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
|
||||
if networks, ok := d.GetOk("network"); ok {
|
||||
@@ -126,6 +134,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int))
|
||||
}
|
||||
|
||||
if reqInterface.NetType == "DPDK" || reqInterface.NetType == "VFNIC" {
|
||||
if netMask, netMaskSet := netInterfaceVal["net_mask"]; netMaskSet {
|
||||
reqInterface.NetMask = uint64(netMask.(int))
|
||||
}
|
||||
}
|
||||
|
||||
ipaddr, ipSet := netInterfaceVal["ip_address"]
|
||||
if ipSet {
|
||||
reqInterface.IPAddr = ipaddr.(string)
|
||||
@@ -170,6 +184,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if imageID, ok := diskVal["image_id"]; ok {
|
||||
reqDataDisk.ImageID = uint64(imageID.(int))
|
||||
}
|
||||
if cache, ok := diskVal["cache"]; ok {
|
||||
reqDataDisk.Cache = cache.(string)
|
||||
}
|
||||
if blkDiscard, ok := diskVal["blk_discard"]; ok {
|
||||
reqDataDisk.BLKDiscard = blkDiscard.(bool)
|
||||
}
|
||||
disksX86 = append(disksX86, reqDataDisk)
|
||||
}
|
||||
|
||||
@@ -328,6 +348,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
|
||||
if !cleanup {
|
||||
|
||||
if enabled, ok := d.GetOk("enabled"); ok {
|
||||
if enabled.(bool) {
|
||||
req := compute.EnableRequest{ComputeID: computeId}
|
||||
@@ -424,6 +445,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
if start, ok := d.GetOk("started"); ok && start.(bool) {
|
||||
req := compute.StartRequest{ComputeID: computeId}
|
||||
if nodeID, ok := d.GetOk("node_id"); ok {
|
||||
req.NodeID = uint64(nodeID.(int))
|
||||
}
|
||||
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
|
||||
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
|
||||
warnings.Add(err)
|
||||
@@ -436,19 +460,16 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if pin, ok := d.GetOk("pin_to_stack"); ok && pin.(bool) {
|
||||
if pin, ok := d.GetOk("pin_to_node"); ok && pin.(bool) {
|
||||
start, _ := d.GetOk("started")
|
||||
_, stackOk := d.GetOk("stack_id")
|
||||
_, nodeOk := d.GetOk("node_id")
|
||||
|
||||
if !start.(bool) && !stackOk {
|
||||
warnings.Add(errors.New("cannot pin to stack a VM, that is not started and stack_id is not set"))
|
||||
if !start.(bool) && !nodeOk {
|
||||
warnings.Add(errors.New("cannot pin to node a VM, that is not started and node_id is not set"))
|
||||
} else {
|
||||
req := compute.PinToStackRequest{
|
||||
ComputeID: computeId,
|
||||
}
|
||||
|
||||
if stackID, ok := d.Get("stack_id").(int); ok {
|
||||
req.TargetStackID = uint64(stackID)
|
||||
req := compute.PinToNodeRequest{
|
||||
ComputeID: computeId,
|
||||
TargetNodeID: uint64(d.Get("node_id").(int)),
|
||||
}
|
||||
|
||||
if force, ok := d.Get("force_pin").(bool); ok {
|
||||
@@ -459,7 +480,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
req.AutoStart = autoStart
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().PinToStack(ctx, req)
|
||||
_, err := c.CloudBroker().Compute().PinToNode(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
@@ -628,7 +649,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if !d.Get("pin_to_stack").(bool) && d.Get("auto_start_w_node").(bool) {
|
||||
if !d.Get("pin_to_node").(bool) && d.Get("auto_start_w_node").(bool) {
|
||||
req := compute.UpdateRequest{
|
||||
ComputeID: computeId,
|
||||
AutoStart: d.Get("auto_start_w_node").(bool),
|
||||
@@ -658,6 +679,14 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if readOnly, ok := d.GetOk("read_only"); ok {
|
||||
if readOnly.(bool) {
|
||||
if err := utilityComputeUpdateReadOnly(ctx, d, m); err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", computeId, d.Get("name").(string))
|
||||
@@ -805,6 +834,18 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("boot_disk_cache") {
|
||||
if err := utilityComputeUpdateBootDiskCache(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("boot_disk_blk_discard") {
|
||||
if err := utilityComputeUpdateBootDiskBLKDiscard(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("extra_disks") {
|
||||
err := utilityComputeExtraDisksConfigure(ctx, d, m, true) // pass do_delta = true to apply changes, if any
|
||||
if err != nil {
|
||||
@@ -812,8 +853,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("pin_to_stack") {
|
||||
if err := utilityComputePinToStack(ctx, d, m); err != nil {
|
||||
if d.HasChange("pin_to_node") {
|
||||
if err := utilityComputePinToNode(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
@@ -946,6 +987,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("read_only") {
|
||||
if err := utilityComputeUpdateReadOnly(ctx, d, m); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return append(resourceComputeRead(ctx, d, m), warnings.Get()...)
|
||||
}
|
||||
|
||||
@@ -980,12 +1027,12 @@ func ResourceCompute() *schema.Resource {
|
||||
SchemaVersion: 2,
|
||||
|
||||
CustomizeDiff: func(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error {
|
||||
if diff.HasChanges() || diff.HasChanges("chipset", "pin_to_stack", "auto_start_w_node", "libvirt_settings", "network", "affinity_rules", "anti_affinity_rules",
|
||||
if diff.HasChanges() || diff.HasChanges("chipset", "pin_to_node", "auto_start_w_node", "libvirt_settings", "network", "affinity_rules", "anti_affinity_rules",
|
||||
"extra_disks", "tags", "port_forwarding", "user_access", "snapshot", "pci_devices", "preferred_cpu", "security_groups") {
|
||||
diff.SetNewComputed("updated_time")
|
||||
diff.SetNewComputed("updated_by")
|
||||
}
|
||||
if diff.HasChanges("pin_to_stack") {
|
||||
if diff.HasChanges("pin_to_node") {
|
||||
diff.SetNewComputed("pinned")
|
||||
}
|
||||
if diff.HasChanges("started") {
|
||||
|
||||
@@ -228,6 +228,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"boot_partition": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -236,6 +240,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cache": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -939,11 +947,11 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"stack_id": {
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"stack_name": {
|
||||
"node_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
@@ -1011,6 +1019,11 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "Shows if compute is locked to read-only operations.",
|
||||
},
|
||||
"vnc_password": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -1100,14 +1113,6 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"virtual_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"virtual_image_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
//extra parameters
|
||||
"boot_disk_size": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -1181,7 +1186,7 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Find by tech status",
|
||||
},
|
||||
"stack_name": {
|
||||
"node_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by node name.",
|
||||
@@ -1196,10 +1201,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Find by IP address",
|
||||
},
|
||||
"stack_id": {
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by stack ID",
|
||||
Description: "Find by node ID",
|
||||
},
|
||||
"cd_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -1460,6 +1465,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1483,10 +1492,6 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"interfaces": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -1829,11 +1834,11 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"stack_id": {
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"stack_name": {
|
||||
"node_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by node name.",
|
||||
@@ -1890,6 +1895,11 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "Shows if compute is in read-only mode.",
|
||||
},
|
||||
"vgpus": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -1901,10 +1911,6 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"virtual_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"loader_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -2238,10 +2244,6 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"interfaces": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -2545,11 +2547,11 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"stack_id": {
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"stack_name": {
|
||||
"node_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by node name.",
|
||||
@@ -2617,10 +2619,6 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"virtual_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"loader_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -3180,7 +3178,7 @@ func dataSourceComputePCIDeviceListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"stack_id": {
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
@@ -3406,12 +3404,24 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Default: false,
|
||||
Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.",
|
||||
},
|
||||
"boot_disk_blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"boot_disk_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.",
|
||||
},
|
||||
"boot_disk_cache": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "none",
|
||||
ValidateFunc: validation.StringInSlice([]string{"none", "writethrough"}, false),
|
||||
Description: "Setting the boot disk caching mode",
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -3447,11 +3457,11 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Default: 0,
|
||||
Description: "ID of CD-ROM live image to boot",
|
||||
},
|
||||
"stack_id": {
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "ID of stack to start compute",
|
||||
Description: "ID of node to start compute",
|
||||
},
|
||||
"is": {
|
||||
Type: schema.TypeString,
|
||||
@@ -3521,16 +3531,22 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
DiffSuppressFunc: networkSubresIPAddreDiffSupperss,
|
||||
Description: "unique_identifier of LogicalPort on SDN side",
|
||||
},
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "network enable flag",
|
||||
},
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "network enable flag",
|
||||
},
|
||||
"net_mask": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Subnet mask, used only for DPDK and VFNIC network types",
|
||||
},
|
||||
},
|
||||
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
||||
},
|
||||
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
||||
},
|
||||
|
||||
"libvirt_settings": {
|
||||
Type: schema.TypeSet,
|
||||
@@ -3654,7 +3670,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
"value": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Required: true,
|
||||
Description: "value that must match the key to be taken into account when analyzing this rule",
|
||||
},
|
||||
},
|
||||
@@ -3695,7 +3711,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
"value": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Required: true,
|
||||
Description: "value that must match the key to be taken into account when analyzing this rule",
|
||||
},
|
||||
},
|
||||
@@ -3704,8 +3720,16 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
"disks": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"cache": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "none",
|
||||
ValidateFunc: validation.StringInSlice([]string{"none", "writethrough"}, false),
|
||||
Description: "Setting the disk caching mode",
|
||||
},
|
||||
"disk_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
@@ -3721,6 +3745,11 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "Storage policy id of disk. The rules of the specified storage policy will be used.",
|
||||
},
|
||||
"blk_discard": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -3927,7 +3956,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"pin_to_stack": {
|
||||
"pin_to_node": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
@@ -4487,10 +4516,10 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"stack_name": {
|
||||
"node_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the stack, on which VM started",
|
||||
Description: "Name of the node, on which VM started",
|
||||
},
|
||||
"stateless_sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -4520,6 +4549,12 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"read_only": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Sets read-only mode for this compute. Only data operations allowed when enabled.",
|
||||
},
|
||||
"vnc_password": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -4609,10 +4644,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"virtual_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"virtual_image_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -35,14 +35,17 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-cty/cty"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/compute"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/tasks"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
@@ -88,8 +91,8 @@ func utilityComputeStarted(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if altBootId, ok := d.Get("alt_boot_id").(int); ok {
|
||||
req.AltBootID = uint64(altBootId)
|
||||
}
|
||||
if stackId, ok := d.Get("stack_id").(int); ok {
|
||||
req.StackID = uint64(stackId)
|
||||
if nodeId, ok := d.Get("node_id").(int); ok {
|
||||
req.NodeID = uint64(nodeId)
|
||||
}
|
||||
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
|
||||
return err
|
||||
@@ -108,6 +111,28 @@ func utilityComputeStarted(ctx context.Context, d *schema.ResourceData, m interf
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeUpdateReadOnly(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
computeId, err := strconv.ParseUint(d.Id(), 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req := compute.ChangeReadOnlyRequest{
|
||||
ComputeID: computeId,
|
||||
ReadOnly: d.Get("read_only").(bool),
|
||||
}
|
||||
|
||||
if _, err := c.CloudBroker().Compute().ChangeReadOnly(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("resourceCompute: read_only=%t for Compute ID %d", req.ReadOnly, computeId)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
@@ -235,6 +260,9 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
resizedDisks := make([]interface{}, 0)
|
||||
renamedDisks := make([]interface{}, 0)
|
||||
changeStoragePolicyDisks := make([]interface{}, 0)
|
||||
cacheUpdatedDisks := make([]interface{}, 0)
|
||||
blkDiscardUpdatedDisks := make([]interface{}, 0)
|
||||
migratedDisks := make([]interface{}, 0)
|
||||
presentNewDisks := make([]interface{}, 0)
|
||||
presentOldDisks := make([]interface{}, 0)
|
||||
|
||||
@@ -280,9 +308,18 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
if isRenameDisk(oldConv, el) {
|
||||
renamedDisks = append(renamedDisks, el)
|
||||
}
|
||||
if isChangeStoragePolicy(oldConv, el) {
|
||||
if isMigrateDisk(oldConv, el) {
|
||||
migratedDisks = append(migratedDisks, el)
|
||||
} else if isChangeStoragePolicy(oldConv, el) {
|
||||
changeStoragePolicyDisks = append(changeStoragePolicyDisks, el)
|
||||
}
|
||||
if isChangeCacheDisk(oldConv, el) {
|
||||
cacheUpdatedDisks = append(cacheUpdatedDisks, el)
|
||||
}
|
||||
|
||||
if isChangeBLKDiscardDisk(oldConv, el) {
|
||||
blkDiscardUpdatedDisks = append(blkDiscardUpdatedDisks, el)
|
||||
}
|
||||
}
|
||||
|
||||
if len(deletedDisks) > 0 {
|
||||
@@ -332,6 +369,9 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
if diskConv["image_id"].(int) != 0 {
|
||||
req.ImageID = uint64(diskConv["image_id"].(int))
|
||||
}
|
||||
if cacheVal, ok := diskConv["cache"].(string); ok {
|
||||
req.Cache = cacheVal
|
||||
}
|
||||
diskID, err := c.CloudBroker().Compute().DiskAdd(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -409,6 +449,58 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
}
|
||||
}
|
||||
|
||||
if len(cacheUpdatedDisks) > 0 {
|
||||
for _, disk := range cacheUpdatedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if diskConv["disk_type"].(string) == "B" {
|
||||
continue
|
||||
}
|
||||
|
||||
diskID := uint64(diskConv["disk_id"].(int))
|
||||
if diskID == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
req := disks.UpdateRequest{
|
||||
DiskID: diskID,
|
||||
Cache: diskConv["cache"].(string),
|
||||
}
|
||||
_, err := c.CloudBroker().Disks().Update(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(blkDiscardUpdatedDisks) > 0 {
|
||||
for _, disk := range blkDiscardUpdatedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if diskConv["disk_type"].(string) == "B" {
|
||||
continue
|
||||
}
|
||||
|
||||
diskID := uint64(diskConv["disk_id"].(int))
|
||||
if diskID == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
req := disks.UpdateRequest{
|
||||
DiskID: diskID,
|
||||
BLKDiscard: diskConv["blk_discard"].(bool),
|
||||
}
|
||||
_, err := c.CloudBroker().Disks().Update(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(migratedDisks) > 0 {
|
||||
if err := utilityComputeMigrateDisks(ctx, d, m, migratedDisks, oldConv); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for i := range presentNewDisks {
|
||||
newDisk := presentNewDisks[i].(map[string]interface{})
|
||||
oldDisk := presentOldDisks[i].(map[string]interface{})
|
||||
@@ -449,6 +541,56 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeUpdateBootDiskCache(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
newCache := d.Get("boot_disk_cache").(string)
|
||||
|
||||
var bootDiskID uint64
|
||||
if v, ok := d.GetOk("boot_disk_id"); ok {
|
||||
if id, ok := v.(int); ok {
|
||||
bootDiskID = uint64(id)
|
||||
}
|
||||
}
|
||||
|
||||
if bootDiskID == 0 {
|
||||
return fmt.Errorf("cannot update boot_disk_cache: boot disk ID is unknown for compute %s", d.Id())
|
||||
}
|
||||
|
||||
req := disks.UpdateRequest{
|
||||
DiskID: bootDiskID,
|
||||
Cache: newCache,
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Disks().Update(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func utilityComputeUpdateBootDiskBLKDiscard(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
newBLKDiscard := d.Get("boot_disk_blk_discard").(bool)
|
||||
|
||||
var bootDiskID uint64
|
||||
if v, ok := d.GetOk("boot_disk_id"); ok {
|
||||
if id, ok := v.(int); ok {
|
||||
bootDiskID = uint64(id)
|
||||
}
|
||||
}
|
||||
|
||||
if bootDiskID == 0 {
|
||||
return fmt.Errorf("cannot update boot_disk_cache: boot disk ID is unknown for compute %s", d.Id())
|
||||
}
|
||||
|
||||
req := disks.UpdateRequest{
|
||||
DiskID: bootDiskID,
|
||||
BLKDiscard: newBLKDiscard,
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Disks().Update(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceData, m interface{}, do_delta bool) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
@@ -709,6 +851,12 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
req.MTU = uint64(netData["mtu"].(int))
|
||||
}
|
||||
|
||||
if req.NetType == "DPDK" || req.NetType == "VFNIC" {
|
||||
if netMask, ok := netData["net_mask"].(int); ok && netMask > 0 {
|
||||
req.NetMask = uint64(netMask)
|
||||
}
|
||||
}
|
||||
|
||||
if netData["sdn_interface_id"].(string) != "" {
|
||||
req.SDNInterfaceID = netData["sdn_interface_id"].(string)
|
||||
}
|
||||
@@ -1613,33 +1761,33 @@ func utilityComputeUpdateCD(ctx context.Context, d *schema.ResourceData, m inter
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputePinToStack(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
func utilityComputePinToNode(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
start, _ := d.GetOk("started")
|
||||
_, stackOk := d.GetOk("stack_id")
|
||||
|
||||
if !start.(bool) && !stackOk {
|
||||
errors.New("cannot pin to stack a VM, that is not started and stack_id is not set")
|
||||
}
|
||||
|
||||
oldPin, newPin := d.GetChange("pin_to_stack")
|
||||
oldPin, newPin := d.GetChange("pin_to_node")
|
||||
if oldPin.(bool) && !newPin.(bool) {
|
||||
req := compute.UnpinFromStackRequest{
|
||||
req := compute.UnpinFromNodeRequest{
|
||||
ComputeID: computeId,
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().UnpinFromStack(ctx, req)
|
||||
_, err := c.CloudBroker().Compute().UnpinFromNode(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !oldPin.(bool) && newPin.(bool) {
|
||||
req := compute.PinToStackRequest{
|
||||
ComputeID: computeId,
|
||||
TargetStackID: uint64(d.Get("stack_id").(int)),
|
||||
start, _ := d.GetOk("started")
|
||||
_, nodeOk := d.GetOk("node_id")
|
||||
|
||||
if !start.(bool) && !nodeOk {
|
||||
return errors.New("cannot pin to node a VM, that is not started and node_id is not set")
|
||||
}
|
||||
|
||||
req := compute.PinToNodeRequest{
|
||||
ComputeID: computeId,
|
||||
TargetNodeID: uint64(d.Get("node_id").(int)),
|
||||
}
|
||||
|
||||
if force, ok := d.Get("force_pin").(bool); ok {
|
||||
@@ -1650,7 +1798,7 @@ func utilityComputePinToStack(ctx context.Context, d *schema.ResourceData, m int
|
||||
req.AutoStart = autoStart
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Compute().PinToStack(ctx, req)
|
||||
_, err := c.CloudBroker().Compute().PinToNode(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1905,6 +2053,30 @@ func isRenameDisk(els []interface{}, el interface{}) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func isChangeCacheDisk(els []interface{}, el interface{}) bool {
|
||||
for _, elOld := range els {
|
||||
elOldConv := elOld.(map[string]interface{})
|
||||
elConv := el.(map[string]interface{})
|
||||
if elOldConv["disk_id"].(int) == elConv["disk_id"].(int) &&
|
||||
elOldConv["cache"].(string) != elConv["cache"].(string) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isChangeBLKDiscardDisk(els []interface{}, el interface{}) bool {
|
||||
for _, elOld := range els {
|
||||
elOldConv := elOld.(map[string]interface{})
|
||||
elConv := el.(map[string]interface{})
|
||||
if elOldConv["disk_id"].(int) == elConv["disk_id"].(int) &&
|
||||
elOldConv["blk_discard"].(bool) != elConv["blk_discard"].(bool) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isChangeStoragePolicy(els []interface{}, el interface{}) bool {
|
||||
for _, elOld := range els {
|
||||
elOldConv := elOld.(map[string]interface{})
|
||||
@@ -1917,6 +2089,22 @@ func isChangeStoragePolicy(els []interface{}, el interface{}) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func isMigrateDisk(els []interface{}, el interface{}) bool {
|
||||
for _, elOld := range els {
|
||||
elOldConv := elOld.(map[string]interface{})
|
||||
elConv := el.(map[string]interface{})
|
||||
if elOldConv["disk_id"].(int) == elConv["disk_id"].(int) &&
|
||||
elOldConv["disk_id"].(int) != 0 {
|
||||
sepIDChanged := elOldConv["sep_id"].(int) != elConv["sep_id"].(int)
|
||||
poolChanged := elOldConv["pool"].(string) != elConv["pool"].(string)
|
||||
if sepIDChanged || poolChanged {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isContainsDisk(els []interface{}, el interface{}) bool {
|
||||
for _, elOld := range els {
|
||||
elOldConv := elOld.(map[string]interface{})
|
||||
@@ -1948,6 +2136,105 @@ func isChangeNodesDisk(els []interface{}, elOld interface{}) (bool, interface{})
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func utilityComputeMigrateDisks(ctx context.Context, d *schema.ResourceData, m interface{}, migratedDisks, oldDisks []interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
for _, disk := range migratedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
|
||||
oldDiskID := uint64(diskConv["disk_id"].(int))
|
||||
if oldDiskID == 0 {
|
||||
log.Debugf("utilityComputeMigrateDisks: skipping disk with id=0")
|
||||
continue
|
||||
}
|
||||
|
||||
newSepID := uint64(diskConv["sep_id"].(int))
|
||||
newPool := diskConv["pool"].(string)
|
||||
storagePolicyID := uint64(diskConv["storage_policy_id"].(int))
|
||||
|
||||
log.Debugf("utilityComputeMigrateDisks: migrating disk_id=%d to sep_id=%d, pool=%s", oldDiskID, newSepID, newPool)
|
||||
|
||||
migrateReq := disks.MigrateRequest{
|
||||
DiskID: oldDiskID,
|
||||
SEPID: newSepID,
|
||||
PoolName: newPool,
|
||||
StoragePolicyID: storagePolicyID,
|
||||
}
|
||||
|
||||
taskID, err := c.CloudBroker().Disks().Migrate(ctx, migrateReq)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to start disk migration for disk_id=%d: %w", oldDiskID, err)
|
||||
}
|
||||
|
||||
log.Debugf("utilityComputeMigrateDisks: disk migration started, taskID=%s", taskID)
|
||||
|
||||
newDiskID, err := utilityComputeWaitForMigrationTask(ctx, c, taskID, oldDiskID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("disk migration task failed for disk_id=%d: %w", oldDiskID, err)
|
||||
}
|
||||
|
||||
log.Debugf("utilityComputeMigrateDisks: disk migration completed, old_disk_id=%d, new_disk_id=%d", oldDiskID, newDiskID)
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeWaitForMigrationTask(ctx context.Context, c *controller.ControllerCfg, taskID string, oldDiskID uint64) (uint64, error) {
|
||||
|
||||
for {
|
||||
|
||||
time.Sleep(15 * time.Second)
|
||||
taskReq := tasks.GetRequest{
|
||||
AuditID: strings.Trim(taskID, `"`),
|
||||
}
|
||||
|
||||
taskInfo, err := c.CloudBroker().Tasks().Get(ctx, taskReq)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to get task status: %w", err)
|
||||
}
|
||||
|
||||
log.Debugf("utilityComputeWaitForMigrationTask: taskID=%s, completed=%t, status=%s", taskID, taskInfo.Completed, taskInfo.Status)
|
||||
|
||||
if taskInfo.Completed {
|
||||
if taskInfo.Error != "" {
|
||||
return 0, fmt.Errorf("migration task failed with error: %s", taskInfo.Error)
|
||||
}
|
||||
|
||||
resultStr, err := taskInfo.Result.ToString()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to get task result: %w", err)
|
||||
}
|
||||
|
||||
log.Debugf("utilityComputeWaitForMigrationTask: migration result: %s", resultStr)
|
||||
|
||||
newDiskID, err := extractNewDiskIDFromResult(resultStr)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to parse migration result: %w", err)
|
||||
}
|
||||
|
||||
return newDiskID, nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func extractNewDiskIDFromResult(result string) (uint64, error) {
|
||||
re := regexp.MustCompile(`Disk ID \d+ successfully migrated to Disk ID (\d+)`)
|
||||
matches := re.FindStringSubmatch(result)
|
||||
|
||||
if len(matches) < 2 {
|
||||
return 0, fmt.Errorf("could not extract new disk ID from result: %s", result)
|
||||
}
|
||||
|
||||
newDiskID, err := strconv.ParseUint(matches[1], 10, 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to parse new disk ID: %w", err)
|
||||
}
|
||||
|
||||
return newDiskID, nil
|
||||
}
|
||||
|
||||
func isContainsAR(els []interface{}, el interface{}) bool {
|
||||
for _, elOld := range els {
|
||||
elOldConv := elOld.(map[string]interface{})
|
||||
|
||||
@@ -69,11 +69,11 @@ func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.Resource
|
||||
if ipAddress, ok := d.GetOk("ip_address"); ok {
|
||||
req.IPAddress = ipAddress.(string)
|
||||
}
|
||||
if stackID, ok := d.GetOk("stack_id"); ok {
|
||||
req.StackID = stackID.(uint64)
|
||||
if nodeID, ok := d.GetOk("node_id"); ok {
|
||||
req.NodeID = nodeID.(uint64)
|
||||
}
|
||||
if stackName, ok := d.GetOk("stack_name"); ok {
|
||||
req.StackName = stackName.(string)
|
||||
if nodeName, ok := d.GetOk("node_name"); ok {
|
||||
req.NodeName = nodeName.(string)
|
||||
}
|
||||
if cdImageID, ok := d.GetOk("cd_image_id"); ok {
|
||||
req.CDImageID = cdImageID.(uint64)
|
||||
|
||||
Reference in New Issue
Block a user