This commit is contained in:
2026-06-02 11:28:16 +03:00
parent af79f6ab3e
commit c734dcfff7
254 changed files with 10439 additions and 3751 deletions

View File

@@ -45,7 +45,9 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/zone"
accessgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/access_group"
defaultsecuritypolicy "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/default_security_policy"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/hypervisors"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/logicalports"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/netobjgroups"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/segments"
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
@@ -71,7 +73,6 @@ import (
cb_vfpool "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vfpool"
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
cb_zone "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/zone"
// cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
)
func newDataSourcesMap() map[string]*schema.Resource {
@@ -119,8 +120,6 @@ func newDataSourcesMap() map[string]*schema.Resource {
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
"decort_rg_list_vins": rg.DataSourceRgListVins(),
"decort_rg_usage": rg.DataSourceRgUsage(),
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
@@ -235,8 +234,6 @@ func newDataSourcesMap() map[string]*schema.Resource {
"decort_cb_disk": cb_disks.DataSourceDisk(),
"decort_cb_disk_list": cb_disks.DataSourceDiskList(),
"decort_cb_disk_list_deleted": cb_disks.DataSourceDiskListDeleted(),
"decort_cb_disk_list_types": cb_disks.DataSourceDiskListTypes(),
"decort_cb_disk_list_types_detailed": cb_disks.DataSourceDiskListTypesDetailed(),
"decort_cb_disk_list_unattached": cb_disks.DataSourceDiskListUnattached(),
"decort_cb_disk_snapshot": cb_disks.DataSourceDiskSnapshot(),
"decort_cb_disk_snapshot_list": cb_disks.DataSourceDiskSnapshotList(),
@@ -309,10 +306,15 @@ func newDataSourcesMap() map[string]*schema.Resource {
"decort_sdn_default_security_policy_list": defaultsecuritypolicy.DataSourceDefaultSecurityPolicyList(),
"decort_sdn_segment": segments.DataSourceSegment(),
"decort_sdn_segment_list": segments.DataSourceSegmentList(),
"decort_sdn_segment_get_status": segments.DataSourceSegmentGetStatus(),
"decort_sdn_hypervisor": hypervisors.DataSourceHypervisor(),
"decort_sdn_hypervisor_list": hypervisors.DataSourceHypervisorList(),
"decort_sdn_logical_port": logicalports.DataSourceLogicalPort(),
"decort_sdn_logical_port_get_by_unique_identifier": logicalports.DataSourceLogicalPortByUniqueID(),
"decort_sdn_logical_port_list": logicalports.DataSourceLogicalPortList(),
"decort_sdn_network_object_group": netobjgroups.DataSourceNetworkObjectGroup(),
"decort_sdn_network_object_group_list": netobjgroups.DataSourceNetworkObjectGroupList(),
}
}

View File

@@ -36,7 +36,9 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
accessgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/access_group"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/hypervisors"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/logicalports"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/netobjgroups"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/segments"
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
@@ -102,6 +104,7 @@ func newResourcesMap() map[string]*schema.Resource {
"decort_cb_image_from_platform_disk": cb_image.ResourceImageFromPlatformDisk(),
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
"decort_cb_multi_image": cb_image.ResourceMultiImage(),
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
"decort_cb_sep": cb_sep.ResourceSep(),
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
@@ -125,8 +128,10 @@ func newResourcesMap() map[string]*schema.Resource {
"decort_cb_vfpool": cb_vfpool.ResourceVFPool(),
"decort_cb_zone": cb_zone.ResourceZone(),
"decort_sdn_segment": segments.ResourceSegment(),
"decort_sdn_access_group": accessgroup.ResourceAccessGroup(),
"decort_sdn_logical_port": logicalports.ResourceLogicalPort(),
"decort_sdn_segment": segments.ResourceSegment(),
"decort_sdn_access_group": accessgroup.ResourceAccessGroup(),
"decort_sdn_hypervisor": hypervisors.ResourceHypervisor(),
"decort_sdn_logical_port": logicalports.ResourceLogicalPort(),
"decort_sdn_network_object_group": netobjgroups.ResourceNetworkObjectGroup(),
}
}

View File

@@ -307,6 +307,10 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -51,10 +51,12 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} {
"created_time": acc.CreatedTime,
"desc": acc.Description,
"deleted_time": acc.DeletedTime,
"deleted_by": acc.DeletedBy,
"account_id": acc.ID,
"account_name": acc.Name,
"status": acc.Status,
"updated_time": acc.UpdatedTime,
"updated_by": acc.UpdatedBy,
"zone_ids": acc.ZoneIDs,
}
res = append(res, temp)
@@ -191,6 +193,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
@@ -207,6 +213,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"zone_ids": {
Type: schema.TypeList,
Computed: true,

View File

@@ -26,6 +26,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
d.Set("send_access_emails", acc.SendAccessEmails)
d.Set("status", acc.Status)
d.Set("updated_by", acc.UpdatedBy)
d.Set("updated_time", acc.UpdatedTime)
d.Set("version", acc.Version)
d.Set("vins", acc.VINS)
@@ -68,6 +69,7 @@ func flattenAccountResource(d *schema.ResourceData, acc account.RecordAccount) e
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
d.Set("send_access_emails", acc.SendAccessEmails)
d.Set("status", acc.Status)
d.Set("updated_by", acc.UpdatedBy)
d.Set("updated_time", acc.UpdatedTime)
d.Set("version", acc.Version)
d.Set("vins", acc.VINS)

View File

@@ -625,6 +625,10 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -84,6 +84,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
// "boot_partition": {
// Type: schema.TypeInt,
// Computed: true,
@@ -166,6 +170,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
},
Description: "IDs of images using the disk",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -304,6 +312,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
// "purge_attempts": {
// Type: schema.TypeInt,
// Computed: true,
@@ -457,11 +469,6 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Technical status of the disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"vmid": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -93,11 +93,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "ID of the account the disks belong to",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
@@ -128,6 +123,16 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "storage policy ID ",
},
"compute_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by compute ID",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by rg ID",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -151,6 +156,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
// "boot_partition": {
// Type: schema.TypeInt,
// Computed: true,
@@ -234,6 +243,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
},
Description: "IDs of images using the disk",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -378,6 +391,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
// "purge_attempts": {
// Type: schema.TypeInt,
// Computed: true,
@@ -531,11 +548,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Technical status of the disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"vmid": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -1,103 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
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 disks
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listTypes, err := utilityDiskListTypesCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("types", listTypes.Data)
d.Set("entry_count", listTypes.EntryCount)
return nil
}
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceDiskListTypes() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceDiskListTypesRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceDiskListTypesSchemaMake(),
}
}

View File

@@ -1,167 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
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 disks
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, typeListDetailed := range tld.Data {
toMap := typeListDetailed.(map[string]interface{})
temp := map[string]interface{}{
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
"sep_id": toMap["sepId"].(float64),
"sep_name": toMap["sepName"].(string),
}
res = append(res, temp)
}
return res
}
func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
res := make([]interface{}, 0)
for _, pool := range pools {
toMap := pool.(map[string]interface{})
temp := map[string]interface{}{
"name": toMap["name"].(string),
"system": toMap["system"].(string),
"types": toMap["types"].([]interface{}),
}
res = append(res, temp)
}
return res
}
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed))
d.Set("entry_count", listTypesDetailed.EntryCount)
return nil
}
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Pool name",
},
"system": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
},
},
},
"sep_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Storage endpoint provider ID to create disk",
},
"sep_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceDiskListTypesDetailed() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceDiskListTypesDetailedRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceDiskListTypesDetailedSchemaMake(),
}
}

View File

@@ -108,11 +108,6 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "find by pool name",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
@@ -164,6 +159,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -330,6 +329,17 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "ID of the parent disk",
},
"present_to": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"passwd": {
Type: schema.TypeString,
Computed: true,
@@ -453,10 +463,9 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Technical status of the disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,

View File

@@ -449,11 +449,6 @@ func dataSourceDiskReplicationSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Technical status of the disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"vmid": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -89,11 +89,6 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "ID of the account the disks belong to",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
@@ -132,6 +127,10 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
// "boot_partition": {
// Type: schema.TypeInt,
// Computed: true,
@@ -219,6 +218,10 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
},
Description: "IDs of images using the disk",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -359,6 +362,10 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
// "purge_attempts": {
// Type: schema.TypeInt,
// Computed: true,
@@ -512,11 +519,6 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Technical status of the disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"vmid": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -26,6 +26,7 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter
"account_name": unattachedDisk.AccountName,
"acl": string(unattachedDiskAcl),
"blk_discard": unattachedDisk.BLKDiscard,
"block_size": unattachedDisk.BlockSize,
"boot_partition": unattachedDisk.BootPartition,
"created_time": unattachedDisk.CreatedTime,
"deleted_time": unattachedDisk.DeletedTime,
@@ -48,6 +49,8 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter
"passwd": unattachedDisk.Password,
"pci_slot": unattachedDisk.PCISlot,
"pool": unattachedDisk.Pool,
"present_to": unattachedDisk.PresentTo,
"provision": unattachedDisk.Provision,
"purge_attempts": unattachedDisk.PurgeAttempts,
"purge_time": unattachedDisk.PurgeTime,
"reality_device_number": unattachedDisk.RealityDeviceNumber,
@@ -62,8 +65,8 @@ func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]inter
"size_used": unattachedDisk.SizeUsed,
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
"status": unattachedDisk.Status,
"to_clean": unattachedDisk.ToClean,
"tech_status": unattachedDisk.TechStatus,
"type": unattachedDisk.Type,
"vmid": unattachedDisk.VMID,
}
res = append(res, tmp)
@@ -77,6 +80,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("account_name", disk.AccountName)
d.Set("acl", string(diskAcl))
d.Set("blk_discard", disk.BLKDiscard)
d.Set("block_size", disk.BlockSize)
// d.Set("boot_partition", disk.BootPartition)
d.Set("computes", flattenDiskComputes(disk.Computes))
d.Set("created_by", disk.CreatedBy)
@@ -95,6 +99,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("iotune", flattenIOTune(disk.IOTune))
// d.Set("iqn", disk.IQN)
// d.Set("login", disk.Login)
d.Set("independent", disk.Independent)
d.Set("machine_id", disk.MachineID)
d.Set("machine_name", disk.MachineName)
d.Set("disk_name", disk.Name)
@@ -105,6 +110,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("pci_slot", disk.PCISlot)
d.Set("pool", disk.Pool)
d.Set("present_to", disk.PresentTo)
d.Set("provision", disk.Provision)
// d.Set("purge_attempts", disk.PurgeAttempts)
d.Set("purge_time", disk.PurgeTime)
d.Set("replication", flattenDiskReplication(disk.Replication))
@@ -123,7 +129,6 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("status", disk.Status)
d.Set("storage_policy_id", disk.StoragePolicyID)
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
d.Set("updated_by", disk.UpdatedBy)
d.Set("updated_time", disk.UpdatedTime)
@@ -192,7 +197,6 @@ func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusRe
d.Set("status", disk.Status)
d.Set("status_replication", statusReplication)
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
}
@@ -222,6 +226,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"account_name": disk.AccountName,
"acl": string(diskAcl),
"blk_discard": disk.BLKDiscard,
"block_size": disk.BlockSize,
"computes": flattenDiskComputes(disk.Computes),
"created_by": disk.CreatedBy,
"created_time": disk.CreatedTime,
@@ -234,6 +239,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"disk_id": disk.ID,
"image_id": disk.ImageID,
"images": disk.Images,
"independent": disk.Independent,
"iotune": flattenIOTune(disk.IOTune),
"machine_id": disk.MachineID,
"machine_name": disk.MachineName,
@@ -245,6 +251,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"pci_slot": disk.PCISlot,
"pool": disk.Pool,
"present_to": disk.PresentTo,
"provision": disk.Provision,
"purge_time": disk.PurgeTime,
"replication": flattenDiskReplication(disk.Replication),
"res_id": disk.ResID,
@@ -261,7 +268,6 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"status": disk.Status,
"storage_policy_id": disk.StoragePolicyID,
"tech_status": disk.TechStatus,
"type": disk.Type,
"vmid": disk.VMID,
"updated_by": disk.UpdatedBy,
"updated_time": disk.UpdatedTime,

View File

@@ -606,6 +606,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
},
Description: "IDs of images using the disk",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
// "iqn": {
// Type: schema.TypeString,
// Computed: true,
@@ -644,11 +648,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "ID of the parent disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
// "passwd": {
// Type: schema.TypeString,
// Computed: true,
@@ -664,6 +663,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
// Computed: true,
// Description: "Number of deletion attempts",
// },
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_time": {
Type: schema.TypeInt,
Computed: true,
@@ -807,6 +810,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Flag indicating whether blk-discard is enabled for the disk",
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
}
return rets

View File

@@ -595,11 +595,6 @@ func resourceDiskReplicationSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Technical status of the disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"vmid": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -34,7 +34,6 @@ package disks
import (
"context"
"strings"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
@@ -68,9 +67,6 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = strings.ToUpper(diskType.(string))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.AccountID = uint64(sepId.(int))
}
@@ -89,6 +85,12 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok {
req.StoragePolicyID = uint64(storagePolicyID.(int))
}
if rgID, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rgID.(int))
}
if computeID, ok := d.GetOk("compute_id"); ok {
req.ComputeID = uint64(computeID.(int))
}
log.Debugf("utilityDiskListCheckPresence: load disk list")
diskList, err := c.CloudAPI().Disks().List(ctx, req)

View File

@@ -50,10 +50,6 @@ func utilityDiskListDeletedCheckPresence(ctx context.Context, d *schema.Resource
req.AccountID = uint64(account_id.(int))
}
if typev, ok := d.GetOk("type"); ok {
req.Type = typev.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}

View File

@@ -25,9 +25,6 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = diskType.(string)
}
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}

View File

@@ -42,8 +42,10 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
d.Set("history", flattenHistory(img.History))
d.Set("hot_resize", img.HotResize)
d.Set("image_id", img.ID)
d.Set("independent", img.Independent)
d.Set("last_modified", img.LastModified)
d.Set("link_to", img.LinkTo)
d.Set("links_to", img.LinksTo)
d.Set("milestones", img.Milestones)
d.Set("image_name", img.Name)
d.Set("network_interface_naming", img.NetworkInterfaceNaming)

View File

@@ -128,6 +128,10 @@ func dataSourceImageExtendSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"last_modified": {
Type: schema.TypeInt,
Computed: true,
@@ -136,6 +140,13 @@ func dataSourceImageExtendSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"milestones": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -89,6 +89,13 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "For virtual images, id image, which current image linked",
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"image_name": {
Type: schema.TypeString,
Computed: true,

View File

@@ -52,9 +52,16 @@ func existComputeID(ctx context.Context, computeId uint64, m interface{}) error
computeImageId := computeRecord.ImageID
bootImageId := -1
for _, d := range computeRecord.Disks {
if d.Type == "B" {
bootImageId = int(d.ImageID)
break
if computeRecord.Chipset == "i440fx" {
if d.PCISlot == 6 {
bootImageId = int(d.ImageID)
break
}
} else {
if d.BusNumber == 6 {
bootImageId = int(d.ImageID)
break
}
}
}

View File

@@ -75,10 +75,11 @@ func resourceImageFromBlankComputeCreate(ctx context.Context, d *schema.Resource
c := m.(*controller.ControllerCfg)
req := compute.CreateTemplateFromBlankRequest{
ComputeID: computeId,
Name: name,
BootType: d.Get("boot_type").(string),
ImageType: d.Get("type").(string),
ComputeID: computeId,
Name: name,
BootType: d.Get("boot_type").(string),
ImageType: d.Get("type").(string),
StoragePolicyID: uint64(d.Get("storage_policy_id").(int)),
}
if username, ok := d.GetOk("username"); ok {
@@ -297,6 +298,11 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "Name of the rescue disk",
},
"storage_policy_id": {
Type: schema.TypeInt,
Required: true,
Description: "Storage policy ID",
},
"boot_type": {
Type: schema.TypeString,
Required: true,
@@ -439,6 +445,13 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"milestones": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -423,6 +423,13 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"milestones": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -1,139 +1,139 @@
/*
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 (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceImageVirtualCreate: called for image %s", d.Get("name").(string))
c := m.(*controller.ControllerCfg)
req := image.CreateVirtualRequest{
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)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(imageId, 10))
d.Set("image_id", imageId)
_, err = utilityImageCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
return resourceImageRead(ctx, d, m)
}
func resourceImageVirtualUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
if d.HasChange("name") {
err := resourceImageRename(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("link_to") {
err := resourceImageVirtualLink(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
return resourceImageRead(ctx, d, m)
}
func resourceImageVirtualLink(ctx context.Context, d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceVirtualImageLink: called for %s, id: %s", d.Get("name").(string), d.Id())
c := m.(*controller.ControllerCfg)
req := image.LinkRequest{
ImageID: uint64(d.Get("image_id").(int)),
TargetID: uint64(d.Get("link_to").(int)),
}
_, err := c.CloudAPI().Image().Link(ctx, req)
if err != nil {
return err
}
return nil
}
func ResourceImageVirtual() *schema.Resource {
return &schema.Resource{
SchemaVersion: 2,
CreateContext: resourceImageVirtualCreate,
ReadContext: resourceImageRead,
UpdateContext: resourceImageVirtualUpdate,
DeleteContext: resourceImageDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout600s,
Read: &constants.Timeout300s,
Update: &constants.Timeout300s,
Delete: &constants.Timeout300s,
Default: &constants.Timeout300s,
},
Schema: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageVirtualSchemaV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentToUpgradeV1,
Version: 1,
},
},
}
}
/*
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 (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceImageVirtualCreate: called for image %s", d.Get("name").(string))
c := m.(*controller.ControllerCfg)
req := image.CreateVirtualRequest{
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)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(imageId, 10))
d.Set("image_id", imageId)
_, err = utilityImageCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
return resourceImageRead(ctx, d, m)
}
func resourceImageVirtualUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
if d.HasChange("name") {
err := resourceImageRename(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("link_to") {
err := resourceImageVirtualLink(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
return resourceImageRead(ctx, d, m)
}
func resourceImageVirtualLink(ctx context.Context, d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceVirtualImageLink: called for %s, id: %s", d.Get("name").(string), d.Id())
c := m.(*controller.ControllerCfg)
req := image.LinkRequest{
ImageID: uint64(d.Get("image_id").(int)),
TargetID: uint64(d.Get("link_to").(int)),
}
_, err := c.CloudAPI().Image().Link(ctx, req)
if err != nil {
return err
}
return nil
}
func ResourceImageVirtual() *schema.Resource {
return &schema.Resource{
SchemaVersion: 2,
CreateContext: resourceImageVirtualCreate,
ReadContext: resourceImageRead,
UpdateContext: resourceImageVirtualUpdate,
DeleteContext: resourceImageDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout600s,
Read: &constants.Timeout300s,
Update: &constants.Timeout300s,
Delete: &constants.Timeout300s,
Default: &constants.Timeout300s,
},
Schema: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageVirtualSchemaV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentToUpgradeV1,
Version: 1,
},
},
}
}

View File

@@ -805,13 +805,13 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
Description: "insert ssl certificate in x509 pem format",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"desc": {
Type: schema.TypeString,

View File

@@ -715,13 +715,13 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
),
Description: "Node RAM in MB.",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"disk": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -290,13 +290,13 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
Description: "Number of worker nodes to create.",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"cpu": {
Type: schema.TypeInt,

View File

@@ -260,6 +260,14 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -319,6 +327,10 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -457,10 +469,6 @@ func computeListDisksSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
@@ -1169,6 +1177,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
},
"loader_meta_iso": {
Type: schema.TypeList,
Computed: true,

View File

@@ -445,6 +445,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
},
}
}

View File

@@ -252,6 +252,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"hot_resize": compute.HotResize,
"network_interface_naming": compute.NetworkInterfaceNaming,
"zone_id": compute.ZoneID,
"weight": compute.Weight,
}
res = append(res, temp)
}
@@ -265,7 +266,6 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
temp := map[string]interface{}{
"disk_name": bootDisk.Name,
"disk_id": bootDisk.ID,
"disk_type": bootDisk.Type,
"sep_id": bootDisk.SepID,
"shareable": bootDisk.Shareable,
"size_max": bootDisk.SizeMax,
@@ -279,6 +279,16 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
"to_clean": bootDisk.ToClean,
"cache": bootDisk.Cache,
"blk_discard": bootDisk.BLKDiscard,
"block_size": bootDisk.BlockSize,
"bus_number": bootDisk.BusNumber,
"provision": bootDisk.Provision,
"pci_slot": bootDisk.PCISlot,
"created_time": bootDisk.CreatedTime,
"created_by": bootDisk.CreatedBy,
"deleted_by": bootDisk.DeletedBy,
"deleted_time": bootDisk.DeletedTime,
"updated_time": bootDisk.UpdatedTime,
"devicename": bootDisk.DeviceName,
}
res = append(res, temp)
@@ -315,7 +325,9 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
"devicename": disk.DeviceName,
"disk_name": disk.Name,
"disk_id": disk.ID,
"disk_type": disk.Type,
"independent": disk.Independent,
"pci_slot": disk.PCISlot,
"bus_number": disk.BusNumber,
"sep_id": disk.SepID,
"shareable": disk.Shareable,
"size_max": disk.SizeMax,
@@ -335,6 +347,8 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex
"permanently": pernamentlyValue,
"cache": disk.Cache,
"blk_discard": disk.BLKDiscard,
"block_size": disk.BlockSize,
"provision": disk.Provision,
"iotune": flattenIotune(disk.IOTune),
}
res = append(res, temp)
@@ -375,10 +389,23 @@ func flattenNetworkWeight(networks []interface{}, netID uint64, netType string)
return 0
}
func findBootDisk(disks compute.ListComputeDisks) *compute.ItemComputeDisk {
func isBootDisk(diskConv map[string]interface{}, chipset string) bool {
if chipset == "i440fx" {
return diskConv["pci_slot"].(int) == 6
}
return diskConv["bus_number"].(int) == 6
}
func findBootDisk(disks compute.ListComputeDisks, chipset string) *compute.ItemComputeDisk {
for _, disk := range disks {
if disk.Type == "B" {
return &disk
if chipset == "i440fx" {
if disk.PCISlot == 6 {
return &disk
}
} else {
if disk.BusNumber == 6 {
return &disk
}
}
}
return &compute.ItemComputeDisk{}
@@ -393,7 +420,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
log.Debugf("flattenCompute: ID %d, RG ID %d", computeRec.ID, computeRec.RGID)
devices, _ := json.Marshal(computeRec.Devices)
bootDisk := findBootDisk(computeRec.Disks)
bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset)
//check extraDisks, ipa_type, is,
d.SetId(strconv.FormatUint(computeRec.ID, 10))
@@ -480,6 +507,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
d.Set("cpu_pin", computeRec.CPUPin)
d.Set("numa_affinity", computeRec.NumaAffinity)
d.Set("hp_backed", computeRec.HPBacked)
d.Set("weight", computeRec.Weight)
d.Set("enabled", false)
if computeRec.Status == status.Enabled {
@@ -586,6 +614,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"acl": string(acl),
"account_id": disk.AccountID,
"blk_discard": disk.BLKDiscard,
"block_size": disk.BlockSize,
"boot_partition": disk.BootPartition,
"bus_number": disk.BusNumber,
"created_time": disk.CreatedTime,
@@ -603,6 +632,7 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"image_id": disk.ImageID,
"images": disk.Images,
"iotune": flattenIotune(disk.IOTune),
"independent": disk.Independent,
"iqn": disk.IQN,
"login": disk.Login,
"milestones": disk.Milestones,
@@ -627,8 +657,8 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf
"status": disk.Status,
"storage_policy_id": disk.StoragePolicyID,
"tech_status": disk.TechStatus,
"type": disk.Type,
"to_clean": disk.ToClean,
"provision": disk.Provision,
"updated_time": disk.UpdatedTime,
}
res = append(res, temp)
@@ -755,6 +785,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("zone_id", computeRec.ZoneID)
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
d.Set("os_version", computeRec.OSVersion)
d.Set("weight", computeRec.Weight)
}
func flattenPCI(pciList compute.ListPCIDevices) []uint64 {

View File

@@ -166,8 +166,8 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema {
Optional: true,
Computed: true,
//Default: 1500,
ValidateFunc: validation.IntBetween(1, 9216),
Description: "Maximum transmission unit, used only for DPDK type, must be 1-9216",
ValidateFunc: validation.IntBetween(1500, 9216),
Description: "Maximum transmission unit, used only for DPDK type, must be 1500-9216",
},
"sdn_interface_id": {

View File

@@ -182,19 +182,3 @@ func existTRUNKId(ctx context.Context, m interface{}, id int) (int, bool) {
return id, false
}
func isMoreThanOneDisksTypeB(ctx context.Context, disks interface{}) bool {
count := 0
for _, elem := range disks.([]interface{}) {
diskVal := elem.(map[string]interface{})
if diskVal["disk_type"].(string) == "B" {
count++
}
if count > 1 {
return true
}
}
return false
}

View File

@@ -71,25 +71,21 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
return diag.Errorf("resourceComputeCreate: can't create Compute because rgID %d is not allowed or does not exist", d.Get("rg_id").(int))
}
hasImage, err := existImageId(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !d.Get("create_blank").(bool) {
hasImage, err := existImageId(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !hasImage {
return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int))
if !hasImage {
return diag.Errorf("resourceComputeCreate: can't create Compute because imageID %d is not allowed or does not exist", d.Get("image_id").(int))
}
}
if zoneID, ok := d.GetOk("zone_id"); ok {
createReqX86.ZoneID = uint64(zoneID.(int))
}
if disks, ok := d.GetOk("disks"); ok {
if isMoreThanOneDisksTypeB(ctx, disks) {
return diag.Errorf("resourceComputeCreate: can't create Compute because block disks have more 1 disk type 'B'")
}
}
if network, ok := d.GetOk("network"); ok {
networkList := network.(*schema.Set).List()
for _, elem := range networkList {
@@ -116,8 +112,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if trunkId, ok := existTRUNKId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't create compute because TRUNK ID %d is not allowed or does not exist", trunkId)
}
//TODO
//SDN check
default:
continue
}
@@ -137,18 +131,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
createReqX86.Pool = pool.(string)
}
if ipaType, ok := d.GetOk("ipa_type"); ok {
createReqX86.IPAType = ipaType.(string)
}
if bootSize, ok := d.GetOk("boot_disk_size"); ok {
createReqX86.BootDisk = uint64(bootSize.(int))
}
if IS, ok := d.GetOk("is"); ok {
createReqX86.IS = IS.(string)
}
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
if networks, ok := d.GetOk("network"); ok {
@@ -178,7 +164,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
reqInterface.Enabled = netInterfaceVal["enabled"].(bool)
}
if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" {
if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" || reqInterface.NetType == "TRUNK" {
reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int))
}
@@ -294,7 +280,31 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
}
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86)
var apiResp uint64
if d.Get("create_blank").(bool) {
log.Debugf("resourceComputeCreate: using createBlank endpoint")
createBlankReq := kvmx86.CreateBlankRequest{
RGID: createReqX86.RGID,
Name: createReqX86.Name,
CPU: createReqX86.CPU,
RAM: createReqX86.RAM,
StoragePolicyID: createReqX86.StoragePolicyID,
WithoutBootDisk: createReqX86.WithoutBootDisk,
BootDisk: createReqX86.BootDisk,
SEPID: createReqX86.SepID,
Pool: createReqX86.Pool,
DataDisks: createReqX86.DataDisks,
Interfaces: createReqX86.Interfaces,
Description: createReqX86.Description,
Chipset: createReqX86.Chipset,
PreferredCPU: createReqX86.PreferredCPU,
ZoneID: createReqX86.ZoneID,
OSVersion: createReqX86.OSVersion,
}
apiResp, err = c.CloudAPI().KVMX86().CreateBlank(ctx, createBlankReq)
} else {
apiResp, err = c.CloudAPI().KVMX86().Create(ctx, createReqX86)
}
if err != nil {
return diag.FromErr(err)
}
@@ -430,7 +440,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if mac == "" {
warnings.Add(errors.New(fmt.Sprintf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId)))
warnings.Add(fmt.Errorf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))
continue
}
secGroupsIDs := make([]uint64, 0)
@@ -458,6 +468,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if start, ok := d.GetOk("started"); ok {
if start.(bool) {
req := compute.StartRequest{ComputeID: computeId}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
warnings.Add(err)
@@ -673,6 +686,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
}
}
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", computeId, d.Get("name").(string))
// We may reuse dataSourceComputeRead here as we maintain similarity
@@ -769,13 +783,15 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
return diag.Errorf("resourceComputeUpdate: can't update Compute because rgID %d not allowed or does not exist", d.Get("rg_id").(int))
}
hasImage, err := existImageId(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !d.Get("create_blank").(bool) {
hasImage, err := existImageId(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !hasImage {
return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int))
if !hasImage {
return diag.Errorf("resourceComputeUpdate: can't update Compute because imageID %d not allowed or does not exist", d.Get("image_id").(int))
}
}
if d.HasChange("zone_id") {
@@ -784,12 +800,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if disks, ok := d.GetOk("disks"); ok {
if isMoreThanOneDisksTypeB(ctx, disks) {
return diag.Errorf("resourceComputeUpdate: can't update Compute because block disks have more 1 disk type 'B'")
}
}
if network, ok := d.GetOk("network"); ok {
networkList := network.(*schema.Set).List()
for _, elem := range networkList {
@@ -816,8 +826,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if trunkId, ok := existTRUNKId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't create compute because TRUNK ID %d is not allowed or does not exist", trunkId)
}
//TODO
//SDNCheck
default:
continue
}
@@ -864,6 +872,10 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if start.(bool) {
req := compute.StartRequest{ComputeID: computeRec.ID}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
return diag.FromErr(err)
}
@@ -1105,7 +1117,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
// If used to be STARTED, we need to start it after update
if isStopRequired {
if _, err := c.CloudAPI().Compute().Start(ctx, compute.StartRequest{ComputeID: computeRec.ID}); err != nil {
req := compute.StartRequest{ComputeID: computeRec.ID}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
return diag.FromErr(err)
}
}
@@ -1176,10 +1193,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
chipset := d.Get("chipset").(string)
if len(deletedDisks) > 0 {
for _, disk := range deletedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
if isBootDisk(diskConv, chipset) {
continue
}
@@ -1201,7 +1220,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if len(addedDisks) > 0 {
for _, disk := range addedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
if isBootDisk(diskConv, chipset) {
continue
}
req := compute.DiskAddRequest{
@@ -1214,9 +1233,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if diskConv["sep_id"].(int) != 0 {
req.SepID = uint64(diskConv["sep_id"].(int))
}
if diskConv["disk_type"].(string) != "" {
req.DiskType = diskConv["disk_type"].(string)
}
if diskConv["pool"].(string) != "" {
req.Pool = diskConv["pool"].(string)
}
@@ -1230,6 +1246,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if err != nil {
return diag.FromErr(err)
}
if iotuneRaw, ok := diskConv["iotune"].([]interface{}); ok && len(iotuneRaw) > 0 {
iotuneMap := iotuneRaw[0].(map[string]interface{})
limitReq := disks.LimitIORequest{
@@ -1259,7 +1276,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if len(resizedDisks) > 0 {
for _, disk := range resizedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
if isBootDisk(diskConv, chipset) {
continue
}
req := compute.DiskResizeRequest{
@@ -1310,7 +1327,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if len(iotuneUpdatedDisks) > 0 {
for _, disk := range iotuneUpdatedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
if isBootDisk(diskConv, chipset) {
continue
}
diskID := uint64(diskConv["disk_id"].(int))
@@ -1847,6 +1864,9 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
req := compute.StartRequest{
ComputeID: computeRec.ID,
}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if !isStopRequired {
if _, err := c.CloudAPI().Compute().Start(ctx, req); err != nil {
return diag.FromErr(err)
@@ -2042,12 +2062,15 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
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'",
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
Description: "PCI slot number of the disk",
},
"bus_number": {
Type: schema.TypeInt,
Computed: true,
Description: "Bus number of the disk on virtual bus (6 = boot disk)",
},
"pool": {
Type: schema.TypeString,
@@ -2152,6 +2175,10 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Disk ID",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"shareable": {
Type: schema.TypeBool,
Computed: true,
@@ -2207,6 +2234,14 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
}
return rets
}
@@ -2353,6 +2388,12 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Default: false,
Description: "If True, the imageId, bootDisk, sepId, pool parameters are ignored and the compute is created without a boot disk in the stopped state.",
},
"create_blank": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.",
},
"boot_disk_size": {
Type: schema.TypeInt,
Optional: true,
@@ -2607,6 +2648,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Default: false,
Description: "Flag for resize compute",
},
"alt_boot_id": {
Type: schema.TypeInt,
Optional: true,
Description: "ID of CD-ROM live image to boot",
},
"started": {
Type: schema.TypeBool,
Optional: true,
@@ -2623,16 +2669,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
Default: true,
},
"is": {
Type: schema.TypeString,
Optional: true,
Description: "system name",
},
"ipa_type": {
Type: schema.TypeString,
Optional: true,
Description: "compute purpose",
},
"network_interface_naming": {
Type: schema.TypeString,
Optional: true,
@@ -2687,7 +2723,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Required: true,
StateFunc: statefuncs.StateFuncToUpper,
ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK"}, false), // observe case while validating
ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "DPDK"}, false), // observe case while validating
Description: "Type of the network",
},
"net_id": {
@@ -2733,6 +2769,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
Description: "Priority weight of the compute. Higher value means higher priority and later migration.",
},
"arch": {
Type: schema.TypeString,
Computed: true,

View File

@@ -299,7 +299,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
if needStart {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil {
var altBootID uint64
if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok {
altBootID = uint64(altBootIDRaw)
} else {
altBootID = 0
}
if numErr, err := utilityComputeStart(ctx, computeId, altBootID, m); err != nil {
apiErrCount += numErr
lastSavedError = err
}
@@ -462,10 +468,14 @@ func utilityComputeStop(ctx context.Context, computeID uint64, m interface{}) er
return nil
}
func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) {
func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) {
c := m.(*controller.ControllerCfg)
startReq := compute.StartRequest{ComputeID: computeID}
if altBootID > 0 {
startReq.AltBootID = altBootID
}
log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID)
_, err := c.CloudAPI().Compute().Start(ctx, startReq)
if err != nil {
@@ -674,7 +684,7 @@ func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m i
if err != nil {
return err
}
bootDisk := findBootDisk(computeRec.Disks)
bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset)
computeDisksIDs := getComputeDiskIDsAPI(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID)
for i, diskID := range computeDisksIDs {

View File

@@ -1,300 +1,300 @@
/*
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 lb
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
)
func flattenLBFrontendBind(d *schema.ResourceData, b *lb.ItemBinding, lbId int64, frontendName string) {
d.Set("lb_id", lbId)
d.Set("frontend_name", frontendName)
d.Set("name", b.Name)
d.Set("address", b.Address)
d.Set("guid", b.GUID)
d.Set("port", b.Port)
}
func flattenLBFrontend(d *schema.ResourceData, f *lb.ItemFrontend, lbId int64) {
d.Set("lb_id", lbId)
d.Set("backend_name", f.Backend)
d.Set("name", f.Name)
d.Set("guid", f.GUID)
d.Set("bindings", flattendBindings(f.Bindings))
}
func flattenResourceLBBackendServer(d *schema.ResourceData, s *lb.ItemServer, lbId int64, backendName string) {
d.Set("lb_id", lbId)
d.Set("backend_name", backendName)
d.Set("name", s.Name)
d.Set("port", s.Port)
d.Set("address", s.Address)
d.Set("check", s.Check)
d.Set("guid", s.GUID)
d.Set("downinter", s.ServerSettings.DownInter)
d.Set("fall", s.ServerSettings.Fall)
d.Set("inter", s.ServerSettings.Inter)
d.Set("maxconn", s.ServerSettings.MaxConn)
d.Set("maxqueue", s.ServerSettings.MaxQueue)
d.Set("rise", s.ServerSettings.Rise)
d.Set("slowstart", s.ServerSettings.SlowStart)
d.Set("weight", s.ServerSettings.Weight)
}
func flattenResourceLBBackend(d *schema.ResourceData, b *lb.ItemBackend, lbId int64) {
d.Set("lb_id", lbId)
d.Set("name", b.Name)
d.Set("algorithm", b.Algorithm)
d.Set("guid", b.GUID)
d.Set("downinter", b.ServerDefaultSettings.DownInter)
d.Set("fall", b.ServerDefaultSettings.Fall)
d.Set("inter", b.ServerDefaultSettings.Inter)
d.Set("maxconn", b.ServerDefaultSettings.MaxConn)
d.Set("maxqueue", b.ServerDefaultSettings.MaxQueue)
d.Set("rise", b.ServerDefaultSettings.Rise)
d.Set("slowstart", b.ServerDefaultSettings.SlowStart)
d.Set("weight", b.ServerDefaultSettings.Weight)
d.Set("servers", flattenServers(b.Servers))
}
func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
d.Set("backends", flattenLBBackends(lb.Backends))
d.Set("created_by", lb.CreatedBy)
d.Set("created_time", lb.CreatedTime)
d.Set("deleted_by", lb.DeletedBy)
d.Set("deleted_time", lb.DeletedTime)
d.Set("desc", lb.Description)
d.Set("dp_api_user", lb.DPAPIUser)
d.Set("extnet_id", lb.ExtNetID)
d.Set("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("manager_id", lb.ManagerId)
d.Set("manager_type", lb.ManagerType)
d.Set("lb_id", lb.ID)
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
d.Set("primary_node", flattenNode(lb.PrimaryNode))
d.Set("rg_id", lb.RGID)
d.Set("rg_name", lb.RGName)
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
d.Set("status", lb.Status)
d.Set("tech_status", lb.TechStatus)
d.Set("updated_by", lb.UpdatedBy)
d.Set("updated_time", lb.UpdatedTime)
d.Set("user_managed", lb.UserManaged)
d.Set("vins_id", lb.VINSID)
d.Set("zone_id", lb.ZoneID)
}
func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("account_id", lb.AccountID)
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
d.Set("backends", flattenLBBackends(lb.Backends))
d.Set("created_by", lb.CreatedBy)
d.Set("created_time", lb.CreatedTime)
d.Set("deleted_by", lb.DeletedBy)
d.Set("deleted_time", lb.DeletedTime)
d.Set("desc", lb.Description)
d.Set("dp_api_user", lb.DPAPIUser)
d.Set("extnet_id", lb.ExtNetID)
d.Set("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("manager_id", lb.ManagerId)
d.Set("manager_type", lb.ManagerType)
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
d.Set("primary_node", flattenNode(lb.PrimaryNode))
d.Set("rg_id", lb.RGID)
d.Set("rg_name", lb.RGName)
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
d.Set("status", lb.Status)
d.Set("tech_status", lb.TechStatus)
d.Set("updated_by", lb.UpdatedBy)
d.Set("updated_time", lb.UpdatedTime)
d.Set("user_managed", lb.UserManaged)
d.Set("vins_id", lb.VINSID)
d.Set("zone_id", lb.ZoneID)
}
func flattenNode(node lb.RecordNode) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
n := map[string]interface{}{
"backend_ip": node.BackendIP,
"compute_id": node.ComputeID,
"frontend_ip": node.FrontendIP,
"guid": node.GUID,
"mgmt_ip": node.MGMTIP,
"network_id": node.NetworkID,
}
temp = append(temp, n)
return temp
}
func flattendBindings(bs []lb.ItemBinding) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(bs))
for _, b := range bs {
t := map[string]interface{}{
"address": b.Address,
"guid": b.GUID,
"name": b.Name,
"port": b.Port,
}
temp = append(temp, t)
}
return temp
}
func flattenFrontends(fs []lb.ItemFrontend) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(fs))
for _, f := range fs {
t := map[string]interface{}{
"backend": f.Backend,
"bindings": flattendBindings(f.Bindings),
"guid": f.GUID,
"name": f.Name,
}
temp = append(temp, t)
}
return temp
}
func flattenServers(servers []lb.ItemServer) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(servers))
for _, server := range servers {
t := map[string]interface{}{
"address": server.Address,
"check": server.Check,
"guid": server.GUID,
"name": server.Name,
"port": server.Port,
"server_settings": flattenServerSettings(server.ServerSettings),
}
temp = append(temp, t)
}
return temp
}
func flattenServerSettings(defSet lb.RecordServerSettings) []map[string]interface{} {
temp := map[string]interface{}{
"downinter": defSet.DownInter,
"fall": defSet.Fall,
"guid": defSet.GUID,
"inter": defSet.Inter,
"maxconn": defSet.MaxConn,
"maxqueue": defSet.MaxQueue,
"rise": defSet.Rise,
"slowstart": defSet.SlowStart,
"weight": defSet.Weight,
}
res := make([]map[string]interface{}, 0)
res = append(res, temp)
return res
}
func flattenLBBackends(backends []lb.ItemBackend) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(backends))
for _, item := range backends {
t := map[string]interface{}{
"algorithm": item.Algorithm,
"guid": item.GUID,
"name": item.Name,
"server_default_settings": flattenServerSettings(item.ServerDefaultSettings),
"servers": flattenServers(item.Servers),
}
temp = append(temp, t)
}
return temp
}
func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lbl.Data))
for _, lb := range lbl.Data {
temp := map[string]interface{}{
"ha_mode": lb.HAMode,
"backend_haip": lb.BackendHAIP,
"backends": flattenLBBackends(lb.Backends),
"created_by": lb.CreatedBy,
"created_time": lb.CreatedTime,
"deleted_by": lb.DeletedBy,
"deleted_time": lb.DeletedTime,
"desc": lb.Description,
"dp_api_user": lb.DPAPIUser,
"dp_api_password": lb.DPAPIPassword,
"extnet_id": lb.ExtNetID,
"frontend_haip": lb.FrontendHAIP,
"frontends": flattenFrontends(lb.Frontends),
"gid": lb.GID,
"guid": lb.GUID,
"manager_id": lb.ManagerId,
"manager_type": lb.ManagerType,
"image_id": lb.ImageID,
"milestones": lb.Milestones,
"name": lb.Name,
"part_k8s": lb.PartK8s,
"primary_node": flattenNode(lb.PrimaryNode),
"rg_id": lb.RGID,
"rg_name": lb.RGName,
"secondary_node": flattenNode(lb.SecondaryNode),
"status": lb.Status,
"tech_status": lb.TechStatus,
"updated_by": lb.UpdatedBy,
"updated_time": lb.UpdatedTime,
"user_managed": lb.UserManaged,
"vins_id": lb.VINSID,
"lb_id": lb.ID,
"zone_id": lb.ZoneID,
}
res = append(res, temp)
}
return res
}
/*
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 lb
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
)
func flattenLBFrontendBind(d *schema.ResourceData, b *lb.ItemBinding, lbId int64, frontendName string) {
d.Set("lb_id", lbId)
d.Set("frontend_name", frontendName)
d.Set("name", b.Name)
d.Set("address", b.Address)
d.Set("guid", b.GUID)
d.Set("port", b.Port)
}
func flattenLBFrontend(d *schema.ResourceData, f *lb.ItemFrontend, lbId int64) {
d.Set("lb_id", lbId)
d.Set("backend_name", f.Backend)
d.Set("name", f.Name)
d.Set("guid", f.GUID)
d.Set("bindings", flattendBindings(f.Bindings))
}
func flattenResourceLBBackendServer(d *schema.ResourceData, s *lb.ItemServer, lbId int64, backendName string) {
d.Set("lb_id", lbId)
d.Set("backend_name", backendName)
d.Set("name", s.Name)
d.Set("port", s.Port)
d.Set("address", s.Address)
d.Set("check", s.Check)
d.Set("guid", s.GUID)
d.Set("downinter", s.ServerSettings.DownInter)
d.Set("fall", s.ServerSettings.Fall)
d.Set("inter", s.ServerSettings.Inter)
d.Set("maxconn", s.ServerSettings.MaxConn)
d.Set("maxqueue", s.ServerSettings.MaxQueue)
d.Set("rise", s.ServerSettings.Rise)
d.Set("slowstart", s.ServerSettings.SlowStart)
d.Set("weight", s.ServerSettings.Weight)
}
func flattenResourceLBBackend(d *schema.ResourceData, b *lb.ItemBackend, lbId int64) {
d.Set("lb_id", lbId)
d.Set("name", b.Name)
d.Set("algorithm", b.Algorithm)
d.Set("guid", b.GUID)
d.Set("downinter", b.ServerDefaultSettings.DownInter)
d.Set("fall", b.ServerDefaultSettings.Fall)
d.Set("inter", b.ServerDefaultSettings.Inter)
d.Set("maxconn", b.ServerDefaultSettings.MaxConn)
d.Set("maxqueue", b.ServerDefaultSettings.MaxQueue)
d.Set("rise", b.ServerDefaultSettings.Rise)
d.Set("slowstart", b.ServerDefaultSettings.SlowStart)
d.Set("weight", b.ServerDefaultSettings.Weight)
d.Set("servers", flattenServers(b.Servers))
}
func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
d.Set("backends", flattenLBBackends(lb.Backends))
d.Set("created_by", lb.CreatedBy)
d.Set("created_time", lb.CreatedTime)
d.Set("deleted_by", lb.DeletedBy)
d.Set("deleted_time", lb.DeletedTime)
d.Set("desc", lb.Description)
d.Set("dp_api_user", lb.DPAPIUser)
d.Set("extnet_id", lb.ExtNetID)
d.Set("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("manager_id", lb.ManagerId)
d.Set("manager_type", lb.ManagerType)
d.Set("lb_id", lb.ID)
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
d.Set("primary_node", flattenNode(lb.PrimaryNode))
d.Set("rg_id", lb.RGID)
d.Set("rg_name", lb.RGName)
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
d.Set("status", lb.Status)
d.Set("tech_status", lb.TechStatus)
d.Set("updated_by", lb.UpdatedBy)
d.Set("updated_time", lb.UpdatedTime)
d.Set("user_managed", lb.UserManaged)
d.Set("vins_id", lb.VINSID)
d.Set("zone_id", lb.ZoneID)
}
func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("account_id", lb.AccountID)
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
d.Set("backends", flattenLBBackends(lb.Backends))
d.Set("created_by", lb.CreatedBy)
d.Set("created_time", lb.CreatedTime)
d.Set("deleted_by", lb.DeletedBy)
d.Set("deleted_time", lb.DeletedTime)
d.Set("desc", lb.Description)
d.Set("dp_api_user", lb.DPAPIUser)
d.Set("extnet_id", lb.ExtNetID)
d.Set("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("manager_id", lb.ManagerId)
d.Set("manager_type", lb.ManagerType)
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
d.Set("primary_node", flattenNode(lb.PrimaryNode))
d.Set("rg_id", lb.RGID)
d.Set("rg_name", lb.RGName)
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
d.Set("status", lb.Status)
d.Set("tech_status", lb.TechStatus)
d.Set("updated_by", lb.UpdatedBy)
d.Set("updated_time", lb.UpdatedTime)
d.Set("user_managed", lb.UserManaged)
d.Set("vins_id", lb.VINSID)
d.Set("zone_id", lb.ZoneID)
}
func flattenNode(node lb.RecordNode) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
n := map[string]interface{}{
"backend_ip": node.BackendIP,
"compute_id": node.ComputeID,
"frontend_ip": node.FrontendIP,
"guid": node.GUID,
"mgmt_ip": node.MGMTIP,
"network_id": node.NetworkID,
}
temp = append(temp, n)
return temp
}
func flattendBindings(bs []lb.ItemBinding) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(bs))
for _, b := range bs {
t := map[string]interface{}{
"address": b.Address,
"guid": b.GUID,
"name": b.Name,
"port": b.Port,
}
temp = append(temp, t)
}
return temp
}
func flattenFrontends(fs []lb.ItemFrontend) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(fs))
for _, f := range fs {
t := map[string]interface{}{
"backend": f.Backend,
"bindings": flattendBindings(f.Bindings),
"guid": f.GUID,
"name": f.Name,
}
temp = append(temp, t)
}
return temp
}
func flattenServers(servers []lb.ItemServer) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(servers))
for _, server := range servers {
t := map[string]interface{}{
"address": server.Address,
"check": server.Check,
"guid": server.GUID,
"name": server.Name,
"port": server.Port,
"server_settings": flattenServerSettings(server.ServerSettings),
}
temp = append(temp, t)
}
return temp
}
func flattenServerSettings(defSet lb.RecordServerSettings) []map[string]interface{} {
temp := map[string]interface{}{
"downinter": defSet.DownInter,
"fall": defSet.Fall,
"guid": defSet.GUID,
"inter": defSet.Inter,
"maxconn": defSet.MaxConn,
"maxqueue": defSet.MaxQueue,
"rise": defSet.Rise,
"slowstart": defSet.SlowStart,
"weight": defSet.Weight,
}
res := make([]map[string]interface{}, 0)
res = append(res, temp)
return res
}
func flattenLBBackends(backends []lb.ItemBackend) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(backends))
for _, item := range backends {
t := map[string]interface{}{
"algorithm": item.Algorithm,
"guid": item.GUID,
"name": item.Name,
"server_default_settings": flattenServerSettings(item.ServerDefaultSettings),
"servers": flattenServers(item.Servers),
}
temp = append(temp, t)
}
return temp
}
func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lbl.Data))
for _, lb := range lbl.Data {
temp := map[string]interface{}{
"ha_mode": lb.HAMode,
"backend_haip": lb.BackendHAIP,
"backends": flattenLBBackends(lb.Backends),
"created_by": lb.CreatedBy,
"created_time": lb.CreatedTime,
"deleted_by": lb.DeletedBy,
"deleted_time": lb.DeletedTime,
"desc": lb.Description,
"dp_api_user": lb.DPAPIUser,
"dp_api_password": lb.DPAPIPassword,
"extnet_id": lb.ExtNetID,
"frontend_haip": lb.FrontendHAIP,
"frontends": flattenFrontends(lb.Frontends),
"gid": lb.GID,
"guid": lb.GUID,
"manager_id": lb.ManagerId,
"manager_type": lb.ManagerType,
"image_id": lb.ImageID,
"milestones": lb.Milestones,
"name": lb.Name,
"part_k8s": lb.PartK8s,
"primary_node": flattenNode(lb.PrimaryNode),
"rg_id": lb.RGID,
"rg_name": lb.RGName,
"secondary_node": flattenNode(lb.SecondaryNode),
"status": lb.Status,
"tech_status": lb.TechStatus,
"updated_by": lb.UpdatedBy,
"updated_time": lb.UpdatedTime,
"user_managed": lb.UserManaged,
"vins_id": lb.VINSID,
"lb_id": lb.ID,
"zone_id": lb.ZoneID,
}
res = append(res, temp)
}
return res
}

View File

@@ -1,119 +1,119 @@
/*
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 lb
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func lbResourceSchemaMake() map[string]*schema.Schema {
sch := createLBSchema()
sch["rg_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
}
sch["name"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
}
sch["zone_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
}
sch["extnet_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
}
sch["vins_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
}
sch["start"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: true,
}
sch["desc"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
}
sch["enable"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["restart"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["restore"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["safe"] = &schema.Schema{
Type: schema.TypeBool,
Default: true,
Optional: true,
}
sch["config_reset"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
///4.4.0
sch["ha_mode"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["sysctl_params"] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeMap,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
}
///
sch["permanently"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
return sch
}
/*
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 lb
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func lbResourceSchemaMake() map[string]*schema.Schema {
sch := createLBSchema()
sch["rg_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
}
sch["name"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
}
sch["zone_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
}
sch["extnet_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
}
sch["vins_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
}
sch["start"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: true,
}
sch["desc"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
}
sch["enable"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["restart"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["restore"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["safe"] = &schema.Schema{
Type: schema.TypeBool,
Default: true,
Optional: true,
}
sch["config_reset"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
///4.4.0
sch["ha_mode"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["sysctl_params"] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeMap,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
}
///
sch["permanently"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
return sch
}

View File

@@ -1,396 +1,396 @@
/*
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 lb
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func createLBSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"ha_mode": {
Type: schema.TypeBool,
Computed: true,
},
"backend_haip": {
Type: schema.TypeString,
Computed: true,
},
"backends": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"algorithm": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"server_default_settings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"downinter": {
Type: schema.TypeInt,
Computed: true,
},
"fall": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"inter": {
Type: schema.TypeInt,
Computed: true,
},
"maxconn": {
Type: schema.TypeInt,
Computed: true,
},
"maxqueue": {
Type: schema.TypeInt,
Computed: true,
},
"rise": {
Type: schema.TypeInt,
Computed: true,
},
"slowstart": {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"servers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": {
Type: schema.TypeString,
Computed: true,
},
"check": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
"server_settings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"downinter": {
Type: schema.TypeInt,
Computed: true,
},
"fall": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"inter": {
Type: schema.TypeInt,
Computed: true,
},
"maxconn": {
Type: schema.TypeInt,
Computed: true,
},
"maxqueue": {
Type: schema.TypeInt,
Computed: true,
},
"rise": {
Type: schema.TypeInt,
Computed: true,
},
"slowstart": {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
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,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"dp_api_user": {
Type: schema.TypeString,
Computed: true,
},
"extnet_id": {
Type: schema.TypeInt,
Computed: true,
},
"frontend_haip": {
Type: schema.TypeString,
Computed: true,
},
"frontends": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backend": {
Type: schema.TypeString,
Computed: true,
},
"bindings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"lb_id": {
Type: schema.TypeInt,
Computed: true,
},
"manager_id": {
Type: schema.TypeInt,
Computed: true,
},
"manager_type": {
Type: schema.TypeString,
Computed: true,
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"part_k8s": {
Type: schema.TypeBool,
Computed: true,
},
"primary_node": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backend_ip": {
Type: schema.TypeString,
Computed: true,
},
"compute_id": {
Type: schema.TypeInt,
Computed: true,
},
"frontend_ip": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_ip": {
Type: schema.TypeString,
Computed: true,
},
"network_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"secondary_node": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backend_ip": {
Type: schema.TypeString,
Computed: true,
},
"compute_id": {
Type: schema.TypeInt,
Computed: true,
},
"frontend_ip": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_ip": {
Type: schema.TypeString,
Computed: true,
},
"network_id": {
Type: schema.TypeInt,
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,
},
"vins_id": {
Type: schema.TypeInt,
Computed: true,
},
}
}
/*
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 lb
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func createLBSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"ha_mode": {
Type: schema.TypeBool,
Computed: true,
},
"backend_haip": {
Type: schema.TypeString,
Computed: true,
},
"backends": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"algorithm": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"server_default_settings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"downinter": {
Type: schema.TypeInt,
Computed: true,
},
"fall": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"inter": {
Type: schema.TypeInt,
Computed: true,
},
"maxconn": {
Type: schema.TypeInt,
Computed: true,
},
"maxqueue": {
Type: schema.TypeInt,
Computed: true,
},
"rise": {
Type: schema.TypeInt,
Computed: true,
},
"slowstart": {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"servers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": {
Type: schema.TypeString,
Computed: true,
},
"check": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
"server_settings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"downinter": {
Type: schema.TypeInt,
Computed: true,
},
"fall": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"inter": {
Type: schema.TypeInt,
Computed: true,
},
"maxconn": {
Type: schema.TypeInt,
Computed: true,
},
"maxqueue": {
Type: schema.TypeInt,
Computed: true,
},
"rise": {
Type: schema.TypeInt,
Computed: true,
},
"slowstart": {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
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,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"dp_api_user": {
Type: schema.TypeString,
Computed: true,
},
"extnet_id": {
Type: schema.TypeInt,
Computed: true,
},
"frontend_haip": {
Type: schema.TypeString,
Computed: true,
},
"frontends": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backend": {
Type: schema.TypeString,
Computed: true,
},
"bindings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"lb_id": {
Type: schema.TypeInt,
Computed: true,
},
"manager_id": {
Type: schema.TypeInt,
Computed: true,
},
"manager_type": {
Type: schema.TypeString,
Computed: true,
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"part_k8s": {
Type: schema.TypeBool,
Computed: true,
},
"primary_node": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backend_ip": {
Type: schema.TypeString,
Computed: true,
},
"compute_id": {
Type: schema.TypeInt,
Computed: true,
},
"frontend_ip": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_ip": {
Type: schema.TypeString,
Computed: true,
},
"network_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"secondary_node": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backend_ip": {
Type: schema.TypeString,
Computed: true,
},
"compute_id": {
Type: schema.TypeInt,
Computed: true,
},
"frontend_ip": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_ip": {
Type: schema.TypeString,
Computed: true,
},
"network_id": {
Type: schema.TypeInt,
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,
},
"vins_id": {
Type: schema.TypeInt,
Computed: true,
},
}
}

View File

@@ -47,17 +47,19 @@ func flattenLocationsList(ll *locations.ListLocations) []map[string]interface{}
res := make([]map[string]interface{}, 0, len(ll.Data))
for _, l := range ll.Data {
temp := map[string]interface{}{
"ckey": l.CKey,
"meta": flattens.FlattenMeta(l.Meta),
"auth_broker": l.AuthBroker,
"flag": l.Flag,
"gid": l.GID,
"guid": l.GUID,
"id": l.ID,
"location_code": l.LocationCode,
"name": l.Name,
"network_modes": l.NetworkModes,
"sdn_support": l.SDNSupport,
"ckey": l.CKey,
"meta": flattens.FlattenMeta(l.Meta),
"auth_broker": l.AuthBroker,
"flag": l.Flag,
"gid": l.GID,
"guid": l.GUID,
"id": l.ID,
"location_code": l.LocationCode,
"name": l.Name,
"network_modes": l.NetworkModes,
"sdn_support": l.SDNSupport,
"zero_access_enabled": l.ZeroAccessEnabled,
"bro_enabled": l.BROEnabled,
}
res = append(res, temp)
}
@@ -183,6 +185,14 @@ func dataSourceLocationsListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "support of SDN",
},
"zero_access_enabled": {
Type: schema.TypeBool,
Computed: true,
},
"bro_enabled": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},

View File

@@ -1,36 +1,36 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package locations
type Location struct {
GridID int `json:"gid"`
Id int `json:"id"`
Guid int `json:"guid"`
LocationCode string `json:"locationCode"`
Name string `json:"name"`
NetworkModes []string `json:"network_modes"`
SDNSupport bool `json:"sdn_support"`
Flag string `json:"flag"`
Meta []interface{} `json:"_meta"`
CKey string `json:"_ckey"`
}
type LocationsList []Location
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package locations
type Location struct {
GridID int `json:"gid"`
Id int `json:"id"`
Guid int `json:"guid"`
LocationCode string `json:"locationCode"`
Name string `json:"name"`
NetworkModes []string `json:"network_modes"`
SDNSupport bool `json:"sdn_support"`
Flag string `json:"flag"`
Meta []interface{} `json:"_meta"`
CKey string `json:"_ckey"`
}
type LocationsList []Location

View File

@@ -202,6 +202,10 @@ func DataSourceResgroup() *schema.Resource {
func aclSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"email": {
Type: schema.TypeString,
Computed: true,
},
"explicit": {
Type: schema.TypeBool,
Computed: true,

View File

@@ -269,6 +269,7 @@ func flattenRgAcl(rgAcls rg.ListACL) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(rgAcls))
for _, rgAcl := range rgAcls {
temp := map[string]interface{}{
"email": rgAcl.Email,
"explicit": rgAcl.Explicit,
"guid": rgAcl.GUID,
"right": rgAcl.Right,

View File

@@ -130,6 +130,9 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
}
if _, ok := d.GetOk("def_net"); !ok {
if defNetType, ok := d.GetOk("def_net_type"); ok {
if defNetType.(string) == "PRIVATE" {
return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use def_net_type=\"PRIVATE\" only when updating an existing RG that already contains a ViNS")
}
req.DefNet = defNetType.(string) // NOTE: in API default network type is set by "def_net" parameter
}
} else {
@@ -220,6 +223,10 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
netType := defNetItem["net_type"].(string)
if netType == "PRIVATE" {
return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use net_type=\"PRIVATE\" in def_net block only when updating an existing RG that already contains a ViNS")
}
req := rg.SetDefNetRequest{
RGID: apiResp,
NetType: netType,
@@ -504,14 +511,31 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter
for _, changedDefNetInterface := range changedDefNet {
defNetItem := changedDefNetInterface.(map[string]interface{})
netType := defNetItem["net_type"].(string)
netID := uint64(defNetItem["net_id"].(int))
if netType == "PRIVATE" {
if netID == 0 {
if len(rgData.VINS) == 0 {
return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: no ViNSes exist in this RG.", rgData.ID)
}
} else {
found := false
for _, vinsID := range rgData.VINS {
if vinsID == netID {
found = true
break
}
}
if !found {
return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: ViNS ID %d is not found in this RG.", rgData.ID, netID)
}
}
}
req := rg.SetDefNetRequest{
RGID: rgData.ID,
NetType: netType,
}
if netID, ok := defNetItem["net_id"]; ok {
req.NetID = uint64(netID.(int))
NetID: netID,
}
_, err := c.CloudAPI().RG().SetDefNet(ctx, req)

View File

@@ -6,7 +6,6 @@ import (
)
func flattenStoragePolicyData(d *schema.ResourceData, storagePolicy *stpolicy.InfoStoragePolicy) {
d.Set("storage_policy_id", storagePolicy.ID)
d.Set("description", storagePolicy.Description)
d.Set("guid", storagePolicy.GUID)
d.Set("limit_iops", storagePolicy.LimitIOPS)

View File

@@ -51,6 +51,10 @@ func dataSourceStoragePolicySchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"sep_tech_status": {
Type: schema.TypeString,
Computed: true,
},
},
},
},

View File

@@ -399,6 +399,7 @@ func flattenVins(d *schema.ResourceData, vins *vins.RecordVINS) {
d.Set("deleted_by", vins.DeletedBy)
d.Set("deleted_time", vins.DeletedTime)
d.Set("desc", vins.Description)
d.Set("enable_secgroups", vins.EnableSecGroups)
d.Set("gid", vins.GID)
d.Set("guid", vins.GUID)
d.Set("lock_status", vins.LockStatus)

View File

@@ -144,6 +144,8 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
req.ZoneID = uint64(zoneID.(int))
}
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
id, err := c.CloudAPI().VINS().CreateInRG(ctx, req)
if err != nil {
d.SetId("")
@@ -181,6 +183,8 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
req.ZoneID = uint64(zoneID.(int))
}
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
id, err := c.CloudAPI().VINS().CreateInAccount(ctx, req)
if err != nil {
d.SetId("")
@@ -908,6 +912,12 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "ID of the Zone to put ViNS into",
}
rets["enable_secgroups"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "enable security groups",
}
return rets
}

View File

@@ -129,7 +129,7 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"lb_ids": {
"lbs_ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
@@ -150,6 +150,50 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"drs": {
Type: schema.TypeBool,
Computed: true,
},
"drs_uid": {
Type: schema.TypeString,
Computed: true,
},
"drs_name": {
Type: schema.TypeString,
Computed: true,
},
"sso_url": {
Type: schema.TypeString,
Computed: true,
},
"app_id": {
Type: schema.TypeString,
Computed: true,
},
"decort_url": {
Type: schema.TypeString,
Computed: true,
},
"domain": {
Type: schema.TypeString,
Computed: true,
},
"ping_addr": {
Type: schema.TypeString,
Computed: true,
},
"broadcast_addr": {
Type: schema.TypeString,
Computed: true,
},
"ssl_skip_verify": {
Type: schema.TypeBool,
Computed: true,
},
"sso_type": {
Type: schema.TypeString,
Computed: true,
},
}
}

View File

@@ -158,6 +158,50 @@ func dataSourceZoneListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"drs": {
Type: schema.TypeBool,
Computed: true,
},
"drs_uid": {
Type: schema.TypeString,
Computed: true,
},
"drs_name": {
Type: schema.TypeString,
Computed: true,
},
"sso_url": {
Type: schema.TypeString,
Computed: true,
},
"app_id": {
Type: schema.TypeString,
Computed: true,
},
"decort_url": {
Type: schema.TypeString,
Computed: true,
},
"domain": {
Type: schema.TypeString,
Computed: true,
},
"ping_addr": {
Type: schema.TypeString,
Computed: true,
},
"broadcast_addr": {
Type: schema.TypeString,
Computed: true,
},
"ssl_skip_verify": {
Type: schema.TypeBool,
Computed: true,
},
"sso_type": {
Type: schema.TypeString,
Computed: true,
},
},
},
},

View File

@@ -56,10 +56,21 @@ func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error {
d.Set("compute_ids", item.ComputeIDs)
d.Set("extnet_ids", item.ExtnetIDs)
d.Set("vins_ids", item.VinsIDs)
d.Set("lb_ids", item.LBIDs)
d.Set("lbs_ids", item.LBIDs)
d.Set("bservice_ids", item.BserviceIDs)
d.Set("k8s_ids", item.K8SIDs)
d.Set("auto_start", item.AutoStart)
d.Set("drs", item.DRS)
d.Set("drs_uid", item.DRSUID)
d.Set("drs_name", item.DRSName)
d.Set("sso_url", item.SSOURL)
d.Set("app_id", item.AppID)
d.Set("decort_url", item.DecortURL)
d.Set("ping_addr", item.PingAddr)
d.Set("broadcast_addr", item.BroadcastAddr)
d.Set("ssl_skip_verify", item.SSLSkipVerify)
d.Set("domain", item.Domain)
d.Set("sso_type", item.SSOType)
log.Debugf("flattenZone: decoded RecordZone name %q / ID %d, complete",
item.Name, item.ID)
@@ -71,17 +82,28 @@ func flattenZoneList(zone *zone.ListZones) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(zone.Data))
for _, zone := range zone.Data {
temp := map[string]interface{}{
"zone_id": int(zone.ID),
"guid": int(zone.GUID),
"gid": int(zone.GID),
"name": zone.Name,
"description": zone.Description,
"deletable": zone.Deletable,
"status": zone.Status,
"created_time": zone.CreatedTime,
"updated_time": zone.UpdatedTime,
"node_ids": zone.NodeIDs,
"auto_start": zone.AutoStart,
"zone_id": int(zone.ID),
"guid": int(zone.GUID),
"gid": int(zone.GID),
"name": zone.Name,
"description": zone.Description,
"deletable": zone.Deletable,
"status": zone.Status,
"created_time": zone.CreatedTime,
"updated_time": zone.UpdatedTime,
"node_ids": zone.NodeIDs,
"auto_start": zone.AutoStart,
"drs": zone.DRS,
"drs_uid": zone.DRSUID,
"drs_name": zone.DRSName,
"sso_url": zone.SSOURL,
"app_id": zone.AppID,
"decort_url": zone.DecortURL,
"ping_addr": zone.PingAddr,
"broadcast_addr": zone.BroadcastAddr,
"ssl_skip_verify": zone.SSLSkipVerify,
"domain": zone.Domain,
"sso_type": zone.SSOType,
}
res = append(res, temp)
}

View File

@@ -1,62 +1,62 @@
/*
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 zone
import (
"context"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityZoneCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.RecordZone, error) {
c := m.(*controller.ControllerCfg)
req := zone.GetRequest{}
if d.Id() != "" {
zoneId, _ := strconv.ParseUint(d.Id(), 10, 64)
req.ID = zoneId
} else {
req.ID = uint64(d.Get("zone_id").(int))
}
zoneData, err := c.CloudAPI().Zone().Get(ctx, req)
if err != nil {
return nil, err
}
return zoneData, nil
}
/*
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 zone
import (
"context"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityZoneCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.RecordZone, error) {
c := m.(*controller.ControllerCfg)
req := zone.GetRequest{}
if d.Id() != "" {
zoneId, _ := strconv.ParseUint(d.Id(), 10, 64)
req.ID = zoneId
} else {
req.ID = uint64(d.Get("zone_id").(int))
}
zoneData, err := c.CloudAPI().Zone().Get(ctx, req)
if err != nil {
return nil, err
}
return zoneData, nil
}

View File

@@ -1,85 +1,85 @@
/*
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 zone
import (
"context"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityZoneListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.ListZones, error) {
c := m.(*controller.ControllerCfg)
req := zone.ListRequest{}
if byId, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(byId.(int))
}
if gid, ok := d.GetOk("gid"); ok {
req.GID = uint64(gid.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if description, ok := d.GetOk("description"); ok {
req.Description = description.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if deletable, ok := d.GetOk("deletable"); ok {
req.Deletable = deletable.(bool)
}
if nodeID, ok := d.GetOk("nodeId"); ok {
req.NodeID = uint64(nodeID.(int))
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
zoneList, err := c.CloudAPI().Zone().List(ctx, req)
if err != nil {
return nil, err
}
return zoneList, nil
}
/*
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 zone
import (
"context"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityZoneListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.ListZones, error) {
c := m.(*controller.ControllerCfg)
req := zone.ListRequest{}
if byId, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(byId.(int))
}
if gid, ok := d.GetOk("gid"); ok {
req.GID = uint64(gid.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if description, ok := d.GetOk("description"); ok {
req.Description = description.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if deletable, ok := d.GetOk("deletable"); ok {
req.Deletable = deletable.(bool)
}
if nodeID, ok := d.GetOk("nodeId"); ok {
req.NodeID = uint64(nodeID.(int))
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
zoneList, err := c.CloudAPI().Zone().List(ctx, req)
if err != nil {
return nil, err
}
return zoneList, nil
}

View File

@@ -29,6 +29,7 @@ func flattenResourceAccount(d *schema.ResourceData, acc *account.RecordAccount)
d.Set("send_access_emails", acc.SendAccessEmails)
d.Set("status", acc.Status)
d.Set("uniq_pools", acc.UniqPools)
d.Set("updated_by", acc.UpdatedBy)
d.Set("updated_time", acc.UpdatedTime)
d.Set("version", acc.Version)
d.Set("vins", acc.VINS)
@@ -61,6 +62,7 @@ func flattenDataAccount(d *schema.ResourceData, acc *account.RecordAccount) {
d.Set("storage_policy_ids", acc.StoragePolicyIDs)
d.Set("uniq_pools", acc.UniqPools)
d.Set("zone_ids", flattenZones(acc.ZoneIDs))
d.Set("updated_by", acc.UpdatedBy)
d.Set("updated_time", acc.UpdatedTime)
d.Set("version", acc.Version)
d.Set("vins", acc.VINS)
@@ -253,6 +255,7 @@ func flattenListDeleted(al *account.ListAccounts) []map[string]interface{} {
"uniq_pools": acc.UniqPools,
"default_zone_id": acc.DefaultZoneID,
"zone_ids": acc.ZoneIDs,
"updated_by": acc.UpdatedBy,
"updated_time": acc.UpdatedTime,
"version": acc.Version,
"vins": acc.VINS,
@@ -291,6 +294,7 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} {
"uniq_pools": acc.UniqPools,
"default_zone_id": acc.DefaultZoneID,
"zone_ids": acc.ZoneIDs,
"updated_by": acc.UpdatedBy,
"updated_time": acc.UpdatedTime,
"version": acc.Version,
"vins": acc.VINS,

View File

@@ -282,6 +282,10 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
@@ -723,6 +727,10 @@ func dataSourceAccountListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
@@ -1465,6 +1473,10 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
@@ -2331,6 +2343,10 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
},
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -1,38 +0,0 @@
package disks
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listTypesDetailed, err := utilityDiskListTypesDetailedCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed))
d.Set("entry_count", listTypesDetailed.EntryCount)
return nil
}
func DataSourceDiskListTypesDetailed() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceDiskListTypesDetailedRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceDiskListTypesDetailedSchemaMake(),
}
}

View File

@@ -14,6 +14,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("account_name", disk.AccountName)
d.Set("acl", string(diskAcl))
d.Set("blk_discard", disk.BLKDiscard)
d.Set("block_size", disk.BlockSize)
d.Set("boot_partition", disk.BootPartition)
d.Set("computes", flattenDiskComputes(disk.Computes))
d.Set("created_by", disk.CreatedBy)
@@ -29,6 +30,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("disk_id", disk.ID)
d.Set("image_id", disk.ImageID)
d.Set("images", disk.Images)
d.Set("independent", disk.Independent)
d.Set("iotune", flattenIOTune(disk.IOTune))
d.Set("iqn", disk.IQN)
d.Set("login", disk.Login)
@@ -44,6 +46,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("pool", disk.Pool)
d.Set("purge_attempts", disk.PurgeAttempts)
d.Set("present_to", disk.PresentTo)
d.Set("provision", disk.Provision)
d.Set("purge_time", disk.PurgeTime)
d.Set("replication", flattenDiskReplication(disk.Replication))
d.Set("reality_device_number", disk.RealityDeviceNumber)
@@ -62,7 +65,6 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
d.Set("status", disk.Status)
d.Set("storage_policy_id", disk.StoragePolicyID)
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
d.Set("updated_by", disk.UpdatedBy)
d.Set("updated_time", disk.UpdatedTime)
@@ -117,7 +119,6 @@ func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusRe
d.Set("status", disk.Status)
d.Set("status_replication", statusReplication)
d.Set("tech_status", disk.TechStatus)
d.Set("type", disk.Type)
d.Set("vmid", disk.VMID)
}
@@ -187,6 +188,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"account_name": disk.AccountName,
"acl": string(diskAcl),
"blk_discard": disk.BLKDiscard,
"block_size": disk.BlockSize,
"boot_partition": disk.BootPartition,
"computes": flattenDiskComputes(disk.Computes),
"created_by": disk.CreatedBy,
@@ -202,6 +204,7 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"disk_id": disk.ID,
"image_id": disk.ImageID,
"images": disk.Images,
"independent": disk.Independent,
"iotune": flattenIOTune(disk.IOTune),
"iqn": disk.IQN,
"login": disk.Login,
@@ -217,6 +220,8 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"pool": disk.Pool,
"purge_attempts": disk.PurgeAttempts,
"purge_time": disk.PurgeTime,
"present_to": disk.PresentTo,
"provision": disk.Provision,
"replication": flattenDiskReplication(disk.Replication),
"reality_device_number": disk.RealityDeviceNumber,
"reference_id": disk.ReferenceID,
@@ -234,7 +239,6 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
"status": disk.Status,
"storage_policy_id": disk.StoragePolicyID,
"tech_status": disk.TechStatus,
"type": disk.Type,
"vmid": disk.VMID,
"updated_by": disk.UpdatedBy,
"updated_time": disk.UpdatedTime,
@@ -243,7 +247,6 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
res = append(res, temp)
}
return res
}
func flattendDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
@@ -261,36 +264,6 @@ func flattendDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
res = append(res, temp)
}
return res
}
func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, typeListDetailed := range tld.Data {
toMap := typeListDetailed.(map[string]interface{})
temp := map[string]interface{}{
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
"sep_id": toMap["sepId"].(float64),
"sep_name": toMap["sepName"].(string),
}
res = append(res, temp)
}
return res
}
func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
res := make([]interface{}, 0)
for _, pool := range pools {
toMap := pool.(map[string]interface{})
temp := map[string]interface{}{
"name": toMap["name"].(string),
"system": toMap["system"].(string),
"types": toMap["types"].([]interface{}),
}
res = append(res, temp)
}
return res
}
@@ -304,6 +277,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter
"account_name": unattachedDisk.AccountName,
"acl": string(unattachedDiskAcl),
"blk_discard": unattachedDisk.BLKDiscard,
"block_size": unattachedDisk.BlockSize,
"boot_partition": unattachedDisk.BootPartition,
"created_time": unattachedDisk.CreatedTime,
"deleted_time": unattachedDisk.DeletedTime,
@@ -327,6 +301,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter
"pci_slot": unattachedDisk.PCISlot,
"pool": unattachedDisk.Pool,
"present_to": unattachedDisk.PresentTo,
"provision": unattachedDisk.Provision,
"purge_attempts": unattachedDisk.PurgeAttempts,
"purge_time": unattachedDisk.PurgeTime,
"reality_device_number": unattachedDisk.RealityDeviceNumber,
@@ -342,7 +317,7 @@ func flattenDiskListUnattached(ul *disks.ListUnattachedDisks) []map[string]inter
"snapshots": flattenDiskSnapshotList(unattachedDisk.Snapshots),
"status": unattachedDisk.Status,
"tech_status": unattachedDisk.TechStatus,
"type": unattachedDisk.Type,
"to_clean": unattachedDisk.ToClean,
"vmid": unattachedDisk.VMID,
}
res = append(res, tmp)

View File

@@ -102,6 +102,12 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
log.Debugf("resourceDiskCreate: finished present for disk %d", d.Get("disk_id"))
}
if _, ok := d.GetOk("block_size"); ok {
if err := resourceDiskChangeBlockSize(ctx, d, m); err != nil {
w.Add(err)
}
}
if _, ok := d.GetOk("iotune"); ok {
if err := resourceDiskChangeIotune(ctx, d, m); err != nil {
w.Add(err)
@@ -244,14 +250,20 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
}
}
if d.HasChange("cache") {
if err := resourceDiskChangeCache(ctx, d, m); err != nil {
return diag.FromErr(err)
if d.HasChanges("cache", "blk_discard", "block_size") {
updateReq := disks.UpdateRequest{
DiskID: uint64(d.Get("disk_id").(int)),
}
}
if d.HasChange("blk_discard") {
if err := resourceDiskChangeBLKDiscard(ctx, d, m); err != nil {
if d.HasChange("cache") {
updateReq.Cache = d.Get("cache").(string)
}
if d.HasChange("blk_discard") {
updateReq.BLKDiscard = d.Get("blk_discard").(bool)
}
if d.HasChange("block_size") {
updateReq.BlockSize = d.Get("block_size").(string)
}
if _, err := c.CloudBroker().Disks().Update(ctx, updateReq); err != nil {
return diag.FromErr(err)
}
}
@@ -382,22 +394,12 @@ func resourceDiskChangeStoragePolicyID(ctx context.Context, d *schema.ResourceDa
return err
}
func resourceDiskChangeCache(ctx context.Context, d *schema.ResourceData, m interface{}) error {
func resourceDiskChangeBlockSize(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
_, err := c.CloudBroker().Disks().Update(ctx, disks.UpdateRequest{
DiskID: uint64(d.Get("disk_id").(int)),
Cache: d.Get("cache").(string),
})
return err
}
func resourceDiskChangeBLKDiscard(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
_, err := c.CloudBroker().Disks().Update(ctx, disks.UpdateRequest{
DiskID: uint64(d.Get("disk_id").(int)),
BLKDiscard: d.Get("blk_discard").(bool),
DiskID: uint64(d.Get("disk_id").(int)),
BlockSize: d.Get("block_size").(string),
})
return err
}

View File

@@ -2,6 +2,7 @@ package disks
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func dataSourceDiskSchemaMake() map[string]*schema.Schema {
@@ -26,6 +27,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -97,6 +102,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -212,6 +221,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
@@ -350,10 +363,6 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
@@ -412,11 +421,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "ID of the account the disks belong to",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
@@ -447,6 +451,16 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "storage policy ID ",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by rg id",
},
"compute_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by compute id",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -468,6 +482,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -543,6 +561,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -658,6 +680,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
@@ -796,10 +822,6 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
@@ -859,11 +881,6 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "ID of the account the disks belong to",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
@@ -900,6 +917,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -975,6 +996,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Computed: true,
@@ -1090,6 +1115,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
@@ -1228,10 +1257,6 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
Computed: true,
@@ -1259,105 +1284,6 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema {
return res
}
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Pool name",
},
"system": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
},
},
},
"sep_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Storage endpoint provider ID to create disk",
},
"sep_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
}
func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"by_id": {
@@ -1380,11 +1306,6 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Find by status",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "type of the disks",
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
@@ -1450,6 +1371,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -1638,6 +1563,10 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,
@@ -1748,10 +1677,9 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Technical status of the disk",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
"vmid": {
Type: schema.TypeInt,
@@ -1952,11 +1880,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Required: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
@@ -2008,6 +1931,12 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Optional: true,
Default: false,
},
"block_size": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"512", "512e", "4k"}, false),
},
"account_name": {
Type: schema.TypeString,
Computed: true,
@@ -2079,6 +2008,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Optional: true,
@@ -2201,6 +2134,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"purge_attempts": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -33,7 +33,6 @@ package disks
import (
"context"
"strings"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
@@ -67,9 +66,6 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = strings.ToUpper(diskType.(string))
}
if pool, ok := d.GetOk("pool"); ok {
req.Pool = pool.(string)
}
@@ -88,6 +84,12 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok {
req.StoragePolicyID = uint64(storagePolicyID.(int))
}
if rgID, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rgID.(int))
}
if computeID, ok := d.GetOk("compute_id"); ok {
req.ComputeID = uint64(computeID.(int))
}
log.Debugf("utilityDiskListCheckPresence: load disk list")
diskList, err := c.CloudBroker().Disks().List(ctx, req)

View File

@@ -65,9 +65,6 @@ func utilityDiskListDeletedCheckPresence(ctx context.Context, d *schema.Resource
if account_id, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(account_id.(int))
}
if typev, ok := d.GetOk("type"); ok {
req.Type = typev.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}

View File

@@ -1,35 +0,0 @@
package disks
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
c := m.(*controller.ControllerCfg)
req := disks.ListTypesRequest{
Detailed: false,
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
typesList, err := c.CloudBroker().Disks().ListTypes(ctx, req)
if err != nil {
return nil, err
}
return typesList, nil
}

View File

@@ -1,38 +0,0 @@
package disks
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*disks.ListTypes, error) {
c := m.(*controller.ControllerCfg)
req := disks.ListTypesRequest{
Detailed: true,
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed")
listTypesDetailed, err := c.CloudBroker().Disks().ListTypes(ctx, req)
log.Debugf("%+v", listTypesDetailed.Data[0].(map[string]interface{}))
if err != nil {
return nil, err
}
return listTypesDetailed, nil
}

View File

@@ -25,9 +25,6 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = diskType.(string)
}
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}

View File

@@ -78,6 +78,8 @@ func resourceDPDKNetCreate(ctx context.Context, d *schema.ResourceData, m interf
}
}
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
dpdkID, err := c.CloudBroker().DPDKNet().Create(ctx, req)
if err != nil {
d.SetId("")
@@ -93,17 +95,6 @@ func resourceDPDKNetCreate(ctx context.Context, d *schema.ResourceData, m interf
warnings.Add(err)
}
if d.Get("enable_secgroups").(bool) {
req := dpdk.UpdateRequest{
DPDKID: dpdkID,
EnableSecGroups: true,
}
_, err := c.CloudBroker().DPDKNet().Update(ctx, req)
if err != nil {
warnings.Add(err)
}
}
return append(warnings.Get(), resourceDPDKNetRead(ctx, d, m)...)
}

View File

@@ -136,6 +136,8 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa
req.MTU = uint(mtu.(int))
}
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
log.Debugf("cloudbroker: Sent create request")
netID, err := c.CloudBroker().ExtNet().Create(ctx, req)
if err != nil {
@@ -234,18 +236,6 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa
}
}
if d.Get("enable_secgroups").(bool) {
log.Debugf("resourceExtnetCreate: trying to enable secgroups for extnet with ID %d", netID)
req := extnet.UpdateRequest{
NetID: netID,
EnableSecGroups: true,
}
_, err := c.CloudBroker().ExtNet().Update(ctx, req)
if err != nil {
w.Add(err)
}
}
return resourceExtnetRead(ctx, d, m)
}

View File

@@ -68,6 +68,34 @@ func flattenFlipgroup(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) {
d.Set("updated_time", flip.UpdatedTime)
}
func flattenFlipgroupResource(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) {
d.Set("flipgroup_id", flip.ID)
d.Set("account_id", flip.AccountID)
d.Set("account_name", flip.AccountName)
d.Set("client_ids", flip.ClientIDs)
d.Set("client_names", flip.ClientNames)
d.Set("client_type", flip.ClientType)
d.Set("conn_id", flip.ConnID)
d.Set("conn_type", flip.ConnType)
d.Set("created_by", flip.CreatedBy)
d.Set("created_time", flip.CreatedTime)
d.Set("default_gw", flip.DefaultGW)
d.Set("deleted_by", flip.DeletedBy)
d.Set("deleted_time", flip.DeletedTime)
d.Set("desc", flip.Description)
d.Set("gid", flip.GID)
d.Set("guid", flip.GUID)
d.Set("ip", flip.IP)
d.Set("milestones", flip.Milestones)
d.Set("name", flip.Name)
d.Set("net_id", flip.NetID)
d.Set("net_type", flip.NetType)
d.Set("network", flip.Network)
d.Set("status", flip.Status)
d.Set("updated_by", flip.UpdatedBy)
d.Set("updated_time", flip.UpdatedTime)
}
func flattenFlipgroupsList(fg *flipgroup.ListFLIPGroups) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(fg.Data))
for _, flip := range fg.Data {

View File

@@ -110,9 +110,9 @@ func resourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interf
return diag.Errorf("The flipgroup status is destroyed and cannot be read.")
}
flattenFlipgroup(d, fg)
flattenFlipgroupResource(d, fg)
log.Debugf("resourceFlipgroupRead: after flattenFlipgroup: flipgroup_id %s, name %s",
log.Debugf("resourceFlipgroupRead: after flattenFlipgroupResource: flipgroup_id %s, name %s",
d.Id(), d.Get("name").(string))
return nil

View File

@@ -27,16 +27,17 @@ func flattenGridList(gl *grid.ListGrids) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(gl.Data))
for _, item := range gl.Data {
temp := map[string]interface{}{
"resources": flattenGridResources(item.Resources),
"name": item.Name,
"auth_broker": flattens.FlattenMeta(item.AuthBroker),
"flag": item.Flag,
"gid": item.GID,
"guid": item.GUID,
"location_code": item.LocationCode,
"id": item.ID,
"network_modes": item.NetworkModes,
"sdn_support": item.SDNSupport,
"resources": flattenGridResources(item.Resources),
"name": item.Name,
"auth_broker": flattens.FlattenMeta(item.AuthBroker),
"flag": item.Flag,
"gid": item.GID,
"guid": item.GUID,
"location_code": item.LocationCode,
"id": item.ID,
"network_modes": item.NetworkModes,
"sdn_support": item.SDNSupport,
"zero_access_enabled": item.ZeroAccessEnabled,
}
res = append(res, temp)
}

View File

@@ -260,6 +260,10 @@ func dataSourceGridListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"zero_access_enabled": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},

View File

@@ -20,6 +20,7 @@ import (
cb_trunk "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/trunk"
cb_vfpool "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vfpool"
cb_vins "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vins"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
@@ -595,14 +596,21 @@ func ExistK8s(ctx context.Context, k8sId uint64, c *controller.ControllerCfg) er
return nil
}
func IsMoreThanOneDisksTypeB(ctx context.Context, disks interface{}) error {
func IsMoreThanOneDisksTypeB(ctx context.Context, disks interface{}, chipset string) error {
count := 0
key := "bus_number"
if chipset == "i440fx" {
key = "pci_slot"
}
for _, elem := range disks.([]interface{}) {
diskVal := elem.(map[string]interface{})
if diskVal["disk_type"].(string) == "B" {
if val, ok := diskVal[key].(int); ok && val == 6 {
count++
}
if count > 1 {
return fmt.Errorf("block disks have more 1 disk type 'B'")
}
@@ -648,9 +656,16 @@ func ExistBlankCompute(ctx context.Context, computeId uint64, m interface{}) err
computeImageId := computeRecord.ImageID
bootImageId := -1
for _, d := range computeRecord.Disks {
if d.Type == "B" {
bootImageId = int(d.ImageID)
break
if computeRecord.Chipset == "i440fx" {
if d.PCISlot == 6 {
bootImageId = int(d.ImageID)
break
}
} else {
if d.BusNumber == 6 {
bootImageId = int(d.ImageID)
break
}
}
}
@@ -679,3 +694,20 @@ func ExistPlatformDisk(ctx context.Context, diskId uint64, m interface{}) error
return nil
}
func ExistSDNNet(ctx context.Context, sdnIds []string, c *controller.ControllerCfg) []error {
var errs []error
for _, uniqueIdentifier := range sdnIds {
if uniqueIdentifier == "" {
continue
}
req := logicalports.GetByUniqueIdentifierRequest{ID: uniqueIdentifier}
_, err := c.SDN().LogicalPorts().GetByUniqueIdentifier(ctx, req)
if err != nil {
errs = append(errs, fmt.Errorf("SDN logical port with unique identifier %q not found", uniqueIdentifier))
}
}
return errs
}

View File

@@ -30,8 +30,10 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
d.Set("guid", img.GUID)
d.Set("history", flattenHistory(img.History))
d.Set("hot_resize", img.HotResize)
d.Set("independent", img.Independent)
d.Set("last_modified", img.LastModified)
d.Set("link_to", img.LinkTo)
d.Set("links_to", img.LinksTo)
d.Set("milestones", img.Milestones)
d.Set("name", img.Name)
d.Set("network_interface_naming", img.NetworkInterfaceNaming)
@@ -52,6 +54,7 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) {
d.Set("storage_policy_id", img.StoragePolicyID)
d.Set("tech_status", img.TechStatus)
d.Set("to_clean", img.ToClean)
d.Set("target_ids", img.LinksTo)
d.Set("image_type", img.Type)
d.Set("url", img.URL)
d.Set("username", img.Username)
@@ -111,8 +114,10 @@ func flattenImageList(il *image.ListImages) []map[string]interface{} {
"guid": item.GUID,
"history": flattenHistory(item.History),
"hot_resize": item.HotResize,
"independent": item.Independent,
"last_modified": item.LastModified,
"link_to": item.LinkTo,
"links_to": item.LinksTo,
"milestones": item.Milestones,
"name": item.Name,
"network_interface_naming": item.NetworkInterfaceNaming,

View File

@@ -59,10 +59,11 @@ func resourceImageFromBlankComputeCreate(ctx context.Context, d *schema.Resource
}
req := compute.CreateTemplateFromBlankRequest{
ComputeID: uint64(d.Get("compute_id").(int)),
Name: d.Get("name").(string),
BootType: d.Get("boot_type").(string),
ImageType: d.Get("image_type").(string),
ComputeID: uint64(d.Get("compute_id").(int)),
Name: d.Get("name").(string),
BootType: d.Get("boot_type").(string),
ImageType: d.Get("image_type").(string),
StoragePolicyID: uint64(d.Get("storage_policy_id").(int)),
}
if username, ok := d.GetOk("username"); ok {

View File

@@ -0,0 +1,274 @@
package image
import (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
"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/dc"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
)
func resourceMultiImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceMultiImageCreate: called for image %s", d.Get("name").(string))
c := m.(*controller.ControllerCfg)
targetIDsRaw := d.Get("target_ids").([]interface{})
targetIDs := make([]uint64, 0, len(targetIDsRaw))
for _, id := range targetIDsRaw {
targetIDs = append(targetIDs, uint64(id.(int)))
}
req := image.CreateMultiImageRequest{
Name: d.Get("name").(string),
TargetIDs: targetIDs,
AccountID: uint64(d.Get("account_id").(int)),
}
imageId, err := c.CloudBroker().Image().CreateMultiImage(ctx, req)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(imageId, 10))
d.Set("image_id", imageId)
var w dc.Warnings
if !d.Get("enabled").(bool) {
if err := resourceImageChangeEnabled(ctx, d, m); err != nil {
w.Add(err)
}
}
if _, ok := d.GetOk("shared_with"); ok {
if err := resourceImageShare(ctx, d, m); err != nil {
w.Add(err)
}
}
if _, ok := d.GetOk("computeci_id"); ok {
if err := resourceImageChangeComputeci(ctx, d, m); err != nil {
w.Add(err)
}
}
updReq := image.EditRequest{}
updReq.ImageID = uint64(d.Get("image_id").(int))
if _, ok := d.GetOk("username"); ok {
updReq.Username = d.Get("username").(string)
}
if _, ok := d.GetOk("password"); ok {
updReq.Password = d.Get("password").(string)
}
if _, ok := d.GetOk("account_id"); ok {
updReq.AccountID = uint64(d.Get("account_id").(int))
}
if _, ok := d.GetOkExists("bootable"); ok {
updReq.Bootable = d.Get("bootable").(bool)
}
if _, ok := d.GetOkExists("hot_resize"); ok {
updReq.HotResize = d.Get("hot_resize").(bool)
}
if _, ok := d.GetOk("network_interface_naming"); ok {
updReq.NetworkInterfaceNaming = d.Get("network_interface_naming").(string)
}
_, err = c.CloudBroker().Image().Edit(ctx, updReq)
if err != nil {
w.Add(err)
}
return append(resourceMultiImageRead(ctx, d, m), w.Get()...)
}
func resourceMultiImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceMultiImageRead: called for %s id: %s", d.Get("name").(string), d.Id())
img, err := utilityImageCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
switch img.Status {
case status.Modeled:
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
case status.Destroyed, status.Purged:
d.SetId("")
return diag.Errorf("The resource cannot be updated because it has been destroyed")
}
flattenImage(d, img)
return nil
}
func resourceMultiImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceMultiImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
_, err := utilityImageCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
c := m.(*controller.ControllerCfg)
req := image.DeleteRequest{
ImageID: uint64(d.Get("image_id").(int)),
}
_, err = c.CloudBroker().Image().Delete(ctx, req)
if err != nil {
return diag.FromErr(err)
}
d.SetId("")
return nil
}
func resourceMultiImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceMultiImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
img, err := utilityImageCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
switch img.Status {
case status.Modeled:
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
case status.Destroyed, status.Purged:
d.SetId("")
return diag.Errorf("The resource cannot be updated because it has been destroyed")
}
if d.HasChange("enabled") {
err := resourceImageChangeEnabled(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("shared_with") {
err := resourceImageShare(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("computeci_id") {
err := resourceImageChangeComputeci(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
if d.HasChanges("name", "username", "password", "account_id", "bootable", "hot_resize") {
err := resourceImageEdit(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("target_ids") {
err := resourceMultiImageUpdateLinks(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
return resourceMultiImageRead(ctx, d, m)
}
func resourceMultiImageUpdateLinks(ctx context.Context, d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceMultiImageUpdateLinks: called for %s, id: %s", d.Get("name").(string), d.Id())
c := m.(*controller.ControllerCfg)
imageID := uint64(d.Get("image_id").(int))
oldRaw, newRaw := d.GetChange("target_ids")
oldIDs := oldRaw.([]interface{})
newIDs := newRaw.([]interface{})
oldSet := make(map[uint64]bool)
for _, id := range oldIDs {
oldSet[uint64(id.(int))] = true
}
newSet := make(map[uint64]bool)
for _, id := range newIDs {
newSet[uint64(id.(int))] = true
}
toAdd := make([]uint64, 0)
for id := range newSet {
if !oldSet[id] {
toAdd = append(toAdd, id)
}
}
toRemove := make([]uint64, 0)
for id := range oldSet {
if !newSet[id] {
toRemove = append(toRemove, id)
}
}
if len(toAdd) > 0 {
req := image.MultiImageAddLinksRequest{
ImageID: imageID,
TargetIDs: toAdd,
}
_, err := c.CloudBroker().Image().MultiImageAddLinks(ctx, req)
if err != nil {
return err
}
}
if len(toRemove) > 0 {
req := image.MultiImageDelLinksRequest{
ImageID: imageID,
TargetIDs: toRemove,
}
_, err := c.CloudBroker().Image().MultiImageDelLinks(ctx, req)
if err != nil {
return err
}
}
return nil
}
func ResourceMultiImage() *schema.Resource {
return &schema.Resource{
SchemaVersion: 2,
CreateContext: resourceMultiImageCreate,
ReadContext: resourceMultiImageRead,
UpdateContext: resourceMultiImageUpdate,
DeleteContext: resourceMultiImageDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout600s,
Read: &constants.Timeout300s,
Update: &constants.Timeout300s,
Delete: &constants.Timeout300s,
Default: &constants.Timeout300s,
},
Schema: resourceMultiImageSchemaMake(),
}
}

View File

@@ -252,6 +252,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "image id",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"last_modified": {
Type: schema.TypeInt,
Computed: true,
@@ -260,6 +264,13 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
@@ -518,6 +529,10 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Does this machine supports hot resize",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"last_modified": {
Type: schema.TypeInt,
Computed: true,
@@ -526,6 +541,13 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
@@ -751,10 +773,12 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema {
},
"status": {
Type: schema.TypeString,
Computed: true},
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true},
Computed: true,
},
"user_group_id": {
Type: schema.TypeString,
Computed: true,
@@ -1037,10 +1061,12 @@ func resourceImageSchemaMake() map[string]*schema.Schema {
},
"status": {
Type: schema.TypeString,
Computed: true},
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true},
Computed: true,
},
"user_group_id": {
Type: schema.TypeString,
Computed: true,
@@ -1072,11 +1098,22 @@ func resourceImageSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "image id",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"link_to": {
Type: schema.TypeInt,
Computed: true,
Description: "",
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
@@ -1334,6 +1371,10 @@ func resourceVirtualImageSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Image id",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"last_modified": {
Type: schema.TypeInt,
Computed: true,
@@ -1425,6 +1466,259 @@ func resourceVirtualImageSchemaMake() map[string]*schema.Schema {
}
}
func resourceMultiImageSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"target_ids": {
Type: schema.TypeList,
Required: true,
Description: "IDs of real images to link this multi image to",
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"name": {
Type: schema.TypeString,
Required: true,
Description: "Name of the multi image",
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Account id 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,
Default: 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,
},
},
"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,
},
},
},
},
"architecture": {
Type: schema.TypeString,
Computed: true,
},
"boot_type": {
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,
},
},
},
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"last_modified": {
Type: schema.TypeInt,
Computed: true,
},
"link_to": {
Type: schema.TypeInt,
Computed: true,
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"pool_name": {
Type: schema.TypeString,
Computed: true,
},
"present_to": {
Type: schema.TypeMap,
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,
},
"size": {
Type: schema.TypeInt,
Computed: true,
},
"snapshot_id": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
"image_type": {
Type: schema.TypeString,
Computed: true,
},
"url": {
Type: schema.TypeString,
Computed: true,
},
"version": {
Type: schema.TypeString,
Computed: true,
},
}
}
func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"compute_id": {
@@ -1437,6 +1731,11 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "Name of the rescue disk",
},
"storage_policy_id": {
Type: schema.TypeInt,
Required: true,
Description: "Storage policy ID",
},
"boot_type": {
Type: schema.TypeString,
Required: true,
@@ -1550,10 +1849,12 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
},
"status": {
Type: schema.TypeString,
Computed: true},
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true},
Computed: true,
},
"user_group_id": {
Type: schema.TypeString,
Computed: true,
@@ -1620,6 +1921,13 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
@@ -1815,10 +2123,12 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
},
"status": {
Type: schema.TypeString,
Computed: true},
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true},
Computed: true,
},
"user_group_id": {
Type: schema.TypeString,
Computed: true,
@@ -1881,6 +2191,13 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"links_to": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"milestones": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -1466,14 +1466,14 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "insert ssl certificate in x509 pem format",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"lb_sysctl_params": {
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"lb_sysctl_params": {
Type: schema.TypeList,
Optional: true,
Description: "Custom sysctl values for Load Balancer instance. Applied on boot.",
@@ -1810,19 +1810,19 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
),
Description: "Node RAM in MB.",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"disk": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.",
},
"chipset": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
Default: "Q35",
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
},
"disk": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.",
},
"labels": {
Type: schema.TypeList,
Computed: true,

View File

@@ -18,7 +18,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
customFields, _ := json.Marshal(computeRec.CustomFields)
devices, _ := json.Marshal(computeRec.Devices)
userData, _ := json.Marshal(computeRec.Userdata)
bootDisk := findBootDisk(computeRec.Disks)
bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset)
if len(computeRec.Interfaces) > 0 {
log.Debugf("flattenCompute: calling parseComputeInterfacesToNetworks for %d interfaces", len(computeRec.Interfaces))
@@ -113,6 +113,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
d.Set("cpu_pin", computeRec.CPUPin)
d.Set("numa_affinity", computeRec.NumaAffinity)
d.Set("hp_backed", computeRec.HPBacked)
d.Set("weight", computeRec.Weight)
return nil
}
@@ -269,10 +270,12 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
"node_ids": nodeIds,
"size": disk.SizeMax,
"sep_id": disk.SEPID,
"disk_type": disk.Type,
"pci_slot": disk.PCISlot,
"bus_number": disk.BusNumber,
"pool": disk.Pool,
"desc": disk.Description,
"image_id": disk.ImageID,
"independent": disk.Independent,
"disk_id": disk.ID,
"shareable": disk.Shareable,
"size_used": disk.SizeUsed,
@@ -289,6 +292,8 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks []
"update_time": disk.UpdatedTime,
"cache": disk.Cache,
"blk_discard": disk.BLKDiscard,
"block_size": disk.BlockSize,
"provision": disk.Provision,
"iotune": flattenIOTune(disk.IOTune),
}
res = append(res, temp)
@@ -408,6 +413,7 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"hot_resize": computeItem.HotResize,
"network_interface_naming": computeItem.NetworkInterfaceNaming,
"zone_id": computeItem.ZoneID,
"weight": computeItem.Weight,
}
res = append(res, temp)
}
@@ -495,6 +501,7 @@ func flattenDeletedComputeList(computes *compute.ListDeletedComputes) []map[stri
"hot_resize": computeItem.HotResize,
"network_interface_naming": computeItem.NetworkInterfaceNaming,
"zone_id": computeItem.ZoneID,
"weight": computeItem.Weight,
}
res = append(res, temp)
}
@@ -842,8 +849,9 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute
d.Set("zone_id", compFacts.ZoneID)
d.Set("loader_meta_iso", flattenLoaderMetaIso(compFacts.LoaderMetaIso))
d.Set("os_version", compFacts.OSVersion)
d.Set("weight", compFacts.Weight)
//extra fields setting
bootDisk := findBootDisk(compFacts.Disks)
bootDisk := findBootDisk(compFacts.Disks, compFacts.Chipset)
if bootDisk != nil {
d.Set("boot_disk_size", bootDisk.SizeMax)
d.Set("boot_disk_id", bootDisk.ID) // we may need boot disk ID in resize operations
@@ -900,6 +908,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
"meta": flattens.FlattenMeta(disk.Meta),
"account_id": disk.AccountID,
"blk_discard": disk.BLKDiscard,
"block_size": disk.BlockSize,
"boot_partition": disk.BootPartition,
"bus_number": disk.BusNumber,
"created_time": disk.CreatedTime,
@@ -915,6 +924,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
"disk_id": disk.ID,
"image_id": disk.ImageID,
"images": disk.Images,
"independent": disk.Independent,
"iotune": flattenIOTune(disk.IOTune),
"iqn": disk.IQN,
"login": disk.Login,
@@ -945,6 +955,7 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} {
"tech_status": disk.TechStatus,
"type": disk.Type,
"to_clean": disk.ToClean,
"provision": disk.Provision,
"updated_time": disk.UpdatedTime,
}
res = append(res, temp)

View File

@@ -17,8 +17,10 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro
errs = append(errs, err)
}
if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil {
errs = append(errs, err)
if !d.Get("create_blank").(bool) {
if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil {
errs = append(errs, err)
}
}
if netErrs := existNetworks(ctx, d, c); errs != nil {
@@ -26,7 +28,7 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro
}
if disks, ok := d.GetOk("disks"); ok {
if err := ic.IsMoreThanOneDisksTypeB(ctx, disks); err != nil {
if err := ic.IsMoreThanOneDisksTypeB(ctx, disks, d.Get("chipset").(string)); err != nil {
errs = append(errs, err)
}
}
@@ -37,8 +39,7 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro
func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg) []error {
var errs []error
var vinsIds, extNetIds, vfpoolIds, dpdkIds, trunkIds []uint64
//TODO
//var sdnIds []string
var sdnIds []string
networksIface, ok := d.GetOk("network")
if !ok {
@@ -60,10 +61,8 @@ func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.Co
dpdkIds = append(dpdkIds, uint64(network["net_id"].(int)))
case "TRUNK":
trunkIds = append(trunkIds, uint64(network["net_id"].(int)))
//TODO
//case "SDN": sdnIds = append(sdnIds, network["sdn_interface_id"].(string))
case "SDN":
sdnIds = append(sdnIds, network["sdn_interface_id"].(string))
default:
continue
}
@@ -89,10 +88,9 @@ func existNetworks(ctx context.Context, d *schema.ResourceData, c *controller.Co
errs = append(errs, trunkErrs...)
}
//TODO
//if sdnErrs := ic.ExistSDNNet(ctx, sdnIds, c); sdnErrs != nil {
// errs = append(errs, sdnErrs...)
//}
if sdnErrs := ic.ExistSDNNet(ctx, sdnIds, c); sdnErrs != nil {
errs = append(errs, sdnErrs...)
}
return errs
}

View File

@@ -77,10 +77,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
createReqX86.NodeID = uint64(nodeID.(int))
}
if ipaType, ok := d.GetOk("ipa_type"); ok {
createReqX86.IPAType = ipaType.(string)
}
if bootSize, ok := d.GetOk("boot_disk_size"); ok {
createReqX86.BootDisk = uint64(bootSize.(int))
}
@@ -89,10 +85,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
createReqX86.BootDiskCache = bootDiskCache.(string)
}
if IS, ok := d.GetOk("is"); ok {
createReqX86.IS = IS.(string)
}
if zoneID, ok := d.GetOk("zone_id"); ok {
createReqX86.ZoneID = uint64(zoneID.(int))
}
@@ -130,7 +122,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
reqInterface.Enabled = netInterfaceVal["enabled"].(bool)
}
if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" {
if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" || reqInterface.NetType == "TRUNK" {
reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int))
}
@@ -251,7 +243,33 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
}
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
apiResp, err := c.CloudBroker().KVMX86().Create(ctx, createReqX86)
var apiResp uint64
var err error
if d.Get("create_blank").(bool) {
log.Debugf("resourceComputeCreate: using createBlank endpoint")
createBlankReq := kvmx86.CreateBlankRequest{
RGID: createReqX86.RGID,
Name: createReqX86.Name,
CPU: createReqX86.CPU,
RAM: createReqX86.RAM,
StoragePolicyID: createReqX86.StoragePolicyID,
WithoutBootDisk: createReqX86.WithoutBootDisk,
BootDisk: createReqX86.BootDisk,
SEPID: createReqX86.SEPID,
Pool: createReqX86.Pool,
DataDisks: createReqX86.DataDisks,
Interfaces: createReqX86.Interfaces,
Description: createReqX86.Description,
Chipset: createReqX86.Chipset,
PreferredCPU: createReqX86.PreferredCPU,
ZoneID: createReqX86.ZoneID,
OSVersion: createReqX86.OSVersion,
}
apiResp, err = c.CloudBroker().KVMX86().CreateBlank(ctx, createBlankReq)
} else {
apiResp, err = c.CloudBroker().KVMX86().Create(ctx, createReqX86)
}
if err != nil {
return diag.FromErr(err)
}
@@ -291,6 +309,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
bootType, bootTypeOk := d.GetOk("boot_type")
hotResize, hotResizeOk := d.GetOkExists("hot_resize")
networkInterfaceNaming, networkInterfaceNamingOk := d.GetOk("network_interface_naming")
weight, weightOk := d.GetOk("weight")
if loaderTypeOk {
updateReq.LoaderType = loaderType.(string)
@@ -308,8 +327,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
updateReq.NetworkInterfaceNaming = networkInterfaceNaming.(string)
}
if loaderTypeOk || bootTypeOk || hotResizeOk || networkInterfaceNamingOk {
log.Debugf("resourceComputeCreate: change loaderType or bootType or hotResize or networkInterfaceNaming on ComputeID: %d", computeId)
if weightOk {
updateReq.Weight = uint64(weight.(int))
}
if loaderTypeOk || bootTypeOk || hotResizeOk || networkInterfaceNamingOk || weightOk {
log.Debugf("resourceComputeCreate: change loaderType or bootType or hotResize or networkInterfaceNaming or weight on ComputeID: %d", computeId)
updateReq.ComputeID = computeId
_, err := c.CloudBroker().Compute().Update(ctx, updateReq)
if err != nil {
@@ -381,7 +404,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if mac == "" {
warnings.Add(errors.New(fmt.Sprintf("add libvirt virtio: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId)))
warnings.Add(fmt.Errorf("add libvirt virtio: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))
continue
}
log.Debugf("resourceComputeCreate: Configure libvirt virtio interface parameters on Network with type %s and id %d", netType, netId)
@@ -420,7 +443,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if mac == "" {
warnings.Add(errors.New(fmt.Sprintf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId)))
warnings.Add(fmt.Errorf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))
continue
}
secGroupsIDs := make([]uint64, 0)
@@ -448,6 +471,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if nodeID, ok := d.GetOk("node_id"); ok {
req.NodeID = uint64(nodeID.(int))
}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
warnings.Add(err)
@@ -677,6 +703,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if err != nil {
warnings.Add(err)
}
if err := utilityComputeCreateBlockSize(ctx, d, m); err != nil {
warnings.Add(err)
}
if err := utilityComputeCreateIOTune(ctx, d, m); err != nil {
warnings.Add(err)
}
@@ -874,7 +903,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
"boot_type",
"hot_resize",
"network_interface_naming",
"os_version") {
"os_version",
"weight") {
if err := utilityComputeUpdate(ctx, d, m); err != nil {
return diag.FromErr(err)
}

View File

@@ -232,6 +232,14 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"block_size": {
Type: schema.TypeString,
Computed: true,
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"boot_partition": {
Type: schema.TypeInt,
Computed: true,
@@ -287,6 +295,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Optional: true,
@@ -588,6 +600,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"interfaces": {
Type: schema.TypeList,
Computed: true,
@@ -1150,6 +1166,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
@@ -1931,6 +1951,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -2221,6 +2245,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"sep_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -2639,6 +2667,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -3409,6 +3441,12 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
Default: false,
},
"create_blank": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.",
},
"boot_disk_size": {
Type: schema.TypeInt,
Optional: true,
@@ -3463,16 +3501,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "ID of node to start compute",
},
"is": {
Type: schema.TypeString,
Optional: true,
Description: "system name",
},
"ipa_type": {
Type: schema.TypeString,
Optional: true,
Description: "compute purpose",
},
"custom_fields": {
Type: schema.TypeString,
Optional: true,
@@ -3521,8 +3549,8 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
Computed: true,
//Default: 1500,
ValidateFunc: validation.IntBetween(1, 9216),
Description: "Maximum transmission unit, used only for DPDK type, must be 1-9216",
ValidateFunc: validation.IntBetween(1500, 9216),
Description: "Maximum transmission unit, used only for DPDK type, must be 1500-9216",
},
"sdn_interface_id": {
Type: schema.TypeString,
@@ -3531,22 +3559,22 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
DiffSuppressFunc: networkSubresIPAddreDiffSupperss,
Description: "unique_identifier of LogicalPort on SDN side",
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "network enable flag",
},
"net_mask": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Subnet mask, used only for DPDK and VFNIC network types",
"enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "network enable flag",
},
"net_mask": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "Subnet mask, used only for DPDK and VFNIC network types",
},
},
},
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
},
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
},
"libvirt_settings": {
Type: schema.TypeSet,
@@ -3609,7 +3637,7 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Required: true,
StateFunc: statefuncs.StateFuncToUpper,
ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK"}, false), // observe case while validating
ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "DPDK"}, false), // observe case while validating
Description: "Type of the network",
},
"net_id": {
@@ -3750,18 +3778,31 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
Default: false,
},
"block_size": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Disk block size",
},
"provision": {
Type: schema.TypeString,
Computed: true,
},
"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'",
"pci_slot": {
Type: schema.TypeInt,
Computed: true,
Description: "PCI slot number of the disk",
},
"bus_number": {
Type: schema.TypeInt,
Computed: true,
Description: "Bus number of the disk on virtual bus (6 = boot disk)",
},
"pool": {
Type: schema.TypeString,
@@ -3788,11 +3829,67 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Specify image id for create disk from template",
},
"independent": {
Type: schema.TypeBool,
Computed: true,
},
"permanently": {
Type: schema.TypeBool,
Optional: true,
Description: "Disk deletion status",
},
"disk_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Disk ID",
},
"present_to": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"shareable": {
Type: schema.TypeBool,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
},
"size_used": {
Type: schema.TypeInt,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
"devicename": {
Type: schema.TypeString,
Computed: true,
},
"create_by": {
Type: schema.TypeString,
Computed: true,
},
"create_time": {
Type: schema.TypeInt,
Computed: true,
},
"delete_by": {
Type: schema.TypeString,
Computed: true,
},
"delete_time": {
Type: schema.TypeInt,
Computed: true,
},
"update_time": {
Type: schema.TypeInt,
Computed: true,
},
"iotune": {
Type: schema.TypeList,
Optional: true,
@@ -3868,58 +3965,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
},
},
},
"disk_id": {
Type: schema.TypeInt,
Computed: true,
Description: "Disk ID",
},
"present_to": {
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"shareable": {
Type: schema.TypeBool,
Computed: true,
},
"size_max": {
Type: schema.TypeInt,
Computed: true,
},
"size_used": {
Type: schema.TypeInt,
Computed: true,
},
"to_clean": {
Type: schema.TypeBool,
Computed: true,
},
"devicename": {
Type: schema.TypeString,
Computed: true,
},
"create_by": {
Type: schema.TypeString,
Computed: true,
},
"create_time": {
Type: schema.TypeInt,
Computed: true,
},
"delete_by": {
Type: schema.TypeString,
Computed: true,
},
"delete_time": {
Type: schema.TypeInt,
Computed: true,
},
"update_time": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -4159,6 +4204,13 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "the OS version installed on the VM",
},
"weight": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntAtLeast(1),
Description: "Priority weight of the compute. Higher value means higher priority and later migration.",
},
// Computed properties
"account_id": {
Type: schema.TypeInt,

View File

@@ -209,7 +209,11 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa
}
if isStopRequired {
if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil {
req := compute.StartRequest{ComputeID: computeId}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
return err
}
}
@@ -262,11 +266,14 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
changeStoragePolicyDisks := make([]interface{}, 0)
cacheUpdatedDisks := make([]interface{}, 0)
blkDiscardUpdatedDisks := make([]interface{}, 0)
blockSizeUpdatedDisks := make([]interface{}, 0)
iotuneUpdatedDisks := make([]interface{}, 0)
migratedDisks := make([]interface{}, 0)
presentNewDisks := make([]interface{}, 0)
presentOldDisks := make([]interface{}, 0)
chipset := d.Get("chipset").(string)
oldDisks, newDisks := d.GetChange("disks")
oldConv := oldDisks.([]interface{})
newConv := newDisks.([]interface{})
@@ -322,6 +329,10 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
blkDiscardUpdatedDisks = append(blkDiscardUpdatedDisks, el)
}
if isChangeBlockSizeDisk(oldConv, el) {
blockSizeUpdatedDisks = append(blockSizeUpdatedDisks, el)
}
if isChangeIOTuneDisk(oldConv, el) {
iotuneUpdatedDisks = append(iotuneUpdatedDisks, el)
}
@@ -330,7 +341,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
if len(deletedDisks) > 0 {
for _, disk := range deletedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
if isBootDisk(diskConv, chipset) {
continue
}
@@ -350,9 +361,6 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
if len(addedDisks) > 0 {
for _, disk := range addedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
continue
}
req := compute.DiskAddRequest{
ComputeID: computeId,
DiskName: diskConv["disk_name"].(string),
@@ -362,9 +370,6 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
if diskConv["sep_id"].(int) != 0 {
req.SepID = uint64(diskConv["sep_id"].(int))
}
if diskConv["disk_type"].(string) != "" {
req.DiskType = diskConv["disk_type"].(string)
}
if diskConv["pool"].(string) != "" {
req.Pool = diskConv["pool"].(string)
}
@@ -381,6 +386,16 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
if err != nil {
return err
}
if blockSize, ok := diskConv["block_size"].(string); ok && blockSize != "" {
updateReq := disks.UpdateRequest{
DiskID: diskID,
BlockSize: blockSize,
}
_, err := c.CloudBroker().Disks().Update(ctx, updateReq)
if err != nil {
return err
}
}
if nodeIDs, ok := diskConv["node_ids"]; ok {
presentIDs := nodeIDs.(*schema.Set).List()
if len(presentIDs) > 0 {
@@ -421,14 +436,16 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
return err
}
}
if err != nil {
return err
}
}
}
if len(resizedDisks) > 0 {
for _, disk := range resizedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
if isBootDisk(diskConv, chipset) {
continue
}
req := compute.DiskResizeRequest{
@@ -478,7 +495,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
if len(cacheUpdatedDisks) > 0 {
for _, disk := range cacheUpdatedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
if isBootDisk(diskConv, chipset) {
continue
}
@@ -501,7 +518,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
if len(blkDiscardUpdatedDisks) > 0 {
for _, disk := range blkDiscardUpdatedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
if isBootDisk(diskConv, chipset) {
continue
}
@@ -521,18 +538,43 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
}
}
if len(iotuneUpdatedDisks) > 0 {
for _, disk := range iotuneUpdatedDisks {
if len(blockSizeUpdatedDisks) > 0 {
for _, disk := range blockSizeUpdatedDisks {
diskConv := disk.(map[string]interface{})
if diskConv["disk_type"].(string) == "B" {
if isBootDisk(diskConv, chipset) {
continue
}
diskID := uint64(diskConv["disk_id"].(int))
if diskID == 0 {
continue
}
iotuneRaw, ok := diskConv["iotune"].([]interface{})
if !ok || len(iotuneRaw) == 0 {
req := disks.UpdateRequest{
DiskID: diskID,
BlockSize: diskConv["block_size"].(string),
}
_, err := c.CloudBroker().Disks().Update(ctx, req)
if err != nil {
return err
}
}
}
if len(iotuneUpdatedDisks) > 0 {
for _, disk := range iotuneUpdatedDisks {
diskConv := disk.(map[string]interface{})
if isBootDisk(diskConv, chipset) {
continue
}
diskID := uint64(diskConv["disk_id"].(int))
if diskID == 0 {
continue
}
iotuneRaw := diskConv["iotune"].([]interface{})
if len(iotuneRaw) == 0 {
continue
}
iotuneMap := iotuneRaw[0].(map[string]interface{})
@@ -778,10 +820,23 @@ func utilityComputePCIDevicesList(ctx context.Context, d *schema.ResourceData, m
return res, nil
}
func findBootDisk(disks compute.ListDisks) *compute.ItemDisk {
func isBootDisk(diskConv map[string]interface{}, chipset string) bool {
if chipset == "i440fx" {
return diskConv["pci_slot"].(int) == 6
}
return diskConv["bus_number"].(int) == 6
}
func findBootDisk(disks compute.ListDisks, chipset string) *compute.ItemDisk {
for _, disk := range disks {
if disk.Type == "B" {
return &disk
if chipset == "i440fx" {
if disk.PCISlot == 6 {
return &disk
}
} else {
if disk.BusNumber == 6 {
return &disk
}
}
}
return &compute.ItemDisk{}
@@ -981,7 +1036,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
if needStart {
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil {
var altBootID uint64
if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok {
altBootID = uint64(altBootIDRaw)
} else {
altBootID = 0
}
if numErr, err := utilityComputeStart(ctx, computeId, altBootID, m); err != nil {
apiErrCount += numErr
lastSavedError = err
}
@@ -1264,6 +1325,10 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
req.OSVersion = d.Get("os_version").(string)
}
if d.HasChange("weight") {
req.Weight = uint64(d.Get("weight").(int))
}
req.CPUPin = d.Get("cpu_pin").(bool)
req.HPBacked = d.Get("hp_backed").(bool)
req.AutoStart = d.Get("auto_start_w_node").(bool)
@@ -1308,7 +1373,11 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
// If used to be STARTED, we need to start it after update
if isStopRequired {
if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil {
req := compute.StartRequest{ComputeID: computeId}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
req.AltBootID = uint64(altBootID)
}
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
return err
}
}
@@ -1779,6 +1848,9 @@ func utilityComputeRollback(ctx context.Context, d *schema.ResourceData, m inter
}
startReq := compute.StartRequest{ComputeID: computeId}
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
startReq.AltBootID = uint64(altBootID)
}
log.Debugf("utilityComputeRollback: starting compute %d", computeId)
@@ -2036,10 +2108,14 @@ func utilityComputeStop(ctx context.Context, d *schema.ResourceData, m interface
return nil
}
func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) {
func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) {
c := m.(*controller.ControllerCfg)
startReq := compute.StartRequest{ComputeID: computeID}
if altBootID != 0 {
startReq.AltBootID = altBootID
}
log.Debugf("utilityComputeStart: starting compute %d", computeID)
_, err := c.CloudBroker().Compute().Start(ctx, startReq)
if err != nil {
@@ -2048,6 +2124,109 @@ func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (
return 0, nil
}
func utilityComputeCreateBlockSize(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
diskList := d.Get("disks").([]interface{})
blockSizeArr := make([]string, 0, len(diskList))
hasAny := false
for _, elem := range diskList {
diskVal := elem.(map[string]interface{})
bs := diskVal["block_size"].(string)
blockSizeArr = append(blockSizeArr, bs)
if bs != "" {
hasAny = true
}
}
if !hasAny {
return nil
}
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
if err != nil {
return err
}
bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset)
computeDisksIDs := getComputeDiskIDs(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID)
for i, diskID := range computeDisksIDs {
if i >= len(blockSizeArr) || blockSizeArr[i] == "" {
continue
}
req := disks.UpdateRequest{
DiskID: diskID.(uint64),
BlockSize: blockSizeArr[i],
}
_, err := c.CloudBroker().Disks().Update(ctx, req)
if err != nil {
return err
}
}
return nil
}
func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
diskList := d.Get("disks").([]interface{})
iotuneArr := make([]interface{}, 0, len(diskList))
hasAny := false
for _, elem := range diskList {
diskVal := elem.(map[string]interface{})
iotune := diskVal["iotune"].([]interface{})
iotuneArr = append(iotuneArr, iotune)
if len(iotune) > 0 {
hasAny = true
}
}
if !hasAny {
return nil
}
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
if err != nil {
return err
}
bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset)
computeDisksIDs := getComputeDiskIDs(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID)
for i, diskID := range computeDisksIDs {
if i >= len(iotuneArr) {
continue
}
iotune, ok := iotuneArr[i].([]interface{})
if !ok || len(iotune) == 0 {
continue
}
iotuneMap := iotune[0].(map[string]interface{})
req := disks.LimitIORequest{
DiskID: diskID.(uint64),
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
}
_, err := c.CloudBroker().Disks().LimitIO(ctx, req)
if err != nil {
return err
}
}
return nil
}
func utilityComputeCreatePresentDisk(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
var errs error
@@ -2059,7 +2238,7 @@ func utilityComputeCreatePresentDisk(ctx context.Context, d *schema.ResourceData
}
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
bootDisk := findBootDisk(computeRec.Disks)
bootDisk := findBootDisk(computeRec.Disks, computeRec.Chipset)
if err != nil {
errs = errors.Join(err)
}
@@ -2141,6 +2320,18 @@ func isChangeBLKDiscardDisk(els []interface{}, el interface{}) bool {
return false
}
func isChangeBlockSizeDisk(els []interface{}, el interface{}) bool {
for _, elOld := range els {
elOldConv := elOld.(map[string]interface{})
elConv := el.(map[string]interface{})
if elOldConv["disk_id"].(int) == elConv["disk_id"].(int) &&
elOldConv["block_size"].(string) != elConv["block_size"].(string) {
return true
}
}
return false
}
func isChangeIOTuneDisk(els []interface{}, el interface{}) bool {
for _, elOld := range els {
elOldConv := elOld.(map[string]interface{})
@@ -2175,66 +2366,6 @@ func isChangeIOTuneDisk(els []interface{}, el interface{}) bool {
return false
}
func utilityComputeCreateIOTune(ctx context.Context, d *schema.ResourceData, m interface{}) error {
c := m.(*controller.ControllerCfg)
diskList := d.Get("disks").([]interface{})
iotuneArr := make([]interface{}, 0, len(diskList))
hasAny := false
for _, elem := range diskList {
diskVal := elem.(map[string]interface{})
iotune := diskVal["iotune"].([]interface{})
iotuneArr = append(iotuneArr, iotune)
if len(iotune) > 0 {
hasAny = true
}
}
if !hasAny {
return nil
}
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
if err != nil {
return err
}
bootDisk := findBootDisk(computeRec.Disks)
computeDisksIDs := getComputeDiskIDs(computeRec.Disks, diskList, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID)
for i, diskID := range computeDisksIDs {
if i >= len(iotuneArr) {
continue
}
iotune, ok := iotuneArr[i].([]interface{})
if !ok || len(iotune) == 0 {
continue
}
iotuneMap := iotune[0].(map[string]interface{})
req := disks.LimitIORequest{
DiskID: diskID.(uint64),
ReadBytesSec: uint64(iotuneMap["read_bytes_sec"].(int)),
ReadBytesSecMax: uint64(iotuneMap["read_bytes_sec_max"].(int)),
ReadIOPSSec: uint64(iotuneMap["read_iops_sec"].(int)),
ReadIOPSSecMax: uint64(iotuneMap["read_iops_sec_max"].(int)),
SizeIOPSSec: uint64(iotuneMap["size_iops_sec"].(int)),
TotalBytesSec: uint64(iotuneMap["total_bytes_sec"].(int)),
TotalBytesSecMax: uint64(iotuneMap["total_bytes_sec_max"].(int)),
TotalIOPSSec: uint64(iotuneMap["total_iops_sec"].(int)),
TotalIOPSSecMax: uint64(iotuneMap["total_iops_sec_max"].(int)),
WriteBytesSec: uint64(iotuneMap["write_bytes_sec"].(int)),
WriteBytesSecMax: uint64(iotuneMap["write_bytes_sec_max"].(int)),
WriteIOPSSec: uint64(iotuneMap["write_iops_sec"].(int)),
WriteIOPSSecMax: uint64(iotuneMap["write_iops_sec_max"].(int)),
}
_, err := c.CloudBroker().Disks().LimitIO(ctx, req)
if err != nil {
return err
}
}
return nil
}
func isChangeStoragePolicy(els []interface{}, el interface{}) bool {
for _, elOld := range els {
elOldConv := elOld.(map[string]interface{})

View File

@@ -263,11 +263,12 @@ func flattenGetNetAddr(address node.NetAddr) []map[string]interface{} {
func flattenCpuInfo(info node.CpuInfo) []map[string]interface{} {
res := make([]map[string]interface{}, 1)
temp := map[string]interface{}{
"clock_speed": info.ClockSpeed,
"core_count": info.CoreCount,
"phys_count": info.PhysCount,
"flags": info.Flags,
"model_name": info.ModelName,
"clock_speed": info.ClockSpeed,
"core_count": info.CoreCount,
"phys_count": info.PhysCount,
"flags": info.Flags,
"model_name": info.ModelName,
"thread_count": info.ThreadCount,
}
res[0] = temp
return res

View File

@@ -52,7 +52,7 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vcpu": {
Type: schema.TypeInt,
Type: schema.TypeFloat,
Computed: true,
},
"ram": {
@@ -121,6 +121,10 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"thread_count": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
@@ -498,6 +502,11 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "find node by status",
},
"zone_id": {
Type: schema.TypeInt,
Optional: true,
Description: "find node by zone id",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
@@ -570,6 +579,10 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"thread_count": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},

View File

@@ -76,6 +76,9 @@ func utilityNodeListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if Size, ok := d.GetOk("size"); ok {
req.Size = uint64(Size.(int))
}
if zoneId, ok := d.GetOk("zone_id"); ok {
req.ZoneID = uint64(zoneId.(int))
}
log.Debugf("utilityNodeListCheckPresence: load node list")
nodeList, err := c.CloudBroker().Node().List(ctx, req)

View File

@@ -48,6 +48,7 @@ func flattenRgAcl(rgACLs rg.ListACL) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(rgACLs))
for _, acl := range rgACLs {
temp := map[string]interface{}{
"email": acl.Email,
"explicit": acl.Explicit,
"guid": acl.GUID,
"right": acl.Right,

View File

@@ -107,6 +107,9 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
if _, ok := d.GetOk("def_net"); !ok {
if defNetType, ok := d.GetOk("def_net_type"); ok {
if defNetType.(string) == "PRIVATE" {
return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use def_net_type=\"PRIVATE\" only when updating an existing RG that already contains a ViNS")
}
req.DefNet = defNetType.(string)
}
} else {
@@ -186,7 +189,14 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
}
}
if _, ok := d.GetOk("def_net"); ok {
if defNet, ok := d.GetOk("def_net"); ok {
if defNet.(*schema.Set).Len() > 0 {
defNetList := defNet.(*schema.Set).List()
defNetItem := defNetList[0].(map[string]interface{})
if defNetItem["net_type"].(string) == "PRIVATE" {
return diag.Errorf("resourceResgroupCreate: cannot create RG with def_net net_type=\"PRIVATE\": no ViNSes exist in a newly created RG. Use net_type=\"PRIVATE\" in def_net block only when updating an existing RG that already contains a ViNS")
}
}
if err := resourceRGSetDefNet(ctx, d, m); err != nil {
w.Add(err)
}
@@ -483,7 +493,32 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter
}
if d.HasChange("def_net") {
oldDefNet, _ := d.GetChange("def_net")
oldDefNet, newDefNet := d.GetChange("def_net")
if newDefNet.(*schema.Set).Len() > 0 {
defNetList := newDefNet.(*schema.Set).List()
defNetItem := defNetList[0].(map[string]interface{})
netType := defNetItem["net_type"].(string)
netID := uint64(defNetItem["net_id"].(int))
if netType == "PRIVATE" {
if netID == 0 {
if len(rgData.VINS) == 0 {
return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: no ViNSes exist in this RG", rgData.ID)
}
} else {
found := false
for _, vinsID := range rgData.VINS {
if vinsID == netID {
found = true
break
}
}
if !found {
return diag.Errorf("resourceResgroupUpdate: cannot set def_net net_type=\"PRIVATE\" for RG ID %d: ViNS ID %d is not found in this RG", rgData.ID, netID)
}
}
}
}
if oldDefNet.(*schema.Set).Len() > 0 {
_, err := c.CloudBroker().RG().RemoveDefNet(ctx, rg.RemoveDefNetRequest{RGID: rgData.ID})
if err != nil {

View File

@@ -25,6 +25,10 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"email": {
Type: schema.TypeString,
Computed: true,
},
"explicit": {
Type: schema.TypeBool,
Computed: true,
@@ -2461,6 +2465,10 @@ func resourceRgSchemaMake() map[string]*schema.Schema {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"email": {
Type: schema.TypeString,
Computed: true,
},
"explicit": {
Type: schema.TypeBool,
Computed: true,

View File

@@ -338,7 +338,6 @@ func resourceSepChangePools(ctx context.Context, d *schema.ResourceData, m inter
log.Debugf(string(marshalPool))
addPoolReq := sep.AddPoolRequest{
SEPID: uint64(d.Get("sep_id").(int)),
Sync: true,
Pool: string(marshalPool),
}

View File

@@ -6,7 +6,6 @@ import (
)
func flattenStoragePolicyData(d *schema.ResourceData, storagePolicy *stpolicy.InfoStoragePolicy) {
d.Set("storage_policy_id", storagePolicy.ID)
d.Set("description", storagePolicy.Description)
d.Set("guid", storagePolicy.GUID)
d.Set("limit_iops", storagePolicy.LimitIOPS)
@@ -62,13 +61,28 @@ func flattenStoragePolicyList(storagePolicyList *stpolicy.ListStoragePolicies) [
return res
}
func flattenAccessSEPPoolsResource(accessSEPPools stpolicy.ListAccessSEPPools) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, asp := range accessSEPPools {
for _, poolName := range asp.PoolNames {
temp := map[string]interface{}{
"sep_id": asp.SEPID,
"sep_name": asp.Name,
"pool_name": poolName,
"sep_tech_status": asp.SepTechStatus,
}
res = append(res, temp)
}
}
return res
}
func flattenStoragePolicyResource(d *schema.ResourceData, storagePolicy *stpolicy.InfoStoragePolicy) {
d.Set("storage_policy_id", storagePolicy.ID)
d.Set("description", storagePolicy.Description)
d.Set("guid", storagePolicy.GUID)
d.Set("limit_iops", storagePolicy.LimitIOPS)
d.Set("name", storagePolicy.Name)
d.Set("status", storagePolicy.Status)
d.Set("access_seps_pools", flattenAccessSEPPools(storagePolicy.AccessSEPPools))
d.Set("access_seps_pools", flattenAccessSEPPoolsResource(storagePolicy.AccessSEPPools))
d.Set("usage", flattenUsage(storagePolicy.Usage))
}

View File

@@ -61,7 +61,6 @@ func resourceStoragePolicyCreate(ctx context.Context, d *schema.ResourceData, m
}
d.SetId(strconv.FormatUint(storagePolicyID, 10))
d.Set("storage_policy_id", storagePolicyID)
if enabled, ok := d.GetOk("enabled"); ok {
isToEnable := enabled.(bool)

View File

@@ -7,10 +7,6 @@ import (
func resourceStoragePolicySchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"storage_policy_id": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Required: true,
@@ -32,6 +28,10 @@ func resourceStoragePolicySchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Required: true,
},
"sep_tech_status": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
@@ -129,6 +129,10 @@ func dataSourceStoragePolicySchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"sep_tech_status": {
Type: schema.TypeString,
Computed: true,
},
},
},
},

View File

@@ -15,11 +15,11 @@ func flattenTrunkResource(d *schema.ResourceData, details *trunk.ItemTrunk) {
d.Set("name", details.Name)
d.Set("mac", details.MAC)
d.Set("description", details.Description)
d.Set("accountIds", details.AccountIDs)
d.Set("ovsBridge", details.OVSBridge)
d.Set("nativeVlanId", details.NativeVLANID)
d.Set("account_ids", details.AccountIDs)
d.Set("ovs_bridge", details.OVSBridge)
d.Set("native_vlan_id", details.NativeVLANID)
d.Set("status", details.Status)
d.Set("trunkTags", details.TrunkTags)
d.Set("trunk_tags", details.TrunkTags)
d.Set("created_at", details.CreatedAt)
d.Set("created_by", details.CreatedBy)
d.Set("updated_at", details.UpdatedAt)

View File

@@ -33,6 +33,7 @@ package vfpool
import (
"context"
"fmt"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -85,6 +86,12 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa
}
config, configOk := d.GetOk("config")
enableVal := d.Get("enable").(bool)
if enableVal && !configOk {
return diag.FromErr(fmt.Errorf("enable requires config to be set"))
}
if configOk {
configArray := config.(*schema.Set).List()
req.Config = make([]vfpool.Config, 0, len(configArray))
@@ -117,10 +124,8 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa
warnings := dc.Warnings{}
if enable, ok := d.GetOk("enable"); ok {
if err := utilityVFPoolEnabled(ctx, m, enable.(bool), vfPoolID, configOk); err != nil {
warnings.Add(err)
}
if err := utilityVFPoolEnabled(ctx, m, enableVal, vfPoolID); err != nil {
warnings.Add(err)
}
log.Debugf("resourceVFPoolCreate: create VFPool with ID: %d, complete", vfPoolID)
@@ -147,20 +152,12 @@ func resourceVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfa
log.Debugf("resourceVFPoolUpdate: called VFPool with id %d", vfPoolID)
_, ok := d.GetOk("config")
if d.HasChanges("name,", "description", "account_access", "rg_access,", "config") {
if d.HasChanges("name", "description", "account_access", "rg_access", "config", "enable") {
if err := utilityVFPoolUpdate(ctx, d, m, vfPoolID); err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("enable") {
if err := utilityVFPoolEnabled(ctx, m, d.Get("enable").(bool), vfPoolID, ok); err != nil {
return diag.FromErr(err)
}
}
log.Debugf("resourceVFPoolUpdate: update VFPool with id %d, complete", vfPoolID)
return resourceVFPoolRead(ctx, d, m)

View File

@@ -64,37 +64,26 @@ func utilityVFpoolCheckPresence(ctx context.Context, d *schema.ResourceData, m i
return vfpoolData, nil
}
func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64, configOk bool) error {
func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64) error {
c := m.(*controller.ControllerCfg)
if enable && configOk {
req := vfpool.EnableRequest{
VFPoolID: vfPoolID,
}
_, err := c.CloudBroker().VFPool().Enable(ctx, req)
if err != nil {
return err
}
}
if enable && !configOk {
return fmt.Errorf("you must provide configuration for this resource, after enabling it")
}
if !enable {
req := vfpool.DisableRequest{
VFPoolID: vfPoolID,
}
_, err := c.CloudBroker().VFPool().Disable(ctx, req)
if err != nil {
return err
}
var err error
if enable {
_, err = c.CloudBroker().VFPool().Enable(ctx, vfpool.EnableRequest{VFPoolID: vfPoolID})
} else {
_, err = c.CloudBroker().VFPool().Disable(ctx, vfpool.DisableRequest{VFPoolID: vfPoolID})
}
log.Debugf("utilityVFPoolEnabled: enable=%v vfPool ID %d after completing its resource configuration", enable, vfPoolID)
return nil
return err
}
func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, vfPoolID uint64) error {
hasConfig := len(d.Get("config").(*schema.Set).List()) > 0
if d.Get("enable").(bool) && !hasConfig {
return fmt.Errorf("enable requires config to be set")
}
c := m.(*controller.ControllerCfg)
vfPool, err := utilityVFpoolCheckPresence(ctx, d, m)
@@ -190,7 +179,7 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac
}
log.Debugf("utilityVFPoolUpdate: update vfPool with ID: %d, complete with params=%v", vfPoolID, req)
if len(d.Get("config").(*schema.Set).List()) > 0 && d.Get("enable").(bool) {
if hasConfig && d.Get("enable").(bool) {
reqEnable := vfpool.EnableRequest{
VFPoolID: vfPoolID,
}
@@ -201,8 +190,6 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac
return err
}
log.Debugf("utilityVFPoolUpdate: enable vfPool with ID: %d, complete", vfPoolID)
} else {
return (fmt.Errorf("the vfPool is not enabled after update, you must provide configuration for this resource, after enabling it"))
}
return nil

View File

@@ -1,34 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
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 vgpu
const VGPU_LIST_API = "/restmachine/cloudbroker/vgpu/list"

View File

@@ -1,120 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
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 vgpu
import (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceVGPURead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
vgpu, err := utilityVGPUCheckPresence(ctx, d, m)
if vgpu == nil {
d.SetId("")
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(vgpu.ID, 10))
d.Set("vgpu_id", vgpu.ID)
d.Set("account_id", vgpu.AccountID)
d.Set("mode", vgpu.Mode)
d.Set("pgpu", vgpu.PGPUID)
d.Set("profile_id", vgpu.ProfileID)
d.Set("ram", vgpu.RAM)
d.Set("status", vgpu.Status)
d.Set("type", vgpu.Type)
d.Set("vm_id", vgpu.VMID)
return nil
}
func dataSourceVGPUSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"vgpu_id": {
Type: schema.TypeInt,
Required: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"mode": {
Type: schema.TypeString,
Computed: true,
},
"pgpu": {
Type: schema.TypeInt,
Computed: true,
},
"profile_id": {
Type: schema.TypeInt,
Computed: true,
},
"ram": {
Type: schema.TypeInt,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"vm_id": {
Type: schema.TypeInt,
Computed: true,
},
}
}
func DataSourceVGPU() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceVGPURead,
Schema: dataSourceVGPUSchemaMake(),
}
}

View File

@@ -1,74 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
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 vgpu
import (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vgpu"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityVGPUCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vgpu.ItemVGPU, error) {
c := m.(*controller.ControllerCfg)
req := vgpu.ListRequest{
Size: 50,
}
var vgpuId uint64
var err error
if vId, ok := d.GetOk("vgpu_id"); ok {
vgpuId = uint64(vId.(int))
} else {
vgpuId, err = strconv.ParseUint(d.Id(), 10, 64)
if err != nil {
return nil, err
}
}
for page := 1; ; page++ {
req.Page = uint64(page)
vgpus, err := c.CloudBroker().VGPU().List(ctx, req)
if err != nil {
return nil, err
}
for _, vgpu := range vgpus.Data {
if vgpu.ID == vgpuId {
return &vgpu, nil
}
}
}
}

View File

@@ -88,6 +88,8 @@ func createVinsInAcc(ctx context.Context, d *schema.ResourceData, m interface{},
req.ZoneID = uint64(zoneID.(int))
}
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
return req, nil
}
@@ -143,6 +145,8 @@ func createVinsInRG(ctx context.Context, d *schema.ResourceData, m interface{},
req.ZoneID = uint64(zoneID.(int))
}
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
return req, nil
}

View File

@@ -115,12 +115,6 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
}
}
if d.Get("enable_secgroups").(bool) {
if err := resourceVinsEnableSecgroups(ctx, d, m, vinsID); err != nil {
warnings.Add(err)
}
}
return append(warnings.Get(), resourceVinsRead(ctx, d, m)...)
}
@@ -437,21 +431,6 @@ func resourceVinsIpReserve(ctx context.Context, d *schema.ResourceData, m interf
return errs
}
func resourceVinsEnableSecgroups(ctx context.Context, d *schema.ResourceData, m interface{}, vinsID uint64) error {
c := m.(*controller.ControllerCfg)
req := vins.UpdateRequest{
VINSID: vinsID,
EnableSecGroups: true,
}
_, err := c.CloudBroker().VINS().Update(ctx, req)
if err != nil {
return err
}
return nil
}
func resourceVinsNatRuleAdd(ctx context.Context, d *schema.ResourceData, m interface{}, vinsId uint64) []error {
var errs []error
c := m.(*controller.ControllerCfg)

View File

@@ -150,6 +150,50 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
},
},
"drs": {
Type: schema.TypeBool,
Computed: true,
},
"drs_uid": {
Type: schema.TypeString,
Computed: true,
},
"drs_name": {
Type: schema.TypeString,
Computed: true,
},
"sso_url": {
Type: schema.TypeString,
Computed: true,
},
"app_id": {
Type: schema.TypeString,
Computed: true,
},
"decort_url": {
Type: schema.TypeString,
Computed: true,
},
"domain": {
Type: schema.TypeString,
Computed: true,
},
"ping_addr": {
Type: schema.TypeString,
Computed: true,
},
"broadcast_addr": {
Type: schema.TypeString,
Computed: true,
},
"ssl_skip_verify": {
Type: schema.TypeBool,
Computed: true,
},
"sso_type": {
Type: schema.TypeString,
Computed: true,
},
}
}

Some files were not shown because too many files have changed in this diff Show More