4.12.0
This commit is contained in:
@@ -260,6 +260,14 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"provision": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"boot_partition": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -319,6 +327,10 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"independent": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"iotune": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -457,10 +469,6 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"to_clean": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -1169,6 +1177,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"weight": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"loader_meta_iso": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
|
||||
@@ -445,6 +445,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"weight": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -252,6 +252,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"hot_resize": compute.HotResize,
|
||||
"network_interface_naming": compute.NetworkInterfaceNaming,
|
||||
"zone_id": compute.ZoneID,
|
||||
"weight": compute.Weight,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -265,7 +266,6 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
|
||||
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,
|
||||
@@ -279,6 +279,16 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
|
||||
"to_clean": bootDisk.ToClean,
|
||||
"cache": bootDisk.Cache,
|
||||
"blk_discard": bootDisk.BLKDiscard,
|
||||
"block_size": bootDisk.BlockSize,
|
||||
"bus_number": bootDisk.BusNumber,
|
||||
"provision": bootDisk.Provision,
|
||||
"pci_slot": bootDisk.PCISlot,
|
||||
"created_time": bootDisk.CreatedTime,
|
||||
"created_by": bootDisk.CreatedBy,
|
||||
"deleted_by": bootDisk.DeletedBy,
|
||||
"deleted_time": bootDisk.DeletedTime,
|
||||
"updated_time": bootDisk.UpdatedTime,
|
||||
"devicename": bootDisk.DeviceName,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
@@ -315,7 +325,9 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
||||
"devicename": disk.DeviceName,
|
||||
"disk_name": disk.Name,
|
||||
"disk_id": disk.ID,
|
||||
"disk_type": disk.Type,
|
||||
"independent": disk.Independent,
|
||||
"pci_slot": disk.PCISlot,
|
||||
"bus_number": disk.BusNumber,
|
||||
"sep_id": disk.SepID,
|
||||
"shareable": disk.Shareable,
|
||||
"size_max": disk.SizeMax,
|
||||
@@ -335,6 +347,8 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
|
||||
"permanently": pernamentlyValue,
|
||||
"cache": disk.Cache,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"block_size": disk.BlockSize,
|
||||
"provision": disk.Provision,
|
||||
"iotune": flattenIotune(disk.IOTune),
|
||||
}
|
||||
res = append(res, temp)
|
||||
@@ -375,10 +389,23 @@ func flattenNetworkWeight(networks []interface{}, netID uint64, netType string)
|
||||
return 0
|
||||
}
|
||||
|
||||
func findBootDisk(disks compute.ListComputeDisks) *compute.ItemComputeDisk {
|
||||
func isBootDisk(diskConv map[string]interface{}, chipset string) bool {
|
||||
if chipset == "i440fx" {
|
||||
return diskConv["pci_slot"].(int) == 6
|
||||
}
|
||||
return diskConv["bus_number"].(int) == 6
|
||||
}
|
||||
|
||||
func findBootDisk(disks compute.ListComputeDisks, chipset string) *compute.ItemComputeDisk {
|
||||
for _, disk := range disks {
|
||||
if disk.Type == "B" {
|
||||
return &disk
|
||||
if chipset == "i440fx" {
|
||||
if disk.PCISlot == 6 {
|
||||
return &disk
|
||||
}
|
||||
} else {
|
||||
if disk.BusNumber == 6 {
|
||||
return &disk
|
||||
}
|
||||
}
|
||||
}
|
||||
return &compute.ItemComputeDisk{}
|
||||
@@ -393,7 +420,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
||||
log.Debugf("flattenCompute: ID %d, RG ID %d", computeRec.ID, computeRec.RGID)
|
||||
|
||||
devices, _ := json.Marshal(computeRec.Devices)
|
||||
bootDisk := findBootDisk(computeRec.Disks)
|
||||
bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset)
|
||||
|
||||
//check extraDisks, ipa_type, is,
|
||||
d.SetId(strconv.FormatUint(computeRec.ID, 10))
|
||||
@@ -480,6 +507,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
|
||||
d.Set("cpu_pin", computeRec.CPUPin)
|
||||
d.Set("numa_affinity", computeRec.NumaAffinity)
|
||||
d.Set("hp_backed", computeRec.HPBacked)
|
||||
d.Set("weight", computeRec.Weight)
|
||||
|
||||
d.Set("enabled", false)
|
||||
if computeRec.Status == status.Enabled {
|
||||
@@ -586,6 +614,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
|
||||
"acl": string(acl),
|
||||
"account_id": disk.AccountID,
|
||||
"blk_discard": disk.BLKDiscard,
|
||||
"block_size": disk.BlockSize,
|
||||
"boot_partition": disk.BootPartition,
|
||||
"bus_number": disk.BusNumber,
|
||||
"created_time": disk.CreatedTime,
|
||||
@@ -603,6 +632,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
|
||||
"image_id": disk.ImageID,
|
||||
"images": disk.Images,
|
||||
"iotune": flattenIotune(disk.IOTune),
|
||||
"independent": disk.Independent,
|
||||
"iqn": disk.IQN,
|
||||
"login": disk.Login,
|
||||
"milestones": disk.Milestones,
|
||||
@@ -627,8 +657,8 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
|
||||
"status": disk.Status,
|
||||
"storage_policy_id": disk.StoragePolicyID,
|
||||
"tech_status": disk.TechStatus,
|
||||
"type": disk.Type,
|
||||
"to_clean": disk.ToClean,
|
||||
"provision": disk.Provision,
|
||||
"updated_time": disk.UpdatedTime,
|
||||
}
|
||||
res = append(res, temp)
|
||||
@@ -755,6 +785,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
d.Set("zone_id", computeRec.ZoneID)
|
||||
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
|
||||
d.Set("os_version", computeRec.OSVersion)
|
||||
d.Set("weight", computeRec.Weight)
|
||||
}
|
||||
|
||||
func flattenPCI(pciList compute.ListPCIDevices) []uint64 {
|
||||
|
||||
@@ -166,8 +166,8 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
//Default: 1500,
|
||||
ValidateFunc: validation.IntBetween(1, 9216),
|
||||
Description: "Maximum transmission unit, used only for DPDK type, must be 1-9216",
|
||||
ValidateFunc: validation.IntBetween(1500, 9216),
|
||||
Description: "Maximum transmission unit, used only for DPDK type, must be 1500-9216",
|
||||
},
|
||||
|
||||
"sdn_interface_id": {
|
||||
|
||||
@@ -182,19 +182,3 @@ func existTRUNKId(ctx context.Context, m interface{}, id int) (int, bool) {
|
||||
|
||||
return id, false
|
||||
}
|
||||
|
||||
func isMoreThanOneDisksTypeB(ctx context.Context, disks interface{}) bool {
|
||||
count := 0
|
||||
|
||||
for _, elem := range disks.([]interface{}) {
|
||||
diskVal := elem.(map[string]interface{})
|
||||
if diskVal["disk_type"].(string) == "B" {
|
||||
count++
|
||||
}
|
||||
if count > 1 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -71,25 +71,21 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
return diag.Errorf("resourceComputeCreate: can't create Compute because rgID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
||||
}
|
||||
|
||||
hasImage, err := existImageId(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
if !d.Get("create_blank").(bool) {
|
||||
hasImage, err := existImageId(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !hasImage {
|
||||
return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int))
|
||||
if !hasImage {
|
||||
return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int))
|
||||
}
|
||||
}
|
||||
|
||||
if zoneID, ok := d.GetOk("zone_id"); ok {
|
||||
createReqX86.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
|
||||
if disks, ok := d.GetOk("disks"); ok {
|
||||
if isMoreThanOneDisksTypeB(ctx, disks) {
|
||||
return diag.Errorf("resourceComputeCreate: can't create Compute because block disks have more 1 disk type 'B'")
|
||||
}
|
||||
}
|
||||
|
||||
if network, ok := d.GetOk("network"); ok {
|
||||
networkList := network.(*schema.Set).List()
|
||||
for _, elem := range networkList {
|
||||
@@ -116,8 +112,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if trunkId, ok := existTRUNKId(ctx, m, networkData["net_id"].(int)); !ok {
|
||||
return diag.Errorf("resourceComputeCreate: can't create compute because TRUNK ID %d is not allowed or does not exist", trunkId)
|
||||
}
|
||||
//TODO
|
||||
//SDN check
|
||||
default:
|
||||
continue
|
||||
}
|
||||
@@ -137,18 +131,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.Pool = pool.(string)
|
||||
}
|
||||
|
||||
if ipaType, ok := d.GetOk("ipa_type"); ok {
|
||||
createReqX86.IPAType = ipaType.(string)
|
||||
}
|
||||
|
||||
if bootSize, ok := d.GetOk("boot_disk_size"); ok {
|
||||
createReqX86.BootDisk = uint64(bootSize.(int))
|
||||
}
|
||||
|
||||
if IS, ok := d.GetOk("is"); ok {
|
||||
createReqX86.IS = IS.(string)
|
||||
}
|
||||
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
|
||||
if networks, ok := d.GetOk("network"); ok {
|
||||
@@ -178,7 +164,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
reqInterface.Enabled = netInterfaceVal["enabled"].(bool)
|
||||
}
|
||||
|
||||
if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" {
|
||||
if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" || reqInterface.NetType == "TRUNK" {
|
||||
reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int))
|
||||
}
|
||||
|
||||
@@ -294,7 +280,31 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
|
||||
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
||||
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86)
|
||||
var apiResp uint64
|
||||
if d.Get("create_blank").(bool) {
|
||||
log.Debugf("resourceComputeCreate: using createBlank endpoint")
|
||||
createBlankReq := kvmx86.CreateBlankRequest{
|
||||
RGID: createReqX86.RGID,
|
||||
Name: createReqX86.Name,
|
||||
CPU: createReqX86.CPU,
|
||||
RAM: createReqX86.RAM,
|
||||
StoragePolicyID: createReqX86.StoragePolicyID,
|
||||
WithoutBootDisk: createReqX86.WithoutBootDisk,
|
||||
BootDisk: createReqX86.BootDisk,
|
||||
SEPID: createReqX86.SepID,
|
||||
Pool: createReqX86.Pool,
|
||||
DataDisks: createReqX86.DataDisks,
|
||||
Interfaces: createReqX86.Interfaces,
|
||||
Description: createReqX86.Description,
|
||||
Chipset: createReqX86.Chipset,
|
||||
PreferredCPU: createReqX86.PreferredCPU,
|
||||
ZoneID: createReqX86.ZoneID,
|
||||
OSVersion: createReqX86.OSVersion,
|
||||
}
|
||||
apiResp, err = c.CloudAPI().KVMX86().CreateBlank(ctx, createBlankReq)
|
||||
} else {
|
||||
apiResp, err = c.CloudAPI().KVMX86().Create(ctx, createReqX86)
|
||||
}
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@@ -430,7 +440,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
if mac == "" {
|
||||
warnings.Add(errors.New(fmt.Sprintf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId)))
|
||||
warnings.Add(fmt.Errorf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))
|
||||
continue
|
||||
}
|
||||
secGroupsIDs := make([]uint64, 0)
|
||||
@@ -458,6 +468,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if start, ok := d.GetOk("started"); ok {
|
||||
if start.(bool) {
|
||||
req := compute.StartRequest{ComputeID: computeId}
|
||||
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||
req.AltBootID = uint64(altBootID)
|
||||
}
|
||||
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
|
||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||
warnings.Add(err)
|
||||
@@ -673,6 +686,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", computeId, d.Get("name").(string))
|
||||
|
||||
// We may reuse dataSourceComputeRead here as we maintain similarity
|
||||
@@ -769,13 +783,15 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
return diag.Errorf("resourceComputeUpdate: can't update Compute because rgID %d not allowed or does not exist", d.Get("rg_id").(int))
|
||||
}
|
||||
|
||||
hasImage, err := existImageId(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
if !d.Get("create_blank").(bool) {
|
||||
hasImage, err := existImageId(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !hasImage {
|
||||
return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int))
|
||||
if !hasImage {
|
||||
return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int))
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("zone_id") {
|
||||
@@ -784,12 +800,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if disks, ok := d.GetOk("disks"); ok {
|
||||
if isMoreThanOneDisksTypeB(ctx, disks) {
|
||||
return diag.Errorf("resourceComputeUpdate: can't update Compute because block disks have more 1 disk type 'B'")
|
||||
}
|
||||
}
|
||||
|
||||
if network, ok := d.GetOk("network"); ok {
|
||||
networkList := network.(*schema.Set).List()
|
||||
for _, elem := range networkList {
|
||||
@@ -816,8 +826,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if trunkId, ok := existTRUNKId(ctx, m, networkData["net_id"].(int)); !ok {
|
||||
return diag.Errorf("resourceComputeCreate: can't create compute because TRUNK ID %d is not allowed or does not exist", trunkId)
|
||||
}
|
||||
//TODO
|
||||
//SDNCheck
|
||||
default:
|
||||
continue
|
||||
}
|
||||
@@ -864,6 +872,10 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if start.(bool) {
|
||||
req := compute.StartRequest{ComputeID: computeRec.ID}
|
||||
|
||||
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||
req.AltBootID = uint64(altBootID)
|
||||
}
|
||||
|
||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@@ -1105,7 +1117,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
// If used to be STARTED, we need to start it after update
|
||||
if isStopRequired {
|
||||
if _, err := c.CloudAPI().Compute().Start(ctx, compute.StartRequest{ComputeID: computeRec.ID}); err != nil {
|
||||
|
||||
req := compute.StartRequest{ComputeID: computeRec.ID}
|
||||
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||
req.AltBootID = uint64(altBootID)
|
||||
}
|
||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
@@ -1176,10 +1193,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
chipset := d.Get("chipset").(string)
|
||||
|
||||
if len(deletedDisks) > 0 {
|
||||
for _, disk := range deletedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if diskConv["disk_type"].(string) == "B" {
|
||||
if isBootDisk(diskConv, chipset) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -1201,7 +1220,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if len(addedDisks) > 0 {
|
||||
for _, disk := range addedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if diskConv["disk_type"].(string) == "B" {
|
||||
if isBootDisk(diskConv, chipset) {
|
||||
continue
|
||||
}
|
||||
req := compute.DiskAddRequest{
|
||||
@@ -1214,9 +1233,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if diskConv["sep_id"].(int) != 0 {
|
||||
req.SepID = uint64(diskConv["sep_id"].(int))
|
||||
}
|
||||
if diskConv["disk_type"].(string) != "" {
|
||||
req.DiskType = diskConv["disk_type"].(string)
|
||||
}
|
||||
if diskConv["pool"].(string) != "" {
|
||||
req.Pool = diskConv["pool"].(string)
|
||||
}
|
||||
@@ -1230,6 +1246,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 {
|
||||
iotuneMap := iotuneRaw[0].(map[string]interface{})
|
||||
limitReq := disks.LimitIORequest{
|
||||
@@ -1259,7 +1276,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if len(resizedDisks) > 0 {
|
||||
for _, disk := range resizedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if diskConv["disk_type"].(string) == "B" {
|
||||
if isBootDisk(diskConv, chipset) {
|
||||
continue
|
||||
}
|
||||
req := compute.DiskResizeRequest{
|
||||
@@ -1310,7 +1327,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if len(iotuneUpdatedDisks) > 0 {
|
||||
for _, disk := range iotuneUpdatedDisks {
|
||||
diskConv := disk.(map[string]interface{})
|
||||
if diskConv["disk_type"].(string) == "B" {
|
||||
if isBootDisk(diskConv, chipset) {
|
||||
continue
|
||||
}
|
||||
diskID := uint64(diskConv["disk_id"].(int))
|
||||
@@ -1847,6 +1864,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
req := compute.StartRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||
req.AltBootID = uint64(altBootID)
|
||||
}
|
||||
if !isStopRequired {
|
||||
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -2042,12 +2062,15 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "Storage endpoint provider ID; by default the same with boot disk",
|
||||
},
|
||||
"disk_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false),
|
||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
||||
"pci_slot": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "PCI slot number of the disk",
|
||||
},
|
||||
"bus_number": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Bus number of the disk on virtual bus (6 = boot disk)",
|
||||
},
|
||||
"pool": {
|
||||
Type: schema.TypeString,
|
||||
@@ -2152,6 +2175,10 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Disk ID",
|
||||
},
|
||||
"independent": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"shareable": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
@@ -2207,6 +2234,14 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"block_size": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"provision": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
@@ -2353,6 +2388,12 @@ 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.",
|
||||
},
|
||||
"create_blank": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.",
|
||||
},
|
||||
"boot_disk_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -2607,6 +2648,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Default: false,
|
||||
Description: "Flag for resize compute",
|
||||
},
|
||||
"alt_boot_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "ID of CD-ROM live image to boot",
|
||||
},
|
||||
"started": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -2623,16 +2669,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
"is": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "system name",
|
||||
},
|
||||
"ipa_type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "compute purpose",
|
||||
},
|
||||
"network_interface_naming": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
@@ -2687,7 +2723,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
StateFunc: statefuncs.StateFuncToUpper,
|
||||
ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK"}, false), // observe case while validating
|
||||
ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "DPDK"}, false), // observe case while validating
|
||||
Description: "Type of the network",
|
||||
},
|
||||
"net_id": {
|
||||
@@ -2733,6 +2769,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"weight": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Priority weight of the compute. Higher value means higher priority and later migration.",
|
||||
},
|
||||
"arch": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -299,7 +299,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
|
||||
if needStart {
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil {
|
||||
var altBootID uint64
|
||||
if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok {
|
||||
altBootID = uint64(altBootIDRaw)
|
||||
} else {
|
||||
altBootID = 0
|
||||
}
|
||||
if numErr, err := utilityComputeStart(ctx, computeId, altBootID, m); err != nil {
|
||||
apiErrCount += numErr
|
||||
lastSavedError = err
|
||||
}
|
||||
@@ -462,10 +468,14 @@ func utilityComputeStop(ctx context.Context, computeID uint64, m interface{}) er
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) {
|
||||
func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
startReq := compute.StartRequest{ComputeID: computeID}
|
||||
|
||||
if altBootID > 0 {
|
||||
startReq.AltBootID = altBootID
|
||||
}
|
||||
|
||||
log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID)
|
||||
_, err := c.CloudAPI().Compute().Start(ctx, startReq)
|
||||
if err != nil {
|
||||
@@ -674,7 +684,7 @@ func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m i
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bootDisk := findBootDisk(computeRec.Disks)
|
||||
bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset)
|
||||
computeDisksIDs := getComputeDiskIDsAPI(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID)
|
||||
|
||||
for i, diskID := range computeDisksIDs {
|
||||
|
||||
Reference in New Issue
Block a user