From 069d63a65ce7a65fe243bde776a487c17969faa3 Mon Sep 17 00:00:00 2001 From: Alexey Fetisov Date: Fri, 6 Feb 2026 17:00:13 +0300 Subject: [PATCH] 4.10.3 --- CHANGELOG.md | 27 +- Makefile | 2 +- .../service/cloudapi/disks/old_schemas.go | 421 +++++ .../service/cloudapi/disks/resource_disk.go | 9 +- .../service/cloudapi/disks/state_upgraders.go | 14 + .../service/cloudapi/image/old_schemas.go | 782 +++++++++ .../service/cloudapi/image/resource_image.go | 9 +- .../resource_image_from_blank_compute.go | 9 +- .../resource_image_from_platform_disk.go | 9 +- .../cloudapi/image/resource_image_virtual.go | 9 +- .../service/cloudapi/image/state_upgraders.go | 14 + .../service/cloudbroker/disks/old_schemas.go | 391 +++++ .../cloudbroker/disks/resource_disk.go | 9 +- .../cloudbroker/disks/state_upgrader.go | 14 + .../service/cloudbroker/image/old_schemas.go | 1394 +++++++++++++++++ .../cloudbroker/image/resource_cdrom_image.go | 9 +- .../cloudbroker/image/resource_image.go | 9 +- .../resource_image_from_blank_compute.go | 9 +- .../resource_image_from_platform_disk.go | 9 +- .../image/resource_virtual_image.go | 9 +- .../cloudbroker/image/state_upgrader.go | 14 + 21 files changed, 3138 insertions(+), 34 deletions(-) create mode 100644 internal/service/cloudapi/disks/old_schemas.go create mode 100644 internal/service/cloudapi/disks/state_upgraders.go create mode 100644 internal/service/cloudapi/image/old_schemas.go create mode 100644 internal/service/cloudapi/image/state_upgraders.go create mode 100644 internal/service/cloudbroker/disks/old_schemas.go create mode 100644 internal/service/cloudbroker/disks/state_upgrader.go create mode 100644 internal/service/cloudbroker/image/old_schemas.go create mode 100644 internal/service/cloudbroker/image/state_upgrader.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e99581a..abb18e57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,30 +1,13 @@ -## Version 4.10.2 - -### Добавлено - -#### storage policy -| Идентификатор
задачи | Описание | -| --- | --- | -| BATF-1090 | Отображение вычисляемых полей `sep_name` в блоке `access_seps_pools` datasource `decort_storage_policy_list` в cloudapi/stpolicy и в datasource `decort_cb_storage_policy_list` в cloudbroker/stpolicy | +## Version 4.10.3 ### Исправлено -#### account +#### disks | Идентификатор
задачи | Описание | | --- | --- | -| BATF-1061 | Исправлен sample resource `decort_cb_account` в cloudbroker/account | -| BATF-1061 | Вывод значения поле `storage_policy_ids` в data_sourse`decort_cb_account` в cloudbroker/account | +| BATF-1204 | Ошибка построения и применения плана при использовании состояния, созданного в предыдущих версиях провайдера в resources `decort_disk` в cloudapi/disks и в `decort_cb_disk` cloudbroker/disks | -#### kvmvm +#### image | Идентификатор
задачи | Описание | | --- | --- | -| BATF-1079 | Отображение поля `disks` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm при импорте | -| BATF-1083 | Отображение поля `boot_disk` в resource `decort_kvmvm` в cloudapi/kvmvm при обновлении поля `image_id` | -| BATF-1088 | Исправлена логика работы поля `pin_to_stack` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | -| BATF-1092 | Отображение вычисляемых полей `devicename`,`created_by`, `deleted_by`, `updated_time` в блоке `disks` и блока `loader_meta_iso` в resource `decort_kvmvm`, datasource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm`, datasource `decort_cb_kvmvm` в cloudbroker/kvmvm | -| BATF-1144 | Остановка виртуальной машины перед удалением в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm | - -#### rg -| Идентификатор
задачи | Описание | -| --- | --- | -| BATF-1062 | Отображение datasourses `decort_rg_list_deleted` в cloudapi/rg и `decort_cb_rg_list_deleted` в cloudbroker/rg | \ No newline at end of file +| BATF-1204 | Ошибка построения и применения плана при использовании состояния, созданного в предыдущих версиях провайдера в resources `decort_image_from_blank_compute`, `decort_image_from_platform_disk`, `decort_virtual_image` в cloudapi/image и в `decort_cb_cdrom_image`, `decort_cb_image`, `decort_cb_image_from_blank_compute`, `decort_cb_image_from_platform_disk`, `decort_cb_virtual_image` в cloudbroker/image | \ No newline at end of file diff --git a/Makefile b/Makefile index 8a1e27d3..ab99e703 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.10.2 +VERSION=4.10.3 OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH) FILES = ${BINARY}_${VERSION}_darwin_amd64\ diff --git a/internal/service/cloudapi/disks/old_schemas.go b/internal/service/cloudapi/disks/old_schemas.go new file mode 100644 index 00000000..a5bca26d --- /dev/null +++ b/internal/service/cloudapi/disks/old_schemas.go @@ -0,0 +1,421 @@ +package disks + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceDiskV1() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeInt, + Required: true, + //ForceNew: true, + Description: "The unique ID of the subscriber-owner of the disk", + }, + "disk_name": { + Type: schema.TypeString, + Required: true, + Description: "Name of disk", + }, + "size_max": { + Type: schema.TypeInt, + Required: true, + Description: "Size in GB", + }, + "gid": { + Type: schema.TypeInt, + Required: true, + //ForceNew: true, + Description: "ID of the grid (platform)", + }, + "pool": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Pool for disk location", + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Storage endpoint provider ID to create disk", + }, + "desc": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Description of disk", + }, + "type": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{"D", "B", "T"}, false), + Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'", + }, + "detach": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Detaching the disk from compute", + }, + "permanently": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Whether to completely delete the disk, works only with non attached disks", + }, + "shareable": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + "iotune": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "read_bytes_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Number of bytes to read per second", + }, + "read_bytes_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum number of bytes to read", + }, + "read_iops_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Number of io read operations per second", + }, + "read_iops_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum number of io read operations", + }, + "size_iops_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Size of io operations", + }, + "total_bytes_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Total size bytes per second", + }, + "total_bytes_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum total size of bytes per second", + }, + "total_iops_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Total number of io operations per second", + }, + "total_iops_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum total number of io operations per second", + }, + "write_bytes_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Number of bytes to write per second", + }, + "write_bytes_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum number of bytes to write per second", + }, + "write_iops_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Number of write operations per second", + }, + "write_iops_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum number of write operations per second", + }, + }, + }, + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "disk_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Disk ID. Duplicates the value of the ID parameter", + }, + "account_name": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the subscriber '(account') to whom this disk belongs", + }, + "acl": { + Type: schema.TypeString, + Computed: true, + }, + // "boot_partition": { + // Type: schema.TypeInt, + // Computed: true, + // Description: "Number of disk partitions", + // }, + "computes": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compute_id": { + Type: schema.TypeString, + Computed: true, + }, + "compute_name": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "created_time": { + Type: schema.TypeInt, + Computed: true, + Description: "Created time", + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + Description: "Deleted time", + }, + "destruction_time": { + Type: schema.TypeInt, + Computed: true, + Description: "Time of final deletion", + }, + "devicename": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the device", + }, + // "disk_path": { + // Type: schema.TypeString, + // Computed: true, + // Description: "Disk path", + // }, + // "guid": { + // Type: schema.TypeInt, + // Computed: true, + // Description: "Disk ID on the storage side", + // }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Image ID", + }, + "images": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "IDs of images using the disk", + }, + // "iqn": { + // Type: schema.TypeString, + // Computed: true, + // Description: "Disk IQN", + // }, + // "login": { + // Type: schema.TypeString, + // Computed: true, + // Description: "Login to access the disk", + // }, + // "milestones": { + // Type: schema.TypeInt, + // Computed: true, + // Description: "Milestones", + // }, + "order": { + Type: schema.TypeInt, + Computed: true, + Description: "Disk order", + }, + "params": { + Type: schema.TypeString, + Computed: true, + Description: "Disk params", + }, + "parent_id": { + Type: schema.TypeInt, + Computed: true, + Description: "ID of the parent disk", + }, + // "passwd": { + // Type: schema.TypeString, + // Computed: true, + // Description: "Password to access the disk", + // }, + "pci_slot": { + Type: schema.TypeInt, + Computed: true, + Description: "ID of the pci slot to which the disk is connected", + }, + // "purge_attempts": { + // Type: schema.TypeInt, + // Computed: true, + // Description: "Number of deletion attempts", + // }, + "purge_time": { + Type: schema.TypeInt, + Computed: true, + Description: "Time of the last deletion attempt", + }, + "replication": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disk_id": { + Type: schema.TypeInt, + Computed: true, + }, + "pool_id": { + Type: schema.TypeString, + Computed: true, + }, + "role": { + Type: schema.TypeString, + Computed: true, + }, + "self_volume_id": { + Type: schema.TypeString, + Computed: true, + }, + "storage_id": { + Type: schema.TypeString, + Computed: true, + }, + "volume_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + Description: "Replication status", + }, + // "reality_device_number": { + // Type: schema.TypeInt, + // Computed: true, + // Description: "Reality device number", + // }, + // "reference_id": { + // Type: schema.TypeString, + // Computed: true, + // Description: "ID of the reference to the disk", + // }, + "res_id": { + Type: schema.TypeString, + Computed: true, + Description: "Resource ID", + }, + "res_name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the resource", + }, + "role": { + Type: schema.TypeString, + Computed: true, + Description: "Disk role", + }, + "sep_type": { + Type: schema.TypeString, + Computed: true, + Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform", + }, + "size_used": { + Type: schema.TypeFloat, + Computed: true, + Description: "Number of used space, in GB", + }, + "snapshots": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the snapshot", + }, + "label": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the snapshot", + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + Description: "Reference to the snapshot", + }, + "snap_set_guid": { + Type: schema.TypeString, + Computed: true, + Description: "The set snapshot ID", + }, + "snap_set_time": { + Type: schema.TypeInt, + Computed: true, + Description: "The set time of the snapshot", + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + Description: "Snapshot time", + }, + }, + }, + }, + "status": { + Type: schema.TypeString, + Computed: true, + Description: "Disk status", + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + Description: "Technical status of the disk", + }, + "vmid": { + Type: schema.TypeInt, + Computed: true, + Description: "Virtual Machine ID (Deprecated)", + }, + }, + } +} diff --git a/internal/service/cloudapi/disks/resource_disk.go b/internal/service/cloudapi/disks/resource_disk.go index f6be06e4..7ad1e7e1 100644 --- a/internal/service/cloudapi/disks/resource_disk.go +++ b/internal/service/cloudapi/disks/resource_disk.go @@ -805,7 +805,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { func ResourceDisk() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceDiskCreate, ReadContext: resourceDiskRead, @@ -825,5 +825,12 @@ func ResourceDisk() *schema.Resource { }, Schema: resourceDiskSchemaMake(), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceDiskV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourceDiskUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudapi/disks/state_upgraders.go b/internal/service/cloudapi/disks/state_upgraders.go new file mode 100644 index 00000000..50fd2672 --- /dev/null +++ b/internal/service/cloudapi/disks/state_upgraders.go @@ -0,0 +1,14 @@ +package disks + +import ( + "context" + + log "github.com/sirupsen/logrus" +) + +func resourceDiskUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) { + log.Debug("resourceDiskUpgradeV1: upgrading state") + rawState["present_to"] = make(map[string]uint64) + + return rawState, nil +} diff --git a/internal/service/cloudapi/image/old_schemas.go b/internal/service/cloudapi/image/old_schemas.go new file mode 100644 index 00000000..c637ed4b --- /dev/null +++ b/internal/service/cloudapi/image/old_schemas.go @@ -0,0 +1,782 @@ +package image + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs" +) + +func resourceImageFromBlankComputeSchemaV1() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compute_id": { + Type: schema.TypeInt, + Required: true, + Description: "Compute Id", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the rescue disk", + }, + "boot_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true), + Description: "Boot type of image BIOS or UEFI", + }, + "type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true), + Description: "Image type linux, windows or other", + }, + + "username": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional username for the image", + }, + "password": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional password for the image", + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "AccountId to make the image exclusive", + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "storage endpoint provider ID", + }, + "pool_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "pool for image create", + }, + "hot_resize": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this machine supports hot resize", + }, + "async_mode": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "create an image in async/sync mode", + }, + + "image_id": { + Type: schema.TypeInt, + Computed: true, + }, + "unc_path": { + Type: schema.TypeString, + Computed: true, + }, + "ckey": { + Type: schema.TypeString, + Computed: true, + }, + "acl": { + Type: schema.TypeString, + Computed: true, + }, + "architecture": { + Type: schema.TypeString, + Computed: true, + }, + "bootable": { + Type: schema.TypeBool, + Computed: true, + }, + "compute_ci_id": { + Type: schema.TypeInt, + Computed: true, + }, + "cd_presented_to": { + Type: schema.TypeString, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "desc": { + Type: schema.TypeString, + Computed: true, + }, + "drivers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + "gid": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "history": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "last_modified": { + Type: schema.TypeInt, + Computed: true, + }, + "link_to": { + Type: schema.TypeInt, + Computed: true, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "image_name": { + Type: schema.TypeString, + Computed: true, + }, + "network_interface_naming": { + Type: schema.TypeString, + Computed: true, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "rescuecd": { + Type: schema.TypeBool, + Computed: true, + }, + "shared_with": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "size": { + Type: schema.TypeInt, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + }, + "version": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceImageFromBlankDiskSchemaV1() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disk_id": { + Type: schema.TypeInt, + Required: true, + Description: "Disk Id", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the rescue disk", + }, + "boot_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true), + Description: "Boot type of image BIOS or UEFI", + }, + "type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true), + Description: "Image type linux, windows or other", + }, + "architecture": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"X86_64"}, true), + Description: "binary architecture of this image, one of X86_64", + }, + + "username": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional username for the image", + }, + "password": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional password for the image", + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "AccountId to make the image exclusive", + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "storage endpoint provider ID", + }, + "pool_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "pool for image create", + }, + "drivers": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + StateFunc: statefuncs.StateFuncToUpper, + ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86"}, false), // observe case while validating + Type: schema.TypeString, + }, + Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]", + }, + "bootable": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "bootable image", + }, + "hot_resize": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this machine supports hot resize", + }, + "async_mode": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "create an image in async/sync mode", + }, + + "image_id": { + Type: schema.TypeInt, + Computed: true, + }, + "unc_path": { + Type: schema.TypeString, + Computed: true, + }, + "ckey": { + Type: schema.TypeString, + Computed: true, + }, + "acl": { + Type: schema.TypeString, + Computed: true, + }, + "compute_ci_id": { + Type: schema.TypeInt, + Computed: true, + }, + "cd_presented_to": { + Type: schema.TypeString, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "desc": { + Type: schema.TypeString, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + "gid": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "history": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "last_modified": { + Type: schema.TypeInt, + Computed: true, + }, + "link_to": { + Type: schema.TypeInt, + Computed: true, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "image_name": { + Type: schema.TypeString, + Computed: true, + }, + "network_interface_naming": { + Type: schema.TypeString, + Computed: true, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "rescuecd": { + Type: schema.TypeBool, + Computed: true, + }, + "shared_with": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "size": { + Type: schema.TypeInt, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + }, + "version": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func dataSourceImageExtendSchemaV1() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "image_id": { + Type: schema.TypeInt, + Required: true, + }, + "show_all": { + Type: schema.TypeBool, + Default: false, + Optional: true, + }, + "unc_path": { + Type: schema.TypeString, + Computed: true, + }, + "ckey": { + Type: schema.TypeString, + Computed: true, + }, + "account_id": { + Type: schema.TypeInt, + Computed: true, + }, + "acl": { + Type: schema.TypeString, + Computed: true, + }, + "architecture": { + Type: schema.TypeString, + Computed: true, + }, + "boot_type": { + Type: schema.TypeString, + Computed: true, + }, + "bootable": { + Type: schema.TypeBool, + Computed: true, + }, + "compute_ci_id": { + Type: schema.TypeInt, + Computed: true, + }, + "cd_presented_to": { + Type: schema.TypeString, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "desc": { + Type: schema.TypeString, + Computed: true, + }, + "drivers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + "gid": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "history": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "hot_resize": { + Type: schema.TypeBool, + Computed: true, + }, + "last_modified": { + Type: schema.TypeInt, + Computed: true, + }, + "link_to": { + Type: schema.TypeInt, + Computed: true, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "image_name": { + Type: schema.TypeString, + Computed: true, + }, + "network_interface_naming": { + Type: schema.TypeString, + Computed: true, + }, + "password": { + Type: schema.TypeString, + Computed: true, + }, + "pool_name": { + Type: schema.TypeString, + Computed: true, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "rescuecd": { + Type: schema.TypeBool, + Computed: true, + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + }, + "shared_with": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "size": { + Type: schema.TypeInt, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "username": { + Type: schema.TypeString, + Computed: true, + }, + "version": { + Type: schema.TypeString, + Computed: true, + }, + } +} +func resourceMainImageSchemaV1(sch map[string]*schema.Schema) map[string]*schema.Schema { + delete(sch, "show_all") + sch["name"] = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "Name of the rescue disk", + } + + sch["url"] = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "URL where to download media from", + } + + sch["image_id"] = &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "image id", + } + + sch["boot_type"] = &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true), + Description: "Boot type of image bios or uefi", + } + + sch["type"] = &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true), + Description: "Image type linux, windows or other", + } + + sch["hot_resize"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this machine supports hot resize", + } + + sch["username"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional username for the image", + } + + sch["password"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional password for the image", + } + + sch["account_id"] = &schema.Schema{ + Type: schema.TypeInt, + Required: true, + Description: "AccountId to make the image exclusive", + } + + sch["username_dl"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "username for upload binary media", + } + + sch["password_dl"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "password for upload binary media", + } + + sch["pool_name"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "pool for image create", + } + + sch["sep_id"] = &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "storage endpoint provider ID", + } + + sch["architecture"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{"X86_64"}, true), + Description: "binary architecture of this image, one of X86_64", + } + + sch["drivers"] = &schema.Schema{ + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + } + + sch["network_interface_naming"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, true), + Description: "select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming", + } + + return sch +} + +func resourceImageSchemaV1() *schema.Resource { + return &schema.Resource{Schema: resourceMainImageSchemaV1(dataSourceImageExtendSchemaV1())} +} + +func resourceMainImageVirtualSchemaV1(sch map[string]*schema.Schema) map[string]*schema.Schema { + delete(sch, "show_all") + sch["name"] = &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "Name of the rescue disk", + } + + sch["link_to"] = &schema.Schema{ + Type: schema.TypeInt, + Required: true, + Description: "ID of real image to link this virtual image to upon creation", + } + + sch["image_id"] = &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + Description: "Image id", + } + + return sch +} + +func resourceImageVirtualSchemaV1() *schema.Resource { + return &schema.Resource{Schema: resourceMainImageVirtualSchemaV1(dataSourceImageExtendSchemaV1())} +} diff --git a/internal/service/cloudapi/image/resource_image.go b/internal/service/cloudapi/image/resource_image.go index 723126e2..a2e06665 100644 --- a/internal/service/cloudapi/image/resource_image.go +++ b/internal/service/cloudapi/image/resource_image.go @@ -272,7 +272,7 @@ func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interfac func ResourceImage() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceImageCreate, ReadContext: resourceImageRead, @@ -292,5 +292,12 @@ func ResourceImage() *schema.Resource { }, Schema: resourceImageSchemaMake(dataSourceImageExtendSchemaMake()), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceImageSchemaV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentToUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudapi/image/resource_image_from_blank_compute.go b/internal/service/cloudapi/image/resource_image_from_blank_compute.go index d27ec9ed..f1bb1daf 100644 --- a/internal/service/cloudapi/image/resource_image_from_blank_compute.go +++ b/internal/service/cloudapi/image/resource_image_from_blank_compute.go @@ -255,7 +255,7 @@ func resourceImageFromBlankComputeUpdate(ctx context.Context, d *schema.Resource func ResourceImageFromBlankCompute() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceImageFromBlankComputeCreate, ReadContext: resourceImageFromBlankComputeRead, @@ -275,6 +275,13 @@ func ResourceImageFromBlankCompute() *schema.Resource { }, Schema: resourceImageFromBlankComputeSchemaMake(), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceImageFromBlankComputeSchemaV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentToUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudapi/image/resource_image_from_platform_disk.go b/internal/service/cloudapi/image/resource_image_from_platform_disk.go index 78bef7de..756ebab6 100644 --- a/internal/service/cloudapi/image/resource_image_from_platform_disk.go +++ b/internal/service/cloudapi/image/resource_image_from_platform_disk.go @@ -238,7 +238,7 @@ func resourceImageFromPlatformDiskUpdate(ctx context.Context, d *schema.Resource func ResourceImageFromPlatformDisk() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceImageFromPlatformDiskCreate, ReadContext: resourceImageFromPlatformDiskRead, @@ -258,6 +258,13 @@ func ResourceImageFromPlatformDisk() *schema.Resource { }, Schema: resourceImageFromPlatformDiskSchemaMake(), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceImageFromBlankDiskSchemaV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentToUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudapi/image/resource_image_virtual.go b/internal/service/cloudapi/image/resource_image_virtual.go index db61e227..1aae5628 100644 --- a/internal/service/cloudapi/image/resource_image_virtual.go +++ b/internal/service/cloudapi/image/resource_image_virtual.go @@ -108,7 +108,7 @@ func resourceImageVirtualLink(ctx context.Context, d *schema.ResourceData, m int func ResourceImageVirtual() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceImageVirtualCreate, ReadContext: resourceImageRead, @@ -128,5 +128,12 @@ func ResourceImageVirtual() *schema.Resource { }, Schema: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceImageVirtualSchemaV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentToUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudapi/image/state_upgraders.go b/internal/service/cloudapi/image/state_upgraders.go new file mode 100644 index 00000000..4ed85d99 --- /dev/null +++ b/internal/service/cloudapi/image/state_upgraders.go @@ -0,0 +1,14 @@ +package image + +import ( + "context" + + log "github.com/sirupsen/logrus" +) + +func resourcePresentToUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) { + log.Debug("resourcePresentToUpgradeV1: upgrading state") + rawState["present_to"] = make(map[string]uint64) + + return rawState, nil +} diff --git a/internal/service/cloudbroker/disks/old_schemas.go b/internal/service/cloudbroker/disks/old_schemas.go new file mode 100644 index 00000000..092a7159 --- /dev/null +++ b/internal/service/cloudbroker/disks/old_schemas.go @@ -0,0 +1,391 @@ +package disks + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceDiskV1() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeInt, + Required: true, + //ForceNew: true, + }, + "gid": { + Type: schema.TypeInt, + Required: true, + //ForceNew: true, + }, + "disk_name": { + Type: schema.TypeString, + Required: true, + }, + "type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"D", "B", "T"}, false), + Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'", + }, + + "desc": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "size_max": { + Type: schema.TypeInt, + Required: true, + }, + "ssd_size": { + Type: schema.TypeInt, + Optional: true, + }, + "iops": { + Type: schema.TypeInt, + Optional: true, + Description: "max IOPS disk can perform", + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "pool": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "node_ids": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "detach": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "detach disk from machine first", + }, + "permanently": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "whether to completely delete the disk, works only with non attached disks", + }, + "shareable": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + "restore": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "restore deleting disk", + }, + "account_name": { + Type: schema.TypeString, + Computed: true, + }, + "acl": { + Type: schema.TypeString, + Computed: true, + }, + "boot_partition": { + Type: schema.TypeInt, + Computed: true, + }, + "computes": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compute_id": { + Type: schema.TypeString, + Computed: true, + }, + "compute_name": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "created_time": { + Type: schema.TypeInt, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "destruction_time": { + Type: schema.TypeInt, + Computed: true, + }, + "devicename": { + Type: schema.TypeString, + Computed: true, + }, + "disk_path": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "disk_id": { + Type: schema.TypeInt, + Computed: true, + }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + }, + "images": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "iotune": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "read_bytes_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "read_bytes_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "read_iops_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "read_iops_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "size_iops_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "total_bytes_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "total_bytes_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "total_iops_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "total_iops_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "write_bytes_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "write_bytes_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "write_iops_sec": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "write_iops_sec_max": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + }, + }, + }, + "iqn": { + Type: schema.TypeString, + Computed: true, + }, + "login": { + Type: schema.TypeString, + Computed: true, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + + "order": { + Type: schema.TypeInt, + Computed: true, + }, + "params": { + Type: schema.TypeString, + Computed: true, + }, + "parent_id": { + Type: schema.TypeInt, + Computed: true, + }, + "passwd": { + Type: schema.TypeString, + Computed: true, + }, + "pci_slot": { + Type: schema.TypeInt, + Computed: true, + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "purge_time": { + Type: schema.TypeInt, + Computed: true, + }, + "replication": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disk_id": { + Type: schema.TypeInt, + Computed: true, + }, + "pool_id": { + Type: schema.TypeString, + Computed: true, + }, + "role": { + Type: schema.TypeString, + Computed: true, + }, + "self_volume_id": { + Type: schema.TypeString, + Computed: true, + }, + "storage_id": { + Type: schema.TypeString, + Computed: true, + }, + "volume_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + Description: "Replication status", + }, + "reality_device_number": { + Type: schema.TypeInt, + Computed: true, + }, + "reference_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_name": { + Type: schema.TypeString, + Computed: true, + }, + "role": { + Type: schema.TypeString, + Computed: true, + }, + "sep_type": { + Type: schema.TypeString, + Computed: true, + }, + "size_used": { + Type: schema.TypeFloat, + Computed: true, + }, + "snapshots": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "label": { + Type: schema.TypeString, + Computed: true, + }, + "reference_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "snap_set_guid": { + Type: schema.TypeString, + Computed: true, + }, + "snap_set_time": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + }, + "vmid": { + Type: schema.TypeInt, + Computed: true, + }, + }, + } +} diff --git a/internal/service/cloudbroker/disks/resource_disk.go b/internal/service/cloudbroker/disks/resource_disk.go index 5642fb29..bbf7f40b 100644 --- a/internal/service/cloudbroker/disks/resource_disk.go +++ b/internal/service/cloudbroker/disks/resource_disk.go @@ -418,7 +418,7 @@ func resourceDiskChangeNodes(ctx context.Context, d *schema.ResourceData, m inte func ResourceDisk() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceDiskCreate, ReadContext: resourceDiskRead, @@ -438,5 +438,12 @@ func ResourceDisk() *schema.Resource { }, Schema: resourceDiskSchemaMake(), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceDiskV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourceDiskUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudbroker/disks/state_upgrader.go b/internal/service/cloudbroker/disks/state_upgrader.go new file mode 100644 index 00000000..50fd2672 --- /dev/null +++ b/internal/service/cloudbroker/disks/state_upgrader.go @@ -0,0 +1,14 @@ +package disks + +import ( + "context" + + log "github.com/sirupsen/logrus" +) + +func resourceDiskUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) { + log.Debug("resourceDiskUpgradeV1: upgrading state") + rawState["present_to"] = make(map[string]uint64) + + return rawState, nil +} diff --git a/internal/service/cloudbroker/image/old_schemas.go b/internal/service/cloudbroker/image/old_schemas.go new file mode 100644 index 00000000..6378b37a --- /dev/null +++ b/internal/service/cloudbroker/image/old_schemas.go @@ -0,0 +1,1394 @@ +package image + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs" +) + +func resourceCDROMImageV1() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the rescue disk", + }, + "url": { + Type: schema.TypeString, + Required: true, + Description: "URL where to download ISO from", + }, + "gid": { + Type: schema.TypeInt, + Required: true, + Description: "grid (platform) ID where this template should be create in", + }, + "drivers": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]", + }, + "hot_resize": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this machine supports hot resize", + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "AccountId to make the image exclusive", + }, + "username_dl": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "username for upload binary media", + }, + "password_dl": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "password for upload binary media", + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "storage endpoint provider ID", + }, + "pool_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "pool for image create", + }, + "architecture": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "binary architecture of this image, one of X86_64", + }, + "bootable": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this image boot OS", + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + "computeci_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "shared_with": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "enabled_stacks": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "unc_path": { + Type: schema.TypeString, + Computed: true, + Description: "unc path", + }, + "ckey": { + Type: schema.TypeString, + Computed: true, + }, + "meta": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "meta", + }, + "acl": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "explicit": { + Type: schema.TypeBool, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "right": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true}, + "type": { + Type: schema.TypeString, + Computed: true}, + "user_group_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "boot_type": { + Type: schema.TypeString, + Computed: true, + Description: "Boot type of image bios or uefi", + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + Description: "image id", + }, + "image_type": { + Type: schema.TypeString, + Computed: true, + Description: "Image type linux, windows or other", + }, + "link_to": { + Type: schema.TypeInt, + Computed: true, + Description: "", + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "reference_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_name": { + Type: schema.TypeString, + Computed: true, + }, + "rescuecd": { + Type: schema.TypeBool, + Computed: true, + }, + "last_modified": { + Type: schema.TypeInt, + Computed: true, + }, + "desc": { + Type: schema.TypeString, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "snapshot_id": { + Type: schema.TypeString, + Computed: true, + Description: "snapshot id", + }, + "status": { + Type: schema.TypeString, + Computed: true, + Description: "status", + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + Description: "tech atatus", + }, + "version": { + Type: schema.TypeString, + Computed: true, + Description: "version", + }, + "size": { + Type: schema.TypeInt, + Computed: true, + Description: "image size", + }, + "history": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + } +} + +func resourceImageV1() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the rescue disk", + }, + "url": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "URL where to download media from", + }, + "file_path": { + Type: schema.TypeString, + Optional: true, + Description: "path to image file", + }, + "gid": { + Type: schema.TypeInt, + Required: true, + Description: "grid (platform) ID where this template should be create in", + }, + "boot_type": { + Type: schema.TypeString, + Required: true, + Description: "Boot type of image bios or uefi", + }, + "image_type": { + Type: schema.TypeString, + Required: true, + Description: "Image type linux, windows or other", + }, + "drivers": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]", + }, + "hot_resize": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this machine supports hot resize", + }, + "network_interface_naming": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, true), + Description: "select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming", + }, + "username": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional username for the image", + }, + "password": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional password for the image", + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "AccountId to make the image exclusive", + }, + "username_dl": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "username for upload binary media", + }, + "password_dl": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "password for upload binary media", + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "storage endpoint provider ID", + }, + "pool_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "pool for image create", + }, + "architecture": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "binary architecture of this image, one of X86_64", + }, + "bootable": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this image boot OS", + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + "computeci_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "sync_mode": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Create image from a media identified by URL (in synchronous mode)", + }, + "enabled_stacks": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "shared_with": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + + "accounts": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "unc_path": { + Type: schema.TypeString, + Computed: true, + Description: "unc path", + }, + "acl": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "explicit": { + Type: schema.TypeBool, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "right": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true}, + "type": { + Type: schema.TypeString, + Computed: true}, + "user_group_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "cd_presented_to": { + Type: schema.TypeString, + Computed: true, + }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + Description: "image id", + }, + "link_to": { + Type: schema.TypeInt, + Computed: true, + Description: "", + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "reference_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_name": { + Type: schema.TypeString, + Computed: true, + }, + "rescuecd": { + Type: schema.TypeBool, + Computed: true, + }, + "last_modified": { + Type: schema.TypeInt, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "desc": { + Type: schema.TypeString, + Computed: true, + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "snapshot_id": { + Type: schema.TypeString, + Computed: true, + Description: "snapshot id", + }, + "status": { + Type: schema.TypeString, + Computed: true, + Description: "status", + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + Description: "tech atatus", + }, + "version": { + Type: schema.TypeString, + Computed: true, + Description: "version", + }, + "size": { + Type: schema.TypeInt, + Computed: true, + Description: "image size", + }, + "history": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + } +} + +func resourceVirtualImageV1() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "link_to": { + Type: schema.TypeInt, + Required: true, + Description: "ID of real image to link this virtual image to upon creation", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the rescue disk", + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "AccountId to make the image exclusive", + }, + "bootable": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this image boot OS", + }, + "computeci_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + "hot_resize": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this machine supports hot resize", + }, + "password": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional password for the image", + }, + "username": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Optional username for the image", + }, + "shared_with": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "enabled_stacks": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + + "unc_path": { + Type: schema.TypeString, + Computed: true, + Description: "unc path", + }, + "ckey": { + Type: schema.TypeString, + Computed: true, + }, + "meta": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "meta", + }, + "acl": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "explicit": { + Type: schema.TypeBool, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "right": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "user_group_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "architecture": { + Type: schema.TypeString, + Computed: true, + Description: "binary architecture of this image, one of X86_64", + }, + "boot_type": { + Type: schema.TypeString, + Computed: true, + Description: "Boot type of image bios or uefi", + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "desc": { + Type: schema.TypeString, + Computed: true, + }, + "drivers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]", + }, + "gid": { + Type: schema.TypeInt, + Computed: true, + Description: "grid (platform) ID where this template should be create in", + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "history": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Image id", + }, + "last_modified": { + Type: schema.TypeInt, + Computed: true, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "pool_name": { + Type: schema.TypeString, + Computed: true, + Description: "pool for image create", + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "reference_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_name": { + Type: schema.TypeString, + Computed: true, + }, + "rescuecd": { + Type: schema.TypeBool, + Computed: true, + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + Description: "storage endpoint provider ID", + }, + "size": { + Type: schema.TypeInt, + Computed: true, + Description: "image size", + }, + "snapshot_id": { + Type: schema.TypeString, + Computed: true, + Description: "snapshot id", + }, + "status": { + Type: schema.TypeString, + Computed: true, + Description: "status", + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + Description: "tech atatus", + }, + "image_type": { + Type: schema.TypeString, + Computed: true, + Description: "Image type linux, windows or other", + }, + "url": { + Type: schema.TypeString, + Computed: true, + Description: "URL where to download media from", + }, + "version": { + Type: schema.TypeString, + Computed: true, + Description: "version", + }, + }, + } +} + +func resourceImageFromBlankComputeV1() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compute_id": { + Type: schema.TypeInt, + Required: true, + Description: "Compute Id", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the rescue disk", + }, + "boot_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true), + Description: "Boot type of image BIOS or UEFI", + }, + "image_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true), + Description: "Image type linux, windows or other", + }, + + "username": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional username for the image", + }, + "password": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional password for the image", + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "AccountId to make the image exclusive", + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "storage endpoint provider ID", + }, + "pool_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "pool for image create", + }, + "hot_resize": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this machine supports hot resize", + }, + "async_mode": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "create an image in async/sync mode", + }, + "bootable": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this image boot OS", + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + "computeci_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "enabled_stacks": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "shared_with": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + + "accounts": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "network_interface_naming": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, true), + Description: "select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming", + }, + + "image_id": { + Type: schema.TypeInt, + Computed: true, + }, + "unc_path": { + Type: schema.TypeString, + Computed: true, + }, + "acl": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "explicit": { + Type: schema.TypeBool, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "right": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true}, + "type": { + Type: schema.TypeString, + Computed: true}, + "user_group_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "architecture": { + Type: schema.TypeString, + Computed: true, + }, + "cd_presented_to": { + Type: schema.TypeString, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "desc": { + Type: schema.TypeString, + Computed: true, + }, + "drivers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "gid": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "history": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "last_modified": { + Type: schema.TypeInt, + Computed: true, + }, + "link_to": { + Type: schema.TypeInt, + Computed: true, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "reference_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_name": { + Type: schema.TypeString, + Computed: true, + }, + "rescuecd": { + Type: schema.TypeBool, + Computed: true, + }, + "size": { + Type: schema.TypeInt, + Computed: true, + }, + "snapshot_id": { + Type: schema.TypeString, + Computed: true, + Description: "snapshot id", + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + }, + "url": { + Type: schema.TypeString, + Computed: true, + }, + "version": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceImageFromPlatformDiskV1() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disk_id": { + Type: schema.TypeInt, + Required: true, + Description: "Disk Id", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the rescue disk", + }, + "boot_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"bios", "uefi"}, true), + Description: "Boot type of image BIOS or UEFI", + }, + "image_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true), + Description: "Image type linux, windows or other", + }, + "architecture": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"X86_64"}, true), + Description: "Image type linux, windows or other", + }, + + "username": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional username for the image", + }, + "password": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Optional password for the image", + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "AccountId to make the image exclusive", + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "storage endpoint provider ID", + }, + "drivers": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + StateFunc: statefuncs.StateFuncToUpper, + ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86"}, false), // observe case while validating + Type: schema.TypeString, + }, + Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]", + }, + "pool_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "pool for image create", + }, + "hot_resize": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this machine supports hot resize", + }, + "async_mode": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "create an image in async/sync mode", + }, + "bootable": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Does this image boot OS", + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + "computeci_id": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "enabled_stacks": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "shared_with": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + + "accounts": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "network_interface_naming": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, true), + Description: "select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming", + }, + + "image_id": { + Type: schema.TypeInt, + Computed: true, + }, + "unc_path": { + Type: schema.TypeString, + Computed: true, + }, + "acl": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "explicit": { + Type: schema.TypeBool, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "right": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true}, + "type": { + Type: schema.TypeString, + Computed: true}, + "user_group_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "cd_presented_to": { + Type: schema.TypeString, + Computed: true, + }, + "deleted_time": { + Type: schema.TypeInt, + Computed: true, + }, + "desc": { + Type: schema.TypeString, + Computed: true, + }, + "gid": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "history": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "last_modified": { + Type: schema.TypeInt, + Computed: true, + }, + "link_to": { + Type: schema.TypeInt, + Computed: true, + }, + "milestones": { + Type: schema.TypeInt, + Computed: true, + }, + "provider_name": { + Type: schema.TypeString, + Computed: true, + }, + "purge_attempts": { + Type: schema.TypeInt, + Computed: true, + }, + "present_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "reference_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_id": { + Type: schema.TypeString, + Computed: true, + }, + "res_name": { + Type: schema.TypeString, + Computed: true, + }, + "rescuecd": { + Type: schema.TypeBool, + Computed: true, + }, + "size": { + Type: schema.TypeInt, + Computed: true, + }, + "snapshot_id": { + Type: schema.TypeString, + Computed: true, + Description: "snapshot id", + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tech_status": { + Type: schema.TypeString, + Computed: true, + }, + "url": { + Type: schema.TypeString, + Computed: true, + }, + "version": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} diff --git a/internal/service/cloudbroker/image/resource_cdrom_image.go b/internal/service/cloudbroker/image/resource_cdrom_image.go index 92abeb05..ef5253ab 100644 --- a/internal/service/cloudbroker/image/resource_cdrom_image.go +++ b/internal/service/cloudbroker/image/resource_cdrom_image.go @@ -207,7 +207,7 @@ func resourceImageCDROMEdit(ctx context.Context, d *schema.ResourceData, m inter func ResourceCDROMImage() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceCDROMImageCreate, ReadContext: resourceCDROMImageRead, @@ -227,5 +227,12 @@ func ResourceCDROMImage() *schema.Resource { }, Schema: resourceCDROMImageSchemaMake(), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceCDROMImageV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentTOUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudbroker/image/resource_image.go b/internal/service/cloudbroker/image/resource_image.go index 82a6d1c8..5ccce973 100644 --- a/internal/service/cloudbroker/image/resource_image.go +++ b/internal/service/cloudbroker/image/resource_image.go @@ -356,7 +356,7 @@ func resourceImageEdit(ctx context.Context, d *schema.ResourceData, m interface{ func ResourceImage() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceImageCreate, ReadContext: resourceImageRead, @@ -376,5 +376,12 @@ func ResourceImage() *schema.Resource { }, Schema: resourceImageSchemaMake(), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceImageV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentTOUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudbroker/image/resource_image_from_blank_compute.go b/internal/service/cloudbroker/image/resource_image_from_blank_compute.go index 406a3ca6..f2983994 100644 --- a/internal/service/cloudbroker/image/resource_image_from_blank_compute.go +++ b/internal/service/cloudbroker/image/resource_image_from_blank_compute.go @@ -254,7 +254,7 @@ func resourceImageFromBlankComputeUpdate(ctx context.Context, d *schema.Resource func ResourceImageFromBlankCompute() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceImageFromBlankComputeCreate, ReadContext: resourceImageFromBlankComputeRead, @@ -274,5 +274,12 @@ func ResourceImageFromBlankCompute() *schema.Resource { }, Schema: resourceImageFromBlankComputeSchemaMake(), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceImageFromBlankComputeV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentTOUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudbroker/image/resource_image_from_platform_disk.go b/internal/service/cloudbroker/image/resource_image_from_platform_disk.go index c9515e4e..c2afa05d 100644 --- a/internal/service/cloudbroker/image/resource_image_from_platform_disk.go +++ b/internal/service/cloudbroker/image/resource_image_from_platform_disk.go @@ -256,7 +256,7 @@ func resourceImageFromPlatformDiskUpdate(ctx context.Context, d *schema.Resource func ResourceImageFromPlatformDisk() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceImageFromPlatformDiskCreate, ReadContext: resourceImageFromPlatformDiskRead, @@ -276,5 +276,12 @@ func ResourceImageFromPlatformDisk() *schema.Resource { }, Schema: resourceImageFromPlatformDiskSchemaMake(), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceImageFromPlatformDiskV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentTOUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudbroker/image/resource_virtual_image.go b/internal/service/cloudbroker/image/resource_virtual_image.go index 68ba353e..a6814c87 100644 --- a/internal/service/cloudbroker/image/resource_virtual_image.go +++ b/internal/service/cloudbroker/image/resource_virtual_image.go @@ -183,7 +183,7 @@ func resourceImageLink(ctx context.Context, d *schema.ResourceData, m interface{ func ResourceVirtualImage() *schema.Resource { return &schema.Resource{ - SchemaVersion: 1, + SchemaVersion: 2, CreateContext: resourceVirtualImageCreate, ReadContext: resourceVirtualImageRead, @@ -203,5 +203,12 @@ func ResourceVirtualImage() *schema.Resource { }, Schema: resourceVirtualImageSchemaMake(), + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceVirtualImageV1().CoreConfigSchema().ImpliedType(), + Upgrade: resourcePresentTOUpgradeV1, + Version: 1, + }, + }, } } diff --git a/internal/service/cloudbroker/image/state_upgrader.go b/internal/service/cloudbroker/image/state_upgrader.go new file mode 100644 index 00000000..d58e2d67 --- /dev/null +++ b/internal/service/cloudbroker/image/state_upgrader.go @@ -0,0 +1,14 @@ +package image + +import ( + "context" + + log "github.com/sirupsen/logrus" +) + +func resourcePresentTOUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) { + log.Debug("resourcePresentTOUpgradeV1: upgrading state") + rawState["present_to"] = make(map[string]uint64) + + return rawState, nil +}