This commit is contained in:
2025-11-18 16:20:26 +03:00
parent 4b3f21d9be
commit e42fbcef39
397 changed files with 17560 additions and 1501 deletions

View File

@@ -127,6 +127,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "page number",
},
"storage_policy_id": {
Type: schema.TypeInt,
Optional: true,
},
"size": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -60,7 +60,9 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
d.Set("size", img.Size)
d.Set("snapshot_id", img.SnapshotID)
d.Set("status", img.Status)
d.Set("storage_policy_id", img.StoragePolicyID)
d.Set("tech_status", img.TechStatus)
d.Set("to_clean", img.ToClean)
d.Set("type", img.Type)
d.Set("username", img.Username)
d.Set("version", img.Version)
@@ -86,6 +88,7 @@ func flattenImageList(il *image.ListImages) []map[string]interface{} {
"sep_id": img.SepID,
"size": img.Size,
"status": img.Status,
"storage_policy_id": img.StoragePolicyID,
"type": img.Type,
"username": img.Username,
"virtual": img.Virtual,

View File

@@ -206,10 +206,18 @@ func dataSourceImageExtendSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"storage_policy_id": {
Type: schema.TypeInt,
Computed: true,
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,

View File

@@ -1,137 +1,141 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package image
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func dataSourceImageSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Owner account id",
},
"architecture": {
Type: schema.TypeString,
Computed: true,
Description: "Image architecture",
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
Description: "Boot image type",
},
"bootable": {
Type: schema.TypeBool,
Computed: true,
Description: "Flag, true if image is bootable, otherwise - false",
},
"cdrom": {
Type: schema.TypeBool,
Computed: true,
Description: "Flag, true if image is cdrom image, otherwise - false",
},
"desc": {
Type: schema.TypeString,
Computed: true,
Description: "Image description",
},
"drivers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "Image drivers",
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
Description: "Flag, true if image supports hot resize, else if not",
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Image id",
},
"link_to": {
Type: schema.TypeInt,
Computed: true,
Description: "For virtual images, id image, which current image linked",
},
"image_name": {
Type: schema.TypeString,
Computed: true,
Description: "Image name",
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
"pool_name": {
Type: schema.TypeString,
Computed: true,
Description: "Image pool",
},
"sep_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Image storage endpoint id",
},
"size": {
Type: schema.TypeInt,
Computed: true,
Description: "Image size",
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: "Image status",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "Image type",
},
"username": {
Type: schema.TypeString,
Computed: true,
Description: "username",
},
"virtual": {
Type: schema.TypeBool,
Computed: true,
Description: "True if image is virtula, otherwise - else",
},
}
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package image
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func dataSourceImageSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Owner account id",
},
"architecture": {
Type: schema.TypeString,
Computed: true,
Description: "Image architecture",
},
"boot_type": {
Type: schema.TypeString,
Computed: true,
Description: "Boot image type",
},
"bootable": {
Type: schema.TypeBool,
Computed: true,
Description: "Flag, true if image is bootable, otherwise - false",
},
"cdrom": {
Type: schema.TypeBool,
Computed: true,
Description: "Flag, true if image is cdrom image, otherwise - false",
},
"desc": {
Type: schema.TypeString,
Computed: true,
Description: "Image description",
},
"drivers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "Image drivers",
},
"hot_resize": {
Type: schema.TypeBool,
Computed: true,
Description: "Flag, true if image supports hot resize, else if not",
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Image id",
},
"link_to": {
Type: schema.TypeInt,
Computed: true,
Description: "For virtual images, id image, which current image linked",
},
"image_name": {
Type: schema.TypeString,
Computed: true,
Description: "Image name",
},
"network_interface_naming": {
Type: schema.TypeString,
Computed: true,
},
"pool_name": {
Type: schema.TypeString,
Computed: true,
Description: "Image pool",
},
"sep_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Image storage endpoint id",
},
"size": {
Type: schema.TypeInt,
Computed: true,
Description: "Image size",
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: "Image status",
},
"storage_policy_id": {
Type: schema.TypeInt,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "Image type",
},
"username": {
Type: schema.TypeString,
Computed: true,
Description: "username",
},
"virtual": {
Type: schema.TypeBool,
Computed: true,
Description: "True if image is virtula, otherwise - else",
},
}
}

