v4.3.1
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package constants
|
||||
|
||||
//CloudApi - a part of url for cloudapi
|
||||
const CloudApi = "/restmachine/cloudapi"
|
||||
|
||||
//CloudBroker - a part of url for cloudbroker
|
||||
const CloudBroker = "/restmachine/cloudbroker"
|
||||
@@ -637,10 +637,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"custom_fields": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
// "custom_fields": {
|
||||
// Type: schema.TypeString,
|
||||
// Computed: true,
|
||||
// },
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -154,10 +154,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"custom_fields": { //NEED
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
// "custom_fields": { //NEED
|
||||
// Type: schema.TypeString,
|
||||
// Computed: true,
|
||||
// },
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -150,7 +150,7 @@ func flattenListACL(listAcl compute.ListACL) []map[string]interface{} {
|
||||
func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, compute := range computes.Data {
|
||||
customFields, _ := json.Marshal(compute.CustomFields)
|
||||
// customFields, _ := json.Marshal(compute.CustomFields)
|
||||
devices, _ := json.Marshal(compute.Devices)
|
||||
temp := map[string]interface{}{
|
||||
"acl": flattenListACL(compute.ACL),
|
||||
@@ -169,44 +169,44 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
|
||||
"cpus": compute.CPU,
|
||||
"created_by": compute.CreatedBy,
|
||||
"created_time": compute.CreatedTime,
|
||||
"custom_fields": string(customFields),
|
||||
"deleted_by": compute.DeletedBy,
|
||||
"deleted_time": compute.DeletedTime,
|
||||
"desc": compute.Description,
|
||||
"devices": string(devices),
|
||||
"disks": flattenDisks(compute.Disks),
|
||||
"driver": compute.Driver,
|
||||
"gid": compute.GID,
|
||||
"guid": compute.GUID,
|
||||
"compute_id": compute.ID,
|
||||
"image_id": compute.ImageID,
|
||||
"interfaces": flattenInterfaces(compute.Interfaces),
|
||||
"lock_status": compute.LockStatus,
|
||||
"manager_id": compute.ManagerID,
|
||||
"manager_type": compute.ManagerType,
|
||||
"migrationjob": compute.MigrationJob,
|
||||
"milestones": compute.Milestones,
|
||||
"name": compute.Name,
|
||||
"pinned": compute.Pinned,
|
||||
"ram": compute.RAM,
|
||||
"reference_id": compute.ReferenceID,
|
||||
"registered": compute.Registered,
|
||||
"res_name": compute.ResName,
|
||||
"rg_id": compute.RGID,
|
||||
"rg_name": compute.RGName,
|
||||
"snap_sets": flattenSnapSets(compute.SnapSets),
|
||||
"stateless_sep_id": compute.StatelessSepID,
|
||||
"stateless_sep_type": compute.StatelessSepType,
|
||||
"status": compute.Status,
|
||||
"tags": flattenTags(compute.Tags),
|
||||
"tech_status": compute.TechStatus,
|
||||
"total_disk_size": compute.TotalDiskSize,
|
||||
"updated_by": compute.UpdatedBy,
|
||||
"updated_time": compute.UpdatedTime,
|
||||
"user_managed": compute.UserManaged,
|
||||
"vgpus": compute.VGPUs,
|
||||
"vins_connected": compute.VINSConnected,
|
||||
"virtual_image_id": compute.VirtualImageID,
|
||||
// "custom_fields": string(customFields),
|
||||
"deleted_by": compute.DeletedBy,
|
||||
"deleted_time": compute.DeletedTime,
|
||||
"desc": compute.Description,
|
||||
"devices": string(devices),
|
||||
"disks": flattenDisks(compute.Disks),
|
||||
"driver": compute.Driver,
|
||||
"gid": compute.GID,
|
||||
"guid": compute.GUID,
|
||||
"compute_id": compute.ID,
|
||||
"image_id": compute.ImageID,
|
||||
"interfaces": flattenInterfaces(compute.Interfaces),
|
||||
"lock_status": compute.LockStatus,
|
||||
"manager_id": compute.ManagerID,
|
||||
"manager_type": compute.ManagerType,
|
||||
"migrationjob": compute.MigrationJob,
|
||||
"milestones": compute.Milestones,
|
||||
"name": compute.Name,
|
||||
"pinned": compute.Pinned,
|
||||
"ram": compute.RAM,
|
||||
"reference_id": compute.ReferenceID,
|
||||
"registered": compute.Registered,
|
||||
"res_name": compute.ResName,
|
||||
"rg_id": compute.RGID,
|
||||
"rg_name": compute.RGName,
|
||||
"snap_sets": flattenSnapSets(compute.SnapSets),
|
||||
"stateless_sep_id": compute.StatelessSepID,
|
||||
"stateless_sep_type": compute.StatelessSepType,
|
||||
"status": compute.Status,
|
||||
"tags": flattenTags(compute.Tags),
|
||||
"tech_status": compute.TechStatus,
|
||||
"total_disk_size": compute.TotalDiskSize,
|
||||
"updated_by": compute.UpdatedBy,
|
||||
"updated_time": compute.UpdatedTime,
|
||||
"user_managed": compute.UserManaged,
|
||||
"vgpus": compute.VGPUs,
|
||||
"vins_connected": compute.VINSConnected,
|
||||
"virtual_image_id": compute.VirtualImageID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -541,7 +541,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
d.Set("cpus", computeRec.CPU)
|
||||
d.Set("created_by", computeRec.CreatedBy)
|
||||
d.Set("created_time", computeRec.CreatedTime)
|
||||
d.Set("custom_fields", flattenCustomFields(computeRec.CustomFields))
|
||||
// d.Set("custom_fields", flattenCustomFields(computeRec.CustomFields))
|
||||
d.Set("deleted_by", computeRec.DeletedBy)
|
||||
d.Set("deleted_time", computeRec.DeletedTime)
|
||||
d.Set("desc", computeRec.Description)
|
||||
|
||||
@@ -192,16 +192,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
createReqX86.Driver = driver
|
||||
|
||||
if custom_fields, ok := d.GetOk("custom_fields"); ok {
|
||||
val := custom_fields.(string)
|
||||
val = strings.ReplaceAll(val, "\\", "")
|
||||
val = strings.ReplaceAll(val, "\n", "")
|
||||
val = strings.ReplaceAll(val, "\t", "")
|
||||
val = strings.TrimSpace(val)
|
||||
|
||||
createReqX86.CustomFields = val
|
||||
}
|
||||
|
||||
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
||||
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86)
|
||||
if err != nil {
|
||||
@@ -1345,35 +1335,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("custom_fields") {
|
||||
val := d.Get("custom_fields").(string)
|
||||
val = strings.ReplaceAll(val, "\\", "")
|
||||
val = strings.ReplaceAll(val, "\n", "")
|
||||
val = strings.ReplaceAll(val, "\t", "")
|
||||
val = strings.TrimSpace(val)
|
||||
|
||||
if len(val) > 0 {
|
||||
req := compute.SetCustomFieldsRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
CustomFields: val,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().Compute().SetCustomFields(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
} else {
|
||||
req := compute.DeleteCustomFieldsRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().Compute().DeleteCustomFields(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
|
||||
defer resourceComputeRead(ctx, d, m)
|
||||
@@ -1717,10 +1678,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Schema: disksSubresourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"custom_fields": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"stateless": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
|
||||
Reference in New Issue
Block a user