parent
294680282e
commit
e2ee45ee14
@ -1,8 +1,24 @@
|
|||||||
## Version 4.5.0
|
## Version 4.5.1
|
||||||
|
|
||||||
## Feature
|
## Feature
|
||||||
- Added support for authorization using the Basis.Virtual Security system. Add client and config
|
- Refactoring BVS config
|
||||||
|
- Added and updated data sources and resources for cloudbroker groups:
|
||||||
|
* account
|
||||||
|
* audit
|
||||||
|
* disks
|
||||||
|
* extnet
|
||||||
|
* flipgroup
|
||||||
|
* grid
|
||||||
|
* image
|
||||||
|
* k8ci
|
||||||
|
* k8s
|
||||||
|
* kvmvm (compute)
|
||||||
|
* lb (load balancer)
|
||||||
|
* pcidevice
|
||||||
|
* rg (resource group)
|
||||||
|
* sep
|
||||||
|
* stack
|
||||||
|
* vins
|
||||||
|
|
||||||
### Bugfix
|
### Bugfix
|
||||||
- Fixed bservice and rg schema and flatten in cloudapi
|
- Fixed description update for compute in cloudapi/kvmvm
|
||||||
- Add stateUpgrader for k8s_cp in cloudapi/k8s
|
|
||||||
|
|||||||
@ -1,161 +1,254 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package provider
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/extnet"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/extnet"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/stack"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/stack"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
||||||
|
|
||||||
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
||||||
// cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
cb_audit "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/audit"
|
||||||
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
||||||
// cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||||
// cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
||||||
// cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_grid "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/grid"
|
||||||
// cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
// cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
||||||
// cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
||||||
// cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||||
// cb_stack "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/stack"
|
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
||||||
// cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
|
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
||||||
)
|
cb_stack "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/stack"
|
||||||
|
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
||||||
func newDataSourcesMap() map[string]*schema.Resource {
|
|
||||||
return map[string]*schema.Resource{
|
// cb_vgpu "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vgpu"
|
||||||
"decort_account": account.DataSourceAccount(),
|
cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
|
||||||
"decort_resgroup": rg.DataSourceResgroup(),
|
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
||||||
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
)
|
||||||
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
|
||||||
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
func newDataSourcesMap() map[string]*schema.Resource {
|
||||||
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
return map[string]*schema.Resource{
|
||||||
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
"decort_account": account.DataSourceAccount(),
|
||||||
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
"decort_resgroup": rg.DataSourceResgroup(),
|
||||||
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
||||||
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
||||||
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
||||||
"decort_k8s": k8s.DataSourceK8s(),
|
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
||||||
"decort_k8s_list": k8s.DataSourceK8sList(),
|
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||||
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
||||||
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
||||||
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
||||||
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
||||||
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
"decort_k8s": k8s.DataSourceK8s(),
|
||||||
"decort_vins": vins.DataSourceVins(),
|
"decort_k8s_list": k8s.DataSourceK8sList(),
|
||||||
"decort_vins_list": vins.DataSourceVinsList(),
|
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
||||||
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||||
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||||
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
||||||
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
||||||
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
"decort_vins": vins.DataSourceVins(),
|
||||||
"decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
|
"decort_vins_list": vins.DataSourceVinsList(),
|
||||||
"decort_vins_static_route": vins.DataSourceStaticRoute(),
|
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
||||||
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
||||||
"decort_disk": disks.DataSourceDisk(),
|
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
||||||
"decort_disk_list": disks.DataSourceDiskList(),
|
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
||||||
"decort_rg_list": rg.DataSourceRgList(),
|
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
||||||
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
"decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
|
||||||
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
"decort_vins_static_route": vins.DataSourceStaticRoute(),
|
||||||
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
||||||
"decort_rg_audits": rg.DataSourceRgAudits(),
|
"decort_disk": disks.DataSourceDisk(),
|
||||||
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
"decort_disk_list": disks.DataSourceDiskList(),
|
||||||
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
"decort_rg_list": rg.DataSourceRgList(),
|
||||||
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
||||||
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
||||||
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
||||||
"decort_rg_usage": rg.DataSourceRgUsage(),
|
"decort_rg_audits": rg.DataSourceRgAudits(),
|
||||||
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
||||||
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
||||||
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
||||||
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
||||||
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
||||||
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
"decort_rg_usage": rg.DataSourceRgUsage(),
|
||||||
"decort_account_list": account.DataSourceAccountList(),
|
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
||||||
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
||||||
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
||||||
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
||||||
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
||||||
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
||||||
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
"decort_account_list": account.DataSourceAccountList(),
|
||||||
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
||||||
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
||||||
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
||||||
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
||||||
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
||||||
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
||||||
"decort_bservice": bservice.DataSourceBasicService(),
|
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
||||||
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
||||||
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
||||||
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
||||||
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
||||||
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
||||||
"decort_extnet": extnet.DataSourceExtnet(),
|
"decort_bservice": bservice.DataSourceBasicService(),
|
||||||
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
||||||
"decort_locations_list": locations.DataSourceLocationsList(),
|
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
||||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
||||||
"decort_image_list": image.DataSourceImageList(),
|
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
||||||
"decort_image": image.DataSourceImage(),
|
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
||||||
"decort_lb": lb.DataSourceLB(),
|
"decort_extnet": extnet.DataSourceExtnet(),
|
||||||
"decort_lb_list": lb.DataSourceLBList(),
|
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
||||||
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
"decort_locations_list": locations.DataSourceLocationsList(),
|
||||||
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||||
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
"decort_image_list": image.DataSourceImageList(),
|
||||||
"decort_stack": stack.DataSourceStack(),
|
"decort_image": image.DataSourceImage(),
|
||||||
"decort_stack_list": stack.DataSourceStackList(),
|
"decort_lb": lb.DataSourceLB(),
|
||||||
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
|
"decort_lb_list": lb.DataSourceLBList(),
|
||||||
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
|
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||||
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
||||||
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
|
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
||||||
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
|
"decort_stack": stack.DataSourceStack(),
|
||||||
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
"decort_stack_list": stack.DataSourceStackList(),
|
||||||
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
|
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
|
||||||
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
|
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
|
||||||
|
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
||||||
"decort_cb_account": cb_account.DataSourceAccount(),
|
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
|
||||||
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
|
||||||
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
|
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
||||||
"decort_cb_account_deleted_list": cb_account.DataSourceAccountDeletedList(),
|
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
|
||||||
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
|
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
|
||||||
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
|
|
||||||
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
"decort_cb_account": cb_account.DataSourceAccount(),
|
||||||
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
||||||
"decort_cb_account_resource_consumption_get": cb_account.DataSourceAccountResourceConsumptionGet(),
|
"decort_cb_account_computes_list": cb_account.DataSourceAccountComputesList(),
|
||||||
"decort_cb_account_resource_consumption_list": cb_account.DataSourceAccountResourceConsumptionList(),
|
"decort_cb_account_list_deleted": cb_account.DataSourceAccountDeletedList(),
|
||||||
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
"decort_cb_account_disks_list": cb_account.DataSourceAccountDisksList(),
|
||||||
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
|
"decort_cb_account_flipgroups_list": cb_account.DataSourceAccountFlipGroupsList(),
|
||||||
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
|
"decort_cb_account_rg_list": cb_account.DataSourceAccountRGList(),
|
||||||
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
|
"decort_cb_account_vins_list": cb_account.DataSourceAccountVinsList(),
|
||||||
"decort_cb_extnet_static_route_list": cb_extnet.DataSourceStaticRouteList(),
|
"decort_cb_account_resource_consumption_get": cb_account.DataSourceAccountResourceConsumptionGet(),
|
||||||
"decort_cb_extnet_static_route": cb_extnet.DataSourceStaticRoute(),
|
"decort_cb_account_resource_consumption_list": cb_account.DataSourceAccountResourceConsumptionList(),
|
||||||
}
|
"decort_cb_account_audits_list": cb_account.DataSourceAccountAuditsList(),
|
||||||
}
|
"decort_cb_audit": cb_audit.DataSourceAudit(),
|
||||||
|
"decort_cb_audit_list": cb_audit.DataSourceAuditList(),
|
||||||
|
"decort_cb_audit_linked_jobs": cb_audit.DataSourceAuditLinkedJobs(),
|
||||||
|
"decort_cb_extnet": cb_extnet.DataSourceExtnetCB(),
|
||||||
|
"decort_cb_extnet_list": cb_extnet.DataSourceExtnetListCB(),
|
||||||
|
"decort_cb_extnet_default": cb_extnet.DataSourceExtnetDefaultCB(),
|
||||||
|
"decort_cb_extnet_static_route_list": cb_extnet.DataSourceStaticRouteList(),
|
||||||
|
"decort_cb_extnet_static_route": cb_extnet.DataSourceStaticRoute(),
|
||||||
|
"decort_cb_image": cb_image.DataSourceImage(),
|
||||||
|
"decort_cb_grid": cb_grid.DataSourceGrid(),
|
||||||
|
"decort_cb_grid_get_status": cb_grid.DataSourceGridGetStatus(),
|
||||||
|
"decort_cb_grid_post_status": cb_grid.DataSourceGridPostStatus(),
|
||||||
|
"decort_cb_grid_get_diagnosis": cb_grid.DataSourceGridGetDiagnosis(),
|
||||||
|
"decort_cb_grid_post_diagnosis": cb_grid.DataSourceGridPostDiagnosis(),
|
||||||
|
"decort_cb_grid_list": cb_grid.DataSourceGridList(),
|
||||||
|
"decort_cb_grid_list_emails": cb_grid.DataSourceGridListEmails(),
|
||||||
|
"decort_cb_grid_list_consumption": cb_grid.DataSourceGridListConsumption(),
|
||||||
|
"decort_cb_grid_get_consumption": cb_grid.DataSourceGridGetConsumption(),
|
||||||
|
"decort_cb_image_list": cb_image.DataSourceImageList(),
|
||||||
|
"decort_cb_image_list_stacks": cb_image.DataSourceImageListStacks(),
|
||||||
|
"decort_cb_kvmvm": cb_kvmvm.DataSourceCompute(),
|
||||||
|
"decort_cb_kvmvm_affinity_relations": cb_kvmvm.DataSourceComputeAffinityRelations(),
|
||||||
|
"decort_cb_kvmvm_audits": cb_kvmvm.DataSourceComputeAudits(),
|
||||||
|
"decort_cb_kvmvm_boot_order_get": cb_kvmvm.DataSourceComputeBootOrderGet(),
|
||||||
|
"decort_cb_kvmvm_get_audits": cb_kvmvm.DataSourceComputeGetAudits(),
|
||||||
|
"decort_cb_kvmvm_get_console_url": cb_kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||||
|
"decort_cb_kvmvm_get_log": cb_kvmvm.DataSourceComputeGetLog(),
|
||||||
|
"decort_cb_kvmvm_list": cb_kvmvm.DataSourceComputeList(),
|
||||||
|
"decort_cb_kvmvm_list_deleted": cb_kvmvm.DataSourceComputeListDeleted(),
|
||||||
|
"decort_cb_kvmvm_migrate_storage_info": cb_kvmvm.DataSourceComputeMigrateStorageInfo(),
|
||||||
|
"decort_cb_kvmvm_pci_device_list": cb_kvmvm.DataSourceComputePCIDeviceList(),
|
||||||
|
"decort_cb_kvmvm_pfw_list": cb_kvmvm.DataSourceComputePfwList(),
|
||||||
|
"decort_cb_kvmvm_snapshot_list": cb_kvmvm.DataSourceComputeSnapshotList(),
|
||||||
|
"decort_cb_kvmvm_snapshot_usage": cb_kvmvm.DataSourceComputeSnapshotUsage(),
|
||||||
|
"decort_cb_kvmvm_user_list": cb_kvmvm.DataSourceComputeUserList(),
|
||||||
|
"decort_cb_kvmvm_vgpu_list": cb_kvmvm.DataSourceComputeVGPUList(),
|
||||||
|
"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(),
|
||||||
|
"decort_cb_pcidevice": cb_pcidevice.DataSourcePcidevice(),
|
||||||
|
"decort_cb_pcidevice_list": cb_pcidevice.DataSourcePcideviceList(),
|
||||||
|
"decort_cb_rg": cb_rg.DataSourceResgroup(),
|
||||||
|
"decort_cb_rg_affinity_group_computes": cb_rg.DataSourceRgAffinityGroupComputes(),
|
||||||
|
"decort_cb_rg_affinity_groups_get": cb_rg.DataSourceRgAffinityGroupsGet(),
|
||||||
|
"decort_cb_rg_affinity_groups_list": cb_rg.DataSourceRgAffinityGroupsList(),
|
||||||
|
"decort_cb_rg_resource_consumption_get": cb_rg.DataSourceRGResourceConsumptionGet(),
|
||||||
|
"decort_cb_rg_resource_consumption_list": cb_rg.DataSourceRGResourceConsumptionList(),
|
||||||
|
"decort_cb_rg_audits": cb_rg.DataSourceRgAudits(),
|
||||||
|
"decort_cb_rg_list": cb_rg.DataSourceRgList(),
|
||||||
|
"decort_cb_rg_list_deleted": cb_rg.DataSourceRgListDeleted(),
|
||||||
|
"decort_cb_rg_list_computes": cb_rg.DataSourceRgListComputes(),
|
||||||
|
"decort_cb_rg_list_lb": cb_rg.DataSourceRgListLb(),
|
||||||
|
"decort_cb_rg_list_pfw": cb_rg.DataSourceRgListPfw(),
|
||||||
|
"decort_cb_rg_list_vins": cb_rg.DataSourceRgListVins(),
|
||||||
|
"decort_cb_rg_usage": cb_rg.DataSourceRgUsage(),
|
||||||
|
"decort_cb_sep_list": cb_sep.DataSourceSepList(),
|
||||||
|
"decort_cb_sep": cb_sep.DataSourceSep(),
|
||||||
|
"decort_cb_sep_consumption": cb_sep.DataSourceSepConsumption(),
|
||||||
|
"decort_cb_sep_disk_list": cb_sep.DataSourceSepDiskList(),
|
||||||
|
"decort_cb_sep_config": cb_sep.DataSourceSepConfig(),
|
||||||
|
"decort_cb_sep_pool": cb_sep.DataSourceSepPool(),
|
||||||
|
"decort_cb_lb": cb_lb.DataSourceLB(),
|
||||||
|
"decort_cb_lb_list": cb_lb.DataSourceLBList(),
|
||||||
|
"decort_cb_lb_list_deleted": cb_lb.DataSourceLBListDeleted(),
|
||||||
|
"decort_cb_flipgroup_list": cb_flipgroup.DataSourceFlipgroupList(),
|
||||||
|
"decort_cb_flipgroup": cb_flipgroup.DataSourceFlipgroup(),
|
||||||
|
"decort_cb_stack_list": cb_stack.DataSourceStacksList(),
|
||||||
|
"decort_cb_stack": cb_stack.DataSourceStack(),
|
||||||
|
"decort_cb_vins": cb_vins.DataSourceVins(),
|
||||||
|
"decort_cb_vins_list": cb_vins.DataSourceVinsList(),
|
||||||
|
"decort_cb_vins_audits": cb_vins.DataSourceVinsAudits(),
|
||||||
|
"decort_cb_vins_ip_list": cb_vins.DataSourceVinsIpList(),
|
||||||
|
"decort_cb_vins_list_deleted": cb_vins.DataSourceVinsListDeleted(),
|
||||||
|
"decort_cb_vins_ext_net_list": cb_vins.DataSourceVinsExtNetList(),
|
||||||
|
"decort_cb_vins_nat_rule_list": cb_vins.DataSourceVinsNatRuleList(),
|
||||||
|
"decort_cb_vins_static_route": cb_vins.DataSourceStaticRoute(),
|
||||||
|
"decort_cb_vins_static_route_list": cb_vins.DataSourceStaticRouteList(),
|
||||||
|
"decort_cb_k8ci": cb_k8ci.DataSourceK8CI(),
|
||||||
|
"decort_cb_k8ci_list": cb_k8ci.DataSourceK8CIList(),
|
||||||
|
"decort_cb_k8ci_list_deleted": cb_k8ci.DataSourceK8CIListDeleted(),
|
||||||
|
"decort_cb_k8s": cb_k8s.DataSourceK8s(),
|
||||||
|
"decort_cb_k8s_list": cb_k8s.DataSourceK8sList(),
|
||||||
|
"decort_cb_k8s_list_deleted": cb_k8s.DataSourceK8sListDeleted(),
|
||||||
|
"decort_cb_k8s_wg": cb_k8s.DataSourceK8sWg(),
|
||||||
|
"decort_cb_k8s_wg_cloud_init": cb_k8s.DataSourceK8sWgCloudInit(),
|
||||||
|
"decort_cb_k8s_wg_list": cb_k8s.DataSourceK8sWgList(),
|
||||||
|
"decort_cb_k8s_computes": cb_k8s.DataSourceK8sComputes(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,150 +1,168 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package provider
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/location"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/location"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Provider() *schema.Provider {
|
func Provider() *schema.Provider {
|
||||||
return &schema.Provider{
|
return &schema.Provider{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"authenticator": {
|
"authenticator": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"decs3o", "legacy", "jwt", "bvs"}, true), // ignore case while validating
|
ValidateFunc: validation.StringInSlice([]string{"decs3o", "legacy", "jwt", "bvs"}, true), // ignore case while validating
|
||||||
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
|
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"oauth2_url": {
|
"oauth2_url": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
||||||
Description: "OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.",
|
Description: "OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"controller_url": {
|
"controller_url": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.",
|
Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"user": {
|
"user": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_USER", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_USER", nil),
|
||||||
Description: "User name for DECORT cloud API operations in 'legacy' authentication mode.",
|
Description: "User name for DECORT cloud API operations in 'legacy' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"password": {
|
"password": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_PASSWORD", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_PASSWORD", nil),
|
||||||
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"bvs_user": {
|
"bvs_user": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_USER", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_USER", nil),
|
||||||
Description: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
|
Description: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"bvs_password": {
|
"bvs_password": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_PASSWORD", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_PASSWORD", nil),
|
||||||
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"domain": {
|
"domain": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_DOMAIN", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_DOMAIN", nil),
|
||||||
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"app_id": {
|
"app_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
||||||
Description: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
Description: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"app_secret": {
|
"app_secret": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
||||||
Description: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
Description: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"jwt": {
|
"jwt": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_JWT", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_JWT", nil),
|
||||||
Description: "JWT to access DECORT cloud API in 'jwt' authentication mode.",
|
Description: "JWT to access DECORT cloud API in 'jwt' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"allow_unverified_ssl": {
|
"allow_unverified_ssl": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: false,
|
Default: false,
|
||||||
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
"path_cfg": {
|
||||||
ResourcesMap: newResourcesMap(),
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
DataSourcesMap: newDataSourcesMap(),
|
Description: "The path of the configuration file entry",
|
||||||
|
},
|
||||||
ConfigureContextFunc: providerConfigure,
|
|
||||||
}
|
"path_token": {
|
||||||
}
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
|
Description: "The path of the token file entry",
|
||||||
decsController, err := controller.ControllerConfigure(d)
|
},
|
||||||
if err != nil {
|
|
||||||
return nil, diag.FromErr(err)
|
"time_to_refresh": {
|
||||||
}
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
gridId, err := location.UtilityLocationGetDefaultGridID(ctx, decsController)
|
Description: "The number of minutes before the expiration of the token, a refresh will be made",
|
||||||
if err != nil {
|
},
|
||||||
return nil, diag.FromErr(err)
|
},
|
||||||
}
|
|
||||||
if gridId == 0 {
|
ResourcesMap: newResourcesMap(),
|
||||||
return nil, diag.FromErr(fmt.Errorf("providerConfigure: invalid default Grid ID = 0"))
|
|
||||||
}
|
DataSourcesMap: newDataSourcesMap(),
|
||||||
|
|
||||||
return decsController, nil
|
ConfigureContextFunc: providerConfigure,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
|
||||||
|
decsController, err := controller.ControllerConfigure(d)
|
||||||
|
if err != nil {
|
||||||
|
return nil, diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
gridId, err := location.UtilityLocationGetDefaultGridID(ctx, decsController)
|
||||||
|
if err != nil {
|
||||||
|
return nil, diag.FromErr(err)
|
||||||
|
}
|
||||||
|
if gridId == 0 {
|
||||||
|
return nil, diag.FromErr(fmt.Errorf("providerConfigure: invalid default Grid ID = 0"))
|
||||||
|
}
|
||||||
|
|
||||||
|
return decsController, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -1,104 +1,103 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package provider
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/pfw"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/pfw"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
|
||||||
|
|
||||||
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
|
||||||
// cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
cb_disks "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/disks"
|
||||||
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
cb_extnet "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/extnet"
|
||||||
// cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
cb_flipgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/flipgroup"
|
||||||
// cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
cb_image "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/image"
|
||||||
// cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
cb_k8ci "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8ci"
|
||||||
// cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
cb_k8s "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/k8s"
|
||||||
// cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
cb_kvmvm "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/kvmvm"
|
||||||
// cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb"
|
||||||
// cb_pfw "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pfw"
|
cb_pcidevice "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
|
||||||
// cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
cb_rg "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/rg"
|
||||||
// cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep"
|
||||||
// cb_snapshot "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/snapshot"
|
cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
||||||
// cb_vins "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vins"
|
)
|
||||||
)
|
|
||||||
|
func newResourcesMap() map[string]*schema.Resource {
|
||||||
func newResourcesMap() map[string]*schema.Resource {
|
return map[string]*schema.Resource{
|
||||||
return map[string]*schema.Resource{
|
"decort_resgroup": rg.ResourceResgroup(),
|
||||||
"decort_resgroup": rg.ResourceResgroup(),
|
"decort_kvmvm": kvmvm.ResourceCompute(),
|
||||||
"decort_kvmvm": kvmvm.ResourceCompute(),
|
"decort_disk": disks.ResourceDisk(),
|
||||||
"decort_disk": disks.ResourceDisk(),
|
"decort_disk_snapshot": disks.ResourceDiskSnapshot(),
|
||||||
"decort_disk_snapshot": disks.ResourceDiskSnapshot(),
|
"decort_vins": vins.ResourceVins(),
|
||||||
"decort_vins": vins.ResourceVins(),
|
"decort_pfw": pfw.ResourcePfw(),
|
||||||
"decort_pfw": pfw.ResourcePfw(),
|
"decort_k8s": k8s.ResourceK8s(),
|
||||||
"decort_k8s": k8s.ResourceK8s(),
|
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
||||||
"decort_k8s_wg": k8s.ResourceK8sWg(),
|
"decort_k8s_cp": k8s.ResourceK8sCP(),
|
||||||
"decort_k8s_cp": k8s.ResourceK8sCP(),
|
"decort_snapshot": snapshot.ResourceSnapshot(),
|
||||||
"decort_snapshot": snapshot.ResourceSnapshot(),
|
"decort_account": account.ResourceAccount(),
|
||||||
"decort_account": account.ResourceAccount(),
|
"decort_bservice": bservice.ResourceBasicService(),
|
||||||
"decort_bservice": bservice.ResourceBasicService(),
|
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
|
||||||
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
|
"decort_image": image.ResourceImage(),
|
||||||
"decort_image": image.ResourceImage(),
|
"decort_image_virtual": image.ResourceImageVirtual(),
|
||||||
"decort_image_virtual": image.ResourceImageVirtual(),
|
"decort_lb": lb.ResourceLB(),
|
||||||
"decort_lb": lb.ResourceLB(),
|
"decort_lb_backend": lb.ResourceLBBackend(),
|
||||||
"decort_lb_backend": lb.ResourceLBBackend(),
|
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
|
||||||
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
|
"decort_lb_frontend": lb.ResourceLBFrontend(),
|
||||||
"decort_lb_frontend": lb.ResourceLBFrontend(),
|
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
|
||||||
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
|
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
|
||||||
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
|
"decort_vins_static_route": vins.ResourceStaticRoute(),
|
||||||
"decort_vins_static_route": vins.ResourceStaticRoute(),
|
|
||||||
|
"decort_cb_account": cb_account.ResourceAccount(),
|
||||||
"decort_cb_account": cb_account.ResourceAccount(),
|
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
|
||||||
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),
|
"decort_cb_extnet_static_route": cb_extnet.ResourceStaticRoute(),
|
||||||
// "decort_cb_disk": cb_disks.ResourceDisk(),
|
"decort_cb_disk": cb_disks.ResourceDisk(),
|
||||||
// "decort_cb_image": cb_image.ResourceImage(),
|
"decort_cb_disk_snapshot": cb_disks.ResourceDiskSnapshot(),
|
||||||
// "decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
"decort_cb_image": cb_image.ResourceImage(),
|
||||||
// "decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
||||||
// "decort_cb_delete_images": cb_image.ResourceDeleteImages(),
|
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
||||||
// "decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
||||||
// "decort_cb_sep": cb_sep.ResourceSep(),
|
"decort_cb_sep": cb_sep.ResourceSep(),
|
||||||
// "decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
||||||
// "decort_cb_resgroup": cb_rg.ResourceResgroup(),
|
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
||||||
// "decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
"decort_cb_vins": cb_vins.ResourceVins(),
|
||||||
// "decort_cb_vins": cb_vins.ResourceVins(),
|
"decort_cb_k8ci": cb_k8ci.ResourceK8CI(),
|
||||||
// "decort_cb_pfw": cb_pfw.ResourcePfw(),
|
"decort_cb_k8s_cp": cb_k8s.ResourceK8sCP(),
|
||||||
// "decort_cb_k8s": cb_k8s.ResourceK8s(),
|
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
||||||
// "decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
"decort_cb_vins_static_route": cb_vins.ResourceStaticRoute(),
|
||||||
// "decort_cb_snapshot": cb_snapshot.ResourceSnapshot(),
|
"decort_cb_flipgroup": cb_flipgroup.ResourceFlipgroup(),
|
||||||
// "decort_cb_flipgroup": cb_flipgroup.ResourceFlipgroup(),
|
"decort_cb_lb": cb_lb.ResourceLB(),
|
||||||
// "decort_cb_lb": cb_lb.ResourceLB(),
|
"decort_cb_lb_backend": cb_lb.ResourceLBBackend(),
|
||||||
// "decort_cb_lb_backend": cb_lb.ResourceLBBackend(),
|
"decort_cb_lb_backend_server": cb_lb.ResourceLBBackendServer(),
|
||||||
// "decort_cb_lb_backend_server": cb_lb.ResourceLBBackendServer(),
|
"decort_cb_lb_frontend": cb_lb.ResourceLBFrontend(),
|
||||||
// "decort_cb_lb_frontend": cb_lb.ResourceLBFrontend(),
|
"decort_cb_lb_frontend_bind": cb_lb.ResourceLBFrontendBind(),
|
||||||
// "decort_cb_lb_frontend_bind": cb_lb.ResourceLBFrontendBind(),
|
"decort_cb_rg": cb_rg.ResourceResgroup(),
|
||||||
"decort_cb_extnet_static_route": cb_extnet.ResourceStaticRoute(),
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -1,109 +1,70 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
id := uuid.New()
|
||||||
d.Set("items", flattenAccountAuditsList(accountAuditsList))
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenAccountAuditsList(accountAuditsList))
|
||||||
return nil
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceAccountAuditsListSchemaMake() map[string]*schema.Schema {
|
|
||||||
res := map[string]*schema.Schema{
|
func DataSourceAccountAuditsList() *schema.Resource {
|
||||||
"account_id": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Required: true,
|
|
||||||
Description: "ID of the account",
|
ReadContext: dataSourceAccountAuditsListRead,
|
||||||
},
|
|
||||||
"items": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeList,
|
Read: &constants.Timeout30s,
|
||||||
Computed: true,
|
Default: &constants.Timeout60s,
|
||||||
Description: "Search Result",
|
},
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: dataSourceAccountAuditsListSchemaMake(),
|
||||||
"call": {
|
}
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"responsetime": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"statuscode": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"user": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceAccountAuditsList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceAccountAuditsListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountAuditsListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,225 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
id := uuid.New()
|
||||||
d.Set("items", flattenAccountComputesList(accountComputesList))
|
d.SetId(id.String())
|
||||||
d.Set("entry_count", accountComputesList.EntryCount)
|
d.Set("items", flattenAccountComputesList(accountComputesList))
|
||||||
|
d.Set("entry_count", accountComputesList.EntryCount)
|
||||||
return nil
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
|
|
||||||
res := map[string]*schema.Schema{
|
func DataSourceAccountComputesList() *schema.Resource {
|
||||||
"account_id": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Required: true,
|
|
||||||
Description: "ID of the account",
|
ReadContext: dataSourceAccountComputesListRead,
|
||||||
},
|
|
||||||
"compute_id": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeInt,
|
Read: &constants.Timeout30s,
|
||||||
Optional: true,
|
Default: &constants.Timeout60s,
|
||||||
Description: "Filter by compute ID",
|
},
|
||||||
},
|
|
||||||
"name": {
|
Schema: dataSourceAccountComputesListSchemaMake(),
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Optional: true,
|
}
|
||||||
Description: "Filter by compute name",
|
|
||||||
},
|
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by RG name",
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by RG ID",
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by tech. status",
|
|
||||||
},
|
|
||||||
"ip_address": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by IP address",
|
|
||||||
},
|
|
||||||
"extnet_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by extnet name",
|
|
||||||
},
|
|
||||||
"extnet_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by extnet ID",
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page number",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page size",
|
|
||||||
},
|
|
||||||
"items": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Search Result",
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cpus": {
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
"compute_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"compute_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ram": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"registered": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"total_disks_size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"user_managed": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"vins_connected": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func DataSourceAccountComputesList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceAccountComputesListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountComputesListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,284 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DataSourceAccountDeletedList() *schema.Resource {
|
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return &schema.Resource{
|
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
||||||
SchemaVersion: 1,
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
ReadContext: dataSourceAccountDeletedListRead,
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
id := uuid.New()
|
||||||
Default: &constants.Timeout60s,
|
d.SetId(id.String())
|
||||||
},
|
d.Set("items", flattenListDeleted(accountDeletedList))
|
||||||
|
d.Set("entry_count", accountDeletedList.EntryCount)
|
||||||
Schema: dataSourceAccountListDeletedSchemaMake(),
|
|
||||||
}
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func DataSourceAccountDeletedList() *schema.Resource {
|
||||||
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
return &schema.Resource{
|
||||||
if err != nil {
|
SchemaVersion: 1,
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
ReadContext: dataSourceAccountDeletedListRead,
|
||||||
|
|
||||||
id := uuid.New()
|
Timeouts: &schema.ResourceTimeout{
|
||||||
d.SetId(id.String())
|
Read: &constants.Timeout30s,
|
||||||
d.Set("items", flattenListDeleted(accountDeletedList))
|
Default: &constants.Timeout60s,
|
||||||
d.Set("entry_count", accountDeletedList.EntryCount)
|
},
|
||||||
|
|
||||||
return nil
|
Schema: dataSourceAccountListDeletedSchemaMake(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
func dataSourceAccountListDeletedSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{
|
|
||||||
"by_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by ID",
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by name",
|
|
||||||
},
|
|
||||||
"acl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by ACL",
|
|
||||||
},
|
|
||||||
"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{
|
|
||||||
"dc_location": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ckey": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"meta": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"company": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"companyurl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cpu_allocation_parameter": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cpu_allocation_ratio": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deactivation_time": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"displayname": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"resource_limits": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"cu_c": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_d": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_dm": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_i": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_m": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_np": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gpu_units": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"resource_types": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"send_access_emails": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"uniq_pools": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"version": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"vins": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,151 +1,70 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
id := uuid.New()
|
||||||
d.Set("items", flattenAccountDisksList(accountDisksList))
|
d.SetId(id.String())
|
||||||
d.Set("entry_count", accountDisksList.EntryCount)
|
d.Set("items", flattenAccountDisksList(accountDisksList))
|
||||||
|
d.Set("entry_count", accountDisksList.EntryCount)
|
||||||
return nil
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
|
|
||||||
res := map[string]*schema.Schema{
|
func DataSourceAccountDisksList() *schema.Resource {
|
||||||
"account_id": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Required: true,
|
|
||||||
Description: "ID of the account",
|
ReadContext: dataSourceAccountDisksListRead,
|
||||||
},
|
|
||||||
"disk_id": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeInt,
|
Read: &constants.Timeout30s,
|
||||||
Optional: true,
|
Default: &constants.Timeout60s,
|
||||||
Description: "Filter by disk ID",
|
},
|
||||||
},
|
|
||||||
"name": {
|
Schema: dataSourceAccountDisksListSchemaMake(),
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Optional: true,
|
}
|
||||||
Description: "Filter by disk name",
|
|
||||||
},
|
|
||||||
"disk_max_size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by disk max size",
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by disk type",
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page number",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page size",
|
|
||||||
},
|
|
||||||
"items": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Search Result",
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pool_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"shareable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"size_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceAccountDisksList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceAccountDisksListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountDisksListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,218 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
id := uuid.New()
|
||||||
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
|
d.SetId(id.String())
|
||||||
d.Set("entry_count", accountFlipGroupsList.EntryCount)
|
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
|
||||||
|
d.Set("entry_count", accountFlipGroupsList.EntryCount)
|
||||||
return nil
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
|
|
||||||
res := map[string]*schema.Schema{
|
func DataSourceAccountFlipGroupsList() *schema.Resource {
|
||||||
"account_id": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Required: true,
|
|
||||||
Description: "ID of the account",
|
ReadContext: dataSourceAccountFlipGroupsListRead,
|
||||||
},
|
|
||||||
"name": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeString,
|
Read: &constants.Timeout30s,
|
||||||
Optional: true,
|
Default: &constants.Timeout60s,
|
||||||
Description: "Filter by name",
|
},
|
||||||
},
|
|
||||||
"vins_id": {
|
Schema: dataSourceAccountFlipGroupsListSchemaMake(),
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Optional: true,
|
}
|
||||||
Description: "Filter by ViNS ID",
|
|
||||||
},
|
|
||||||
"vins_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by ViNS name",
|
|
||||||
},
|
|
||||||
"extnet_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by extnet ID",
|
|
||||||
},
|
|
||||||
"by_ip": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by IP",
|
|
||||||
},
|
|
||||||
"flipgroup_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by flipgroup ID",
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page number",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page size",
|
|
||||||
},
|
|
||||||
"items": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Search Result",
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"client_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"conn_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"default_gw": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"fg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ip": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"milestones": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"fg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"net_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"net_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"netmask": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceAccountFlipGroupsList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceAccountFlipGroupsListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountFlipGroupsListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,292 +1,72 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Nikita Sorokin, <nesorokin@basistech.ru>
|
Nikita Sorokin, <nesorokin@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DataSourceAccountList() *schema.Resource {
|
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return &schema.Resource{
|
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
||||||
SchemaVersion: 1,
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
ReadContext: dataSourceAccountListRead,
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
id := uuid.New()
|
||||||
Default: &constants.Timeout60s,
|
d.SetId(id.String())
|
||||||
},
|
d.Set("items", flattenAccountList(accountList))
|
||||||
|
d.Set("entry_count", accountList.EntryCount)
|
||||||
Schema: dataSourceAccountListSchemaMake(),
|
|
||||||
}
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func DataSourceAccountList() *schema.Resource {
|
||||||
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
return &schema.Resource{
|
||||||
if err != nil {
|
SchemaVersion: 1,
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
ReadContext: dataSourceAccountListRead,
|
||||||
|
|
||||||
id := uuid.New()
|
Timeouts: &schema.ResourceTimeout{
|
||||||
d.SetId(id.String())
|
Read: &constants.Timeout30s,
|
||||||
d.Set("items", flattenAccountList(accountList))
|
Default: &constants.Timeout60s,
|
||||||
d.Set("entry_count", accountList.EntryCount)
|
},
|
||||||
|
|
||||||
return nil
|
Schema: dataSourceAccountListSchemaMake(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
|
|
||||||
res := map[string]*schema.Schema{
|
|
||||||
"by_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by ID",
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by name",
|
|
||||||
},
|
|
||||||
"acl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by ACL",
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by status",
|
|
||||||
},
|
|
||||||
"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{
|
|
||||||
"dc_location": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ckey": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"meta": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"company": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"companyurl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cpu_allocation_parameter": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cpu_allocation_ratio": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deactivation_time": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"displayname": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"resource_limits": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"cu_c": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_d": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_dm": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_i": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_m": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"cu_np": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gpu_units": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"resource_types": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"send_access_emails": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"uniq_pools": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"version": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"vins": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -1,362 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DataSourceAccountRGList() *schema.Resource {
|
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return &schema.Resource{
|
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
||||||
SchemaVersion: 1,
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
ReadContext: dataSourceAccountRGListRead,
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
id := uuid.New()
|
||||||
Default: &constants.Timeout60s,
|
d.SetId(id.String())
|
||||||
},
|
d.Set("items", flattenAccountRGList(accountRGList))
|
||||||
|
d.Set("entry_count", accountRGList.EntryCount)
|
||||||
Schema: dataSourceAccountRGListSchemaMake(),
|
|
||||||
}
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func DataSourceAccountRGList() *schema.Resource {
|
||||||
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
return &schema.Resource{
|
||||||
if err != nil {
|
SchemaVersion: 1,
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
ReadContext: dataSourceAccountRGListRead,
|
||||||
|
|
||||||
id := uuid.New()
|
Timeouts: &schema.ResourceTimeout{
|
||||||
d.SetId(id.String())
|
Read: &constants.Timeout30s,
|
||||||
d.Set("items", flattenAccountRGList(accountRGList))
|
Default: &constants.Timeout60s,
|
||||||
d.Set("entry_count", accountRGList.EntryCount)
|
},
|
||||||
|
|
||||||
return nil
|
Schema: dataSourceAccountRGListSchemaMake(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
|
|
||||||
res := map[string]*schema.Schema{
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "ID of the account",
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page number",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page size",
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by RG ID",
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by name",
|
|
||||||
},
|
|
||||||
"vins_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by ViNS ID",
|
|
||||||
},
|
|
||||||
"vm_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by VM ID",
|
|
||||||
},
|
|
||||||
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by status",
|
|
||||||
},
|
|
||||||
"items": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Search Result",
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: dataSourceAccountRGSchemaMake(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func dataSourceAccountRGSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{
|
|
||||||
"computes": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"started": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"stopped": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"resources": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"consumed": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"cpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disksize": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disksizemax": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"extips": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"exttraffic": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ram": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"seps": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"data_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size_max": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"limits": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"cpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disksize": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disksizemax": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"extips": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"exttraffic": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ram": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"seps": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"reserved": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"cpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disksize": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disksizemax": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"extips": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"exttraffic": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ram": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"seps": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"data_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size_max": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"milestones": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"vinses": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,192 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
id := uuid.New()
|
||||||
d.Set("items", flattenAccountVinsList(accountVinsList))
|
d.SetId(id.String())
|
||||||
d.Set("entry_count", accountVinsList.EntryCount)
|
d.Set("items", flattenAccountVinsList(accountVinsList))
|
||||||
|
d.Set("entry_count", accountVinsList.EntryCount)
|
||||||
return nil
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
|
|
||||||
res := map[string]*schema.Schema{
|
func DataSourceAccountVinsList() *schema.Resource {
|
||||||
"account_id": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Required: true,
|
|
||||||
Description: "ID of the account",
|
ReadContext: dataSourceAccountVinsListRead,
|
||||||
},
|
|
||||||
"vins_id": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeInt,
|
Read: &constants.Timeout30s,
|
||||||
Optional: true,
|
Default: &constants.Timeout60s,
|
||||||
Description: "Filter by ViNS ID",
|
},
|
||||||
},
|
|
||||||
"name": {
|
Schema: dataSourceAccountVinsListSchemaMake(),
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Optional: true,
|
}
|
||||||
Description: "Filter by name",
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by RG ID",
|
|
||||||
},
|
|
||||||
"ext_ip": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Filter by external IP",
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page number",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Page size",
|
|
||||||
},
|
|
||||||
"items": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Search Result",
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"computes": {
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
"external_ip": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"vin_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"vin_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"network": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pri_vnf_dev_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_by": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"updated_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceAccountVinsList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceAccountVinsListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceAccountVinsListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,541 +1,342 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
log "github.com/sirupsen/logrus"
|
||||||
log "github.com/sirupsen/logrus"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/account"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/account"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
"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/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
)
|
||||||
)
|
|
||||||
|
func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
log.Debugf("resourseAccountCreate")
|
||||||
log.Debugf("resourseAccountCreate")
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
|
req := account.CreateRequest{
|
||||||
req := account.CreateRequest{}
|
Name: d.Get("account_name").(string),
|
||||||
|
Username: d.Get("username").(string),
|
||||||
req.Name = d.Get("account_name").(string)
|
}
|
||||||
req.Username = d.Get("username").(string)
|
|
||||||
|
if emailaddress, ok := d.GetOk("emailaddress"); ok {
|
||||||
if emailaddress, ok := d.GetOk("emailaddress"); ok {
|
req.EmailAddress = emailaddress.(string)
|
||||||
req.EmailAddress = emailaddress.(string)
|
}
|
||||||
}
|
|
||||||
|
if sendAccessEmails, ok := d.GetOk("send_access_emails"); ok {
|
||||||
if sendAccessEmails, ok := d.GetOk("send_access_emails"); ok {
|
req.SendAccessEmails = sendAccessEmails.(bool)
|
||||||
req.SendAccessEmails = sendAccessEmails.(bool)
|
}
|
||||||
}
|
|
||||||
|
if uniqPools, ok := d.GetOk("uniq_pools"); ok {
|
||||||
if uniqPools, ok := d.GetOk("uniq_pools"); ok {
|
uniqPools := uniqPools.([]interface{})
|
||||||
uniqPools := uniqPools.([]interface{})
|
for _, pool := range uniqPools {
|
||||||
for _, pool := range uniqPools {
|
req.UniqPools = append(req.UniqPools, pool.(string))
|
||||||
req.UniqPools = append(req.UniqPools, pool.(string))
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if resLimits, ok := d.GetOk("resource_limits"); ok {
|
||||||
if resLimits, ok := d.GetOk("resource_limits"); ok {
|
resLimits := resLimits.([]interface{})[0]
|
||||||
resLimits := resLimits.([]interface{})[0]
|
resLimitsConv := resLimits.(map[string]interface{})
|
||||||
resLimitsConv := resLimits.(map[string]interface{})
|
if resLimitsConv["cu_m"] != nil {
|
||||||
if resLimitsConv["cu_m"] != nil {
|
maxMemCap := int64(resLimitsConv["cu_m"].(float64))
|
||||||
maxMemCap := int64(resLimitsConv["cu_m"].(float64))
|
if maxMemCap == 0 {
|
||||||
if maxMemCap == 0 {
|
req.MaxMemoryCapacity = -1
|
||||||
req.MaxMemoryCapacity = -1
|
} else {
|
||||||
} else {
|
req.MaxMemoryCapacity = maxMemCap
|
||||||
req.MaxMemoryCapacity = maxMemCap
|
}
|
||||||
}
|
}
|
||||||
}
|
if resLimitsConv["cu_dm"] != nil {
|
||||||
if resLimitsConv["cu_dm"] != nil {
|
maxDiskCap := int64(resLimitsConv["cu_dm"].(float64))
|
||||||
maxDiskCap := int64(resLimitsConv["cu_dm"].(float64))
|
if maxDiskCap == 0 {
|
||||||
if maxDiskCap == 0 {
|
req.MaxVDiskCapacity = -1
|
||||||
req.MaxVDiskCapacity = -1
|
} else {
|
||||||
} else {
|
req.MaxVDiskCapacity = maxDiskCap
|
||||||
req.MaxVDiskCapacity = maxDiskCap
|
}
|
||||||
}
|
}
|
||||||
}
|
if resLimitsConv["cu_c"] != nil {
|
||||||
if resLimitsConv["cu_c"] != nil {
|
maxCPUCap := int64(resLimitsConv["cu_c"].(float64))
|
||||||
maxCPUCap := int64(resLimitsConv["cu_c"].(float64))
|
if maxCPUCap == 0 {
|
||||||
if maxCPUCap == 0 {
|
req.MaxCPUCapacity = -1
|
||||||
req.MaxCPUCapacity = -1
|
} else {
|
||||||
} else {
|
req.MaxCPUCapacity = maxCPUCap
|
||||||
req.MaxCPUCapacity = maxCPUCap
|
}
|
||||||
}
|
}
|
||||||
}
|
if resLimitsConv["cu_i"] != nil {
|
||||||
if resLimitsConv["cu_i"] != nil {
|
maxNumPublicIP := int64(resLimitsConv["cu_i"].(float64))
|
||||||
maxNumPublicIP := int64(resLimitsConv["cu_i"].(float64))
|
if maxNumPublicIP == 0 {
|
||||||
if maxNumPublicIP == 0 {
|
req.MaxNumPublicIP = -1
|
||||||
req.MaxNumPublicIP = -1
|
} else {
|
||||||
} else {
|
req.MaxNumPublicIP = maxNumPublicIP
|
||||||
req.MaxNumPublicIP = maxNumPublicIP
|
}
|
||||||
}
|
}
|
||||||
}
|
if resLimitsConv["cu_np"] != nil {
|
||||||
if resLimitsConv["cu_np"] != nil {
|
maxNP := int64(resLimitsConv["cu_np"].(float64))
|
||||||
maxNP := int64(resLimitsConv["cu_np"].(float64))
|
if maxNP == 0 {
|
||||||
if maxNP == 0 {
|
req.MaxNetworkPeerTransfer = -1
|
||||||
req.MaxNetworkPeerTransfer = -1
|
} else {
|
||||||
} else {
|
req.MaxNetworkPeerTransfer = maxNP
|
||||||
req.MaxNetworkPeerTransfer = maxNP
|
}
|
||||||
}
|
}
|
||||||
}
|
if resLimitsConv["gpu_units"] != nil {
|
||||||
if resLimitsConv["gpu_units"] != nil {
|
gpuUnits := int64(resLimitsConv["gpu_units"].(float64))
|
||||||
gpuUnits := int64(resLimitsConv["gpu_units"].(float64))
|
if gpuUnits == 0 {
|
||||||
if gpuUnits == 0 {
|
req.GPUUnits = -1
|
||||||
req.GPUUnits = -1
|
} else {
|
||||||
} else {
|
req.GPUUnits = gpuUnits
|
||||||
req.GPUUnits = gpuUnits
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
accountId, err := c.CloudBroker().Account().Create(ctx, req)
|
||||||
accountId, err := c.CloudBroker().Account().Create(ctx, req)
|
if err != nil {
|
||||||
if err != nil {
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
d.SetId(strconv.FormatUint(accountId, 10))
|
||||||
d.SetId(strconv.FormatUint(accountId, 10))
|
|
||||||
|
var w dc.Warnings
|
||||||
var w dc.Warnings
|
|
||||||
|
if users, ok := d.GetOk("users"); ok {
|
||||||
if users, ok := d.GetOk("users"); ok {
|
addedUsers := users.([]interface{})
|
||||||
addedUsers := users.([]interface{})
|
|
||||||
|
for _, user := range addedUsers {
|
||||||
for _, user := range addedUsers {
|
userConv := user.(map[string]interface{})
|
||||||
userConv := user.(map[string]interface{})
|
|
||||||
|
req := account.AddUserRequest{
|
||||||
req := account.AddUserRequest{
|
AccountID: accountId,
|
||||||
AccountID: accountId,
|
Username: userConv["user_id"].(string),
|
||||||
Username: userConv["user_id"].(string),
|
AccessType: userConv["access_type"].(string),
|
||||||
AccessType: userConv["access_type"].(string),
|
}
|
||||||
}
|
|
||||||
|
_, err := c.CloudBroker().Account().AddUser(ctx, req)
|
||||||
_, err := c.CloudBroker().Account().AddUser(ctx, req)
|
if err != nil {
|
||||||
if err != nil {
|
w.Add(err)
|
||||||
w.Add(err)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if cpuAllocationParameter, ok := d.GetOk("cpu_allocation_parameter"); ok {
|
||||||
if cpuAllocationParameter, ok := d.GetOk("cpu_allocation_parameter"); ok {
|
cpuAllocationParameter := cpuAllocationParameter.(string)
|
||||||
cpuAllocationParameter := cpuAllocationParameter.(string)
|
|
||||||
|
req := account.SetCPUAllocationParameterRequest{
|
||||||
req := account.SetCPUAllocationParameterRequest{
|
AccountID: accountId,
|
||||||
AccountID: accountId,
|
StrictLoose: cpuAllocationParameter,
|
||||||
StrictLoose: cpuAllocationParameter,
|
}
|
||||||
}
|
|
||||||
|
log.Debugf("setting account cpu allocation parameter")
|
||||||
log.Debugf("setting account cpu allocation parameter")
|
_, err := c.CloudBroker().Account().SetCPUAllocationParameter(ctx, req)
|
||||||
_, err := c.CloudBroker().Account().SetCPUAllocationParameter(ctx, req)
|
if err != nil {
|
||||||
if err != nil {
|
w.Add(err)
|
||||||
w.Add(err)
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if cpuAllocationRatio, ok := d.GetOk("cpu_allocation_ratio"); ok {
|
||||||
if cpuAllocationRatio, ok := d.GetOk("cpu_allocation_ratio"); ok {
|
cpuAllocationRatio := cpuAllocationRatio.(float64)
|
||||||
cpuAllocationRatio := cpuAllocationRatio.(float64)
|
|
||||||
|
req := account.SetCPUAllocationRatioRequest{
|
||||||
req := account.SetCPUAllocationRatioRequest{
|
AccountID: accountId,
|
||||||
AccountID: accountId,
|
Ratio: cpuAllocationRatio,
|
||||||
Ratio: cpuAllocationRatio,
|
}
|
||||||
}
|
|
||||||
|
log.Debugf("setting account cpu allocation ratio")
|
||||||
log.Debugf("setting account cpu allocation ratio")
|
_, err := c.CloudBroker().Account().SetCPUAllocationRatio(ctx, req)
|
||||||
_, err := c.CloudBroker().Account().SetCPUAllocationRatio(ctx, req)
|
if err != nil {
|
||||||
if err != nil {
|
w.Add(err)
|
||||||
w.Add(err)
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if !d.Get("enable").(bool) {
|
||||||
if !d.Get("enable").(bool) {
|
_, err := c.CloudBroker().Account().Disable(ctx, account.DisableRequest{
|
||||||
_, err := c.CloudBroker().Account().Disable(ctx, account.DisableRequest{
|
AccountID: accountId,
|
||||||
AccountID: accountId,
|
})
|
||||||
})
|
|
||||||
|
if err != nil {
|
||||||
if err != nil {
|
w.Add(err)
|
||||||
w.Add(err)
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return append(resourceAccountRead(ctx, d, m), w.Get()...)
|
||||||
diags := resourceAccountRead(ctx, d, m)
|
}
|
||||||
diags = append(diags, w.Get()...)
|
|
||||||
|
func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return diags
|
log.Debugf("resourceAccountRead")
|
||||||
}
|
|
||||||
|
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
||||||
func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
if err != nil {
|
||||||
log.Debugf("resourceAccountRead")
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
flattenResourceAccount(d, acc)
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
flattenResourceAccount(d, acc)
|
|
||||||
|
func resourceAccountDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return nil
|
log.Debugf("resourceAccountDelete")
|
||||||
}
|
|
||||||
|
accountData, err := utilityAccountCheckPresence(ctx, d, m)
|
||||||
func resourceAccountDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
if err != nil {
|
||||||
log.Debugf("resourceAccountDelete")
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
accountData, err := utilityAccountCheckPresence(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
c := m.(*controller.ControllerCfg)
|
||||||
}
|
req := account.DeleteRequest{
|
||||||
|
AccountID: accountData.ID,
|
||||||
c := m.(*controller.ControllerCfg)
|
Permanently: d.Get("permanently").(bool),
|
||||||
req := account.DeleteRequest{
|
}
|
||||||
AccountID: accountData.ID,
|
|
||||||
Permanently: d.Get("permanently").(bool),
|
_, err = c.CloudBroker().Account().Delete(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
_, err = c.CloudBroker().Account().Delete(ctx, req)
|
}
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
|
||||||
|
return nil
|
||||||
d.SetId("")
|
}
|
||||||
|
|
||||||
return nil
|
func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
}
|
log.Debugf("resourceAccountUpdate")
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceAccountUpdate")
|
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
||||||
c := m.(*controller.ControllerCfg)
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
acc, err := utilityAccountCheckPresence(ctx, d, m)
|
return diag.FromErr(err)
|
||||||
if err != nil {
|
}
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
accountId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
}
|
|
||||||
|
hasChanged := false
|
||||||
accountId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
|
||||||
|
switch acc.Status {
|
||||||
hasChanged := false
|
case status.Destroyed:
|
||||||
|
d.SetId("")
|
||||||
switch acc.Status {
|
// return resourceAccountCreate(ctx, d, m)
|
||||||
case status.Destroyed:
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
d.SetId("")
|
case status.Destroying:
|
||||||
// return resourceAccountCreate(ctx, d, m)
|
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
case status.Deleted:
|
||||||
case status.Destroying:
|
if d.Get("restore").(bool) {
|
||||||
return diag.Errorf("The account is in progress with status: %s", acc.Status)
|
_, err := c.CloudBroker().Account().Restore(ctx, account.RestoreRequest{
|
||||||
case status.Deleted:
|
AccountID: accountId,
|
||||||
_, err := c.CloudBroker().Account().Restore(ctx, account.RestoreRequest{
|
})
|
||||||
AccountID: accountId,
|
|
||||||
})
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
if err != nil {
|
}
|
||||||
return diag.FromErr(err)
|
if _, ok := d.GetOk("enable"); ok {
|
||||||
}
|
if err := utilityAccountEnableUpdate(ctx, d, m, acc); err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
hasChanged = true
|
}
|
||||||
case status.Disabled:
|
}
|
||||||
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
hasChanged = true
|
||||||
case status.Confirmed:
|
}
|
||||||
}
|
case status.Disabled:
|
||||||
|
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
|
||||||
if hasChanged {
|
case status.Confirmed:
|
||||||
acc, err = utilityAccountCheckPresence(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
if hasChanged {
|
||||||
return diag.FromErr(err)
|
acc, err = utilityAccountCheckPresence(ctx, d, m)
|
||||||
}
|
if err != nil {
|
||||||
}
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
if d.HasChange("enable") {
|
}
|
||||||
enable := d.Get("enable").(bool)
|
}
|
||||||
|
|
||||||
if enable && acc.Status == status.Disabled {
|
if d.HasChange("enable") {
|
||||||
_, err := c.CloudBroker().Account().Enable(ctx, account.EnableRequest{
|
if err := utilityAccountEnableUpdate(ctx, d, m, acc); err != nil {
|
||||||
AccountID: accountId,
|
return diag.FromErr(err)
|
||||||
})
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
if d.HasChanges("account_name", "send_access_emails", "uniq_pools", "resource_limits") {
|
||||||
}
|
if err := utilityAccountUpdate(ctx, d, m); err != nil {
|
||||||
} else if !enable && acc.Status == status.Enabled {
|
return diag.FromErr(err)
|
||||||
_, err := c.CloudBroker().Account().Disable(ctx, account.DisableRequest{
|
}
|
||||||
AccountID: accountId,
|
}
|
||||||
})
|
|
||||||
|
if d.HasChange("cpu_allocation_parameter") {
|
||||||
if err != nil {
|
if err := utilityAccountCPUParameterUpdate(ctx, d, m); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if d.HasChange("cpu_allocation_ratio") {
|
||||||
req := account.UpdateRequest{
|
if err := utilityAccountCPURatioUpdate(ctx, d, m); err != nil {
|
||||||
AccountID: accountId,
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updated := false
|
|
||||||
|
if d.HasChange("users") {
|
||||||
if d.HasChange("account_name") {
|
if err := utilityAccountUsersUpdate(ctx, d, m, acc); err != nil {
|
||||||
req.Name = d.Get("account_name").(string)
|
return diag.FromErr(err)
|
||||||
updated = true
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("send_access_emails") {
|
return resourceAccountRead(ctx, d, m)
|
||||||
req.SendAccessEmails = d.Get("send_access_emails").(bool)
|
}
|
||||||
updated = true
|
|
||||||
}
|
func ResourceAccount() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
if d.HasChange("uniq_pools") {
|
SchemaVersion: 1,
|
||||||
uniq_pools := d.Get("uniq_pools").([]interface{})
|
|
||||||
|
CreateContext: resourceAccountCreate,
|
||||||
for _, pool := range uniq_pools {
|
ReadContext: resourceAccountRead,
|
||||||
req.UniqPools = append(req.UniqPools, pool.(string))
|
UpdateContext: resourceAccountUpdate,
|
||||||
}
|
DeleteContext: resourceAccountDelete,
|
||||||
|
|
||||||
updated = true
|
Importer: &schema.ResourceImporter{
|
||||||
}
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
|
},
|
||||||
if d.HasChange("resource_limits") {
|
|
||||||
resLimit := d.Get("resource_limits").([]interface{})[0]
|
Timeouts: &schema.ResourceTimeout{
|
||||||
resLimitConv := resLimit.(map[string]interface{})
|
Create: &constants.Timeout60s,
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
if resLimitConv["cu_m"] != nil {
|
Update: &constants.Timeout60s,
|
||||||
maxMemCap := int(resLimitConv["cu_m"].(float64))
|
Delete: &constants.Timeout60s,
|
||||||
if maxMemCap == 0 {
|
Default: &constants.Timeout60s,
|
||||||
req.MaxMemoryCapacity = -1
|
},
|
||||||
} else {
|
|
||||||
req.MaxMemoryCapacity = int64(maxMemCap)
|
Schema: resourceAccountSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if resLimitConv["cu_dm"] != nil {
|
|
||||||
maxDiskCap := int(resLimitConv["cu_dm"].(float64))
|
|
||||||
if maxDiskCap == 0 {
|
|
||||||
req.MaxVDiskCapacity = -1
|
|
||||||
} else {
|
|
||||||
req.MaxVDiskCapacity = int64(maxDiskCap)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if resLimitConv["cu_c"] != nil {
|
|
||||||
maxCPUCap := int(resLimitConv["cu_c"].(float64))
|
|
||||||
if maxCPUCap == 0 {
|
|
||||||
req.MaxCPUCapacity = -1
|
|
||||||
} else {
|
|
||||||
req.MaxCPUCapacity = int64(maxCPUCap)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if resLimitConv["cu_i"] != nil {
|
|
||||||
maxNumPublicIP := int(resLimitConv["cu_i"].(float64))
|
|
||||||
if maxNumPublicIP == 0 {
|
|
||||||
req.MaxNumPublicIP = -1
|
|
||||||
} else {
|
|
||||||
req.MaxNumPublicIP = int64(maxNumPublicIP)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if resLimitConv["cu_np"] != nil {
|
|
||||||
maxNP := int(resLimitConv["cu_np"].(float64))
|
|
||||||
if maxNP == 0 {
|
|
||||||
req.MaxNetworkPeerTransfer = -1
|
|
||||||
} else {
|
|
||||||
req.MaxNetworkPeerTransfer = int64(maxNP)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if resLimitConv["gpu_units"] != nil {
|
|
||||||
gpuUnits := int(resLimitConv["gpu_units"].(float64))
|
|
||||||
if gpuUnits == 0 {
|
|
||||||
req.GPUUnits = -1
|
|
||||||
} else {
|
|
||||||
req.GPUUnits = int64(gpuUnits)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updated = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if updated {
|
|
||||||
_, err := c.CloudBroker().Account().Update(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("cpu_allocation_parameter") {
|
|
||||||
cpuAllocationParameter := d.Get("cpu_allocation_parameter").(string)
|
|
||||||
|
|
||||||
_, err := c.CloudBroker().Account().SetCPUAllocationParameter(ctx, account.SetCPUAllocationParameterRequest{
|
|
||||||
AccountID: acc.ID,
|
|
||||||
StrictLoose: cpuAllocationParameter,
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("cpu_allocation_ratio") {
|
|
||||||
cpuAllocacationRatio := d.Get("cpu_allocation_ratio").(float64)
|
|
||||||
|
|
||||||
_, err := c.CloudBroker().Account().SetCPUAllocationRatio(ctx, account.SetCPUAllocationRatioRequest{
|
|
||||||
AccountID: acc.ID,
|
|
||||||
Ratio: cpuAllocacationRatio,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("users") {
|
|
||||||
deletedUsers := make([]interface{}, 0)
|
|
||||||
addedUsers := make([]interface{}, 0)
|
|
||||||
updatedUsers := make([]interface{}, 0)
|
|
||||||
|
|
||||||
old, new := d.GetChange("users")
|
|
||||||
oldConv := old.([]interface{})
|
|
||||||
newConv := new.([]interface{})
|
|
||||||
for _, el := range oldConv {
|
|
||||||
if !isContainsUser(newConv, el) {
|
|
||||||
deletedUsers = append(deletedUsers, el)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, el := range newConv {
|
|
||||||
if !isContainsUser(oldConv, el) {
|
|
||||||
duplicate := false
|
|
||||||
for _, user := range acc.ACL {
|
|
||||||
if user.UserGroupID == el.(map[string]interface{})["user_id"].(string) {
|
|
||||||
duplicate = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !duplicate {
|
|
||||||
addedUsers = append(addedUsers, el)
|
|
||||||
} else if isChangedUser(oldConv, el) {
|
|
||||||
updatedUsers = append(updatedUsers, el)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, user := range deletedUsers {
|
|
||||||
userConv := user.(map[string]interface{})
|
|
||||||
|
|
||||||
_, err := c.CloudBroker().Account().DeleteUser(ctx, account.DeleteUserRequest{
|
|
||||||
AccountID: accountId,
|
|
||||||
UserName: userConv["user_id"].(string),
|
|
||||||
RecursiveDelete: userConv["recursive_delete"].(bool),
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, user := range addedUsers {
|
|
||||||
userConv := user.(map[string]interface{})
|
|
||||||
|
|
||||||
_, err := c.CloudBroker().Account().AddUser(ctx, account.AddUserRequest{
|
|
||||||
AccountID: accountId,
|
|
||||||
Username: userConv["user_id"].(string),
|
|
||||||
AccessType: strings.ToUpper(userConv["access_type"].(string)),
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, user := range updatedUsers {
|
|
||||||
userConv := user.(map[string]interface{})
|
|
||||||
|
|
||||||
_, err := c.CloudBroker().Account().UpdateUser(ctx, account.UpdateUserRequest{
|
|
||||||
AccountID: accountId,
|
|
||||||
UserID: userConv["user_id"].(string),
|
|
||||||
AccessType: strings.ToUpper(userConv["access_type"].(string)),
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return resourceAccountRead(ctx, d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func isContainsUser(els []interface{}, el interface{}) bool {
|
|
||||||
for _, elOld := range els {
|
|
||||||
elOldConv := elOld.(map[string]interface{})
|
|
||||||
elConv := el.(map[string]interface{})
|
|
||||||
if elOldConv["user_id"].(string) == elConv["user_id"].(string) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func isChangedUser(els []interface{}, el interface{}) bool {
|
|
||||||
for _, elOld := range els {
|
|
||||||
elOldConv := elOld.(map[string]interface{})
|
|
||||||
elConv := el.(map[string]interface{})
|
|
||||||
if elOldConv["user_id"].(string) == elConv["user_id"].(string) &&
|
|
||||||
(!strings.EqualFold(elOldConv["access_type"].(string), elConv["access_type"].(string)) ||
|
|
||||||
elOldConv["recursive_delete"].(bool) != elConv["recursive_delete"].(bool)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourceAccount() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
CreateContext: resourceAccountCreate,
|
|
||||||
ReadContext: resourceAccountRead,
|
|
||||||
UpdateContext: resourceAccountUpdate,
|
|
||||||
DeleteContext: resourceAccountDelete,
|
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
|
||||||
},
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Create: &constants.Timeout60s,
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Update: &constants.Timeout60s,
|
|
||||||
Delete: &constants.Timeout60s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: resourceAccountSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,442 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package disks
|
package disks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
diskList, err := utilityDiskListCheckPresence(ctx, d, m)
|
diskList, err := utilityDiskListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
id := uuid.New()
|
||||||
d.Set("items", flattenDiskList(diskList))
|
d.SetId(id.String())
|
||||||
d.Set("entry_count", diskList.EntryCount)
|
d.Set("items", flattenDiskList(diskList))
|
||||||
|
d.Set("entry_count", diskList.EntryCount)
|
||||||
return nil
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
|
||||||
res := map[string]*schema.Schema{
|
func DataSourceDiskList() *schema.Resource {
|
||||||
"by_id": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Optional: true,
|
|
||||||
Description: "Find by ID",
|
ReadContext: dataSourceDiskListRead,
|
||||||
},
|
|
||||||
"name": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeString,
|
Read: &constants.Timeout30s,
|
||||||
Optional: true,
|
Default: &constants.Timeout60s,
|
||||||
Description: "Find by name",
|
},
|
||||||
},
|
|
||||||
"account_name": {
|
Schema: dataSourceDiskListSchemaMake(),
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Optional: true,
|
}
|
||||||
Description: "Find by account name",
|
|
||||||
},
|
|
||||||
"disk_max_size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Find by max disk size",
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Find by status",
|
|
||||||
},
|
|
||||||
"shared": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Find by shared field",
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
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,
|
|
||||||
Description: "Find by sep id",
|
|
||||||
},
|
|
||||||
"pool": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Find by pool name",
|
|
||||||
},
|
|
||||||
"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{
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"acl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"boot_partition": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"computes": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"compute_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"compute_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"created_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"deleted_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"destruction_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"devicename": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_path": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"image_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"images": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"iotune": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"read_bytes_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"read_bytes_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"read_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"read_iops_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"size_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"total_bytes_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"total_bytes_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"total_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"total_iops_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"write_bytes_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"write_bytes_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"write_iops_sec": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"write_iops_sec_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"iqn": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"login": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"machine_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"machine_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"milestones": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"order": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"params": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"parent_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"passwd": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pci_slot": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"pool": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"present_to": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"purge_attempts": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"purge_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"reality_device_number": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"reference_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"res_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"res_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"sep_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"shareable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"size_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"size_used": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"snapshots": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"label": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"reference_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"res_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"snap_set_guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"snap_set_time": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"vmid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceDiskList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceDiskListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceDiskListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,100 +1,68 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package grid
|
package grid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceGridRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceGridRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
grid, err := utilityGridCheckPresence(ctx, d, m)
|
grid, err := utilityGridCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
d.SetId(strconv.FormatUint(grid.ID, 10))
|
}
|
||||||
flattenGrid(d, grid)
|
d.SetId(strconv.FormatUint(grid.ID, 10))
|
||||||
|
flattenGrid(d, grid)
|
||||||
return nil
|
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceGetGridSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{
|
func DataSourceGrid() *schema.Resource {
|
||||||
"grid_id": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Required: true,
|
|
||||||
},
|
ReadContext: dataSourceGridRead,
|
||||||
"flag": {
|
|
||||||
Type: schema.TypeString,
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Computed: true,
|
Read: &constants.Timeout30s,
|
||||||
},
|
Default: &constants.Timeout60s,
|
||||||
"gid": {
|
},
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
Schema: dataSourceGetGridSchemaMake(),
|
||||||
},
|
}
|
||||||
"guid": {
|
}
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"location_code": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceGrid() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceGridRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceGetGridSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,265 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package grid
|
package grid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceGridListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceGridListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
gridList, err := utilityGridListCheckPresence(ctx, d, m)
|
gridList, err := utilityGridListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
id := uuid.New()
|
}
|
||||||
d.SetId(id.String())
|
id := uuid.New()
|
||||||
d.Set("items", flattenGridList(gridList))
|
d.SetId(id.String())
|
||||||
d.Set("entry_count", gridList.EntryCount)
|
d.Set("items", flattenGridList(gridList))
|
||||||
return nil
|
d.Set("entry_count", gridList.EntryCount)
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceGridListSchemaMake() map[string]*schema.Schema {
|
|
||||||
rets := map[string]*schema.Schema{
|
func DataSourceGridList() *schema.Resource {
|
||||||
"by_id": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Optional: true,
|
|
||||||
Description: "by id",
|
ReadContext: dataSourceGridListRead,
|
||||||
},
|
|
||||||
"name": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeString,
|
Read: &constants.Timeout30s,
|
||||||
Optional: true,
|
Default: &constants.Timeout60s,
|
||||||
Description: "name",
|
},
|
||||||
},
|
|
||||||
"page": {
|
Schema: dataSourceGridListSchemaMake(),
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Optional: true,
|
}
|
||||||
Description: "page number",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "page size",
|
|
||||||
},
|
|
||||||
"items": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Description: "grid list",
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: dataSourceGridSchemaMake(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "entry count",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return rets
|
|
||||||
}
|
|
||||||
|
|
||||||
func dataSourceGridSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{
|
|
||||||
"resources": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"current": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"cpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ext_ips": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ext_traffic": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ram": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"seps": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"data_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size_max": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"reserved": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"cpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size_max": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ext_ips": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ext_traffic": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gpu": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"ram": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"seps": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"data_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"disk_size_max": {
|
|
||||||
Type: schema.TypeFloat,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"flag": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"gid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"location_code": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceGridList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceGridListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceGridListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,63 +1,63 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package grid
|
package grid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/grid"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/grid"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityGridCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*grid.RecordGrid, error) {
|
func utilityGridCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*grid.RecordGrid, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := grid.GetRequest{}
|
req := grid.GetRequest{}
|
||||||
|
|
||||||
if d.Id() != "" {
|
if d.Id() != "" {
|
||||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
req.GID = id
|
req.GID = id
|
||||||
} else {
|
} else {
|
||||||
req.GID = uint64(d.Get("grid_id").(int))
|
req.GID = uint64(d.Get("grid_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("utilityGridCheckPresence: load grid")
|
log.Debugf("utilityGridCheckPresence: load grid")
|
||||||
grid, err := c.CloudBroker().Grid().Get(ctx, req)
|
gridRec, err := c.CloudBroker().Grid().Get(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return grid, nil
|
return gridRec, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,98 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceImageListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
imageList, err := utilityImageListCheckPresence(ctx, d, m)
|
imageList, err := utilityImageListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
id := uuid.New()
|
}
|
||||||
d.SetId(id.String())
|
id := uuid.New()
|
||||||
d.Set("items", flattenImageList(imageList))
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenImageList(imageList))
|
||||||
return nil
|
d.Set("entry_count", imageList.EntryCount)
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceImageListSchemaMake() map[string]*schema.Schema {
|
|
||||||
rets := map[string]*schema.Schema{
|
func DataSourceImageList() *schema.Resource {
|
||||||
"sep_id": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeInt,
|
SchemaVersion: 1,
|
||||||
Optional: true,
|
|
||||||
Description: "filter images by storage endpoint provider ID",
|
ReadContext: dataSourceImageListRead,
|
||||||
},
|
|
||||||
"page": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeInt,
|
Read: &constants.Timeout30s,
|
||||||
Optional: true,
|
Default: &constants.Timeout60s,
|
||||||
Description: "page number",
|
},
|
||||||
},
|
|
||||||
"size": {
|
Schema: dataSourceImageListSchemaMake(),
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Optional: true,
|
}
|
||||||
Description: "page size",
|
|
||||||
},
|
|
||||||
"items": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Description: "image list",
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: dataSourceImageSchemaMake(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return rets
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceImageList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceImageListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceImageListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,167 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceImageListStacksRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceImageListStacksRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
imageListStacks, err := utilityImageListStacksCheckPresence(ctx, d, m)
|
imageListStacks, err := utilityImageListStacksCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
id := uuid.New()
|
}
|
||||||
d.SetId(id.String())
|
id := uuid.New()
|
||||||
d.Set("items", flattenImageListStacks(d, imageListStacks))
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenImageListStacks(imageListStacks))
|
||||||
return nil
|
d.Set("entry_count", imageListStacks.EntryCount)
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
func dataSourceImageListStackSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{
|
func DataSourceImageListStacks() *schema.Resource {
|
||||||
"api_url": {
|
return &schema.Resource{
|
||||||
Type: schema.TypeString,
|
SchemaVersion: 1,
|
||||||
Computed: true,
|
|
||||||
},
|
ReadContext: dataSourceImageListStacksRead,
|
||||||
"api_key": {
|
|
||||||
Type: schema.TypeString,
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Computed: true,
|
Read: &constants.Timeout30s,
|
||||||
},
|
Default: &constants.Timeout60s,
|
||||||
"app_id": {
|
},
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
Schema: dataSourceImageListStacksSchemaMake(),
|
||||||
},
|
}
|
||||||
"desc": {
|
}
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"drivers": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"images": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"login": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"passwd": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"reference_id": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func dataSourceImageListStacksSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{
|
|
||||||
"image_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "image id",
|
|
||||||
},
|
|
||||||
"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: dataSourceImageListStackSchemaMake(),
|
|
||||||
},
|
|
||||||
Description: "items of stacks list",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceImageListStacks() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceImageListStacksRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceImageListStacksSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,382 +1,257 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
"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/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/ic"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||||
func resourceCDROMImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
)
|
||||||
log.Debugf("resourceCDROMImageCreate: called for image %s", d.Get("name").(string))
|
|
||||||
c := m.(*controller.ControllerCfg)
|
func resourceCDROMImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
req := image.CreateCDROMImageRequest{
|
log.Debugf("resourceCDROMImageCreate: called for image %s", d.Get("name").(string))
|
||||||
Name: d.Get("name").(string),
|
c := m.(*controller.ControllerCfg)
|
||||||
URL: d.Get("url").(string),
|
req := image.CreateCDROMImageRequest{
|
||||||
GID: uint64(d.Get("gid").(int)),
|
Name: d.Get("name").(string),
|
||||||
}
|
URL: d.Get("url").(string),
|
||||||
|
}
|
||||||
drivers := []string{}
|
|
||||||
for _, driver := range d.Get("drivers").([]interface{}) {
|
if err := ic.ExistGID(ctx, uint64(d.Get("gid").(int)), c); err != nil {
|
||||||
drivers = append(drivers, driver.(string))
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Drivers = drivers
|
req.GID = uint64(d.Get("gid").(int))
|
||||||
|
|
||||||
if username, ok := d.GetOk("username_dl"); ok {
|
drivers := []string{}
|
||||||
req.UsernameDL = username.(string)
|
for _, driver := range d.Get("drivers").([]interface{}) {
|
||||||
}
|
drivers = append(drivers, driver.(string))
|
||||||
if password, ok := d.GetOk("password_dl"); ok {
|
}
|
||||||
req.PasswordDl = password.(string)
|
req.Drivers = drivers
|
||||||
}
|
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
if username, ok := d.GetOk("username_dl"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
req.UsernameDL = username.(string)
|
||||||
}
|
}
|
||||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
if password, ok := d.GetOk("password_dl"); ok {
|
||||||
req.SEPID = uint64(sepId.(int))
|
req.PasswordDl = password.(string)
|
||||||
}
|
}
|
||||||
if poolName, ok := d.GetOk("pool_name"); ok {
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
req.PoolName = poolName.(string)
|
req.AccountID = uint64(accountId.(int))
|
||||||
}
|
}
|
||||||
if architecture, ok := d.GetOk("architecture"); ok {
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||||
req.Architecture = architecture.(string)
|
req.SEPID = uint64(sepId.(int))
|
||||||
}
|
}
|
||||||
|
if poolName, ok := d.GetOk("pool_name"); ok {
|
||||||
imageId, err := c.CloudBroker().Image().CreateCDROMImage(ctx, req)
|
req.PoolName = poolName.(string)
|
||||||
if err != nil {
|
}
|
||||||
return diag.FromErr(err)
|
if architecture, ok := d.GetOk("architecture"); ok {
|
||||||
}
|
req.Architecture = architecture.(string)
|
||||||
|
}
|
||||||
d.SetId(strconv.FormatUint(imageId, 10))
|
|
||||||
d.Set("image_id", imageId)
|
imageId, err := c.CloudBroker().Image().CreateCDROMImage(ctx, req)
|
||||||
|
if err != nil {
|
||||||
image, err := utilityImageCheckPresence(ctx, d, m)
|
return diag.FromErr(err)
|
||||||
if err != nil {
|
}
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
d.SetId(strconv.FormatUint(imageId, 10))
|
||||||
|
|
||||||
d.Set("bootable", image.Bootable)
|
return resourceImageRead(ctx, d, m)
|
||||||
|
}
|
||||||
diagnostics := resourceImageRead(ctx, d, m)
|
|
||||||
if diagnostics != nil {
|
func resourceCDROMImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return diagnostics
|
log.Debugf("resourceCDROMImageRead: called for %s id: %s", d.Get("name").(string), d.Id())
|
||||||
}
|
|
||||||
|
img, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
return nil
|
if err != nil {
|
||||||
}
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
func resourceCDROMImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
}
|
||||||
log.Debugf("resourceCDROMImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
|
||||||
|
switch img.Status {
|
||||||
imageData, err := utilityImageCheckPresence(ctx, d, m)
|
case status.Modeled:
|
||||||
if err != nil {
|
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
|
||||||
return diag.FromErr(err)
|
case status.Destroyed, status.Purged:
|
||||||
}
|
d.SetId("")
|
||||||
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
c := m.(*controller.ControllerCfg)
|
}
|
||||||
req := image.DeleteCDROMImageRequest{
|
|
||||||
ImageID: imageData.ID,
|
flattenImage(d, img)
|
||||||
}
|
|
||||||
|
return nil
|
||||||
if permanently, ok := d.GetOk("permanently"); ok {
|
}
|
||||||
req.Permanently = permanently.(bool)
|
|
||||||
}
|
func resourceCDROMImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceCDROMImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
_, err = c.CloudBroker().Image().DeleteCDROMImage(ctx, req)
|
|
||||||
if err != nil {
|
imageData, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
return diag.FromErr(err)
|
if err != nil {
|
||||||
}
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
d.SetId("")
|
}
|
||||||
|
|
||||||
return nil
|
c := m.(*controller.ControllerCfg)
|
||||||
}
|
req := image.DeleteCDROMImageRequest{
|
||||||
|
ImageID: imageData.ID,
|
||||||
func resourceCDROMImageSchemaMake() map[string]*schema.Schema {
|
}
|
||||||
return map[string]*schema.Schema{
|
|
||||||
"name": {
|
if permanently, ok := d.GetOk("permanently"); ok {
|
||||||
Type: schema.TypeString,
|
req.Permanently = permanently.(bool)
|
||||||
Required: true,
|
}
|
||||||
Description: "Name of the rescue disk",
|
|
||||||
},
|
_, err = c.CloudBroker().Image().DeleteCDROMImage(ctx, req)
|
||||||
"url": {
|
if err != nil {
|
||||||
Type: schema.TypeString,
|
return diag.FromErr(err)
|
||||||
Required: true,
|
}
|
||||||
Description: "URL where to download ISO from",
|
|
||||||
},
|
d.SetId("")
|
||||||
"gid": {
|
|
||||||
Type: schema.TypeInt,
|
return nil
|
||||||
Required: true,
|
}
|
||||||
Description: "grid (platform) ID where this template should be create in",
|
|
||||||
},
|
func resourceCDROMImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
"boot_type": {
|
log.Debugf("resourceCDROMImageEdit: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
img, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
Description: "Boot type of image bios or uefi",
|
if err != nil {
|
||||||
},
|
d.SetId("")
|
||||||
"image_type": {
|
return diag.FromErr(err)
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Computed: true,
|
|
||||||
Description: "Image type linux, windows or other",
|
switch img.Status {
|
||||||
},
|
case status.Modeled:
|
||||||
"drivers": {
|
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
|
||||||
Type: schema.TypeList,
|
case status.Destroyed, status.Purged:
|
||||||
Required: true,
|
d.SetId("")
|
||||||
Elem: &schema.Schema{
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
Type: schema.TypeString,
|
}
|
||||||
},
|
|
||||||
Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]",
|
if d.HasChange("enabled") {
|
||||||
},
|
err := resourceImageChangeEnabled(ctx, d, m)
|
||||||
"meta": {
|
if err != nil {
|
||||||
Type: schema.TypeList,
|
return diag.FromErr(err)
|
||||||
Computed: true,
|
}
|
||||||
Elem: &schema.Schema{
|
}
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
if d.HasChange("shared_with") {
|
||||||
Description: "meta",
|
err := resourceImageShare(ctx, d, m)
|
||||||
},
|
if err != nil {
|
||||||
"hot_resize": {
|
return diag.FromErr(err)
|
||||||
Type: schema.TypeBool,
|
}
|
||||||
Optional: true,
|
}
|
||||||
Computed: true,
|
|
||||||
Description: "Does this machine supports hot resize",
|
if d.HasChange("computeci_id") {
|
||||||
},
|
err := resourceImageChangeComputeci(ctx, d, m)
|
||||||
// "username": {
|
if err != nil {
|
||||||
// Type: schema.TypeString,
|
return diag.FromErr(err)
|
||||||
// Optional: true,
|
}
|
||||||
// Computed: true,
|
}
|
||||||
// Description: "Optional username for the image",
|
|
||||||
// },
|
if d.HasChange("enabled_stacks") {
|
||||||
// "password": {
|
err := resourceImageUpdateNodes(ctx, d, m)
|
||||||
// Type: schema.TypeString,
|
if err != nil {
|
||||||
// Optional: true,
|
return diag.FromErr(err)
|
||||||
// Computed: true,
|
}
|
||||||
// Description: "Optional password for the image",
|
}
|
||||||
// },
|
|
||||||
"account_id": {
|
if d.HasChanges("name", "password_dl", "username_dl", "account_id", "bootable", "hot_resize") {
|
||||||
Type: schema.TypeInt,
|
err := resourceImageCDROMEdit(ctx, d, m)
|
||||||
Optional: true,
|
if err != nil {
|
||||||
Computed: true,
|
return diag.FromErr(err)
|
||||||
Description: "AccountId to make the image exclusive",
|
}
|
||||||
},
|
}
|
||||||
"username_dl": {
|
|
||||||
Type: schema.TypeString,
|
return nil
|
||||||
Optional: true,
|
}
|
||||||
Computed: true,
|
|
||||||
Description: "username for upload binary media",
|
func resourceImageCDROMEdit(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
},
|
log.Debugf("resourceImageEdit: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
"password_dl": {
|
c := m.(*controller.ControllerCfg)
|
||||||
Type: schema.TypeString,
|
req := image.EditRequest{}
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
req.ImageID = uint64(d.Get("image_id").(int))
|
||||||
Description: "password for upload binary media",
|
if d.HasChange("name") {
|
||||||
},
|
req.Name = d.Get("name").(string)
|
||||||
"sep_id": {
|
}
|
||||||
Type: schema.TypeInt,
|
if d.HasChange("username_dl") {
|
||||||
Optional: true,
|
req.Username = d.Get("username_dl").(string)
|
||||||
Computed: true,
|
}
|
||||||
Description: "storage endpoint provider ID",
|
if d.HasChange("password_dl") {
|
||||||
},
|
req.Password = d.Get("password_dl").(string)
|
||||||
"pool_name": {
|
}
|
||||||
Type: schema.TypeString,
|
if d.HasChange("account_id") {
|
||||||
Optional: true,
|
req.AccountID = uint64(d.Get("account_id").(int))
|
||||||
Computed: true,
|
}
|
||||||
Description: "pool for image create",
|
if d.HasChange("bootable") {
|
||||||
},
|
req.Bootable = d.Get("bootable").(bool)
|
||||||
"architecture": {
|
}
|
||||||
Type: schema.TypeString,
|
if d.HasChange("hot_resize") {
|
||||||
Optional: true,
|
req.HotResize = d.Get("hot_resize").(bool)
|
||||||
Computed: true,
|
}
|
||||||
Description: "binary architecture of this image, one of X86_64 of PPC64_LE",
|
|
||||||
},
|
_, err := c.CloudBroker().Image().Edit(ctx, req)
|
||||||
"image_id": {
|
if err != nil {
|
||||||
Type: schema.TypeInt,
|
return err
|
||||||
Computed: true,
|
}
|
||||||
Description: "image id",
|
return nil
|
||||||
},
|
}
|
||||||
"permanently": {
|
|
||||||
Type: schema.TypeBool,
|
func ResourceCDROMImage() *schema.Resource {
|
||||||
Optional: true,
|
return &schema.Resource{
|
||||||
Computed: true,
|
SchemaVersion: 1,
|
||||||
Description: "Whether to completely delete the image",
|
|
||||||
},
|
CreateContext: resourceCDROMImageCreate,
|
||||||
"bootable": {
|
ReadContext: resourceCDROMImageRead,
|
||||||
Type: schema.TypeBool,
|
UpdateContext: resourceCDROMImageUpdate,
|
||||||
Optional: true,
|
DeleteContext: resourceCDROMImageDelete,
|
||||||
Computed: true,
|
|
||||||
Description: "Does this image boot OS",
|
Importer: &schema.ResourceImporter{
|
||||||
},
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
"unc_path": {
|
},
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Description: "unc path",
|
Create: &constants.Timeout60s,
|
||||||
},
|
Read: &constants.Timeout30s,
|
||||||
"link_to": {
|
Update: &constants.Timeout60s,
|
||||||
Type: schema.TypeInt,
|
Delete: &constants.Timeout60s,
|
||||||
Computed: true,
|
Default: &constants.Timeout60s,
|
||||||
Description: "",
|
},
|
||||||
},
|
|
||||||
"status": {
|
Schema: resourceCDROMImageSchemaMake(),
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Computed: true,
|
}
|
||||||
Description: "status",
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "tech atatus",
|
|
||||||
},
|
|
||||||
"version": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "version",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "image size",
|
|
||||||
},
|
|
||||||
"enabled": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"computeci_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"milestones": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"provider_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"purge_attempts": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"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,
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"shared_with": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"enabled_stacks": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"history": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourceCDROMImage() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
CreateContext: resourceCDROMImageCreate,
|
|
||||||
ReadContext: resourceImageRead,
|
|
||||||
UpdateContext: resourceImageUpdate,
|
|
||||||
DeleteContext: resourceCDROMImageDelete,
|
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
|
||||||
},
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Create: &constants.Timeout60s,
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Update: &constants.Timeout60s,
|
|
||||||
Delete: &constants.Timeout60s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: resourceCDROMImageSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,611 +1,341 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
"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/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||||
|
)
|
||||||
func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageCreate: called for image %s", d.Get("name").(string))
|
func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceImageCreate: called for image %s", d.Get("name").(string))
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := image.CreateRequest{
|
c := m.(*controller.ControllerCfg)
|
||||||
Name: d.Get("name").(string),
|
|
||||||
URL: d.Get("url").(string),
|
syncMode := d.Get("sync_mode").(bool)
|
||||||
GID: uint64(d.Get("gid").(int)),
|
var imageId uint64
|
||||||
BootType: d.Get("boot_type").(string),
|
|
||||||
ImageType: d.Get("image_type").(string),
|
if syncMode {
|
||||||
}
|
req, err := SyncCreateRequest(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
drivers := []string{}
|
return diag.FromErr(err)
|
||||||
for _, driver := range d.Get("drivers").([]interface{}) {
|
}
|
||||||
drivers = append(drivers, driver.(string))
|
imageId, err = c.CloudBroker().Image().SyncCreate(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
req.Drivers = drivers
|
}
|
||||||
|
} else {
|
||||||
if hotresize, ok := d.GetOk("hot_resize"); ok {
|
req, err := CreateRequest(ctx, d, m)
|
||||||
req.HotResize = hotresize.(bool)
|
if err != nil {
|
||||||
}
|
return diag.FromErr(err)
|
||||||
if username, ok := d.GetOk("username"); ok {
|
}
|
||||||
req.Username = username.(string)
|
imageId, err = c.CloudBroker().Image().CreateImage(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
if password, ok := d.GetOk("password"); ok {
|
return diag.FromErr(err)
|
||||||
req.Password = password.(string)
|
}
|
||||||
}
|
}
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
|
||||||
req.AccountID = uint64(accountId.(int))
|
d.SetId(strconv.FormatUint(imageId, 10))
|
||||||
}
|
|
||||||
if usernameDL, ok := d.GetOk("username_dl"); ok {
|
return resourceImageRead(ctx, d, m)
|
||||||
req.UsernameDL = usernameDL.(string)
|
}
|
||||||
}
|
|
||||||
if passwordDL, ok := d.GetOk("password_dl"); ok {
|
func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
req.PasswordDL = passwordDL.(string)
|
log.Debugf("resourceImageRead: called for %s id: %s", d.Get("name").(string), d.Id())
|
||||||
}
|
|
||||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
img, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
req.SEPID = uint64(sepId.(int))
|
if err != nil {
|
||||||
}
|
d.SetId("")
|
||||||
if poolName, ok := d.GetOk("pool_name"); ok {
|
return diag.FromErr(err)
|
||||||
req.PoolName = poolName.(string)
|
}
|
||||||
}
|
|
||||||
if architecture, ok := d.GetOk("architecture"); ok {
|
switch img.Status {
|
||||||
req.Architecture = architecture.(string)
|
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:
|
||||||
imageId, err := c.CloudBroker().Image().CreateImage(ctx, req)
|
d.SetId("")
|
||||||
if err != nil {
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
flattenImage(d, img)
|
||||||
d.SetId(strconv.FormatUint(imageId, 10))
|
|
||||||
d.Set("image_id", imageId)
|
return nil
|
||||||
|
}
|
||||||
return resourceImageRead(ctx, d, m)
|
|
||||||
}
|
func resourceImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageRead: called for %s id: %s", d.Get("name").(string), d.Id())
|
_, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
image, err := utilityImageCheckPresence(ctx, d, m)
|
d.SetId("")
|
||||||
if err != nil {
|
return diag.FromErr(err)
|
||||||
d.SetId("")
|
}
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
c := m.(*controller.ControllerCfg)
|
||||||
|
req := image.DeleteRequest{
|
||||||
flattenImage(d, image)
|
ImageID: uint64(d.Get("image_id").(int)),
|
||||||
|
}
|
||||||
return nil
|
|
||||||
}
|
if reason, ok := d.GetOk("reason"); ok {
|
||||||
|
req.Reason = reason.(string)
|
||||||
func resourceImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
}
|
||||||
log.Debugf("resourceImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
if permanently, ok := d.GetOk("permanently"); ok {
|
||||||
|
req.Permanently = permanently.(bool)
|
||||||
_, err := utilityImageCheckPresence(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
_, err = c.CloudBroker().Image().Delete(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
c := m.(*controller.ControllerCfg)
|
}
|
||||||
req := image.DeleteRequest{
|
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
d.SetId("")
|
||||||
}
|
|
||||||
|
return nil
|
||||||
if reason, ok := d.GetOk("reason"); ok {
|
}
|
||||||
req.Reason = reason.(string)
|
|
||||||
}
|
func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
if permanently, ok := d.GetOk("permanently"); ok {
|
log.Debugf("resourceImageEdit: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
req.Permanently = permanently.(bool)
|
|
||||||
}
|
img, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
_, err = c.CloudBroker().Image().Delete(ctx, req)
|
d.SetId("")
|
||||||
if err != nil {
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
switch img.Status {
|
||||||
d.SetId("")
|
case status.Modeled:
|
||||||
|
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
|
||||||
return nil
|
case status.Destroyed, status.Purged:
|
||||||
}
|
d.SetId("")
|
||||||
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
func resourceImageEditName(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
}
|
||||||
log.Debugf("resourceImageEditName: called for %s, id: %s", d.Get("name").(string), d.Id())
|
|
||||||
c := m.(*controller.ControllerCfg)
|
if d.HasChange("enabled") {
|
||||||
req := image.RenameRequest{
|
err := resourceImageChangeEnabled(ctx, d, m)
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
if err != nil {
|
||||||
Name: d.Get("name").(string),
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_, err := c.CloudBroker().Image().Rename(ctx, req)
|
|
||||||
if err != nil {
|
if d.HasChange("shared_with") {
|
||||||
return err
|
err := resourceImageShare(ctx, d, m)
|
||||||
}
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
return nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
if d.HasChange("computeci_id") {
|
||||||
log.Debugf("resourceImageEdit: called for %s, id: %s", d.Get("name").(string), d.Id())
|
err := resourceImageChangeComputeci(ctx, d, m)
|
||||||
c := m.(*controller.ControllerCfg)
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
if d.HasChange("enabled") {
|
}
|
||||||
err := resourceImageChangeEnabled(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
if d.HasChange("enabled_stacks") {
|
||||||
}
|
err := resourceImageUpdateNodes(ctx, d, m)
|
||||||
}
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
if d.HasChange("name") {
|
}
|
||||||
err := resourceImageEditName(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("shared_with") {
|
}
|
||||||
err := resourceImageShare(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
return nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
func resourceImageChangeEnabled(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
if d.HasChange("computeci_id") {
|
c := m.(*controller.ControllerCfg)
|
||||||
err := resourceImageChangeComputeci(ctx, d, m)
|
imageId := uint64(d.Get("image_id").(int))
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
if d.Get("enabled").(bool) {
|
||||||
}
|
req := image.EnableRequest{
|
||||||
}
|
ImageID: imageId,
|
||||||
|
}
|
||||||
if d.HasChange("enabled_stacks") {
|
|
||||||
err := resourceImageUpdateNodes(ctx, d, m)
|
_, err := c.CloudBroker().Image().Enable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return err
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
req := image.DisableRequest{
|
||||||
if d.HasChange("link_to") {
|
ImageID: imageId,
|
||||||
err := resourceImageLink(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
_, err := c.CloudBroker().Image().Disable(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
}
|
return err
|
||||||
|
}
|
||||||
if d.HasChanges("name", "username", "password", "account_id", "bootable", "hot_resize") {
|
}
|
||||||
req := image.EditRequest{}
|
|
||||||
|
return nil
|
||||||
req.ImageID = uint64(d.Get("image_id").(int))
|
}
|
||||||
req.Name = d.Get("name").(string)
|
|
||||||
|
func resourceImageShare(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
req.Username = d.Get("username").(string)
|
log.Debugf("resourceImageShare: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
req.Password = d.Get("password").(string)
|
c := m.(*controller.ControllerCfg)
|
||||||
req.AccountID = uint64(d.Get("account_id").(int))
|
req := image.ShareRequest{
|
||||||
req.Bootable = d.Get("bootable").(bool)
|
ImageId: uint64(d.Get("image_id").(int)),
|
||||||
req.HotResize = d.Get("hot_resize").(bool)
|
}
|
||||||
|
accIds := []uint64{}
|
||||||
_, err := c.CloudBroker().Image().Edit(ctx, req)
|
for _, accId := range d.Get("shared_with").([]interface{}) {
|
||||||
if err != nil {
|
accIds = append(accIds, uint64(accId.(int)))
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
req.AccountIDs = accIds
|
||||||
}
|
|
||||||
|
_, err := c.CloudBroker().Image().Share(ctx, req)
|
||||||
return nil
|
if err != nil {
|
||||||
}
|
return err
|
||||||
|
}
|
||||||
func resourceImageChangeEnabled(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
return nil
|
||||||
imageId := uint64(d.Get("image_id").(int))
|
}
|
||||||
|
|
||||||
if d.Get("enabled").(bool) {
|
func resourceImageChangeComputeci(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
req := image.EnableRequest{
|
c := m.(*controller.ControllerCfg)
|
||||||
ImageID: imageId,
|
|
||||||
}
|
imageId := uint64(d.Get("image_id").(int))
|
||||||
|
computeci := uint64(d.Get("computeci_id").(int))
|
||||||
_, err := c.CloudBroker().Image().Enable(ctx, req)
|
|
||||||
if err != nil {
|
if computeci == 0 {
|
||||||
return err
|
req := image.ComputeCIUnsetRequest{
|
||||||
}
|
ImageID: imageId,
|
||||||
} else {
|
}
|
||||||
req := image.DisableRequest{
|
|
||||||
ImageID: imageId,
|
_, err := c.CloudBroker().Image().ComputeCIUnset(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return err
|
||||||
_, err := c.CloudBroker().Image().Disable(ctx, req)
|
}
|
||||||
if err != nil {
|
} else {
|
||||||
return err
|
req := image.ComputeCISetRequest{
|
||||||
}
|
ImageID: imageId,
|
||||||
}
|
ComputeCIID: computeci,
|
||||||
|
}
|
||||||
return nil
|
|
||||||
}
|
_, err := c.CloudBroker().Image().ComputeCISet(ctx, req)
|
||||||
|
if err != nil {
|
||||||
func resourceImageLink(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
return err
|
||||||
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)),
|
return nil
|
||||||
TargetID: uint64(d.Get("link_to").(int)),
|
}
|
||||||
}
|
|
||||||
|
func resourceImageUpdateNodes(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
_, err := c.CloudBroker().Image().Link(ctx, req)
|
log.Debugf("resourceImageUpdateNodes: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
if err != nil {
|
c := m.(*controller.ControllerCfg)
|
||||||
return err
|
req := image.UpdateNodesRequest{
|
||||||
}
|
ImageID: uint64(d.Get("image_id").(int)),
|
||||||
|
}
|
||||||
return nil
|
enabledStacks := []uint64{}
|
||||||
}
|
for _, stack := range d.Get("enabled_stacks").([]interface{}) {
|
||||||
|
enabledStacks = append(enabledStacks, uint64(stack.(int)))
|
||||||
func resourceImageShare(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
}
|
||||||
log.Debugf("resourceImageShare: called for %s, id: %s", d.Get("name").(string), d.Id())
|
|
||||||
c := m.(*controller.ControllerCfg)
|
req.EnabledStacks = enabledStacks
|
||||||
req := image.ShareRequest{
|
|
||||||
ImageId: uint64(d.Get("image_id").(int)),
|
_, err := c.CloudBroker().Image().UpdateNodes(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
accIds := []uint64{}
|
return err
|
||||||
for _, accId := range d.Get("shared_with").([]interface{}) {
|
}
|
||||||
accIds = append(accIds, uint64(accId.(int)))
|
|
||||||
}
|
return nil
|
||||||
req.AccountIDs = accIds
|
}
|
||||||
|
|
||||||
_, err := c.CloudBroker().Image().Share(ctx, req)
|
func resourceImageEdit(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
if err != nil {
|
log.Debugf("resourceImageEdit: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
return err
|
c := m.(*controller.ControllerCfg)
|
||||||
}
|
req := image.EditRequest{}
|
||||||
|
|
||||||
return nil
|
req.ImageID = uint64(d.Get("image_id").(int))
|
||||||
}
|
if d.HasChange("name") {
|
||||||
|
req.Name = d.Get("name").(string)
|
||||||
func resourceImageChangeComputeci(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
}
|
||||||
c := m.(*controller.ControllerCfg)
|
if d.HasChange("username") {
|
||||||
|
req.Username = d.Get("username").(string)
|
||||||
imageId := uint64(d.Get("image_id").(int))
|
}
|
||||||
computeci := uint64(d.Get("computeci_id").(int))
|
if d.HasChange("password") {
|
||||||
|
req.Password = d.Get("password").(string)
|
||||||
if computeci == 0 {
|
}
|
||||||
req := image.ComputeCIUnsetRequest{
|
if d.HasChange("account_id") {
|
||||||
ImageID: imageId,
|
req.AccountID = uint64(d.Get("account_id").(int))
|
||||||
}
|
}
|
||||||
|
if d.HasChange("bootable") {
|
||||||
_, err := c.CloudBroker().Image().ComputeCIUnset(ctx, req)
|
req.Bootable = d.Get("bootable").(bool)
|
||||||
if err != nil {
|
}
|
||||||
return err
|
if d.HasChange("hot_resize") {
|
||||||
}
|
req.HotResize = d.Get("hot_resize").(bool)
|
||||||
} else {
|
}
|
||||||
req := image.ComputeCISetRequest{
|
|
||||||
ImageID: imageId,
|
_, err := c.CloudBroker().Image().Edit(ctx, req)
|
||||||
ComputeCIID: computeci,
|
if err != nil {
|
||||||
}
|
return err
|
||||||
|
}
|
||||||
_, err := c.CloudBroker().Image().ComputeCISet(ctx, req)
|
return nil
|
||||||
if err != nil {
|
}
|
||||||
return err
|
|
||||||
}
|
func ResourceImage() *schema.Resource {
|
||||||
}
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
return nil
|
|
||||||
}
|
CreateContext: resourceImageCreate,
|
||||||
|
ReadContext: resourceImageRead,
|
||||||
func resourceImageUpdateNodes(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
UpdateContext: resourceImageUpdate,
|
||||||
log.Debugf("resourceImageUpdateNodes: called for %s, id: %s", d.Get("name").(string), d.Id())
|
DeleteContext: resourceImageDelete,
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := image.UpdateNodesRequest{
|
Importer: &schema.ResourceImporter{
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
}
|
},
|
||||||
enabledStacks := []uint64{}
|
|
||||||
for _, stack := range d.Get("enabled_stacks").([]interface{}) {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
enabledStacks = append(enabledStacks, uint64(stack.(int)))
|
Create: &constants.Timeout60s,
|
||||||
}
|
Read: &constants.Timeout30s,
|
||||||
|
Update: &constants.Timeout60s,
|
||||||
req.EnabledStacks = enabledStacks
|
Delete: &constants.Timeout60s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
_, err := c.CloudBroker().Image().UpdateNodes(ctx, req)
|
},
|
||||||
if err != nil {
|
|
||||||
return err
|
Schema: resourceImageSchemaMake(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceImageSchemaMake() map[string]*schema.Schema {
|
|
||||||
return map[string]*schema.Schema{
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Name of the rescue disk",
|
|
||||||
},
|
|
||||||
"url": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "URL where to download media from",
|
|
||||||
},
|
|
||||||
"gid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "grid (platform) ID where this template should be create in",
|
|
||||||
},
|
|
||||||
"boot_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Boot type of image bios or uefi",
|
|
||||||
},
|
|
||||||
"image_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Image type linux, windows or other",
|
|
||||||
},
|
|
||||||
"drivers": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Required: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]",
|
|
||||||
},
|
|
||||||
"meta": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
Description: "meta",
|
|
||||||
},
|
|
||||||
"hot_resize": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Does this machine supports hot resize",
|
|
||||||
},
|
|
||||||
"username": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Optional username for the image",
|
|
||||||
},
|
|
||||||
"password": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Optional password for the image",
|
|
||||||
},
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "AccountId to make the image exclusive",
|
|
||||||
},
|
|
||||||
"username_dl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "username for upload binary media",
|
|
||||||
},
|
|
||||||
"password_dl": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "password for upload binary media",
|
|
||||||
},
|
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "storage endpoint provider ID",
|
|
||||||
},
|
|
||||||
"pool_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "pool for image create",
|
|
||||||
},
|
|
||||||
"architecture": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "binary architecture of this image, one of X86_64 of PPC64_LE",
|
|
||||||
},
|
|
||||||
"image_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "image id",
|
|
||||||
},
|
|
||||||
"permanently": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Whether to completely delete the image",
|
|
||||||
},
|
|
||||||
"bootable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Does this image boot OS",
|
|
||||||
},
|
|
||||||
"unc_path": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "unc path",
|
|
||||||
},
|
|
||||||
"link_to": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "",
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "status",
|
|
||||||
},
|
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "tech atatus",
|
|
||||||
},
|
|
||||||
"version": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "version",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "image size",
|
|
||||||
},
|
|
||||||
"enabled": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"computeci_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"milestones": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"provider_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"purge_attempts": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"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,
|
|
||||||
},
|
|
||||||
"reason": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
},
|
|
||||||
"last_modified": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"shared_with": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"sync": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Create image from a media identified by URL (in synchronous mode)",
|
|
||||||
},
|
|
||||||
"enabled_stacks": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"history": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"timestamp": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourceImage() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
CreateContext: resourceImageCreate,
|
|
||||||
ReadContext: resourceImageRead,
|
|
||||||
UpdateContext: resourceImageUpdate,
|
|
||||||
DeleteContext: resourceImageDelete,
|
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
|
||||||
},
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Create: &constants.Timeout60s,
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Update: &constants.Timeout60s,
|
|
||||||
Delete: &constants.Timeout60s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: resourceImageSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,331 +1,220 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
"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/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||||
|
)
|
||||||
func resourceVirtualImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourceImageCreate: called for image %s", d.Get("name").(string))
|
func resourceVirtualImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("resourceImageCreate: called for image %s", d.Get("name").(string))
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := image.CreateVirtualRequest{
|
c := m.(*controller.ControllerCfg)
|
||||||
Name: d.Get("name").(string),
|
req := image.CreateVirtualRequest{
|
||||||
TargetID: uint64(d.Get("target_id").(int)),
|
Name: d.Get("name").(string),
|
||||||
}
|
TargetID: uint64(d.Get("link_to").(int)),
|
||||||
|
}
|
||||||
imageId, err := c.CloudBroker().Image().CreateVirtual(ctx, req)
|
|
||||||
if err != nil {
|
imageId, err := c.CloudBroker().Image().CreateVirtual(ctx, req)
|
||||||
return diag.FromErr(err)
|
if err != nil {
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
d.SetId(strconv.FormatUint(imageId, 10))
|
|
||||||
d.Set("image_id", imageId)
|
d.SetId(strconv.FormatUint(imageId, 10))
|
||||||
|
|
||||||
return resourceImageRead(ctx, d, m)
|
return resourceImageRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceVirtualImageSchemaMake() map[string]*schema.Schema {
|
func resourceVirtualImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return map[string]*schema.Schema{
|
log.Debugf("resourceVirtualImageRead: called for %s id: %s", d.Get("name").(string), d.Id())
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
img, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
Required: true,
|
if err != nil {
|
||||||
Description: "name of the virtual image to create",
|
d.SetId("")
|
||||||
},
|
return diag.FromErr(err)
|
||||||
"target_id": {
|
}
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
switch img.Status {
|
||||||
Description: "ID of real image to link this virtual image to upon creation",
|
case status.Modeled:
|
||||||
},
|
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
|
||||||
"history": {
|
case status.Destroyed, status.Purged:
|
||||||
Type: schema.TypeList,
|
d.SetId("")
|
||||||
Computed: true,
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
Elem: &schema.Resource{
|
}
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"guid": {
|
flattenImage(d, img)
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
return nil
|
||||||
},
|
}
|
||||||
"id": {
|
|
||||||
Type: schema.TypeInt,
|
func resourceVirtualImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
Computed: true,
|
log.Debugf("resourceVirtualImageDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
},
|
|
||||||
"timestamp": {
|
_, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
Type: schema.TypeInt,
|
if err != nil {
|
||||||
Computed: true,
|
d.SetId("")
|
||||||
},
|
return diag.FromErr(err)
|
||||||
},
|
}
|
||||||
},
|
|
||||||
},
|
c := m.(*controller.ControllerCfg)
|
||||||
"url": {
|
req := image.DeleteRequest{
|
||||||
Type: schema.TypeString,
|
ImageID: uint64(d.Get("image_id").(int)),
|
||||||
Computed: true,
|
}
|
||||||
Description: "URL where to download media from",
|
|
||||||
},
|
if reason, ok := d.GetOk("reason"); ok {
|
||||||
"gid": {
|
req.Reason = reason.(string)
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Computed: true,
|
if permanently, ok := d.GetOk("permanently"); ok {
|
||||||
Description: "grid (platform) ID where this template should be create in",
|
req.Permanently = permanently.(bool)
|
||||||
},
|
}
|
||||||
"boot_type": {
|
|
||||||
Type: schema.TypeString,
|
_, err = c.CloudBroker().Image().Delete(ctx, req)
|
||||||
Computed: true,
|
if err != nil {
|
||||||
Description: "Boot type of image bios or uefi",
|
return diag.FromErr(err)
|
||||||
},
|
}
|
||||||
"image_type": {
|
|
||||||
Type: schema.TypeString,
|
d.SetId("")
|
||||||
Computed: true,
|
|
||||||
Description: "Image type linux, windows or other",
|
return nil
|
||||||
},
|
}
|
||||||
"drivers": {
|
|
||||||
Type: schema.TypeList,
|
func resourceVirtualImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
Computed: true,
|
log.Debugf("resourceVirtualImageEdit: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
img, err := utilityImageCheckPresence(ctx, d, m)
|
||||||
},
|
if err != nil {
|
||||||
Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]",
|
d.SetId("")
|
||||||
},
|
return diag.FromErr(err)
|
||||||
"meta": {
|
}
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
switch img.Status {
|
||||||
Elem: &schema.Schema{
|
case status.Modeled:
|
||||||
Type: schema.TypeString,
|
return diag.Errorf("The image is in status: %s, please, contact support for more information", img.Status)
|
||||||
},
|
case status.Destroyed, status.Purged:
|
||||||
Description: "meta",
|
d.SetId("")
|
||||||
},
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
"hot_resize": {
|
}
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
if d.HasChange("enabled") {
|
||||||
Computed: true,
|
err := resourceImageChangeEnabled(ctx, d, m)
|
||||||
Description: "Does this machine supports hot resize",
|
if err != nil {
|
||||||
},
|
return diag.FromErr(err)
|
||||||
"username": {
|
}
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
if d.HasChange("shared_with") {
|
||||||
Description: "Optional username for the image",
|
err := resourceImageShare(ctx, d, m)
|
||||||
},
|
if err != nil {
|
||||||
"password": {
|
return diag.FromErr(err)
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Optional: true,
|
}
|
||||||
Computed: true,
|
|
||||||
Description: "Optional password for the image",
|
if d.HasChange("computeci_id") {
|
||||||
},
|
err := resourceImageChangeComputeci(ctx, d, m)
|
||||||
"account_id": {
|
if err != nil {
|
||||||
Type: schema.TypeInt,
|
return diag.FromErr(err)
|
||||||
Optional: true,
|
}
|
||||||
Computed: true,
|
}
|
||||||
Description: "AccountId to make the image exclusive",
|
|
||||||
},
|
if d.HasChange("enabled_stacks") {
|
||||||
"username_dl": {
|
err := resourceImageUpdateNodes(ctx, d, m)
|
||||||
Type: schema.TypeString,
|
if err != nil {
|
||||||
Optional: true,
|
return diag.FromErr(err)
|
||||||
Computed: true,
|
}
|
||||||
Description: "username for upload binary media",
|
}
|
||||||
},
|
|
||||||
"password_dl": {
|
if d.HasChanges("name", "username", "password", "account_id", "bootable", "hot_resize") {
|
||||||
Type: schema.TypeString,
|
err := resourceImageEdit(ctx, d, m)
|
||||||
Optional: true,
|
if err != nil {
|
||||||
Computed: true,
|
return diag.FromErr(err)
|
||||||
Description: "password for upload binary media",
|
}
|
||||||
},
|
}
|
||||||
"sep_id": {
|
|
||||||
Type: schema.TypeInt,
|
if d.HasChange("link_to") {
|
||||||
Optional: true,
|
err := resourceImageLink(ctx, d, m)
|
||||||
Computed: true,
|
if err != nil {
|
||||||
Description: "storage endpoint provider ID",
|
return diag.FromErr(err)
|
||||||
},
|
}
|
||||||
"pool_name": {
|
}
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
return nil
|
||||||
Computed: true,
|
}
|
||||||
Description: "pool for image create",
|
|
||||||
},
|
func resourceImageLink(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
"architecture": {
|
log.Debugf("resourceVirtualImageLink: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
Type: schema.TypeString,
|
c := m.(*controller.ControllerCfg)
|
||||||
Optional: true,
|
req := image.LinkRequest{
|
||||||
Computed: true,
|
ImageID: uint64(d.Get("image_id").(int)),
|
||||||
Description: "binary architecture of this image, one of X86_64 of PPC64_LE",
|
TargetID: uint64(d.Get("link_to").(int)),
|
||||||
},
|
}
|
||||||
"image_id": {
|
|
||||||
Type: schema.TypeInt,
|
_, err := c.CloudBroker().Image().Link(ctx, req)
|
||||||
Computed: true,
|
if err != nil {
|
||||||
Description: "image id",
|
return err
|
||||||
},
|
}
|
||||||
"permanently": {
|
|
||||||
Type: schema.TypeBool,
|
return nil
|
||||||
Optional: true,
|
}
|
||||||
Computed: true,
|
|
||||||
Description: "Whether to completely delete the image",
|
func ResourceVirtualImage() *schema.Resource {
|
||||||
},
|
return &schema.Resource{
|
||||||
"bootable": {
|
SchemaVersion: 1,
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
CreateContext: resourceVirtualImageCreate,
|
||||||
Computed: true,
|
ReadContext: resourceVirtualImageRead,
|
||||||
Description: "Does this image boot OS",
|
UpdateContext: resourceVirtualImageUpdate,
|
||||||
},
|
DeleteContext: resourceVirtualImageDelete,
|
||||||
"unc_path": {
|
|
||||||
Type: schema.TypeString,
|
Importer: &schema.ResourceImporter{
|
||||||
Computed: true,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
Description: "unc path",
|
},
|
||||||
},
|
|
||||||
"link_to": {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Type: schema.TypeInt,
|
Create: &constants.Timeout60s,
|
||||||
Optional: true,
|
Read: &constants.Timeout30s,
|
||||||
Computed: true,
|
Update: &constants.Timeout60s,
|
||||||
Description: "",
|
Delete: &constants.Timeout60s,
|
||||||
},
|
Default: &constants.Timeout60s,
|
||||||
"status": {
|
},
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
Schema: resourceVirtualImageSchemaMake(),
|
||||||
Description: "status",
|
}
|
||||||
},
|
}
|
||||||
"tech_status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "tech atatus",
|
|
||||||
},
|
|
||||||
"version": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "version",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "image size",
|
|
||||||
},
|
|
||||||
"enabled": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"computeci_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"milestones": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"provider_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"purge_attempts": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"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,
|
|
||||||
},
|
|
||||||
"reason": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
},
|
|
||||||
"last_modified": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"enabled_stacks": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"shared_with": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourceVirtualImage() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
CreateContext: resourceVirtualImageCreate,
|
|
||||||
ReadContext: resourceImageRead,
|
|
||||||
UpdateContext: resourceImageUpdate,
|
|
||||||
DeleteContext: resourceImageDelete,
|
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
|
||||||
},
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Create: &constants.Timeout60s,
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Update: &constants.Timeout60s,
|
|
||||||
Delete: &constants.Timeout60s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: resourceVirtualImageSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,60 +1,60 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityImageCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.RecordImage, error) {
|
func utilityImageCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.RecordImage, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := image.GetRequest{}
|
req := image.GetRequest{}
|
||||||
|
|
||||||
if (strconv.Itoa(d.Get("image_id").(int))) != "0" {
|
if d.Id() != "" {
|
||||||
req.ImageID = uint64(d.Get("image_id").(int))
|
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
} else {
|
req.ImageID = id
|
||||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
} else {
|
||||||
req.ImageID = id
|
req.ImageID = uint64(d.Get("image_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
image, err := c.CloudBroker().Image().Get(ctx, req)
|
image, err := c.CloudBroker().Image().Get(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return image, nil
|
return image, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,66 +1,98 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListImages, error) {
|
func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListImages, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := image.ListRequest{}
|
req := image.ListRequest{}
|
||||||
|
|
||||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||||
req.SepID = uint64(sepId.(int))
|
req.SepID = uint64(sepId.(int))
|
||||||
}
|
}
|
||||||
|
if byId, ok := d.GetOk("by_id"); ok {
|
||||||
if page, ok := d.GetOk("page"); ok {
|
req.ByID = uint64(byId.(int))
|
||||||
req.Page = uint64(page.(int))
|
}
|
||||||
}
|
if name, ok := d.GetOk("name"); ok {
|
||||||
if size, ok := d.GetOk("size"); ok {
|
req.Name = name.(string)
|
||||||
req.Size = uint64(size.(int))
|
}
|
||||||
}
|
if status, ok := d.GetOk("status"); ok {
|
||||||
|
req.Status = status.(string)
|
||||||
log.Debugf("utilityImageListCheckPresence: load image list")
|
}
|
||||||
imageList, err := c.CloudBroker().Image().List(ctx, req)
|
if architecture, ok := d.GetOk("architecture"); ok {
|
||||||
if err != nil {
|
req.Architecture = architecture.(string)
|
||||||
return nil, err
|
}
|
||||||
}
|
if typeImage, ok := d.GetOk("type_image"); ok {
|
||||||
|
req.TypeImage = typeImage.(string)
|
||||||
return imageList, nil
|
}
|
||||||
}
|
if imageSize, ok := d.GetOk("image_size"); ok {
|
||||||
|
req.ImageSize = uint64(imageSize.(int))
|
||||||
|
}
|
||||||
|
if sepName, ok := d.GetOk("sep_name"); ok {
|
||||||
|
req.SEPName = sepName.(string)
|
||||||
|
}
|
||||||
|
if pool, ok := d.GetOk("pool"); ok {
|
||||||
|
req.Pool = pool.(string)
|
||||||
|
}
|
||||||
|
if public, ok := d.GetOk("public"); ok {
|
||||||
|
req.Public = public.(bool)
|
||||||
|
}
|
||||||
|
if hotResize, ok := d.GetOk("hot_resize"); ok {
|
||||||
|
req.HotResize = hotResize.(bool)
|
||||||
|
}
|
||||||
|
if bootable, ok := d.GetOk("bootable"); ok {
|
||||||
|
req.Bootable = bootable.(bool)
|
||||||
|
}
|
||||||
|
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("utilityImageListCheckPresence: load image list")
|
||||||
|
imageList, err := c.CloudBroker().Image().List(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return imageList, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -1,57 +1,73 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityImageListStacksCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListStacks, error) {
|
func utilityImageListStacksCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListStacks, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := image.ListStacksRequest{
|
req := image.ListStacksRequest{
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
ImageID: uint64(d.Get("image_id").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("utilityImageListStacksCheckPresence: load image list")
|
if page, ok := d.GetOk("page"); ok {
|
||||||
imageListStacks, err := c.CloudBroker().Image().ListStacks(ctx, req)
|
req.Page = uint64(page.(int))
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
if size, ok := d.GetOk("size"); ok {
|
||||||
}
|
req.Size = uint64(size.(int))
|
||||||
|
}
|
||||||
return imageListStacks, nil
|
if name, ok := d.GetOk("name"); ok {
|
||||||
}
|
req.Name = name.(string)
|
||||||
|
}
|
||||||
|
if status, ok := d.GetOk("status"); ok {
|
||||||
|
req.Status = status.(string)
|
||||||
|
}
|
||||||
|
if typeImage, ok := d.GetOk("type_image"); ok {
|
||||||
|
req.Type = typeImage.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("utilityImageListStacksCheckPresence: load image list")
|
||||||
|
imageListStacks, err := c.CloudBroker().Image().ListStacks(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return imageListStacks, nil
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,140 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package pcidevice
|
package pcidevice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
)
|
||||||
)
|
|
||||||
|
func dataSourcePcideviceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
func dataSourcePcideviceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
pcidevice, err := utilityPcideviceCheckPresence(ctx, d, m)
|
||||||
pcidevice, err := utilityPcideviceCheckPresence(ctx, d, m)
|
if err != nil {
|
||||||
if err != nil {
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("ckey", pcidevice.CKey)
|
flattenPcidevice(d, pcidevice)
|
||||||
d.Set("meta", flattens.FlattenMeta(pcidevice.Meta))
|
d.SetId(strconv.Itoa(d.Get("device_id").(int)))
|
||||||
d.Set("compute_id", pcidevice.ComputeID)
|
|
||||||
d.Set("description", pcidevice.Description)
|
return nil
|
||||||
d.Set("guid", pcidevice.GUID)
|
}
|
||||||
d.Set("hw_path", pcidevice.HwPath)
|
|
||||||
d.Set("device_id",pcidevice.ID)
|
func DataSourcePcidevice() *schema.Resource {
|
||||||
d.Set("name", pcidevice.Name)
|
return &schema.Resource{
|
||||||
d.Set("rg_id", pcidevice.RGID)
|
SchemaVersion: 1,
|
||||||
d.Set("stack_id", pcidevice.StackID)
|
|
||||||
d.Set("status", pcidevice.Status)
|
ReadContext: dataSourcePcideviceRead,
|
||||||
d.Set("system_name", pcidevice.SystemName)
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
d.SetId(strconv.Itoa(d.Get("device_id").(int)))
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
return nil
|
},
|
||||||
}
|
|
||||||
|
Schema: dataSourcePcideviceSchemaMake(),
|
||||||
func dataSourcePcideviceSchemaMake() map[string]*schema.Schema {
|
}
|
||||||
rets := map[string]*schema.Schema{
|
}
|
||||||
"device_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
ForceNew: true,
|
|
||||||
},
|
|
||||||
"ckey": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"meta": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"compute_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"description": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"guid": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"hw_path": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"stack_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"system_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return rets
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourcePcidevice() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourcePcideviceRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourcePcideviceSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,149 +1,72 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package pcidevice
|
package pcidevice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
)
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
|
||||||
)
|
func dataSourcePcideviceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
pcideviceList, err := utilityPcideviceListCheckPresence(ctx, m)
|
||||||
func flattenPcideviceList(pl *pcidevice.ListPCIDevices) []map[string]interface{} {
|
if err != nil {
|
||||||
res := make([]map[string]interface{}, 0, len(pl.Data))
|
d.SetId("")
|
||||||
for _, item := range pl.Data {
|
return diag.FromErr(err)
|
||||||
temp := map[string]interface{}{
|
}
|
||||||
"ckey": item.CKey,
|
|
||||||
"meta": flattens.FlattenMeta(item.Meta),
|
d.Set("items", flattenPcideviceList(pcideviceList))
|
||||||
"compute_id": item.ComputeID,
|
d.Set("entry_count", pcideviceList.EntryCount)
|
||||||
"description": item.Description,
|
|
||||||
"guid": item.GUID,
|
id := uuid.New()
|
||||||
"hw_path": item.HwPath,
|
d.SetId(id.String())
|
||||||
"device_id": item.ID,
|
|
||||||
"rg_id": item.RGID,
|
return nil
|
||||||
"name": item.Name,
|
}
|
||||||
"stack_id": item.StackID,
|
|
||||||
"status": item.Status,
|
func DataSourcePcideviceList() *schema.Resource {
|
||||||
"system_name": item.SystemName,
|
return &schema.Resource{
|
||||||
}
|
SchemaVersion: 1,
|
||||||
res = append(res, temp)
|
|
||||||
}
|
ReadContext: dataSourcePcideviceListRead,
|
||||||
return res
|
|
||||||
}
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
func dataSourcePcideviceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
Default: &constants.Timeout60s,
|
||||||
pcideviceList, err := utilityPcideviceListCheckPresence(ctx, m)
|
},
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
Schema: dataSourcePcideviceListSchemaMake(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
d.Set("items", flattenPcideviceList(pcideviceList))
|
|
||||||
d.Set("entry_count", pcideviceList.EntryCount)
|
|
||||||
|
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func dataSourcePcideviceListSchemaMake() map[string]*schema.Schema {
|
|
||||||
rets := map[string]*schema.Schema{
|
|
||||||
"by_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "by_id",
|
|
||||||
},
|
|
||||||
"compute_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "compute_id",
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "name",
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "rg_id",
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "status",
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "page number",
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "page size",
|
|
||||||
},
|
|
||||||
"items": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Description: "pcidevice list",
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: dataSourcePcideviceSchemaMake(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"entry_count": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "entry count",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return rets
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourcePcideviceList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourcePcideviceListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourcePcideviceListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,292 +1,229 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package pcidevice
|
package pcidevice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"strconv"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
log "github.com/sirupsen/logrus"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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/controller"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||||
|
)
|
||||||
)
|
|
||||||
|
func resourcePcideviceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
func resourcePcideviceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
log.Debugf("resourcePcideviceCreate: called for pcidevice %s", d.Get("name").(string))
|
||||||
log.Debugf("resourcePcideviceCreate: called for pcidevice %s", d.Get("name").(string))
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
c := m.(*controller.ControllerCfg)
|
createReq := pcidevice.CreateRequest{}
|
||||||
req := pcidevice.CreateRequest{}
|
|
||||||
|
if diags := checkParamsExistence(ctx, d, c); diags != nil {
|
||||||
haveRGID, err := existRGID(ctx, d, m)
|
return diags
|
||||||
if err != nil {
|
}
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
createReq.StackID = uint64(d.Get("stack_id").(int))
|
||||||
if !haveRGID {
|
createReq.RGID = uint64(d.Get("rg_id").(int))
|
||||||
return diag.Errorf("resourcePcideviceCreate: can't create Pcidevice because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
createReq.Name = d.Get("name").(string)
|
||||||
}
|
createReq.HWPath = d.Get("hw_path").(string)
|
||||||
|
|
||||||
haveStackID, err := existStackID(ctx, d, m)
|
if description, ok := d.GetOk("description"); ok {
|
||||||
if err != nil {
|
createReq.Description = description.(string)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
if !haveStackID {
|
pcideviceId, err := c.CloudBroker().PCIDevice().Create(ctx, createReq)
|
||||||
return diag.Errorf("resourcePcideviceCreate: can't create Pcidevice because StackID %d is not allowed or does not exist", d.Get("stack_id").(int))
|
if err != nil {
|
||||||
}
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
req.StackID = uint64(d.Get("stack_id").(int))
|
}
|
||||||
req.RGID = uint64(d.Get("rg_id").(int))
|
|
||||||
req.Name = d.Get("name").(string)
|
d.SetId(strconv.FormatUint(pcideviceId, 10))
|
||||||
req.HWPath = d.Get("hw_path").(string)
|
d.Set("device_id", pcideviceId)
|
||||||
|
|
||||||
if description, ok := d.GetOk("description"); ok {
|
warnings := dc.Warnings{}
|
||||||
req.Description = description.(string)
|
|
||||||
}
|
if enable, ok := d.GetOk("enable"); ok {
|
||||||
|
log.Debugf("resourcePcideviceCreate: enable=%t device_id %d after completing its resource configuration", enable, pcideviceId)
|
||||||
pcideviceId, err := c.CloudBroker().PCIDevice().Create(ctx, req)
|
|
||||||
if err != nil {
|
if enable.(bool) {
|
||||||
return diag.FromErr(err)
|
req := pcidevice.EnableRequest{DeviceID: pcideviceId}
|
||||||
}
|
if _, err := c.CloudBroker().PCIDevice().Enable(ctx, req); err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
d.SetId(strconv.FormatUint(pcideviceId, 10))
|
}
|
||||||
d.Set("device_id", pcideviceId)
|
|
||||||
|
} else {
|
||||||
return resourcePcideviceRead(ctx, d, m)
|
req := pcidevice.DisableRequest{
|
||||||
}
|
DeviceID: pcideviceId,
|
||||||
|
}
|
||||||
func resourcePcideviceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
if force, ok := d.GetOk("force_disable"); ok {
|
||||||
pcidevice, err := utilityPcideviceCheckPresence(ctx, d, m)
|
req.Force = force.(bool)
|
||||||
if err != nil {
|
log.Debugf("force_disable=%v", force)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
if _, err := c.CloudBroker().PCIDevice().Disable(ctx, req); err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
d.Set("ckey", pcidevice.CKey)
|
}
|
||||||
d.Set("meta", flattens.FlattenMeta(pcidevice.Meta))
|
}
|
||||||
d.Set("compute_id", pcidevice.ComputeID)
|
}
|
||||||
d.Set("description", pcidevice.Description)
|
|
||||||
d.Set("guid", pcidevice.GUID)
|
return append(resourcePcideviceRead(ctx, d, m), warnings.Get()...)
|
||||||
d.Set("hw_path", pcidevice.HwPath)
|
}
|
||||||
d.Set("device_id", pcidevice.ID)
|
|
||||||
d.Set("rg_id", pcidevice.RGID)
|
func resourcePcideviceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
d.Set("name", pcidevice.Name)
|
log.Debugf("resourcePcideviceRead: called for pci_device id %d, name %s",
|
||||||
d.Set("stack_id", pcidevice.StackID)
|
d.Id(), d.Get("name").(string))
|
||||||
d.Set("status", pcidevice.Status)
|
|
||||||
d.Set("system_name", pcidevice.SystemName)
|
pcideviceRec, err := utilityPcideviceCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
return nil
|
d.SetId("")
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
func resourcePcideviceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
|
flattenPcidevice(d, pcideviceRec)
|
||||||
haveRGID, err := existRGID(ctx, d, m)
|
|
||||||
if err != nil {
|
log.Debugf("resourcePcideviceRead: after flattenPcidevice: device_id %s, name %s",
|
||||||
return diag.FromErr(err)
|
d.Id(), d.Get("name").(string))
|
||||||
}
|
|
||||||
if !haveRGID {
|
return nil
|
||||||
return diag.Errorf("resourcePcideviceCreate: can't update Pcidevice because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
}
|
||||||
}
|
|
||||||
|
func resourcePcideviceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
haveStackID, err := existStackID(ctx, d, m)
|
log.Debugf("resourcePcideviceUpdate: called for pcidevice id %s, name %s", d.Id(), d.Get("name").(string))
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
c := m.(*controller.ControllerCfg)
|
||||||
}
|
|
||||||
if !haveStackID {
|
if diags := checkParamsExistence(ctx, d, c); diags != nil {
|
||||||
return diag.Errorf("resourcePcideviceCreate: can't update Pcidevice because StackID %d is not allowed or does not exist", d.Get("stack_id").(int))
|
return diags
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("enable") {
|
if d.HasChange("enable") {
|
||||||
state := d.Get("enable").(bool)
|
err := resourcePcideviceChangeEnable(ctx, d, m)
|
||||||
c := m.(*controller.ControllerCfg)
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
if state {
|
}
|
||||||
req := pcidevice.EnableRequest{
|
}
|
||||||
DeviceID: uint64(d.Get("device_id").(int)),
|
|
||||||
}
|
return resourcePcideviceRead(ctx, d, m)
|
||||||
|
}
|
||||||
_, err := c.CloudBroker().PCIDevice().Enable(ctx, req)
|
|
||||||
if err != nil {
|
func resourcePcideviceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return diag.FromErr(err)
|
log.Debugf("resourcePcideviceDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
||||||
}
|
|
||||||
} else {
|
c := m.(*controller.ControllerCfg)
|
||||||
req := pcidevice.DisableRequest{
|
|
||||||
DeviceID: uint64(d.Get("device_id").(int)),
|
pciDevice, err := utilityPcideviceCheckPresence(ctx, d, m)
|
||||||
}
|
if err != nil {
|
||||||
if force, ok := d.GetOk("force"); ok {
|
d.SetId("")
|
||||||
req.Force = force.(bool)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudBroker().PCIDevice().Disable(ctx, req)
|
if pciDevice.Status == status.Destroyed || pciDevice.Status == status.Purged {
|
||||||
if err != nil {
|
return nil
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
}
|
req := pcidevice.DeleteRequest{
|
||||||
}
|
DeviceID: pciDevice.ID,
|
||||||
|
}
|
||||||
return resourcePcideviceRead(ctx, d, m)
|
if force, ok := d.GetOk("force_delete"); ok {
|
||||||
}
|
req.Force = force.(bool)
|
||||||
|
}
|
||||||
func resourcePcideviceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
log.Debugf("resourcePcideviceDelete: called for %s, id: %s", d.Get("name").(string), d.Id())
|
if _, err = c.CloudBroker().PCIDevice().Delete(ctx, req); err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
pciDevice, err := utilityPcideviceCheckPresence(ctx, d, m)
|
}
|
||||||
if err != nil {
|
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
return nil
|
||||||
if pciDevice.Status == status.Destroyed || pciDevice.Status == status.Purged {
|
}
|
||||||
return nil
|
|
||||||
}
|
func ResourcePcidevice() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
c := m.(*controller.ControllerCfg)
|
SchemaVersion: 1,
|
||||||
|
|
||||||
req := pcidevice.DeleteRequest{
|
CreateContext: resourcePcideviceCreate,
|
||||||
DeviceID: pciDevice.ID,
|
ReadContext: resourcePcideviceRead,
|
||||||
}
|
UpdateContext: resourcePcideviceUpdate,
|
||||||
|
DeleteContext: resourcePcideviceDelete,
|
||||||
if force, ok := d.GetOk("force"); ok {
|
|
||||||
req.Force = force.(bool)
|
Importer: &schema.ResourceImporter{
|
||||||
}
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
|
},
|
||||||
_, err = c.CloudBroker().PCIDevice().Delete(ctx, req)
|
|
||||||
if err != nil {
|
Timeouts: &schema.ResourceTimeout{
|
||||||
return diag.FromErr(err)
|
Create: &constants.Timeout60s,
|
||||||
}
|
Read: &constants.Timeout30s,
|
||||||
|
Update: &constants.Timeout60s,
|
||||||
d.SetId("")
|
Delete: &constants.Timeout60s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
return nil
|
},
|
||||||
}
|
|
||||||
|
Schema: resourcePcideviceSchemaMake(),
|
||||||
func resourcePcideviceSchemaMake() map[string]*schema.Schema {
|
}
|
||||||
return map[string]*schema.Schema{
|
}
|
||||||
"ckey": {
|
|
||||||
Type: schema.TypeString,
|
func resourcePcideviceChangeEnable(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||||
Computed: true,
|
enable := d.Get("enable").(bool)
|
||||||
},
|
log.Debugf("resourcePcideviceChangeEnable: enable=%t device_id %s after completing its resource configuration", enable, d.Id())
|
||||||
"meta": {
|
|
||||||
Type: schema.TypeList,
|
pcideviceRec, err := utilityPcideviceCheckPresence(ctx, d, m)
|
||||||
Computed: true,
|
if err != nil {
|
||||||
Elem: &schema.Schema{
|
return err
|
||||||
Type: schema.TypeString,
|
}
|
||||||
},
|
c := m.(*controller.ControllerCfg)
|
||||||
},
|
|
||||||
"compute_id": {
|
if enable {
|
||||||
Type: schema.TypeInt,
|
req := pcidevice.EnableRequest{
|
||||||
Computed: true,
|
DeviceID: pcideviceRec.ID,
|
||||||
},
|
}
|
||||||
"description": {
|
|
||||||
Type: schema.TypeString,
|
if _, err := c.CloudBroker().PCIDevice().Enable(ctx, req); err != nil {
|
||||||
Optional: true,
|
return err
|
||||||
Computed: true,
|
}
|
||||||
Description: "description, just for information",
|
} else {
|
||||||
},
|
req := pcidevice.DisableRequest{
|
||||||
"guid": {
|
DeviceID: pcideviceRec.ID,
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Computed: true,
|
if force, ok := d.GetOk("force_disable"); ok {
|
||||||
},
|
req.Force = force.(bool)
|
||||||
"hw_path": {
|
}
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
if _, err := c.CloudBroker().PCIDevice().Disable(ctx, req); err != nil {
|
||||||
Description: "PCI address of the device",
|
return err
|
||||||
},
|
}
|
||||||
"device_id": {
|
}
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
return nil
|
||||||
Computed: true,
|
}
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Name of Device",
|
|
||||||
},
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "Resource GROUP",
|
|
||||||
},
|
|
||||||
"stack_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
Description: "stackId",
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"system_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"force": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Force delete",
|
|
||||||
},
|
|
||||||
"enable": {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "Enable pci device",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourcePcidevice() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
CreateContext: resourcePcideviceCreate,
|
|
||||||
ReadContext: resourcePcideviceRead,
|
|
||||||
UpdateContext: resourcePcideviceUpdate,
|
|
||||||
DeleteContext: resourcePcideviceDelete,
|
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
|
||||||
},
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Create: &constants.Timeout60s,
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Update: &constants.Timeout60s,
|
|
||||||
Delete: &constants.Timeout60s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: resourcePcideviceSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue