From 2453a32d01b9ef380d2cfb712ff8a938fd9819dd Mon Sep 17 00:00:00 2001 From: Nikita Sorokin Date: Wed, 18 Oct 2023 08:30:37 +0300 Subject: [PATCH] 4.4.2 --- CHANGELOG.md | 29 +- Makefile | 2 +- .../service/cloudapi/kvmvm/old_schemas.go | 879 ++++++++++++++++++ .../cloudapi/kvmvm/resource_compute.go | 27 +- .../service/cloudapi/kvmvm/state_upgraders.go | 8 + internal/service/cloudapi/vins/flattens.go | 1 + samples/cloudapi/resource_k8s_wg/main.tf | 2 +- 7 files changed, 912 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42f320a..9e0576d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,25 +1,8 @@ -## Version 4.4.1 - -### Bugfix -- Add in cloudapi in account/data_source_account_templates_list fields for filters - image_id, name, type, page, size. -- Add in cloudapi in disks/data_source_disk_list_types_detailed, disks/data_source_disk_list_types fields for filters - page, size. -- Add in cloudapi in disks/data_source_disk_list, disks/data_source_disk_list_unattached fields for filters - account_id, type, sep_id, pool_name, page, size. -- Add in cloudapi in extnet/data_source_extnet_computes_list fields for filters - rg_id, compute_id, page, size. -- Add in cloudapi in k8s/data_source_k8s_list_deleted fields for filters page, size, delete field for filters status. In k8s/data_source_k8s_list add fields for filters page, size, includedeleted. -- Add in cloudapi in rg/data_source_rg_affinity_groups_list fields for filters - page, size. -- Fixed tag Required in rg/data_source_rg_list_vins fields - vins_id, page, size. -- Fixed panic in pfw -- Fixed panic in image_virtual -- Fixed error reading data_source_vins_static_route -- Fixed static_route deletion -- Fixed start bservice and bservice_group +## Version 4.4.2 +### Feature +- Added state upgrade from schema version 2 to schema version 3 -## Feature -- Add in cloudapi in account "data_source_account_get_resource_consumption" and "data_source_account_resource_consumption_list". -- Add in cloudapi in kvmvm "data_source_compute_list_deleted", "data_source_compute_pci_device_list", "data_source_compute_vgpu_list". -- Add in cloudapi in rg "data_source_rg_get_resource_consumption", "data_source_rg_resource_consumption_list". -- Add in cloudapi in k8s "decort_k8s_wg_cloud_init". -- Upgraded image_id existence check -- Added sample of image_virtual config -- Added cloud_init parameter to decort_k8s_wg resource +### Bugfix +- Fixed incorrect work data_source_static_route +- Fixed bug with old field "with_default_vins" in state diff --git a/Makefile b/Makefile index 82adf00..bc1ce73 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.4.1 +VERSION=4.4.2 OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH) FILES = ${BINARY}_${VERSION}_darwin_amd64\ diff --git a/internal/service/cloudapi/kvmvm/old_schemas.go b/internal/service/cloudapi/kvmvm/old_schemas.go index 945a369..9f27776 100644 --- a/internal/service/cloudapi/kvmvm/old_schemas.go +++ b/internal/service/cloudapi/kvmvm/old_schemas.go @@ -548,3 +548,882 @@ func resourceComputeResourceV1() *schema.Resource { }, } } + +func resourceComputeResourceV2() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of this compute. Compute names are case sensitive and must be unique in the resource group.", + }, + "rg_id": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + ValidateFunc: validation.IntAtLeast(1), + Description: "ID of the resource group where this compute should be deployed.", + }, + "driver": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + StateFunc: statefuncs.StateFuncToUpper, + ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86", "KVM_PPC"}, false), // observe case while validating + Description: "Hardware architecture of this compute instance.", + }, + "cpu": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntBetween(1, constants.MaxCpusPerCompute), + Description: "Number of CPUs to allocate to this compute instance.", + }, + "ram": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(constants.MinRamPerCompute), + Description: "Amount of RAM in MB to allocate to this compute instance.", + }, + "image_id": { + Type: schema.TypeInt, + Required: true, + //ForceNew: true, //REDEPLOY + Description: "ID of the OS image to base this compute instance on.", + }, + "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.", + }, + "affinity_label": { + Type: schema.TypeString, + Optional: true, + Description: "Set affinity label for compute", + }, + "affinity_rules": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "topology": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"node", "compute"}, false), + Description: "compute or node, for whom rule applies", + }, + "policy": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"RECOMMENDED", "REQUIRED"}, false), + Description: "RECOMMENDED or REQUIRED, the degree of 'strictness' of this rule", + }, + "mode": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"EQ", "NE", "ANY"}, false), + Description: "EQ or NE or ANY - the comparison mode is 'value', recorded by the specified 'key'", + }, + "key": { + Type: schema.TypeString, + Required: true, + Description: "key that are taken into account when analyzing this rule will be identified", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "value that must match the key to be taken into account when analyzing this rule", + }, + }, + }, + }, + "anti_affinity_rules": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "topology": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"node", "compute"}, false), + Description: "compute or node, for whom rule applies", + }, + "policy": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"RECOMMENDED", "REQUIRED"}, false), + Description: "RECOMMENDED or REQUIRED, the degree of 'strictness' of this rule", + }, + "mode": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"EQ", "NE", "ANY"}, false), + Description: "EQ or NE or ANY - the comparison mode is 'value', recorded by the specified 'key'", + }, + "key": { + Type: schema.TypeString, + Required: true, + Description: "key that are taken into account when analyzing this rule will be identified", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "value that must match the key to be taken into account when analyzing this rule", + }, + }, + }, + }, + "disks": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disk_name": { + Type: schema.TypeString, + Required: true, + Description: "Name for disk", + }, + "size": { + Type: schema.TypeInt, + Required: true, + Description: "Disk size in GiB", + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + 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'", + }, + "pool": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Pool name; by default will be chosen automatically", + }, + "desc": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Optional description", + }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + Optional: true, + Description: "Specify image id for create disk from template", + }, + "permanently": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + Description: "Disk deletion status", + }, + "disk_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Disk ID", + }, + "shareable": { + Type: schema.TypeBool, + Computed: true, + }, + "size_max": { + Type: schema.TypeInt, + Computed: true, + }, + "size_used": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "custom_fields": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "stateless": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Compute will be stateless (SVA_KVM_X86) if set to True", + }, + "with_default_vins": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "Create compute with default resgroup ViNS (true) or without any interfaces (false). This parameter is ignored if network block is specified", + }, + "boot_disk": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disk_name": { + Type: schema.TypeString, + Required: true, + Description: "Name for disk", + }, + "size": { + Type: schema.TypeInt, + Required: true, + Description: "Disk size in GiB", + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + 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'", + }, + "pool": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Pool name; by default will be chosen automatically", + }, + "desc": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Optional description", + }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + Optional: true, + Description: "Specify image id for create disk from template", + }, + "permanently": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + Description: "Disk deletion status", + }, + "disk_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Disk ID", + }, + "shareable": { + Type: schema.TypeBool, + Computed: true, + }, + "size_max": { + Type: schema.TypeInt, + Computed: true, + }, + "size_used": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + Description: "ID of SEP to create bootDisk on. Uses image's sepId if not set.", + }, + "pool": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + Description: "Pool to use if sepId is set, can be also empty if needed to be chosen by system.", + }, + + "extra_disks": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + MaxItems: constants.MaxExtraDisksPerCompute, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + Description: "Optional list of IDs of extra disks to attach to this compute. You may specify several extra disks.", + }, + + "network": { + Type: schema.TypeSet, + Optional: true, + MinItems: 1, + MaxItems: constants.MaxNetworksPerCompute, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "net_type": { + Type: schema.TypeString, + Required: true, + StateFunc: statefuncs.StateFuncToUpper, + ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, false), // observe case while validating + Description: "Type of the network for this connection, either EXTNET or VINS.", + }, + + "net_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the network for this connection.", + }, + + "ip_address": { + Type: schema.TypeString, + Optional: true, + Computed: true, + DiffSuppressFunc: networkSubresIPAddreDiffSupperss, + Description: "Optional IP address to assign to this connection. This IP should belong to the selected network and free for use.", + }, + + "mac": { + Type: schema.TypeString, + Computed: true, + Description: "MAC address associated with this connection. MAC address is assigned automatically.", + }, + }, + }, + Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.", + }, + + "tags": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Required: true, + }, + "value": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + + "port_forwarding": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "public_port_start": { + Type: schema.TypeInt, + Required: true, + }, + "public_port_end": { + Type: schema.TypeInt, + Optional: true, + Default: -1, + }, + "local_port": { + Type: schema.TypeInt, + Required: true, + }, + "proto": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"tcp", "udp"}, false), + }, + }, + }, + }, + + "user_access": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "username": { + Type: schema.TypeString, + Required: true, + }, + "access_type": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + + "snapshot": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "label": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + + "rollback": { + Type: schema.TypeSet, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "label": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + + "cd": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cdrom_id": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + + "pin_to_stack": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "description": { + Type: schema.TypeString, + Optional: true, + Description: "Optional text description of this compute instance.", + }, + + "cloud_init": { + Type: schema.TypeString, + Optional: true, + Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.", + }, + + "enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "If true - enable compute, else - disable", + }, + + "pause": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "reset": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "auto_start": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Flag for redeploy compute", + }, + "force_stop": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Flag for redeploy compute", + }, + "data_disks": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"KEEP", "DETACH", "DESTROY"}, false), + Default: "DETACH", + Description: "Flag for redeploy compute", + }, + "started": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "Is compute started.", + }, + "detach_disks": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + "permanently": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + "is": { + Type: schema.TypeString, + Optional: true, + Description: "system name", + }, + "ipa_type": { + Type: schema.TypeString, + Optional: true, + Description: "compute purpose", + }, + // The rest are Compute properties, which are "computed" once it is created + "account_id": { + Type: schema.TypeInt, + Computed: true, + Description: "ID of the account this compute instance belongs to.", + }, + "account_name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the account this compute instance belongs to.", + }, + "affinity_weight": { + Type: schema.TypeInt, + Computed: true, + }, + "arch": { + Type: schema.TypeString, + Computed: true, + }, + "boot_order": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "boot_disk_id": { + Type: schema.TypeInt, + Computed: true, + Description: "This compute instance boot disk ID.", + }, + "clone_reference": { + Type: schema.TypeInt, + Computed: true, + }, + "clones": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "computeci_id": { + Type: schema.TypeInt, + Computed: true, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "created_time": { + Type: schema.TypeInt, + Computed: true, + }, + "deleted_by": { + Type: schema.TypeString, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "devices": { + Type: schema.TypeString, + Computed: true, + }, + "gid": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "compute_id": { + Type: schema.TypeInt, + Computed: true, + }, + "interfaces": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "conn_id": { + Type: schema.TypeInt, + Computed: true, + }, + "conn_type": { + Type: schema.TypeString, + Computed: true, + }, + "def_gw": { + Type: schema.TypeString, + Computed: true, + }, + "flip_group_id": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "ip_address": { + Type: schema.TypeString, + Computed: true, + }, + "listen_ssh": { + Type: schema.TypeBool, + Computed: true, + }, + "mac": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "net_id": { + Type: schema.TypeInt, + Computed: true, + }, + "netmask": { + Type: schema.TypeInt, + Computed: true, + }, + "net_type": { + Type: schema.TypeString, + Computed: true, + }, + "pci_slot": { + Type: schema.TypeInt, + Computed: true, + }, + "qos": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "e_rate": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "in_brust": { + Type: schema.TypeInt, + Computed: true, + }, + "in_rate": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "target": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "vnfs": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + }, + }, + }, + "lock_status": { + Type: schema.TypeString, + Computed: true, + }, + "manager_id": { + Type: schema.TypeInt, + Computed: true, + }, + "manager_type": { + Type: schema.TypeString, + Computed: true, + }, + "migrationjob": { + Type: schema.TypeInt, + Computed: true, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "natable_vins_id": { + Type: schema.TypeInt, + Computed: true, + }, + "natable_vins_ip": { + Type: schema.TypeString, + Computed: true, + }, + "natable_vins_name": { + Type: schema.TypeString, + Computed: true, + }, + "natable_vins_network": { + Type: schema.TypeString, + Computed: true, + }, + "natable_vins_network_name": { + Type: schema.TypeString, + Computed: true, + }, + "os_users": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + Description: "GUID of this guest OS user.", + }, + + "login": { + Type: schema.TypeString, + Computed: true, + Description: "Login name of this guest OS user.", + }, + + "password": { + Type: schema.TypeString, + Computed: true, + //Sensitive: true, + Description: "Password of this guest OS user.", + }, + + "public_key": { + Type: schema.TypeString, + Computed: true, + Description: "SSH public key of this guest OS user.", + }, + }, + }, + Description: "Guest OS users provisioned on this compute instance.", + }, + "pinned": { + Type: schema.TypeBool, + Computed: true, + }, + "reference_id": { + Type: schema.TypeString, + Computed: true, + }, + "registered": { + Type: schema.TypeBool, + Computed: true, + }, + "res_name": { + Type: schema.TypeString, + Computed: true, + }, + "rg_name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the resource group where this compute instance is located.", + }, + "snap_sets": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disks": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "label": { + Type: schema.TypeString, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "stateless_sep_id": { + Type: schema.TypeInt, + Computed: true, + }, + "stateless_sep_type": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_time": { + Type: schema.TypeInt, + Computed: true, + }, + "user_managed": { + Type: schema.TypeBool, + Computed: true, + }, + "vgpus": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "virtual_image_id": { + Type: schema.TypeInt, + Computed: true, + }, + "virtual_image_name": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} diff --git a/internal/service/cloudapi/kvmvm/resource_compute.go b/internal/service/cloudapi/kvmvm/resource_compute.go index 30199f5..52046a5 100644 --- a/internal/service/cloudapi/kvmvm/resource_compute.go +++ b/internal/service/cloudapi/kvmvm/resource_compute.go @@ -1615,14 +1615,14 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { "rg_id": { Type: schema.TypeInt, Required: true, - ForceNew: true, + // ForceNew: true, ValidateFunc: validation.IntAtLeast(1), Description: "ID of the resource group where this compute should be deployed.", }, "driver": { Type: schema.TypeString, Required: true, - ForceNew: true, + // ForceNew: true, StateFunc: statefuncs.StateFuncToUpper, ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86", "KVM_PPC"}, false), // observe case while validating Description: "Hardware architecture of this compute instance.", @@ -1754,17 +1754,17 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { }, }, "sep_id": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - ForceNew: true, + Type: schema.TypeInt, + Optional: true, + Computed: true, + // ForceNew: true, Description: "ID of SEP to create bootDisk on. Uses image's sepId if not set.", }, "pool": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + // ForceNew: true, Description: "Pool to use if sepId is set, can be also empty if needed to be chosen by system.", }, @@ -2132,7 +2132,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { func ResourceCompute() *schema.Resource { return &schema.Resource{ - SchemaVersion: 2, + SchemaVersion: 3, CreateContext: resourceComputeCreate, ReadContext: resourceComputeRead, @@ -2158,6 +2158,11 @@ func ResourceCompute() *schema.Resource { Upgrade: resourceCompueteStateUpgradeV1, Version: 1, }, + { + Type: resourceComputeResourceV2().CoreConfigSchema().ImpliedType(), + Upgrade: resourceComputeStateUpgradeV2, + Version: 2, + }, }, } } diff --git a/internal/service/cloudapi/kvmvm/state_upgraders.go b/internal/service/cloudapi/kvmvm/state_upgraders.go index 1a9a713..275fc5e 100644 --- a/internal/service/cloudapi/kvmvm/state_upgraders.go +++ b/internal/service/cloudapi/kvmvm/state_upgraders.go @@ -31,3 +31,11 @@ func resourceCompueteStateUpgradeV1(ctx context.Context, rawState map[string]int return rawState, nil } + +func resourceComputeStateUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) { + log.Debug("resourceComputeStateUpgradeV2: upgrading state") + + delete(rawState, "with_default_vins") + + return rawState, nil +} diff --git a/internal/service/cloudapi/vins/flattens.go b/internal/service/cloudapi/vins/flattens.go index 8765d18..d1ff95f 100644 --- a/internal/service/cloudapi/vins/flattens.go +++ b/internal/service/cloudapi/vins/flattens.go @@ -530,6 +530,7 @@ func flattenStaticRouteData(d *schema.ResourceData, route *vins.ItemRoutes) { d.Set("guid", route.GUID) d.Set("netmask", route.Netmask) d.Set("compute_ids", route.ComputeIds) + d.Set("route_id", route.ID) } /// diff --git a/samples/cloudapi/resource_k8s_wg/main.tf b/samples/cloudapi/resource_k8s_wg/main.tf index 223e75b..0d853ff 100644 --- a/samples/cloudapi/resource_k8s_wg/main.tf +++ b/samples/cloudapi/resource_k8s_wg/main.tf @@ -26,7 +26,7 @@ resource "decort_k8s_wg" "wg" { #id экземпляра k8s #обязательный параметр #тип - число - k8s_id = 1234 //это значение должно быть и результат вызова decort_k8s.cluster.id + k8s_id = 1234 #имя worker group #обязательный параметр