View File

@@ -35,7 +35,6 @@ 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 resourceImageSchemaMake(sch map[string]*schema.Schema) map[string]*schema.Schema {
@@ -73,6 +72,12 @@ func resourceImageSchemaMake(sch map[string]*schema.Schema) map[string]*schema.S
Description: "Image type linux, windows or unknown",
}
sch["storage_policy_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
Description: "ID of the storage policy",
}
sch["hot_resize"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
@@ -126,16 +131,6 @@ func resourceImageSchemaMake(sch map[string]*schema.Schema) map[string]*schema.S
Description: "storage endpoint provider ID",
}
sch["drivers"] = &schema.Schema{
Type: schema.TypeList,
Required: true,
StateFunc: statefuncs.StateFuncToUpper,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"KVM_X86"}, false),
},
}
sch["network_interface_naming"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,

View File

@@ -50,6 +50,13 @@ func resourceImageVirtualSchemaMake(sch map[string]*schema.Schema) map[string]*s
Description: "ID of real image to link this virtual image to upon creation",
}
sch["account_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "account_id",
}
sch["image_id"] = &schema.Schema{
Type: schema.TypeInt,
Computed: true,

View File

@@ -63,20 +63,14 @@ func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interfac
c := m.(*controller.ControllerCfg)
req := image.CreateRequest{
AccountID: uint64(d.Get("account_id").(int)),
Name: d.Get("name").(string),
URL: d.Get("url").(string),
BootType: d.Get("boot_type").(string),
ImageType: d.Get("type").(string),
AccountID: uint64(d.Get("account_id").(int)),
Name: d.Get("name").(string),
URL: d.Get("url").(string),
BootType: d.Get("boot_type").(string),
ImageType: d.Get("type").(string),
StoragePolicyID: uint64(d.Get("storage_policy_id").(int)),
}
drivers := []string{}
for _, driver := range d.Get("drivers").([]interface{}) {
drivers = append(drivers, driver.(string))
}
req.Drivers = drivers
if hotresize, ok := d.GetOk("hot_resize"); ok {
req.HotResize = hotresize.(bool)
}

View File

@@ -490,6 +490,10 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
"version": {
Type: schema.TypeString,
Computed: true,

View File

@@ -48,7 +48,6 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
)
@@ -95,11 +94,6 @@ func resourceImageFromPlatformDiskCreate(ctx context.Context, d *schema.Resource
if poolName, ok := d.GetOk("pool_name"); ok {
req.PoolName = poolName.(string)
}
if driversInterface, ok := d.GetOk("drivers"); ok {
for _, d := range driversInterface.([]interface{}) {
req.Drivers = append(req.Drivers, d.(string))
}
}
if hotresize, ok := d.GetOk("hot_resize"); ok {
req.HotResize = hotresize.(bool)
}
@@ -320,16 +314,6 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
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,
@@ -385,6 +369,13 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"drivers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
@@ -483,6 +474,10 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
"version": {
Type: schema.TypeString,
Computed: true,

View File

@@ -49,8 +49,9 @@ func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m i
c := m.(*controller.ControllerCfg)
req := image.CreateVirtualRequest{
Name: d.Get("name").(string),
TargetID: uint64(d.Get("link_to").(int)),
Name: d.Get("name").(string),
TargetID: uint64(d.Get("link_to").(int)),
AccountID: uint64(d.Get("account_id").(int)),
}
imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req)

View File

@@ -103,6 +103,9 @@ func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData,
if enabled, ok := d.GetOkExists("enabled"); ok {
req.Enabled = enabled.(bool)
}
if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok {
req.StoragePolicyID = uint64(storagePolicyID.(int))
}
log.Debugf("utilityImageListCheckPresence: load image list")
imageList, err := c.CloudAPI().Image().List(ctx, req)