From b60f32c5704a65b9d271e2b5eeff2b3056fca227 Mon Sep 17 00:00:00 2001 From: Nikita Sorokin Date: Thu, 10 Aug 2023 20:22:43 +0300 Subject: [PATCH] v4.3.1 --- CHANGELOG.md | 53 +----------- Makefile | 2 +- internal/constants/api.go | 27 ------- .../cloudapi/kvmvm/data_source_compute.go | 8 +- .../kvmvm/data_source_compute_list.go | 8 +- internal/service/cloudapi/kvmvm/flattens.go | 80 +++++++++---------- .../cloudapi/kvmvm/resource_compute.go | 43 ---------- samples/cloudapi/data_location_url/main.tf | 0 8 files changed, 52 insertions(+), 169 deletions(-) delete mode 100644 internal/constants/api.go delete mode 100644 samples/cloudapi/data_location_url/main.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index db12000..bd2bd50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,51 +1,4 @@ -## Version 4.3.0 +## Version 4.3.1 -## Features -- CloudBroker (requires admin privileges): - - Created "decort_cb_extnet" resource - used to create and manage Extnet instances - - Created "decort_cb_extnet" data source - used to read information about Extnet instance - - Created "decort_cb_extnet_list" data source - used to read information about multiple Extnet instances -- CloudAPI: - - Updated resource_compute: added "custom_fields" and "with_default_vins" parameters: - - Set "with_default_vins" to false to create compute without any attached networks. This parameter is ignored if any network block is specified - - Added ability to create stateless computes (SVA_KVM_X86) - - Created "decort_k8ci_list" data source - used to read information about available K8CI instances - - Updated resources && data sources to platform version 3.8.7, which includes: - - Added new optional fields to all list data sources, used to filter results, which are: - - decort_account_list - - decort_bservice_list - - decort_kvmvm_list - - decort_disk_list - - decort_extnet_list - - decort_flipgroup_list - - decort_image_list - - decort_k8s_list - - decort_k8s_list_deleted - - decort_rg_list - - decort_vins_list - - decort_account_deleted_list - - decort_account_computes_list - - decort_account_disks_list - - decort_account_flipgroups_list - - decort_account_rg_list - - decort_account_vins_list - - decort_disk_list_deleted - - decort_disk_list_unattached - - decort_lb_list - - decort_lb_list_deleted - - decort_rg_list_computes - - decort_rg_list_deleted - - decort_rg_list_lb - - decort_rg_list_pfw - - decort_rg_list_vins - - decort_vins_list_deleted - - Added "cu_dm" field to resgroup and account resource limits and consumed units - - Added "reference_id" field to compute snapshots model - - Added "stateless_sep_id" and "stateless_sep_type" fields to compute models -- Misc: - - Added darwin_arm64, linux_arm64 as release build targets - - Every release starting from version 4.3.0 will have installers included in the archive - - install.sh - used on linux, darwin and bsd systems - - install.bat - used on windows machines - - Updated samples - - Updated README +## Bugfixes +- Deleted custom_fields field from kvmvm resource \ No newline at end of file diff --git a/Makefile b/Makefile index 93fac6c..41223e7 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ ZIPDIR = ./zip BINARY=${NAME} WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH} MAINPATH = ./cmd/decort/ -VERSION=4.3.0 +VERSION=4.3.1 #OS_ARCH=darwin_amd64 # OS_ARCH=windows_amd64 OS_ARCH=linux_amd64 diff --git a/internal/constants/api.go b/internal/constants/api.go deleted file mode 100644 index 7ad4369..0000000 --- a/internal/constants/api.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -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" diff --git a/internal/service/cloudapi/kvmvm/data_source_compute.go b/internal/service/cloudapi/kvmvm/data_source_compute.go index 0901174..c0307d8 100644 --- a/internal/service/cloudapi/kvmvm/data_source_compute.go +++ b/internal/service/cloudapi/kvmvm/data_source_compute.go @@ -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, diff --git a/internal/service/cloudapi/kvmvm/data_source_compute_list.go b/internal/service/cloudapi/kvmvm/data_source_compute_list.go index 32f38e4..04bfde8 100644 --- a/internal/service/cloudapi/kvmvm/data_source_compute_list.go +++ b/internal/service/cloudapi/kvmvm/data_source_compute_list.go @@ -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, diff --git a/internal/service/cloudapi/kvmvm/flattens.go b/internal/service/cloudapi/kvmvm/flattens.go index 85a09ac..3a12292 100644 --- a/internal/service/cloudapi/kvmvm/flattens.go +++ b/internal/service/cloudapi/kvmvm/flattens.go @@ -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) diff --git a/internal/service/cloudapi/kvmvm/resource_compute.go b/internal/service/cloudapi/kvmvm/resource_compute.go index 9ec4893..524ef66 100644 --- a/internal/service/cloudapi/kvmvm/resource_compute.go +++ b/internal/service/cloudapi/kvmvm/resource_compute.go @@ -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, diff --git a/samples/cloudapi/data_location_url/main.tf b/samples/cloudapi/data_location_url/main.tf deleted file mode 100644 index e69de29..0000000