From e42fbcef3951029d78e8f0ea4873b95b46ff9309 Mon Sep 17 00:00:00 2001 From: Alexey Fetisov Date: Tue, 18 Nov 2025 16:20:26 +0300 Subject: [PATCH] 4.10.1 --- CHANGELOG.md | 192 ++-- Makefile | 2 +- README.md | 13 +- docs/data-sources/account.md | 14 +- docs/data-sources/account_deleted_list.md | 2 + docs/data-sources/account_list.md | 2 + .../account_resource_consumption_get.md | 55 ++ .../account_resource_consumption_list.md | 46 + docs/data-sources/audit.md | 1 + docs/data-sources/audit_list.md | 77 ++ docs/data-sources/bservice_deleted_list.md | 1 + docs/data-sources/bservice_list.md | 1 + docs/data-sources/cb_account.md | 14 +- docs/data-sources/cb_account_list.md | 13 +- docs/data-sources/cb_account_list_deleted.md | 12 +- .../cb_account_resource_consumption_get.md | 46 + .../cb_account_resource_consumption_list.md | 46 + docs/data-sources/cb_audit.md | 2 +- docs/data-sources/cb_audit_list.md | 13 +- docs/data-sources/cb_disk.md | 2 + docs/data-sources/cb_disk_list.md | 3 + docs/data-sources/cb_disk_list_deleted.md | 2 + docs/data-sources/cb_disk_list_unattached.md | 1 + docs/data-sources/cb_dpdknet_list.md | 1 + docs/data-sources/cb_extnet_list.md | 2 + docs/data-sources/cb_image.md | 4 +- docs/data-sources/cb_image_list.md | 3 + docs/data-sources/cb_k8ci.md | 1 - docs/data-sources/cb_k8ci_list.md | 4 - docs/data-sources/cb_k8ci_list_deleted.md | 4 - docs/data-sources/cb_k8s_list.md | 1 + docs/data-sources/cb_kvmvm.md | 6 + docs/data-sources/cb_kvmvm_audits.md | 10 + docs/data-sources/cb_kvmvm_list.md | 6 +- docs/data-sources/cb_kvmvm_list_deleted.md | 4 + docs/data-sources/cb_lb_list.md | 1 + docs/data-sources/cb_node.md | 1 + docs/data-sources/cb_rg.md | 10 + docs/data-sources/cb_rg_list.md | 10 + docs/data-sources/cb_rg_list_deleted.md | 10 + docs/data-sources/cb_security_group.md | 58 ++ docs/data-sources/cb_security_group_list.md | 74 ++ docs/data-sources/cb_storage_policy.md | 61 ++ docs/data-sources/cb_storage_policy_list.md | 78 ++ docs/data-sources/cb_vins.md | 36 + docs/data-sources/cb_vins_list.md | 4 +- docs/data-sources/cb_zone.md | 7 + docs/data-sources/disk.md | 2 + docs/data-sources/disk_list.md | 3 + docs/data-sources/disk_list_deleted.md | 2 + docs/data-sources/disk_list_unattached.md | 1 + docs/data-sources/extnet_list.md | 1 + docs/data-sources/image.md | 2 + docs/data-sources/image_list.md | 2 + docs/data-sources/k8s_list.md | 1 + docs/data-sources/k8s_list_deleted.md | 1 + docs/data-sources/kvmvm.md | 6 + docs/data-sources/kvmvm_audits.md | 10 + docs/data-sources/kvmvm_list.md | 5 + docs/data-sources/kvmvm_list_deleted.md | 4 + docs/data-sources/lb_list.md | 1 + docs/data-sources/resgroup.md | 10 + docs/data-sources/rg_list.md | 10 + docs/data-sources/rg_list_deleted.md | 10 + docs/data-sources/sdn_access_group.md | 50 + docs/data-sources/sdn_access_group_list.md | 78 ++ .../sdn_access_group_user_list.md | 63 ++ .../sdn_default_security_policy_list.md | 149 +++ docs/data-sources/sdn_logical_port.md | 88 ++ ...n_logical_port_get_by_unique_identifier.md | 87 ++ docs/data-sources/sdn_logical_port_list.md | 111 +++ docs/data-sources/sdn_segment.md | 117 +++ docs/data-sources/sdn_segment_get_status.md | 39 + docs/data-sources/sdn_segment_list.md | 135 +++ docs/data-sources/security_group.md | 58 ++ docs/data-sources/security_group_list.md | 74 ++ docs/data-sources/storage_policy.md | 61 ++ docs/data-sources/storage_policy_list.md | 78 ++ docs/data-sources/vins.md | 36 + docs/data-sources/vins_list.md | 1 + docs/data-sources/zone.md | 7 + docs/index.md | 1 - docs/resources/account.md | 19 +- docs/resources/bservice_group.md | 3 +- docs/resources/cb_account.md | 23 +- docs/resources/cb_cdrom_image.md | 5 +- docs/resources/cb_disk.md | 3 +- docs/resources/cb_dpdknet.md | 1 + docs/resources/cb_extnet.md | 1 + docs/resources/cb_image.md | 5 +- docs/resources/cb_image_from_blank_compute.md | 2 +- docs/resources/cb_image_from_platform_disk.md | 4 +- docs/resources/cb_k8ci.md | 2 - docs/resources/cb_k8s_cp.md | 1 + docs/resources/cb_k8s_wg.md | 1 + docs/resources/cb_kvmvm.md | 25 +- docs/resources/cb_rg.md | 24 + docs/resources/cb_security_group.md | 67 ++ docs/resources/cb_storage_policy.md | 65 ++ docs/resources/cb_vins.md | 52 ++ docs/resources/cb_virtual_image.md | 2 +- docs/resources/disk.md | 2 + docs/resources/image.md | 4 +- docs/resources/image_from_blank_compute.md | 1 + docs/resources/image_from_platform_disk.md | 3 +- docs/resources/image_virtual.md | 4 +- docs/resources/k8s.md | 1 + docs/resources/k8s_cp.md | 1 + docs/resources/k8s_wg.md | 1 + docs/resources/kvmvm.md | 27 +- docs/resources/resgroup.md | 38 + docs/resources/sdn_access_group.md | 80 ++ docs/resources/sdn_logical_port.md | 110 +++ docs/resources/sdn_segment.md | 132 +++ docs/resources/security_group.md | 67 ++ docs/resources/vins.md | 36 + go.mod | 74 +- go.sum | 231 +++-- internal/controller/controller.go | 17 + internal/provider/data_sources_map.go | 29 + internal/provider/resource_map.go | 13 + .../cloudapi/account/data_source_account.go | 38 +- ...source_account_get_resource_consumption.go | 16 + .../account/data_source_account_list.go | 13 + ...ource_account_resource_consumption_list.go | 29 + internal/service/cloudapi/account/flattens.go | 92 +- .../cloudapi/account/resource_account.go | 45 +- .../cloudapi/account/utility_account_list.go | 4 + .../cloudapi/audit/data_source_audit.go | 6 +- .../cloudapi/audit/data_source_audit_list.go | 244 +++++ internal/service/cloudapi/audit/flattens.go | 24 + .../cloudapi/audit/utility_audit_list.go | 117 +++ .../bservice/data_source_bservice_list.go | 5 + .../bservice/resource_bservice_group.go | 29 +- .../bservice/utility_bservice_list.go | 3 + .../cloudapi/disks/data_source_disk.go | 9 + .../cloudapi/disks/data_source_disk_list.go | 14 + .../disks/data_source_disk_list_unattached.go | 5 + .../disks/data_source_list_deleted.go | 9 + internal/service/cloudapi/disks/flattens.go | 92 +- .../service/cloudapi/disks/resource_disk.go | 22 + .../cloudapi/disks/utility_disk_list.go | 3 + .../disks/utility_disk_list_unattached.go | 3 + .../extnet/data_source_extnet_list.go | 5 + .../cloudapi/extnet/utility_extnet_list.go | 4 +- .../cloudapi/image/data_source_image_list.go | 4 + internal/service/cloudapi/image/flattens.go | 3 + .../cloudapi/image/image_ds_subresource.go | 8 + .../cloudapi/image/image_item_subresource.go | 278 +++--- .../cloudapi/image/image_rs_subresource.go | 17 +- .../image/image_virtual_rs_subresource.go | 7 + .../service/cloudapi/image/resource_image.go | 18 +- .../resource_image_from_blank_compute.go | 4 + .../resource_image_from_platform_disk.go | 27 +- .../cloudapi/image/resource_image_virtual.go | 5 +- .../cloudapi/image/utility_image_list.go | 3 + .../cloudapi/k8s/data_source_k8s_list.go | 5 + internal/service/cloudapi/k8s/resource_k8s.go | 6 + .../service/cloudapi/k8s/resource_k8s_cp.go | 6 + .../service/cloudapi/k8s/resource_k8s_wg.go | 23 +- internal/service/cloudapi/k8s/utility_k8ci.go | 6 - internal/service/cloudapi/k8s/utility_k8s.go | 3 + .../cloudapi/kvmvm/data_source_compute.go | 27 + .../kvmvm/data_source_compute_audits.go | 41 + .../kvmvm/data_source_compute_list.go | 13 + internal/service/cloudapi/kvmvm/flattens.go | 201 ++-- internal/service/cloudapi/kvmvm/models.go | 10 + .../cloudapi/kvmvm/network_subresource.go | 7 + .../cloudapi/kvmvm/resource_compute.go | 265 ++++-- .../service/cloudapi/kvmvm/utility_compute.go | 183 +++- .../cloudapi/kvmvm/utility_compute_audits.go | 31 +- .../cloudapi/kvmvm/utility_compute_list.go | 3 + .../cloudapi/lb/lb_data_subresource.go | 5 + .../service/cloudapi/lb/utility_lb_list.go | 3 + .../service/cloudapi/rg/data_source_rg.go | 24 + .../cloudapi/rg/data_source_rg_list.go | 7 + .../rg/data_source_rg_list_deleted.go | 7 + internal/service/cloudapi/rg/flattens.go | 34 +- internal/service/cloudapi/rg/resource_rg.go | 115 ++- internal/service/cloudapi/rg/utility_rg.go | 128 +++ .../secgroup/data_source_security_group.go | 38 + .../data_source_security_group_list.go | 40 + .../service/cloudapi/secgroup/flattens.go | 68 ++ .../secgroup/resource_security_group.go | 146 +++ internal/service/cloudapi/secgroup/schema.go | 288 ++++++ .../secgroup/utility_security_group.go | 95 ++ .../secgroup/utility_security_group_list.go | 60 ++ .../stpolicy/data_source_storage_policy.go | 37 + .../data_source_storage_policy_list.go | 40 + .../service/cloudapi/stpolicy/flattens.go | 63 ++ internal/service/cloudapi/stpolicy/schema.go | 207 +++++ .../stpolicy/utility_storage_policy.go | 29 + .../stpolicy/utility_storage_policy_list.go | 71 ++ .../cloudapi/trunk/utility_trunk_list.go | 3 + .../service/cloudapi/vins/data_source_vins.go | 45 + .../cloudapi/vins/data_source_vins_list.go | 5 + internal/service/cloudapi/vins/flattens.go | 46 +- .../cloudapi/vins/utility_vins_list.go | 3 + .../service/cloudapi/zone/data_source_zone.go | 49 + internal/service/cloudapi/zone/flattens.go | 7 + .../service/cloudbroker/account/flattens.go | 63 +- .../cloudbroker/account/resource_account.go | 46 +- .../service/cloudbroker/account/schema.go | 324 ++++++- .../cloudbroker/account/utility_account.go | 114 ++- .../account/utility_account_list.go | 4 + .../service/cloudbroker/audit/flattens.go | 27 +- internal/service/cloudbroker/audit/schema.go | 65 +- .../cloudbroker/audit/utility_audit_list.go | 33 + .../service/cloudbroker/disks/flattens.go | 4 + .../cloudbroker/disks/resource_disk.go | 29 +- internal/service/cloudbroker/disks/schema.go | 50 +- .../cloudbroker/disks/utility_disk_list.go | 3 + .../disks/utility_disk_list_unattached.go | 3 + .../service/cloudbroker/dpdknet/flattens.go | 26 +- .../cloudbroker/dpdknet/resource_dpdk.go | 13 +- .../service/cloudbroker/dpdknet/schema.go | 10 + .../cloudbroker/dpdknet/utility_dpdk.go | 4 + .../service/cloudbroker/extnet/flattens.go | 4 +- .../cloudbroker/extnet/resource_extnet.go | 14 +- internal/service/cloudbroker/extnet/schema.go | 15 + .../cloudbroker/extnet/utility_extnet_list.go | 4 + .../extnet/utility_extnet_resource.go | 6 +- .../service/cloudbroker/image/flattens.go | 4 + .../cloudbroker/image/resource_cdrom_image.go | 18 +- .../cloudbroker/image/resource_image.go | 28 - .../resource_image_from_blank_compute.go | 7 - .../resource_image_from_platform_disk.go | 13 +- .../image/resource_virtual_image.go | 12 +- internal/service/cloudbroker/image/schema.go | 133 +-- .../cloudbroker/image/utility_image_list.go | 3 + .../image/utility_resource_create.go | 17 +- internal/service/cloudbroker/k8ci/flattens.go | 4 - .../service/cloudbroker/k8ci/resource_k8ci.go | 2 - internal/service/cloudbroker/k8ci/schema.go | 48 - .../cloudbroker/k8ci/utility_k8ci_list.go | 6 - .../k8ci/utility_k8ci_list_deleted.go | 6 - .../cloudbroker/k8s/resource_k8s_cp.go | 1 + .../cloudbroker/k8s/resource_k8s_wg.go | 17 +- internal/service/cloudbroker/k8s/schema.go | 15 + .../cloudbroker/k8s/utility_k8s_list.go | 3 + .../kvmvm/data_source_compute_audits.go | 1 + .../service/cloudbroker/kvmvm/flattens.go | 337 +++---- internal/service/cloudbroker/kvmvm/models.go | 10 + .../cloudbroker/kvmvm/resource_compute.go | 76 +- internal/service/cloudbroker/kvmvm/schema.go | 201 +++- .../cloudbroker/kvmvm/utility_compute.go | 266 ++++-- .../kvmvm/utility_compute_audits.go | 32 +- .../cloudbroker/kvmvm/utility_compute_list.go | 6 +- internal/service/cloudbroker/lb/schema.go | 5 + .../service/cloudbroker/lb/utility_lb_list.go | 4 + internal/service/cloudbroker/node/flattens.go | 3 +- internal/service/cloudbroker/node/schema.go | 4 + internal/service/cloudbroker/rg/flattens.go | 33 +- .../service/cloudbroker/rg/resource_rg.go | 128 ++- internal/service/cloudbroker/rg/schema.go | 113 +++ internal/service/cloudbroker/rg/utility_rg.go | 90 ++ .../secgroup/data_source_security_group.go | 38 + .../data_source_security_group_list.go | 40 + .../service/cloudbroker/secgroup/flattens.go | 68 ++ .../secgroup/resource_security_group.go | 146 +++ .../service/cloudbroker/secgroup/schema.go | 288 ++++++ .../secgroup/utility_security_group.go | 95 ++ .../secgroup/utility_security_group_list.go | 60 ++ .../stpolicy/data_source_storage_policy.go | 37 + .../data_source_storage_policy_list.go | 40 + .../service/cloudbroker/stpolicy/flattens.go | 74 ++ .../stpolicy/resource_storage_policy.go | 182 ++++ .../service/cloudbroker/stpolicy/schema.go | 281 ++++++ .../stpolicy/utility_storage_policy.go | 115 +++ .../stpolicy/utility_storage_policy_list.go | 70 ++ .../cloudbroker/trunk/utility_trunk_list.go | 3 + internal/service/cloudbroker/vins/flattens.go | 51 +- .../service/cloudbroker/vins/resource_vins.go | 28 + internal/service/cloudbroker/vins/schema.go | 273 +++++- .../service/cloudbroker/vins/utility_vins.go | 24 + .../cloudbroker/vins/utility_vins_list.go | 3 + .../cloudbroker/zone/data_source_zone.go | 49 + internal/service/cloudbroker/zone/flattens.go | 7 + .../service/cloudbroker/zone/resource_zone.go | 2 +- .../service/cloudbroker/zone/utility_zone.go | 2 +- .../data_decort_sdn_access_group.go | 87 ++ .../data_decort_sdn_access_group_list.go | 40 + .../data_decort_sdn_access_group_user_list.go | 39 + internal/service/sdn/access_group/flattens.go | 140 +++ .../resource_decort_sdn_access_group.go | 276 ++++++ internal/service/sdn/access_group/schema.go | 389 ++++++++ .../sdn/access_group/utility_access_group.go | 43 + .../access_group/utility_access_group_list.go | 52 ++ .../utility_access_group_user_list.go | 74 ++ ...decort_sdn_default_security_policy_list.go | 40 + .../sdn/default_security_policy/flattens.go | 130 +++ .../sdn/default_security_policy/schema.go | 369 ++++++++ .../utility_default_security_policy_list.go | 40 + .../logicalports/data_source_logical_port.go | 36 + .../data_source_logical_port_by_unique_id.go | 35 + .../data_source_logical_port_list.go | 39 + internal/service/sdn/logicalports/flattens.go | 114 +++ .../sdn/logicalports/resource_logical_port.go | 226 +++++ internal/service/sdn/logicalports/schema.go | 858 ++++++++++++++++++ .../sdn/logicalports/utility_logical_port.go | 30 + .../utility_logical_port_by_unique_id.go | 30 + .../logicalports/utility_logical_port_list.go | 79 ++ .../sdn/segments/decort_sdn_get_status.go | 70 ++ .../sdn/segments/decort_sdn_segment.go | 67 ++ .../sdn/segments/decort_sdn_segment_list.go | 70 ++ internal/service/sdn/segments/flattens.go | 117 +++ .../sdn/segments/resource_sdn_segment.go | 357 ++++++++ internal/service/sdn/segments/schema.go | 731 +++++++++++++++ .../service/sdn/segments/utility_segment.go | 28 + .../segments/utility_segment_get_status.go | 36 + .../sdn/segments/utility_segment_list.go | 63 ++ samples/README.md | 27 + .../account/data_account_audits_list/main.tf | 5 + .../account/data_account_list/main.tf | 6 + .../cloudapi/account/resource_account/main.tf | 10 +- .../cloudapi/audit/data_audit_list/main.tf | 136 +++ .../bservice/data_bservice_list/main.tf | 6 + .../bservice/resource_bservice_group/main.tf | 15 +- samples/cloudapi/disk/data_disk_list/main.tf | 5 + .../disk/data_disk_list_unattached/main.tf | 5 + samples/cloudapi/disk/resource_disk/main.tf | 6 + .../cloudapi/extnet/data_extnet_list/main.tf | 6 + .../cloudapi/image/data_image_list/main.tf | 5 + samples/cloudapi/image/resource_image/main.tf | 13 +- .../image/resource_image_virtual/main.tf | 7 + samples/cloudapi/k8s/data_k8s_list/main.tf | 6 + samples/cloudapi/k8s/resource_k8s/main.tf | 6 + samples/cloudapi/k8s/resource_k8s_cp/main.tf | 6 + samples/cloudapi/k8s/resource_k8s_wg/main.tf | 6 + .../cloudapi/kvmvm/data_kvmvm_audits/main.tf | 56 +- .../cloudapi/kvmvm/data_kvmvm_list/main.tf | 6 + samples/cloudapi/kvmvm/resource_kvmvm/main.tf | 61 +- samples/cloudapi/lb/data_lb_list/main.tf | 6 + samples/cloudapi/rg/data_rg_audits/main.tf | 5 + samples/cloudapi/rg/resource_rg/main.tf | 16 + .../secgroup/data_security_group/main.tf | 38 + .../secgroup/data_security_group_list/main.tf | 89 ++ .../secgroup/resource_security_group/main.tf | 96 ++ .../stpolicy/data_storage_policy/main.tf | 38 + .../stpolicy/data_storage_policy_list/main.tf | 94 ++ .../cloudapi/trunk/data_trunk_list/main.tf | 5 + .../cloudapi/vins/data_vins_audits/main.tf | 5 + samples/cloudapi/vins/data_vins_list/main.tf | 6 + .../account/data_account_audits_list/main.tf | 5 + .../account/data_account_list/main.tf | 6 + .../account/resource_account/main.tf | 17 + .../cloudbroker/audit/data_audit_list/main.tf | 56 ++ .../cloudbroker/disk/data_disk_list/main.tf | 5 + .../disk/data_disk_list_unattached/main.tf | 4 + .../cloudbroker/disk/resource_disk/main.tf | 13 +- .../dpdknet/resource_dpdknet/main.tf | 7 + .../extnet/data_extnet_list/main.tf | 6 + .../extnet/resource_extnet/main.tf | 7 + .../cloudbroker/image/data_image_list/main.tf | 5 + .../image/data_image_list_stacks/main.tf | 4 + .../cloudbroker/image/resource_image/main.tf | 14 +- .../image/resource_image_cdrom/main.tf | 16 +- .../resource_image_from_blank_compute/main.tf | 7 - .../resource_image_from_platform_disk/main.tf | 12 - .../image/resource_virtual_image/main.tf | 9 +- .../cloudbroker/k8s/data_k8ci_list/main.tf | 10 - .../k8s/data_k8ci_list_deleted/main.tf | 10 - samples/cloudbroker/k8s/data_k8s_list/main.tf | 6 + samples/cloudbroker/k8s/resource_k8ci/main.tf | 12 - .../cloudbroker/k8s/resource_k8s_cp/main.tf | 6 + .../cloudbroker/k8s/resource_k8s_wg/main.tf | 6 + .../kvmvm/data_kvmvm_audits/main.tf | 53 ++ .../cloudbroker/kvmvm/data_kvmvm_list/main.tf | 11 +- .../cloudbroker/kvmvm/resource_kvmvm/main.tf | 62 +- samples/cloudbroker/lb/data_lb_list/main.tf | 6 + samples/cloudbroker/rg/data_rg_audits/main.tf | 5 + samples/cloudbroker/rg/resource_rg/main.tf | 16 + .../secgroup/data_security_group/main.tf | 38 + .../secgroup/data_security_group_list/main.tf | 89 ++ .../secgroup/resource_security_group/main.tf | 96 ++ samples/cloudbroker/sep/resource_sep/main.tf | 2 + .../stpolicy/data_storage_policy/main.tf | 38 + .../stpolicy/data_storage_policy_list/main.tf | 95 ++ .../stpolicy/resource_storage_policy/main.tf | 79 ++ .../cloudbroker/trunk/data_trunk_list/main.tf | 5 + .../cloudbroker/vins/data_vins_audits/main.tf | 5 + .../cloudbroker/vins/data_vins_list/main.tf | 6 + .../cloudbroker/vins/resource_vins/main.tf | 7 + .../cloudbroker/zone/resource_zone/main.tf | 2 +- .../data_decort_sdn_access_group/main.tf | 38 + .../data_decort_sdn_access_group_list/main.tf | 82 ++ .../main.tf | 122 +++ .../resource_decort_sdn_access_group/main.tf | 81 ++ .../main.tf | 61 ++ .../logicalports/data_logical_port/main.tf | 38 + .../data_logical_port_by_unique_id/main.tf | 38 + .../data_logical_port_list/main.tf | 131 +++ .../resource_logical_port/main.tf | 140 +++ samples/sdn/segments/data_segment/main.tf | 43 + .../segments/data_segment_get_status/main.tf | 48 + .../sdn/segments/data_segment_list/main.tf | 104 +++ samples/sdn/segments/resource_segment/main.tf | 154 ++++ 397 files changed, 17558 insertions(+), 1499 deletions(-) create mode 100644 docs/data-sources/audit_list.md create mode 100644 docs/data-sources/cb_security_group.md create mode 100644 docs/data-sources/cb_security_group_list.md create mode 100644 docs/data-sources/cb_storage_policy.md create mode 100644 docs/data-sources/cb_storage_policy_list.md create mode 100644 docs/data-sources/sdn_access_group.md create mode 100644 docs/data-sources/sdn_access_group_list.md create mode 100644 docs/data-sources/sdn_access_group_user_list.md create mode 100644 docs/data-sources/sdn_default_security_policy_list.md create mode 100644 docs/data-sources/sdn_logical_port.md create mode 100644 docs/data-sources/sdn_logical_port_get_by_unique_identifier.md create mode 100644 docs/data-sources/sdn_logical_port_list.md create mode 100644 docs/data-sources/sdn_segment.md create mode 100644 docs/data-sources/sdn_segment_get_status.md create mode 100644 docs/data-sources/sdn_segment_list.md create mode 100644 docs/data-sources/security_group.md create mode 100644 docs/data-sources/security_group_list.md create mode 100644 docs/data-sources/storage_policy.md create mode 100644 docs/data-sources/storage_policy_list.md create mode 100644 docs/resources/cb_security_group.md create mode 100644 docs/resources/cb_storage_policy.md create mode 100644 docs/resources/sdn_access_group.md create mode 100644 docs/resources/sdn_logical_port.md create mode 100644 docs/resources/sdn_segment.md create mode 100644 docs/resources/security_group.md create mode 100644 internal/service/cloudapi/audit/data_source_audit_list.go create mode 100644 internal/service/cloudapi/audit/utility_audit_list.go create mode 100644 internal/service/cloudapi/kvmvm/models.go create mode 100644 internal/service/cloudapi/secgroup/data_source_security_group.go create mode 100644 internal/service/cloudapi/secgroup/data_source_security_group_list.go create mode 100644 internal/service/cloudapi/secgroup/flattens.go create mode 100644 internal/service/cloudapi/secgroup/resource_security_group.go create mode 100644 internal/service/cloudapi/secgroup/schema.go create mode 100644 internal/service/cloudapi/secgroup/utility_security_group.go create mode 100644 internal/service/cloudapi/secgroup/utility_security_group_list.go create mode 100644 internal/service/cloudapi/stpolicy/data_source_storage_policy.go create mode 100644 internal/service/cloudapi/stpolicy/data_source_storage_policy_list.go create mode 100644 internal/service/cloudapi/stpolicy/flattens.go create mode 100644 internal/service/cloudapi/stpolicy/schema.go create mode 100644 internal/service/cloudapi/stpolicy/utility_storage_policy.go create mode 100644 internal/service/cloudapi/stpolicy/utility_storage_policy_list.go create mode 100644 internal/service/cloudbroker/kvmvm/models.go create mode 100644 internal/service/cloudbroker/secgroup/data_source_security_group.go create mode 100644 internal/service/cloudbroker/secgroup/data_source_security_group_list.go create mode 100644 internal/service/cloudbroker/secgroup/flattens.go create mode 100644 internal/service/cloudbroker/secgroup/resource_security_group.go create mode 100644 internal/service/cloudbroker/secgroup/schema.go create mode 100644 internal/service/cloudbroker/secgroup/utility_security_group.go create mode 100644 internal/service/cloudbroker/secgroup/utility_security_group_list.go create mode 100644 internal/service/cloudbroker/stpolicy/data_source_storage_policy.go create mode 100644 internal/service/cloudbroker/stpolicy/data_source_storage_policy_list.go create mode 100644 internal/service/cloudbroker/stpolicy/flattens.go create mode 100644 internal/service/cloudbroker/stpolicy/resource_storage_policy.go create mode 100644 internal/service/cloudbroker/stpolicy/schema.go create mode 100644 internal/service/cloudbroker/stpolicy/utility_storage_policy.go create mode 100644 internal/service/cloudbroker/stpolicy/utility_storage_policy_list.go create mode 100644 internal/service/sdn/access_group/data_decort_sdn_access_group.go create mode 100644 internal/service/sdn/access_group/data_decort_sdn_access_group_list.go create mode 100644 internal/service/sdn/access_group/data_decort_sdn_access_group_user_list.go create mode 100644 internal/service/sdn/access_group/flattens.go create mode 100644 internal/service/sdn/access_group/resource_decort_sdn_access_group.go create mode 100644 internal/service/sdn/access_group/schema.go create mode 100644 internal/service/sdn/access_group/utility_access_group.go create mode 100644 internal/service/sdn/access_group/utility_access_group_list.go create mode 100644 internal/service/sdn/access_group/utility_access_group_user_list.go create mode 100644 internal/service/sdn/default_security_policy/data_decort_sdn_default_security_policy_list.go create mode 100644 internal/service/sdn/default_security_policy/flattens.go create mode 100644 internal/service/sdn/default_security_policy/schema.go create mode 100644 internal/service/sdn/default_security_policy/utility_default_security_policy_list.go create mode 100644 internal/service/sdn/logicalports/data_source_logical_port.go create mode 100644 internal/service/sdn/logicalports/data_source_logical_port_by_unique_id.go create mode 100644 internal/service/sdn/logicalports/data_source_logical_port_list.go create mode 100644 internal/service/sdn/logicalports/flattens.go create mode 100644 internal/service/sdn/logicalports/resource_logical_port.go create mode 100644 internal/service/sdn/logicalports/schema.go create mode 100644 internal/service/sdn/logicalports/utility_logical_port.go create mode 100644 internal/service/sdn/logicalports/utility_logical_port_by_unique_id.go create mode 100644 internal/service/sdn/logicalports/utility_logical_port_list.go create mode 100644 internal/service/sdn/segments/decort_sdn_get_status.go create mode 100644 internal/service/sdn/segments/decort_sdn_segment.go create mode 100644 internal/service/sdn/segments/decort_sdn_segment_list.go create mode 100644 internal/service/sdn/segments/flattens.go create mode 100644 internal/service/sdn/segments/resource_sdn_segment.go create mode 100644 internal/service/sdn/segments/schema.go create mode 100644 internal/service/sdn/segments/utility_segment.go create mode 100644 internal/service/sdn/segments/utility_segment_get_status.go create mode 100644 internal/service/sdn/segments/utility_segment_list.go create mode 100644 samples/cloudapi/audit/data_audit_list/main.tf create mode 100644 samples/cloudapi/secgroup/data_security_group/main.tf create mode 100644 samples/cloudapi/secgroup/data_security_group_list/main.tf create mode 100644 samples/cloudapi/secgroup/resource_security_group/main.tf create mode 100644 samples/cloudapi/stpolicy/data_storage_policy/main.tf create mode 100644 samples/cloudapi/stpolicy/data_storage_policy_list/main.tf create mode 100644 samples/cloudbroker/secgroup/data_security_group/main.tf create mode 100644 samples/cloudbroker/secgroup/data_security_group_list/main.tf create mode 100644 samples/cloudbroker/secgroup/resource_security_group/main.tf create mode 100644 samples/cloudbroker/stpolicy/data_storage_policy/main.tf create mode 100644 samples/cloudbroker/stpolicy/data_storage_policy_list/main.tf create mode 100644 samples/cloudbroker/stpolicy/resource_storage_policy/main.tf create mode 100644 samples/sdn/access_group/data_decort_sdn_access_group/main.tf create mode 100644 samples/sdn/access_group/data_decort_sdn_access_group_list/main.tf create mode 100644 samples/sdn/access_group/data_decort_sdn_access_group_user_list/main.tf create mode 100644 samples/sdn/access_group/resource_decort_sdn_access_group/main.tf create mode 100644 samples/sdn/default_security_policy/data_decort_sdn_default_security_policy_list/main.tf create mode 100644 samples/sdn/logicalports/data_logical_port/main.tf create mode 100644 samples/sdn/logicalports/data_logical_port_by_unique_id/main.tf create mode 100644 samples/sdn/logicalports/data_logical_port_list/main.tf create mode 100644 samples/sdn/logicalports/resource_logical_port/main.tf create mode 100644 samples/sdn/segments/data_segment/main.tf create mode 100644 samples/sdn/segments/data_segment_get_status/main.tf create mode 100644 samples/sdn/segments/data_segment_list/main.tf create mode 100644 samples/sdn/segments/resource_segment/main.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a5ca8be..f1aa26cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,137 +1,223 @@ -## Version 4.10.0 +## Version 4.10.1 ### Добавлено +#### access group +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1109 | Resource `decort_sdn_access_group` и datasources `decort_sdn_access_group`, `decort_sdn_access_group_list`, `decort_sdn_access_group_user_list` в sdn/access_group | + #### account | Идентификатор
задачи | Описание | | --- | --- | -| BATF-923 | Вычисляемое поле `emails` в блоке `ACL` в datasource `decort_cb_account` и в resource `decort_cb_account` в cloudbroker/account | -| BATF-970 | Возможное значение `trunk` в поле `compute_features` в resource `decort_cb_account` в cloudbroker/account | -| BATF-1004 | Вычисляемое поле `emails` в блоке `ACL` в datasource `decort_account` и в resource `decort_account` в cloudapi/account | +| BATF-1061 | Опциональный блок `storage_policy` в блок `resource_limits` в resource `decort_cb_account` в cloudbroker/account | +| BATF-1061 | Вычисляемое поля `storage_policy` в блок `resource_limits` resource `decort_account` и datasources `decort_account`, `decort_account_resource_consumption_get` в cloudapi/account и resource `decort_cb_account` и datasources `decort_cb_account`, `decort_cb_account_list,` `decort_cb_account_list_deleted` в cloudbroker/account | +| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_account_list` в cloudapi/account и в datasource `decort_cb_account_list` в cloudbroker/account | +| BATF-1087 | Вычислямый блок `policies` в блоки `consumed` и `reserved` в datasources `decort_account_resource_consumption_get`, `decort_account_resource_consumption_list` в cloudapi/account и в `decort_cb_account_resource_consumption_get`, `decort_cb_account_resource_consumption_list` в cloudbroker/account | +| BATF-1085| Вычисляемое поле `zone_ids` в datasources `decort_account_list` и `decort_account_deleted_list` в cloudapi/account | -#### kvmvm +#### audit +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1080 | Вычисляемое поле `correlation_id` в datasources `decort_audit` в cloudapi/audit и в`decort_cb_audit_list`, `decort_cb_audit` в cloudbroker/audit | +| BATF-1095 | Опциональные поля `resgroup_id`, `compute_id`, `account_id`, `vins_id`, `service_id`, `k8s_id`, `flipgroup_id`, `lb_id`, `sep_id`, `node_id` и `exclude_audit_lines` в datasource `decort_cb_audit_list` в cloudbroker/audit | +| BATF-1095 | Datasource `decort_audit_list` в cloudapi/audit | + +#### bservice +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1065 | Обязательное поле `storage_policy` в resource `decort_bservice_group` в cloudapi/bservice | +| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_bservice_list` в cloudapi/bservice | + +#### default security policy | Идентификатор
задачи | Описание | | --- | --- | -| BATF-960 | Вычисляемое поле `sdn_interface_id` в datasources `decort_kvmvm`, `decort_kvmvm_list`, `decort_kvmvm_list_deleted` в cloudapi/kvmvm и `decort_cb_kvmvm`, `decort_kvmvm_cb_list`, `decort_kvmvm_cb_list_deleted` в cloudbroker/kvmvm | -| BATF-961 | Добавлена поддержка `net_type` SDN и опциональное поле `sdn_interface_id` в блоке `network` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | -| BATF-971 | Добавлена поддержка `net_type` TRUNK в блоке `network` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | -| BATF-976 | Добавлена возможность указания и изменения `mtu` в блоке `network` для сетей типа `EXTNET` и `DPDK` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | -| BATF-993 | Вычисляемые поля `live_migration_job_id` и `qemu_guest` в datasources `data_kvmvm` и `data_kvmvm_list` в cloudapi/kvmvm и в datasources `decort_cb_kvmvm` и `decort_cb_kvmvm_list` в cloudbroker/kvmvm | -| BATF-1014 | Вычисляемое поле `trunk_tags` в блоке `interfaces` в datasources `decort_kvmvm`, `decort_kvmvm_list`, `decort_kvmvm_list_deleted` и resource `decort_kvmvm` в cloudapi/kvmvm и datasources `decort_cb_kvmvm`, `decort_kvmvm_cb_list`, `decort_kvmvm_cb_list_deleted` и resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1111 | Datasource `decort_sdn_default_security_policy_list` в sdn/default_security_policy | + +#### disks +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1063 | Обязательное поле `storage_policy_id` в resources `decort_disk` в cloudapi/disk и `decort_cb_disk` в cloudbroker/disk | +| BATF-1063 | Вычисляемое поле `storage_policy_id` в data_sources `decort_disk`, `decort_disk_list` и `decort_disk_deleted` в cloudapi/disk и `decort_cb_disk`, `decort_cb_disk_list`, `decort_cb_disk_list_deleted` в cloudbroker/disk | +| BATF-1079 | Вычисляемое поле `to_clean` в data_sources `decort_disk`, `decort_disk_list` и `decort_disk_deleted` в cloudapi/disk и `decort_cb_disk`, `decort_cb_disk_list`, `decort_cb_disk_list_deleted` в cloudbroker/disk | +| BATF-1079 | Вычисляемое поле `to_clean` в resources `decort_disk` в cloudapi/disk и `decort_cb_disk` в cloudbroker/disk | #### extnet | Идентификатор
задачи | Описание | | --- | --- | -| BATF-972 | Опциональные поля `highly_available`, `sec_vnfdev_ip`, `mtu` в resource `decort_cb_extnet` в cloudbroker/extnet | -| BATF-972 | Вычисляемые поля `redundant`, `sec_vnfdev_id`, `mtu` в datasource `decort_extnet` в cloudapi/extnet и в datasources `decort_cb_extnet`, `decort_cb_extnet_list` в cloudbroker/extnet | -| BATF-972 | Вычисляемое поле `pre_reservations` в datasource `decort_extnet` в cloudapi/extnet и в datasource`decort_cb_extnet` в cloudbroker/extnet | +| BATF-1074 | Опциональное поле `enable_secgroups` в resource `decort_cb_extnet` в cloudbroker/extnet | +| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_extnet_list` в cloudapi/extnet и в datasource `decort_cb_extnet_list` в cloudbroker/extnet | -#### grid +#### dpdk | Идентификатор
задачи | Описание | | --- | --- | -| BATF-996 | Вычислительные поля `network_modes` и `sdn_support` в datasources `decort_cb_grid` и `decort_cb_grid_list` в cloudbroker/grid | +| BATF-1074 | Опциональное поле `enable_secgroups` в resource `decort_cb_dpdknet` в cloudbroker/dpdk | #### image | Идентификатор
задачи | Описание | | --- | --- | -| BATF-930 | Опциональное поле `sync_mode` в resource `decort_image` в cloudapi/image | +| BATF-1005 | Опциональный поле `account_id` в resource `decort_image_virtual` в cloudapi/image | +| BATF-1093 | Опциональное поле `storage_policy_id` в datasource `decort_image_list` в cloudapi/image и в datasource `decort_cb_image_list` в cloudbroker/image | +| BATF-1067 | Обязательное поле `storage_policy_id` в resources `decort_image` в cloudapi/image и `decort_cb_image` и `decort_cb_image_cdrom` в cloudbroker/image | +| BATF-1067 | Вычисляемое поле `storage_policy_id` в datasources `decort_image` и `decort_image_list` в cloudapi/image и datasources `decort_cb_image` и `decort_cb_image_list` в cloudbroker/image | +| BATF-1127 | Вычисляемое поле `to_clean` в datasources `decort_image` в cloudapi/image и datasources `decort_cb_image` и `decort_cb_image_list` в cloudbroker/image | +| BATF-1127 | Вычисляемое поле `to_clean` в resources `decort_image`, `decort_image_from_blank_compute`, `decort_image_from_platform_disk`, `decort_image_virtual` в cloudapi/image и resources `decort_cb_image`, `decort_cb_cdrom_image`, `decort_cb_image_from_blank_compute`, `decort_cb_image_from_platform_disk`, `decort_cb_image_virtual` в cloudbroker/image | + +#### k8s +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1066 | Обязательное поле `storage_policy_id`, в resources `decort_k8s`, `decort_k8s_cp`, `decort_k8s_wg` в cloudapi/kvmvm и `decort_cb_k8s_cp`, `decort_cb_k8s_wg`, в cloudbroker/k8s | +| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_kvmvm_list` в cloudapi/kvmvm и в datasource `decort_cb_kvmvm_list` в cloudbroker/kvmvm | + +#### kvmvm +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1057 | Опциональные поля `timestamp_at`, `timestamp_to`, `user`, `call`, `sort_by`, `page`, `size`, `min_status_code`, `max_status_code` в datasources `decort_kvmvm_audits` в cloudapi/kvmvm и `decort_cb_kvmvm_audits` в cloudbroker/kvmvm | +| BATF-1064 | Обязательное поле `storage_policy_id` в resources `decort_kvmvmv` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1064 | Вычисляемое поле `storage_policy_id` в data_sources `decort_kvmvmv` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1073 | Вычисляемые поля `security_groups` и `enable_secgroups` в блоке `interfaces` в data_sources `decort_kvmvmv`, `decort_kvmvmv_list` и `decort_kvmvmv_list_deleted` и resource `decort_kvmvmv` в cloudapi/kvmvm | +| BATF-1073 | Вычисляемые поля `security_groups` и `enable_secgroups` в блоке `interfaces` data_sources `decort_cb_kvmvmv`, `decort_cb_kvmvmv_list` и `decort_cb_kvmvmv_list_deleted` и resource `decort_cb_kvmvmv` в cloudbroker/kvmvm | +| BATF-1073 | Опциональный блок `security_groups` в resource `decort_kvmvmv` в cloudapi/kvmvm и resource `decort_cb_kvmvmv` в cloudbroker/kvmvm | +| BATF-1078 | Опциональное поле `enabled` в блоке `network` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1079 | Вычисляемое поле `to_clean` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1083 | Опциональное поле `os_version` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1083 | Вычисляемое поле `os_version` в datasources `decort_kvmvmv`, `decort_kvmvm_list`, `decort_kvmvm_list_deleted` в cloudapi/kvmvm и `decort_cb_kvmvm`, `decort_cb_kvmvm_list`, `decort_cb_kvmvm_list_deleted` в cloudbroker/kvmvm | +| BATF-1098 | Вычисляемое поле `boot_image_id` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1098 | Вычисляемое поле `boot_image_id` в datasources `decort_kvmvmv`, `decort_kvmvm_list`, `decort_kvmvm_list_deleted` в cloudapi/kvmvm и `decort_cb_kvmvm`, `decort_cb_kvmvm_list`, `decort_cb_kvmvm_list_deleted` в cloudbroker/kvmvm | +| BATF-1088 | Вызов метода `Start` перед методом `pinToStack` в cloudapi/kvmvm | +| BATF-1128 | Перезагрузка виртуальной машины при изменении полей "hot_resize", "cpu" в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm | #### lb | Идентификатор
задачи | Описание | | --- | --- | -| BATF-952 | Вычисляемое поле `account_id` в datasource `decort_lb` в cloudapi/lb и в datasource `decort_cb_lb` в cloudbroker/lb | +| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_lb_list` в cloudapi/lb и в datasource `decort_cb_lb_list` в cloudbroker/lb | -#### locations +#### logical ports | Идентификатор
задачи | Описание | | --- | --- | -| BATF-994 | Вычисляемые поля `network_modes` и `sdn_support` в datasource `decort_locations_list` в cloudbroker/locations | +| BATF-1114 | Datasources `decort_sdn_logical_port`, `decort_sdn_logical_port_get_by_unique_identifier` и `decort_sdn_logical_port_list` и resource `decort_sdn_logical_port` в sdn/logicalports | #### node | Идентификатор
задачи | Описание | | --- | --- | -| BATF-995 | Вычисляемое поле `zone_id` в datasource `decort_cb_node` и вычисляемые поля `sdn_hypervisor_name` и `zone_id`в datasource `decort_cb_node_list` в cloudbroker/node | +| BATF-1081 | Вычисляемое поле `vcpu` в блоке `free` в datasource `decort_cb_node` в cloudbroker/node | #### rg | Идентификатор
задачи | Описание | | --- | --- | -| BATF-932 | Вычисляемые поле `created_by` и `created_time` в resource `decort_resgroup` в cloudapi/rg | -| BATF-970 | Возможное значение `trunk` в поле `compute_features` в resource `decort_cb_rg` в cloudbroker/rg | -| BATF-959 | Опциональное поле `sdn_access_group_id` в resource `decort_resgroup` в cloudapi/rg и в resource `decort_cb_rg` в cloudbroker/rg | -| BATF-959 | Вычисляемые поле `sdn_access_group_id` в datasources `decort_resgroup`, `decort_rg_list`, в cloudapi/rg и в datasources `decort_cb_rg` и `decort_cb_rg_list` в cloudbroker/rg | +| BATF-1062 | Опциональное поле `storage_policy` в resources `decort_resgroup` в cloudapi/rg и в `decort_cb_rg` в cloudbroker/rg | +| BATF-1062 | Вычисляемое поле `storage_policy_ids` в resources `decort_resgroup` в cloudapi/rg и в `decort_cb_rg` в cloudbroker/rg| +| BATF-1062 | Вычисляемое поле `storage_policy_ids` datasources в cloudapi/rg и в cloudbroker/rg | -#### trunk +#### security group +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1071 | Datasources `decort_security_group` и `decort_security_group_list` в cloudapi/secgroup и datasources `decort_cb_security_group` и `decort_cb_security_group_list` в cloudbroker/secgroup | +| BATF-1072 | Resources `decort_security_group` в cloudapi/secgroup и `decort_cb_security_group` в cloudbroker/secgroup | + +#### sdn segment +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1120 | Resource `decort_sdn_segment` и datasources `decort_sdn_segment`, `decort_sdn_segment_get_status` и `decort_sdn_segment_list` в sdn/segments | + +#### storage policy | Идентификатор
задачи | Описание | | --- | --- | -| BATF-973 | Resource `decort_cb_trunk` в cloudbroker/trunk | -| BATF-974 | Datasources `decort_trunk` и `decort_trunk_list` в cloudapi/trunk и datasources `decort_cb_trunk` и `decort_cb_trunk_list` в cloudbroker/trunk | +| BATF-1058 | Datasources `decort_storage_policy` и `decort_storage_policy_list` в cloudapi/storage_policy и datasources `decort_cb_storage_policy` и `decort_cb_storage_policy_list` в cloudbroker/storage_policy | +| BATF-1059 | Resource `decort_cb_storage_policy` в cloudbroker/storage_policy | #### vins | Идентификатор
задачи | Описание | | --- | --- | -| BATF-997 | Вычисляемое поле `sdn_interface_id` в datasource  `decort_vins` в cloudapi/vins и в datasource  `decort_cb_vins` в cloudbroker/vins | +| BATF-1048 | Вычисляемое поле `routes` в блоках `NAT` и `GW` в datasource `decort_vins`, resource `decort_vins` в cloudapi/vins, datasource `decort_cb_vins`, resource `decort_cb_vins` в cloudbroker/vins | +| BATF-1074 | Опциональное поле `enable_secgroups` в resource `decort_cb_vins` в cloudbroker/vins | +| BATF-1094 | Вычисляемое поле `zone_id` в блоках `DHCP`, `GW`, `NAT` и `VNFDev` и вычисляемые поля `security_groups` и `enable_secgroups` в блоке `VNFInterface` в datasource `decort_vins` и в resource `decort_vins` в cloudapi/vins и в datasource `decort_cb_vins` и в resource `decort_cb_vins` в cloudbroker/vins | +| BATF-1075 | Опциональное поле `zone_id` в datasource `decort_vins_list` в cloudapi/vins и в datasource `decort_cb_vins_list` в cloudbroker/vins | +| BATF-1104 | Вычисляемое поле `live_migration_job_id` в блоке `VNFDev` в datasource `decort_vins` и в resource `decort_vins` в cloudapi/vins и в datasource `decort_cb_vins` и в resource `decort_cb_vins` в cloudbroker/vins | -#### user +#### zone | Идентификатор
задачи | Описание | | --- | --- | -| BATF-958 | Опциональное поле `blocked` в блоке `ACL` в resource `resource_user` в cloudbroker/user | -| BATF-958 | Вычисляемое поле `blocked` в блоке `ACL` в datasource `data_user` и `data_user_list` в cloudbroker/user | -| BATF-923 | Опциональное поле `email` в datasource `decort_cb_user_list` в cloudbroker/user | -| BATF-950 | Опциональное поле `provider_name` в resource `decort_cb_user` в cloudbroker/user | +| BGOS-1076 | Вычисляемые поля `account_ids`, `compute_ids`, `extnet_ids`, `vins_ids`, `lb_ids`, `bservice_ids` и `k8s_ids` в datasource `decort_zone` в cloudapi/zone и в datasource `decort_cb_zone` в cloudbroker/zone | ### Исправлено +#### общие изменения +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1116 | Исправлены уязвимости, обновлена версия go до v1.24.0 | + #### account | Идентификатор
задачи | Описание | | --- | --- | -| BATF-956 | Вычисляемое поле `zone_ids` представляет собой список maps в datasource `decort_account` в cloudapi/account и в datasource `decort_cb_account` в cloudbroker/account | +| BATF-894 | Исправлено отображение вычисляемого поля `zone_ids` в resource `decort_account` в cloudapi/account | +| BATF-894 | Исправлено некорректное поведение метода `resourceAccountUpdate` resource `decort_cb_account` в cloudbroker/account | -#### kvmvm +#### bservice | Идентификатор
задачи | Описание | | --- | --- | -| BATF-1009 | Ошибка изменения полей `cpu`, `ram` в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | -| BATF-1010 | Ошибка повторного включения/отключения в resources `decort_kvmvm` в cloudapi/kvmvm и `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1060 | Изменен тип поля `driver` с required на optional в resource `decort_bservice_group` в cloudapi/bservice | #### extnet | Идентификатор
задачи | Описание | | --- | --- | -| BATF-972 | Вычисляемое поля `network_ids` сменило тип с int на []struct в datasource `decort_extnet` в cloudapi/extnet и в datasources `decort_cb_extnet`, `decort_cb_extnet_list`, resource `decort_cb_extnet` в cloudbroker/extnet | +| BATF-893 | Исправлено отображение вычисляемого поля `network_ids` в datasource `decort_cb_extnet_list` в cloudbroker/extnet | +| BATF-972 | Возможность изменения поля `mtu` в resource `decort_cb_extnet` в cloudbroker/extnet | #### image | Идентификатор
задачи | Описание | | --- | --- | -| BATF-930 | Опциональное поле `sync_mode` имеет значение по умолчанию false в resource `decort_cb_image` в cloudbroker/image | -| BATF-926 | Опциональное поле `architecture` стало вычисляемым в resource `decort_image` в cloudapi/image и в resource `decort_cb_image` в cloudbroker/image | -| BATF-926 | Обязательное поле `architecture` стало вычисляемым в resource `decort_image_from_platform_disk` в cloudapi/image и в resource `decort_cb_image_from_platform_disk` в cloudbroker/image | +| BATF-1005 | Опциональный `account_id` теперь может быть использован при создании resource `decort_cb_virtual_image` в cloudbroker/image | +| BATF-1007 | Изменен тип поля `drivers` с required на computed в resources `decort_image`, `decort_image_from_platform_disk` в cloudapi/image и в `decort_cb_image`, `decort_cb_image_from_platform_disk`, `decort_cb_cdrom_image` в cloudbroker/image | -#### flipgroup +#### kvmvm | Идентификатор
задачи | Описание | | --- | --- | -| BATF-929 | Обязательное поле `client_type` стало опциональным в resource `decort_flipgroup` в cloudapi/flipgroup и в resource `decort_cb_flipgroup` в cloudbroker/flipgroup | +| BATF-1049 | Перезагрузка виртуальной машины при изменении полей `ram` и `cpu` в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm | +| BATF-1122 | Перезагрузка виртуальной машины при изменении поля "disks" в resources `decort_kvmvm` и `decort_cb_kvmvm` в cloudapi/kvmvm и в cloudbroker/kvmvm | +| BATF-888 | Исправлено получение вычисляемого поля `zone_ids` в datasources `decort_kvmvm_list` и `decort_kvmvm_list_deleted` в cloudapi/kvmvm | -#### user +#### trunk | Идентификатор
задачи | Описание | | --- | --- | -| BATF-950 | Опциональное поле `groups` стало вычисляемым в resource `decort_cb_user` в cloudbroker/user | +| BATF-1012 | Изменен тип поля `status` с computed на optional в datasource `decort_trunk_list` в cloudapi/trunk и в datasource `decort_cb_trunk_list` в cloudbroker/trunk | + +#### zone +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-887 | Исправлена ошибка при изменении поля `name` в resource `decort_cb_zone` в cloudbroker/zone | + ### Удалено #### account | Идентификатор
задачи | Описание | | --- | --- | -| BATF-990 | Опциональное поле `reason` в resource `decort_account` в cloudapi/account и в resource `decort_cb_account` в cloudbroker/account | +| BATF-1086 | Вычисляемые поля `ckey`, `meta` и `service_account` в datasource `decort_account` в cloudapi/account и в datasources `decort_cb_account`, `decort_cb_account_list` и `decort_cb_account_list_deleted` в cloudbroker/account | +| BATF-1086 | Вычисляемые поля `ckey`, `meta` и `service_account` в resource `decort_account` в cloudapi/account и в resource `decort_cb_account` в cloudbroker/account | + +#### audit +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1095 | Поле `tags` в datasource `decort_cb_audit_list` в cloudbroker/audit | + +#### disks +| Идентификатор
задачи | Описание | +| --- | --- | +| BATF-1096 | Опциональное поле `iops` в resource `decort_cb_disk` в cloudbroker/disks | +| BATF-1089 | Опциональное поле `storage_policy_id` в datasources `decort_disk_list`, `decort_disk_list_unattached` в cloudapi/disks и `decort_cb_disk_list`, `decort_cb_disk_list_unattached` в cloudbroker/disks | #### image | Идентификатор
задачи | Описание | | --- | --- | -| BATF-998 | Значение `SVA_KVM_X86` для обязательного поля `drivers` в resource `decort_image` в cloudapi/image и в resource `decort_cb_image` в cloudbroker/image | +| BATF-1084 | Поле `enabled_stacks` в resources `decort_cb_cdrom_image`, `decort_cb_image_from_blank_compute`, `decort_cb_image_from_platform_disk`, `decort_cb_image` в cloudbroker/image | -#### kvmvm +#### k8ci | Идентификатор
задачи | Описание | | --- | --- | -| BATF-977 | Вычисляемые поля `order` и `vmid` в структуре `disks` в resource `decort_kvmvm` и datasource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` и datasource `decort_cb_kvmvm` в cloudbroker/kvmvm | -| BATF-998 | Значение `SVA_KVM_X86` для обязательного поля `drivers` в resource `decort_kvmvm` в cloudapi/kvmvm и в resource `decort_cb_kvmvm` в cloudbroker/kvmvm | +| BATF-1007 | Поля `worker_driver`, `master_driver` в resource `decort_cb_k8ci` и datasources `decort_cb_k8ci_list`, `decort_cb_k8ci_list_deleted` в cloudbroker/k8ci | -#### vins +#### kvmvm | Идентификатор
задачи | Описание | | --- | --- | -| BATF-933 | Вычисляемое поле `routes` в блоках `NAT` и `GW` в datasource `decort_vins`, resource `decort_vins` в cloudapi/vins, datasource `decort_cb_vins`, resource `decort_cb_vins` в cloudbroker/vins | +| BATF-1091 | Опциональное поле `image_id` в datasources `decort_cb_kvmvm_list` в cloudbroker/kvmvm | diff --git a/Makefile b/Makefile index 30cfe59f..6524b482 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ ZIPDIR = ./zip BINARY=${NAME} WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH} MAINPATH = ./cmd/decort/ -VERSION=4.10.0 +VERSION=4.10.1 OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH) FILES = ${BINARY}_${VERSION}_darwin_amd64\ diff --git a/README.md b/README.md index 0c3d8930..27dab5a6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # terraform-provider-decort -Внимание! Данная версия предназначена только для версии платформы 4.4.0 build 963 - Terraform provider для платформы Digital Energy Cloud Orchestration Technology (DECORT) ## Соответсвие версий платформы версиям провайдера @@ -25,11 +23,13 @@ Terraform provider для платформы Digital Energy Cloud Orchestration ## Режимы работы -Провайдер позволяет работать в двух режимах: +Провайдер позволяет работать в трех режимах: - Режим пользователя, - Режим администратора.
Используйте ресурсы `decort_cb_` для администрирования.
+- Режим SDN.
+ Используйте ресурсы `decort_sdn_` для работы с группой sdn.
Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki ## Возможности провайдера @@ -49,6 +49,7 @@ Terraform provider для платформы Digital Energy Cloud Orchestration - Работа с locations, - Работа с pfw, - Работа с resource groups, + - Работа с security groups, - Работа с snapshots, - Работа с stacks, - Работа с trunk, @@ -73,11 +74,17 @@ Terraform provider для платформы Digital Energy Cloud Orchestration - Работа с resource groups, - Работа с seps, - Работа с user, + - Работа с security groups, - Работа с stacks, - Работа с trunk, - Работа с VINS, - Работа с Zone. +- Режим SDN: + - Работа с access groups, + - Работа с default security policies, + - Работа с segments + Со списком и описанием функционала всех групп можно ознамоиться на Вики проекта: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki ## Установка diff --git a/docs/data-sources/account.md b/docs/data-sources/account.md index 33c66498..265847fb 100644 --- a/docs/data-sources/account.md +++ b/docs/data-sources/account.md @@ -27,7 +27,6 @@ description: |- - `account_name` (String) - `acl` (List of Object) (see [below for nested schema](#nestedatt--acl)) -- `ckey` (String) - `company` (String) - `companyurl` (String) - `compute_features` (List of String) @@ -46,11 +45,10 @@ description: |- - `guid` (Number) - `id` (String) The ID of this resource. - `machines` (List of Object) (see [below for nested schema](#nestedatt--machines)) -- `meta` (List of String) - `resource_limits` (List of Object) (see [below for nested schema](#nestedatt--resource_limits)) - `send_access_emails` (Boolean) -- `service_account` (Boolean) - `status` (String) +- `storage_policy_ids` (List of Number) - `updated_time` (Number) - `version` (Number) - `vins` (List of Number) @@ -111,6 +109,16 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (List of Object) (see [below for nested schema](#nestedobjatt--resource_limits--storage_policy)) + + +### Nested Schema for `resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) + diff --git a/docs/data-sources/account_deleted_list.md b/docs/data-sources/account_deleted_list.md index 551adbd6..4f472678 100644 --- a/docs/data-sources/account_deleted_list.md +++ b/docs/data-sources/account_deleted_list.md @@ -24,6 +24,7 @@ description: |- - `size` (Number) Page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only @@ -54,6 +55,7 @@ Read-Only: - `desc` (String) - `status` (String) - `updated_time` (Number) +- `zone_ids` (List of Number) ### Nested Schema for `items.acl` diff --git a/docs/data-sources/account_list.md b/docs/data-sources/account_list.md index f3e3952d..d3bc6a84 100644 --- a/docs/data-sources/account_list.md +++ b/docs/data-sources/account_list.md @@ -25,6 +25,7 @@ description: |- - `sort_by` (String) sort by one of supported fields, format +|-(field) - `status` (String) Filter by status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only @@ -55,6 +56,7 @@ Read-Only: - `desc` (String) - `status` (String) - `updated_time` (Number) +- `zone_ids` (List of Number) ### Nested Schema for `items.acl` diff --git a/docs/data-sources/account_resource_consumption_get.md b/docs/data-sources/account_resource_consumption_get.md index 9dff999c..c2763bab 100644 --- a/docs/data-sources/account_resource_consumption_get.md +++ b/docs/data-sources/account_resource_consumption_get.md @@ -50,9 +50,32 @@ Read-Only: - `ext_ips` (Number) - `ext_traffic` (Number) - `gpu` (Number) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--consumed--policies)) - `ram` (Number) - `seps` (List of Object) (see [below for nested schema](#nestedobjatt--consumed--seps)) + +### Nested Schema for `consumed.policies` + +Read-Only: + +- `disk_size` (Number) +- `disk_size_max` (Number) +- `id` (String) +- `seps` (List of Object) (see [below for nested schema](#nestedobjatt--consumed--policies--seps)) + + +### Nested Schema for `consumed.policies.seps` + +Read-Only: + +- `data_name` (String) +- `disk_size` (Number) +- `disk_size_max` (Number) +- `sep_id` (String) + + + ### Nested Schema for `consumed.seps` @@ -76,9 +99,32 @@ Read-Only: - `ext_ips` (Number) - `ext_traffic` (Number) - `gpu` (Number) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--reserved--policies)) - `ram` (Number) - `seps` (List of Object) (see [below for nested schema](#nestedobjatt--reserved--seps)) + +### Nested Schema for `reserved.policies` + +Read-Only: + +- `disk_size` (Number) +- `disk_size_max` (Number) +- `id` (String) +- `seps` (List of Object) (see [below for nested schema](#nestedobjatt--reserved--policies--seps)) + + +### Nested Schema for `reserved.policies.seps` + +Read-Only: + +- `data_name` (String) +- `disk_size` (Number) +- `disk_size_max` (Number) +- `sep_id` (String) + + + ### Nested Schema for `reserved.seps` @@ -103,3 +149,12 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (List of Object) (see [below for nested schema](#nestedobjatt--resource_limits--storage_policy)) + + +### Nested Schema for `resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/data-sources/account_resource_consumption_list.md b/docs/data-sources/account_resource_consumption_list.md index 44c3712b..c70a9b8d 100644 --- a/docs/data-sources/account_resource_consumption_list.md +++ b/docs/data-sources/account_resource_consumption_list.md @@ -54,9 +54,32 @@ Read-Only: - `ext_ips` (Number) - `ext_traffic` (Number) - `gpu` (Number) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--items--consumed--policies)) - `ram` (Number) - `seps` (List of Object) (see [below for nested schema](#nestedobjatt--items--consumed--seps)) + +### Nested Schema for `items.consumed.policies` + +Read-Only: + +- `disk_size` (Number) +- `disk_size_max` (Number) +- `id` (String) +- `seps` (List of Object) (see [below for nested schema](#nestedobjatt--items--consumed--policies--seps)) + + +### Nested Schema for `items.consumed.policies.seps` + +Read-Only: + +- `data_name` (String) +- `disk_size` (Number) +- `disk_size_max` (Number) +- `sep_id` (String) + + + ### Nested Schema for `items.consumed.seps` @@ -80,9 +103,32 @@ Read-Only: - `ext_ips` (Number) - `ext_traffic` (Number) - `gpu` (Number) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--items--reserved--policies)) - `ram` (Number) - `seps` (List of Object) (see [below for nested schema](#nestedobjatt--items--reserved--seps)) + +### Nested Schema for `items.reserved.policies` + +Read-Only: + +- `disk_size` (Number) +- `disk_size_max` (Number) +- `id` (String) +- `seps` (List of Object) (see [below for nested schema](#nestedobjatt--items--reserved--policies--seps)) + + +### Nested Schema for `items.reserved.policies.seps` + +Read-Only: + +- `data_name` (String) +- `disk_size` (Number) +- `disk_size_max` (Number) +- `sep_id` (String) + + + ### Nested Schema for `items.reserved.seps` diff --git a/docs/data-sources/audit.md b/docs/data-sources/audit.md index 5a00485b..94b9bdea 100644 --- a/docs/data-sources/audit.md +++ b/docs/data-sources/audit.md @@ -27,6 +27,7 @@ description: |- - `args` (String) - `call` (String) +- `correlation_id` (String) - `guid` (String) - `id` (String) The ID of this resource. - `kwargs` (String) diff --git a/docs/data-sources/audit_list.md b/docs/data-sources/audit_list.md new file mode 100644 index 00000000..2044c20b --- /dev/null +++ b/docs/data-sources/audit_list.md @@ -0,0 +1,77 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_audit_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_audit_list (Data Source) + + + + + + +## Schema + +### Optional + +- `account_id` (Number) +- `call` (String) find by api endpoint (Mongo RegExp supported) +- `compute_id` (Number) +- `exclude_audit_lines` (Boolean) +- `flipgroup_id` (Number) +- `k8s_id` (Number) +- `lb_id` (Number) +- `max_status_code` (Number) find by HTTP max status code +- `min_status_code` (Number) find by HTTP min status code +- `page` (Number) page number +- `request_id` (String) request id +- `resgroup_id` (Number) +- `sep_id` (Number) +- `service_id` (Number) +- `size` (Number) page size +- `sort_by` (String) sort by one of supported fields, format +|-(field) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `timestamp_at` (Number) find all audits after point in time (unixtime) +- `timestamp_to` (Number) find all audits before point in time (unixtime) +- `user` (String) find by user (Mongo RegExp supported) +- `vins_id` (Number) + +### Read-Only + +- `entry_count` (Number) entry count +- `id` (String) The ID of this resource. +- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `account_id` (Number) +- `args` (String) +- `call` (String) +- `compute_id` (Number) +- `correlation_id` (String) +- `guid` (String) +- `kwargs` (String) +- `remote_addr` (String) +- `resgroup_id` (Number) +- `responsetime` (Number) +- `result` (String) +- `status_code` (Number) +- `timestamp` (Number) +- `timestamp_end` (Number) +- `ttl` (String) +- `user` (String) diff --git a/docs/data-sources/bservice_deleted_list.md b/docs/data-sources/bservice_deleted_list.md index c4be4bff..45d16113 100644 --- a/docs/data-sources/bservice_deleted_list.md +++ b/docs/data-sources/bservice_deleted_list.md @@ -23,6 +23,7 @@ description: |- - `size` (Number) Page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only diff --git a/docs/data-sources/bservice_list.md b/docs/data-sources/bservice_list.md index 22896550..aae578db 100644 --- a/docs/data-sources/bservice_list.md +++ b/docs/data-sources/bservice_list.md @@ -29,6 +29,7 @@ description: |- - `status` (String) Filter by status - `tech_status` (String) Filter by tech status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only diff --git a/docs/data-sources/cb_account.md b/docs/data-sources/cb_account.md index ba22e7bc..16a474a5 100644 --- a/docs/data-sources/cb_account.md +++ b/docs/data-sources/cb_account.md @@ -27,7 +27,6 @@ description: |- - `account_name` (String) - `acl` (List of Object) (see [below for nested schema](#nestedatt--acl)) -- `ckey` (String) - `company` (String) - `companyurl` (String) - `compute_features` (List of String) @@ -48,11 +47,12 @@ description: |- - `resource_types` (List of String) - `send_access_emails` (Boolean) - `status` (String) +- `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) - `updated_time` (Number) - `version` (Number) - `vins` (List of Number) -- `zone_ids` (List of Object) (see [below for nested schema](#nestedatt--zone_ids)) +- `zone_ids` (Set of Object) (see [below for nested schema](#nestedatt--zone_ids)) ### Nested Schema for `timeouts` @@ -89,6 +89,16 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (List of Object) (see [below for nested schema](#nestedobjatt--resource_limits--storage_policy)) + + +### Nested Schema for `resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) + diff --git a/docs/data-sources/cb_account_list.md b/docs/data-sources/cb_account_list.md index 4622e0d3..476ba58b 100644 --- a/docs/data-sources/cb_account_list.md +++ b/docs/data-sources/cb_account_list.md @@ -25,6 +25,7 @@ description: |- - `sort_by` (String) sort by one of supported fields, format +|-(field) - `status` (String) Filter by status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only @@ -49,7 +50,6 @@ Read-Only: - `account_id` (Number) - `account_name` (String) - `acl` (List of Object) (see [below for nested schema](#nestedobjatt--items--acl)) -- `ckey` (String) - `company` (String) - `companyurl` (String) - `compute_features` (List of String) @@ -65,11 +65,11 @@ Read-Only: - `desc` (String) - `displayname` (String) - `guid` (Number) -- `meta` (List of String) - `resource_limits` (List of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits)) - `resource_types` (List of String) - `send_access_emails` (Boolean) - `status` (String) +- `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) - `updated_time` (Number) - `version` (Number) @@ -101,3 +101,12 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (List of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits--storage_policy)) + + +### Nested Schema for `items.resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/data-sources/cb_account_list_deleted.md b/docs/data-sources/cb_account_list_deleted.md index 92f2f36a..a78c7efe 100644 --- a/docs/data-sources/cb_account_list_deleted.md +++ b/docs/data-sources/cb_account_list_deleted.md @@ -48,7 +48,6 @@ Read-Only: - `account_id` (Number) - `account_name` (String) - `acl` (List of Object) (see [below for nested schema](#nestedobjatt--items--acl)) -- `ckey` (String) - `company` (String) - `companyurl` (String) - `compute_features` (List of String) @@ -64,11 +63,11 @@ Read-Only: - `desc` (String) - `displayname` (String) - `guid` (Number) -- `meta` (List of String) - `resource_limits` (List of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits)) - `resource_types` (List of String) - `send_access_emails` (Boolean) - `status` (String) +- `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) - `updated_time` (Number) - `version` (Number) @@ -100,3 +99,12 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (List of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits--storage_policy)) + + +### Nested Schema for `items.resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/data-sources/cb_account_resource_consumption_get.md b/docs/data-sources/cb_account_resource_consumption_get.md index b9eccc33..9abfa440 100644 --- a/docs/data-sources/cb_account_resource_consumption_get.md +++ b/docs/data-sources/cb_account_resource_consumption_get.md @@ -50,9 +50,32 @@ Read-Only: - `extips` (Number) - `exttraffic` (Number) - `gpu` (Number) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--consumed--policies)) - `ram` (Number) - `seps` (List of Object) (see [below for nested schema](#nestedobjatt--consumed--seps)) + +### Nested Schema for `consumed.policies` + +Read-Only: + +- `disk_size` (Number) +- `disk_size_max` (Number) +- `id` (String) +- `seps` (List of Object) (see [below for nested schema](#nestedobjatt--consumed--policies--seps)) + + +### Nested Schema for `consumed.policies.seps` + +Read-Only: + +- `data_name` (String) +- `disk_size` (Number) +- `disk_size_max` (Number) +- `sep_id` (String) + + + ### Nested Schema for `consumed.seps` @@ -76,9 +99,32 @@ Read-Only: - `extips` (Number) - `exttraffic` (Number) - `gpu` (Number) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--reserved--policies)) - `ram` (Number) - `seps` (List of Object) (see [below for nested schema](#nestedobjatt--reserved--seps)) + +### Nested Schema for `reserved.policies` + +Read-Only: + +- `disk_size` (Number) +- `disk_size_max` (Number) +- `id` (String) +- `seps` (List of Object) (see [below for nested schema](#nestedobjatt--reserved--policies--seps)) + + +### Nested Schema for `reserved.policies.seps` + +Read-Only: + +- `data_name` (String) +- `disk_size` (Number) +- `disk_size_max` (Number) +- `sep_id` (String) + + + ### Nested Schema for `reserved.seps` diff --git a/docs/data-sources/cb_account_resource_consumption_list.md b/docs/data-sources/cb_account_resource_consumption_list.md index 6d42f945..f7367057 100644 --- a/docs/data-sources/cb_account_resource_consumption_list.md +++ b/docs/data-sources/cb_account_resource_consumption_list.md @@ -54,9 +54,32 @@ Read-Only: - `extips` (Number) - `exttraffic` (Number) - `gpu` (Number) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--items--consumed--policies)) - `ram` (Number) - `seps` (List of Object) (see [below for nested schema](#nestedobjatt--items--consumed--seps)) + +### Nested Schema for `items.consumed.policies` + +Read-Only: + +- `disk_size` (Number) +- `disk_size_max` (Number) +- `id` (String) +- `seps` (List of Object) (see [below for nested schema](#nestedobjatt--items--consumed--policies--seps)) + + +### Nested Schema for `items.consumed.policies.seps` + +Read-Only: + +- `data_name` (String) +- `disk_size` (Number) +- `disk_size_max` (Number) +- `sep_id` (String) + + + ### Nested Schema for `items.consumed.seps` @@ -80,9 +103,32 @@ Read-Only: - `extips` (Number) - `exttraffic` (Number) - `gpu` (Number) +- `policies` (List of Object) (see [below for nested schema](#nestedobjatt--items--reserved--policies)) - `ram` (Number) - `seps` (List of Object) (see [below for nested schema](#nestedobjatt--items--reserved--seps)) + +### Nested Schema for `items.reserved.policies` + +Read-Only: + +- `disk_size` (Number) +- `disk_size_max` (Number) +- `id` (String) +- `seps` (List of Object) (see [below for nested schema](#nestedobjatt--items--reserved--policies--seps)) + + +### Nested Schema for `items.reserved.policies.seps` + +Read-Only: + +- `data_name` (String) +- `disk_size` (Number) +- `disk_size_max` (Number) +- `sep_id` (String) + + + ### Nested Schema for `items.reserved.seps` diff --git a/docs/data-sources/cb_audit.md b/docs/data-sources/cb_audit.md index 9d1edcc3..a94d61b6 100644 --- a/docs/data-sources/cb_audit.md +++ b/docs/data-sources/cb_audit.md @@ -27,6 +27,7 @@ description: |- - `args` (String) - `call` (String) +- `correlation_id` (String) - `guid` (String) - `id` (String) The ID of this resource. - `kwargs` (String) @@ -34,7 +35,6 @@ description: |- - `responsetime` (Number) - `result` (String) - `status_code` (Number) -- `tags` (String) - `timestamp` (Number) - `timestamp_end` (Number) - `ttl` (String) diff --git a/docs/data-sources/cb_audit_list.md b/docs/data-sources/cb_audit_list.md index 6467dc5b..80caa82c 100644 --- a/docs/data-sources/cb_audit_list.md +++ b/docs/data-sources/cb_audit_list.md @@ -17,17 +17,28 @@ description: |- ### Optional +- `account_id` (Number) - `call` (String) find by api endpoint (Mongo RegExp supported) +- `compute_id` (Number) +- `exclude_audit_lines` (Boolean) +- `flipgroup_id` (Number) +- `k8s_id` (Number) +- `lb_id` (Number) - `max_status_code` (Number) find by HTTP max status code - `min_status_code` (Number) find by HTTP min status code +- `node_id` (Number) - `page` (Number) page number - `request_id` (String) request id +- `resgroup_id` (Number) +- `sep_id` (Number) +- `service_id` (Number) - `size` (Number) page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `timestamp_at` (Number) find all audits after point in time (unixtime) - `timestamp_to` (Number) find all audits before point in time (unixtime) - `user` (String) find by user (Mongo RegExp supported) +- `vins_id` (Number) ### Read-Only @@ -51,13 +62,13 @@ Read-Only: - `args` (String) - `call` (String) +- `correlation_id` (String) - `guid` (String) - `kwargs` (String) - `remote_addr` (String) - `responsetime` (Number) - `result` (String) - `status_code` (Number) -- `tags` (String) - `timestamp` (Number) - `timestamp_end` (Number) - `ttl` (String) diff --git a/docs/data-sources/cb_disk.md b/docs/data-sources/cb_disk.md index b5d55460..e7306837 100644 --- a/docs/data-sources/cb_disk.md +++ b/docs/data-sources/cb_disk.md @@ -73,7 +73,9 @@ description: |- - `size_used` (Number) - `snapshots` (List of Object) (see [below for nested schema](#nestedatt--snapshots)) - `status` (String) +- `storage_policy_id` (Number) Storage policy ID - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) - `updated_by` (String) - `updated_time` (Number) diff --git a/docs/data-sources/cb_disk_list.md b/docs/data-sources/cb_disk_list.md index 931b348d..67f88942 100644 --- a/docs/data-sources/cb_disk_list.md +++ b/docs/data-sources/cb_disk_list.md @@ -29,6 +29,7 @@ description: |- - `size` (Number) Page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `status` (String) Find by status +- `storage_policy_id` (Number) storage policy ID - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `type` (String) type of the disks @@ -100,7 +101,9 @@ Read-Only: - `size_used` (Number) - `snapshots` (List of Object) (see [below for nested schema](#nestedobjatt--items--snapshots)) - `status` (String) +- `storage_policy_id` (Number) - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) - `updated_by` (String) - `updated_time` (Number) diff --git a/docs/data-sources/cb_disk_list_deleted.md b/docs/data-sources/cb_disk_list_deleted.md index aba2377c..a6750dfe 100644 --- a/docs/data-sources/cb_disk_list_deleted.md +++ b/docs/data-sources/cb_disk_list_deleted.md @@ -97,7 +97,9 @@ Read-Only: - `size_used` (Number) - `snapshots` (List of Object) (see [below for nested schema](#nestedobjatt--items--snapshots)) - `status` (String) +- `storage_policy_id` (Number) - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) - `updated_by` (String) - `updated_time` (Number) diff --git a/docs/data-sources/cb_disk_list_unattached.md b/docs/data-sources/cb_disk_list_unattached.md index 8f37d86a..aeb077b8 100644 --- a/docs/data-sources/cb_disk_list_unattached.md +++ b/docs/data-sources/cb_disk_list_unattached.md @@ -27,6 +27,7 @@ description: |- - `size` (Number) Page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `status` (String) Find by status +- `storage_policy_id` (Number) storage policy ID - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `type` (String) type of the disks diff --git a/docs/data-sources/cb_dpdknet_list.md b/docs/data-sources/cb_dpdknet_list.md index be7572dc..c1e00ce2 100644 --- a/docs/data-sources/cb_dpdknet_list.md +++ b/docs/data-sources/cb_dpdknet_list.md @@ -53,6 +53,7 @@ Read-Only: - `created_time` (Number) - `desc` (String) - `dpdk_id` (Number) +- `enable_secgroups` (Boolean) - `gid` (Number) - `guid` (Number) - `name` (String) diff --git a/docs/data-sources/cb_extnet_list.md b/docs/data-sources/cb_extnet_list.md index d0c7994a..44f7c27b 100644 --- a/docs/data-sources/cb_extnet_list.md +++ b/docs/data-sources/cb_extnet_list.md @@ -28,6 +28,7 @@ description: |- - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `vlan_id` (Number) Find by VLAN ID - `vnfdev_id` (Number) Find by VnfDEV ID +- `zone_id` (Number) Zone ID ### Read-Only @@ -54,6 +55,7 @@ Read-Only: - `default` (Boolean) - `default_qos` (List of Object) (see [below for nested schema](#nestedobjatt--items--default_qos)) - `desc` (String) +- `enable_secgroups` (Boolean) - `extnet_id` (Number) - `free_ips` (Number) - `gid` (Number) diff --git a/docs/data-sources/cb_image.md b/docs/data-sources/cb_image.md index f5a9b6c7..3c9fdc56 100644 --- a/docs/data-sources/cb_image.md +++ b/docs/data-sources/cb_image.md @@ -61,7 +61,9 @@ description: |- - `size` (Number) image size - `snapshot_id` (String) snapshot id - `status` (String) status -- `tech_status` (String) tech atatus +- `storage_policy_id` (Number) +- `tech_status` (String) tech status +- `to_clean` (Boolean) - `unc_path` (String) unc path - `url` (String) URL where to download media from - `username` (String) Optional username for the image diff --git a/docs/data-sources/cb_image_list.md b/docs/data-sources/cb_image_list.md index 4477ddae..c6a12e27 100644 --- a/docs/data-sources/cb_image_list.md +++ b/docs/data-sources/cb_image_list.md @@ -32,6 +32,7 @@ description: |- - `size` (Number) page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `status` (String) find by status +- `storage_policy_id` (Number) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `type_image` (String) find by type @@ -91,7 +92,9 @@ Read-Only: - `size` (Number) - `snapshot_id` (String) - `status` (String) +- `storage_policy_id` (Number) - `tech_status` (String) +- `to_clean` (Boolean) - `unc_path` (String) - `url` (String) - `username` (String) diff --git a/docs/data-sources/cb_k8ci.md b/docs/data-sources/cb_k8ci.md index 60a08a82..55711315 100644 --- a/docs/data-sources/cb_k8ci.md +++ b/docs/data-sources/cb_k8ci.md @@ -30,7 +30,6 @@ description: |- - `guid` (Number) guid - `id` (String) The ID of this resource. - `lb_image_id` (Number) LB Image ID -- `master_driver` (String) - `master_image_id` (Number) - `max_master_count` (Number) - `max_worker_count` (Number) diff --git a/docs/data-sources/cb_k8ci_list.md b/docs/data-sources/cb_k8ci_list.md index 89569746..ea244e37 100644 --- a/docs/data-sources/cb_k8ci_list.md +++ b/docs/data-sources/cb_k8ci_list.md @@ -19,7 +19,6 @@ description: |- - `by_id` (Number) Filter by ID - `include_disabled` (Boolean) Include deleted k8cis in result -- `master_driver` (String) Filter by master driver - `name` (String) Filter by name - `network_plugin` (String) Filter by network plugin - `page` (Number) Page number @@ -27,7 +26,6 @@ description: |- - `sort_by` (String) sort by one of supported fields, format +|-(field) - `status` (String) Filter by status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `worker_driver` (String) Filter by worker driver ### Read-Only @@ -55,7 +53,6 @@ Read-Only: - `guid` (Number) - `k8ci_id` (Number) - `lb_image_id` (Number) -- `master_driver` (String) - `master_image_id` (Number) - `max_master_count` (Number) - `max_worker_count` (Number) @@ -63,5 +60,4 @@ Read-Only: - `shared_with` (List of Number) - `status` (String) - `version` (String) -- `worker_driver` (String) - `worker_image_id` (Number) diff --git a/docs/data-sources/cb_k8ci_list_deleted.md b/docs/data-sources/cb_k8ci_list_deleted.md index bdcc7d82..a13cf68b 100644 --- a/docs/data-sources/cb_k8ci_list_deleted.md +++ b/docs/data-sources/cb_k8ci_list_deleted.md @@ -18,14 +18,12 @@ description: |- ### Optional - `by_id` (Number) Filter by ID -- `master_driver` (String) Filter by master driver - `name` (String) Filter by name - `network_plugin` (String) Filter by network plugin - `page` (Number) Page number - `size` (Number) Page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `worker_driver` (String) Filter by worker driver ### Read-Only @@ -53,7 +51,6 @@ Read-Only: - `guid` (Number) - `k8ci_id` (Number) - `lb_image_id` (Number) -- `master_driver` (String) - `master_image_id` (Number) - `max_master_count` (Number) - `max_worker_count` (Number) @@ -61,5 +58,4 @@ Read-Only: - `shared_with` (List of Number) - `status` (String) - `version` (String) -- `worker_driver` (String) - `worker_image_id` (Number) diff --git a/docs/data-sources/cb_k8s_list.md b/docs/data-sources/cb_k8s_list.md index 64e821aa..befc4cb1 100644 --- a/docs/data-sources/cb_k8s_list.md +++ b/docs/data-sources/cb_k8s_list.md @@ -30,6 +30,7 @@ description: |- - `status` (String) Filter by status - `tech_status` (String) Filter by Tech Status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only diff --git a/docs/data-sources/cb_kvmvm.md b/docs/data-sources/cb_kvmvm.md index 427285da..ad94a8a7 100644 --- a/docs/data-sources/cb_kvmvm.md +++ b/docs/data-sources/cb_kvmvm.md @@ -36,6 +36,7 @@ description: |- - `auto_start_w_node` (Boolean) - `boot_disk_id` (Number) - `boot_disk_size` (Number) +- `boot_image_id` (Number) - `boot_order` (List of String) - `boot_type` (String) - `cd_image_id` (Number) @@ -80,6 +81,7 @@ description: |- - `numa_affinity` (String) - `numa_node_id` (Number) - `os_users` (List of Object) (see [below for nested schema](#nestedatt--os_users)) +- `os_version` (String) - `pci_devices` (List of Number) - `pinned` (Number) - `pool` (String) @@ -205,7 +207,9 @@ Read-Only: - `size_used` (Number) - `snapshots` (List of Object) (see [below for nested schema](#nestedobjatt--disks--snapshots)) - `status` (String) +- `storage_policy_id` (Number) - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) @@ -264,6 +268,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flip_group_id` (Number) - `guid` (String) @@ -280,6 +285,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `trunk_tags` (String) - `type` (String) diff --git a/docs/data-sources/cb_kvmvm_audits.md b/docs/data-sources/cb_kvmvm_audits.md index b3b00208..215b63ef 100644 --- a/docs/data-sources/cb_kvmvm_audits.md +++ b/docs/data-sources/cb_kvmvm_audits.md @@ -21,10 +21,20 @@ description: |- ### Optional +- `call` (String) +- `max_status_code` (Number) +- `min_status_code` (Number) +- `page` (Number) +- `size` (Number) +- `sort_by` (String) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `timestamp_at` (Number) +- `timestamp_to` (Number) +- `user` (String) ### Read-Only +- `entry_count` (Number) - `id` (String) The ID of this resource. - `items` (List of Object) (see [below for nested schema](#nestedatt--items)) diff --git a/docs/data-sources/cb_kvmvm_list.md b/docs/data-sources/cb_kvmvm_list.md index 195193ad..c48da52a 100644 --- a/docs/data-sources/cb_kvmvm_list.md +++ b/docs/data-sources/cb_kvmvm_list.md @@ -23,7 +23,6 @@ description: |- - `extnet_id` (Number) Find by Extnet ID - `extnet_name` (String) Find by Extnet name - `ignore_k8s` (Boolean) If set to true, ignores any VMs associated with any k8s cluster -- `image_id` (Number) Find by image ID - `includedeleted` (Boolean) - `ip_address` (String) Find by IP address - `name` (String) Find by name @@ -37,6 +36,7 @@ description: |- - `status` (String) Find by status - `tech_status` (String) Find by tech status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only @@ -67,6 +67,7 @@ Read-Only: - `anti_affinity_rules` (List of Object) (see [below for nested schema](#nestedobjatt--items--anti_affinity_rules)) - `arch` (String) - `auto_start_w_node` (Boolean) +- `boot_image_id` (Number) - `boot_order` (List of String) - `boot_type` (String) - `bootdisk_size` (Number) @@ -107,6 +108,7 @@ Read-Only: - `numa_affinity` (String) - `numa_node_id` (Number) - `os_users` (List of Object) (see [below for nested schema](#nestedobjatt--items--os_users)) +- `os_version` (String) - `pinned` (Number) - `preferred_cpu` (List of Number) - `qemu_guest` (List of Object) (see [below for nested schema](#nestedobjatt--items--qemu_guest)) @@ -193,6 +195,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flip_group_id` (Number) - `guid` (String) @@ -209,6 +212,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--items--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `trunk_tags` (String) - `type` (String) diff --git a/docs/data-sources/cb_kvmvm_list_deleted.md b/docs/data-sources/cb_kvmvm_list_deleted.md index 27160e91..7a1f942e 100644 --- a/docs/data-sources/cb_kvmvm_list_deleted.md +++ b/docs/data-sources/cb_kvmvm_list_deleted.md @@ -61,6 +61,7 @@ Read-Only: - `anti_affinity_rules` (List of Object) (see [below for nested schema](#nestedobjatt--items--anti_affinity_rules)) - `arch` (String) - `auto_start_w_node` (Boolean) +- `boot_image_id` (Number) - `boot_order` (List of String) - `boot_type` (String) - `bootdisk_size` (Number) @@ -99,6 +100,7 @@ Read-Only: - `numa_affinity` (String) - `numa_node_id` (Number) - `os_users` (List of Object) (see [below for nested schema](#nestedobjatt--items--os_users)) +- `os_version` (String) - `pinned` (Number) - `preferred_cpu` (List of Number) - `ram` (Number) @@ -183,6 +185,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flip_group_id` (Number) - `guid` (String) @@ -199,6 +202,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--items--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `trunk_tags` (String) - `type` (String) diff --git a/docs/data-sources/cb_lb_list.md b/docs/data-sources/cb_lb_list.md index 993cd4a5..0771be13 100644 --- a/docs/data-sources/cb_lb_list.md +++ b/docs/data-sources/cb_lb_list.md @@ -30,6 +30,7 @@ description: |- - `status` (String) Filter by Status - `tech_status` (String) Filter by TechStatus - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only diff --git a/docs/data-sources/cb_node.md b/docs/data-sources/cb_node.md index 2f0ebb25..af303c22 100644 --- a/docs/data-sources/cb_node.md +++ b/docs/data-sources/cb_node.md @@ -88,6 +88,7 @@ Read-Only: Read-Only: - `ram` (Number) +- `vcpu` (Number) diff --git a/docs/data-sources/cb_rg.md b/docs/data-sources/cb_rg.md index 84f4937a..ef82ff32 100644 --- a/docs/data-sources/cb_rg.md +++ b/docs/data-sources/cb_rg.md @@ -51,6 +51,7 @@ description: |- - `sdn_access_group_id` (String) - `secret` (String) - `status` (String) +- `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) - `updated_by` (String) - `updated_time` (Number) @@ -90,3 +91,12 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (Set of Object) (see [below for nested schema](#nestedobjatt--resource_limits--storage_policy)) + + +### Nested Schema for `resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/data-sources/cb_rg_list.md b/docs/data-sources/cb_rg_list.md index 950bffc3..fc2921dd 100644 --- a/docs/data-sources/cb_rg_list.md +++ b/docs/data-sources/cb_rg_list.md @@ -76,6 +76,7 @@ Read-Only: - `sdn_access_group_id` (String) - `secret` (String) - `status` (String) +- `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) - `updated_by` (String) - `updated_time` (Number) @@ -107,3 +108,12 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (Set of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits--storage_policy)) + + +### Nested Schema for `items.resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/data-sources/cb_rg_list_deleted.md b/docs/data-sources/cb_rg_list_deleted.md index 62db33b9..4b27644e 100644 --- a/docs/data-sources/cb_rg_list_deleted.md +++ b/docs/data-sources/cb_rg_list_deleted.md @@ -73,6 +73,7 @@ Read-Only: - `rg_id` (Number) - `secret` (String) - `status` (String) +- `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) - `updated_by` (String) - `updated_time` (Number) @@ -104,3 +105,12 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (Set of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits--storage_policy)) + + +### Nested Schema for `items.resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/data-sources/cb_security_group.md b/docs/data-sources/cb_security_group.md new file mode 100644 index 00000000..992605b1 --- /dev/null +++ b/docs/data-sources/cb_security_group.md @@ -0,0 +1,58 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_cb_security_group Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_cb_security_group (Data Source) + + + + + + +## Schema + +### Required + +- `security_group_id` (Number) + +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `account_id` (Number) +- `created_at` (Number) +- `created_by` (String) +- `description` (String) +- `id` (String) The ID of this resource. +- `name` (String) +- `rules` (List of Object) (see [below for nested schema](#nestedatt--rules)) +- `updated_at` (Number) +- `updated_by` (String) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `rules` + +Read-Only: + +- `direction` (String) +- `ethertype` (String) +- `id` (Number) +- `port_range_max` (Number) +- `port_range_min` (Number) +- `protocol` (String) +- `remote_ip_prefix` (String) diff --git a/docs/data-sources/cb_security_group_list.md b/docs/data-sources/cb_security_group_list.md new file mode 100644 index 00000000..f0e90bcc --- /dev/null +++ b/docs/data-sources/cb_security_group_list.md @@ -0,0 +1,74 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_cb_security_group_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_cb_security_group_list (Data Source) + + + + + + +## Schema + +### Optional + +- `account_id` (Number) +- `by_id` (Number) +- `created_max` (Number) +- `created_min` (Number) +- `desc` (String) +- `name` (String) +- `page` (Number) +- `size` (Number) +- `sort_by` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `updated_max` (Number) +- `updated_min` (Number) + +### Read-Only + +- `entry_count` (Number) +- `id` (String) The ID of this resource. +- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `account_id` (Number) +- `created_at` (Number) +- `created_by` (String) +- `description` (String) +- `name` (String) +- `rules` (List of Object) (see [below for nested schema](#nestedobjatt--items--rules)) +- `security_group_id` (Number) +- `updated_at` (Number) +- `updated_by` (String) + + +### Nested Schema for `items.rules` + +Read-Only: + +- `direction` (String) +- `ethertype` (String) +- `id` (Number) +- `port_range_max` (Number) +- `port_range_min` (Number) +- `protocol` (String) +- `remote_ip_prefix` (String) diff --git a/docs/data-sources/cb_storage_policy.md b/docs/data-sources/cb_storage_policy.md new file mode 100644 index 00000000..c9e06d56 --- /dev/null +++ b/docs/data-sources/cb_storage_policy.md @@ -0,0 +1,61 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_cb_storage_policy Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_cb_storage_policy (Data Source) + + + + + + +## Schema + +### Required + +- `storage_policy_id` (Number) + +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `access_seps_pools` (List of Object) (see [below for nested schema](#nestedatt--access_seps_pools)) +- `description` (String) +- `guid` (Number) +- `id` (String) The ID of this resource. +- `limit_iops` (Number) +- `name` (String) +- `status` (String) +- `usage` (List of Object) (see [below for nested schema](#nestedatt--usage)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `access_seps_pools` + +Read-Only: + +- `pool_names` (List of String) +- `sep_id` (Number) + + + +### Nested Schema for `usage` + +Read-Only: + +- `accounts` (List of Number) +- `resgroups` (List of Number) diff --git a/docs/data-sources/cb_storage_policy_list.md b/docs/data-sources/cb_storage_policy_list.md new file mode 100644 index 00000000..8607b2ed --- /dev/null +++ b/docs/data-sources/cb_storage_policy_list.md @@ -0,0 +1,78 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_cb_storage_policy_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_cb_storage_policy_list (Data Source) + + + + + + +## Schema + +### Optional + +- `account_id` (Number) +- `by_id` (Number) +- `desc` (String) +- `limit_iops` (Number) +- `name` (String) +- `page` (Number) +- `pool_name` (String) +- `resgroup_id` (Number) +- `sep_id` (Number) +- `size` (Number) +- `sort_by` (String) +- `status` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `entry_count` (Number) +- `id` (String) The ID of this resource. +- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `access_seps_pools` (List of Object) (see [below for nested schema](#nestedobjatt--items--access_seps_pools)) +- `description` (String) +- `guid` (Number) +- `limit_iops` (Number) +- `name` (String) +- `status` (String) +- `storage_policy_id` (Number) +- `usage` (List of Object) (see [below for nested schema](#nestedobjatt--items--usage)) + + +### Nested Schema for `items.access_seps_pools` + +Read-Only: + +- `pool_names` (List of String) +- `sep_id` (Number) + + + +### Nested Schema for `items.usage` + +Read-Only: + +- `accounts` (List of Number) +- `resgroups` (List of Number) diff --git a/docs/data-sources/cb_vins.md b/docs/data-sources/cb_vins.md index a5644528..a7888204 100644 --- a/docs/data-sources/cb_vins.md +++ b/docs/data-sources/cb_vins.md @@ -94,6 +94,7 @@ Read-Only: - `guid` (Number) - `id` (Number) - `interfaces` (List of Object) (see [below for nested schema](#nestedobjatt--vnf_dev--interfaces)) +- `live_migration_job_id` (Number) - `lock_status` (String) - `meta` (List of String) - `milestones` (Number) @@ -103,6 +104,7 @@ Read-Only: - `type` (String) - `vins` (List of Number) - `vnc_password` (String) +- `zone_id` (Number) ### Nested Schema for `vnf_dev.config` @@ -144,6 +146,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flipgroup_id` (Number) - `guid` (String) @@ -160,6 +163,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--vnf_dev--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `type` (String) - `vnfs` (List of Number) @@ -223,6 +227,7 @@ Read-Only: - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.dhcp.config` @@ -302,9 +307,11 @@ Read-Only: - `owner_id` (Number) - `owner_type` (String) - `pure_virtual` (Boolean) +- `routes` (List of Object) (see [below for nested schema](#nestedobjatt--vnfs--gw--routes)) - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.gw.config` @@ -347,6 +354,19 @@ Read-Only: + +### Nested Schema for `vnfs.gw.routes` + +Read-Only: + +- `compute_ids` (List of Number) +- `destination` (String) +- `gateway` (String) +- `guid` (String) +- `netmask` (String) +- `route_id` (Number) + + ### Nested Schema for `vnfs.nat` @@ -367,9 +387,11 @@ Read-Only: - `owner_id` (Number) - `owner_type` (String) - `pure_virtual` (Boolean) +- `routes` (List of Object) (see [below for nested schema](#nestedobjatt--vnfs--nat--routes)) - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.nat.config` @@ -411,3 +433,17 @@ Read-Only: - `dev_id` (Number) - `iface01` (String) - `iface02` (String) + + + + +### Nested Schema for `vnfs.nat.routes` + +Read-Only: + +- `compute_ids` (List of Number) +- `destination` (String) +- `gateway` (String) +- `guid` (String) +- `netmask` (String) +- `route_id` (Number) diff --git a/docs/data-sources/cb_vins_list.md b/docs/data-sources/cb_vins_list.md index 7000d36e..c9b1b50a 100644 --- a/docs/data-sources/cb_vins_list.md +++ b/docs/data-sources/cb_vins_list.md @@ -19,7 +19,6 @@ description: |- - `account_id` (Number) Find by account id - `by_id` (Number) Find by id -- `entry_count` (Number) entry count - `ext_ip` (String) Find by ext ip - `include_deleted` (Boolean) include deleted computes - `name` (String) Name @@ -30,9 +29,11 @@ description: |- - `status` (String) sort by status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `vnfdev_id` (Number) find by VNF Device id +- `zone_id` (Number) Zone ID ### Read-Only +- `entry_count` (Number) entry count - `id` (String) The ID of this resource. - `items` (List of Object) (see [below for nested schema](#nestedatt--items)) @@ -59,6 +60,7 @@ Read-Only: - `deleted_by` (String) - `deleted_time` (Number) - `description` (String) +- `enable_secgroups` (Boolean) - `external_ip` (String) - `extnet_id` (Number) - `free_ips` (Number) diff --git a/docs/data-sources/cb_zone.md b/docs/data-sources/cb_zone.md index eea08c2b..55492ed1 100644 --- a/docs/data-sources/cb_zone.md +++ b/docs/data-sources/cb_zone.md @@ -25,16 +25,23 @@ description: |- ### Read-Only +- `account_ids` (List of Number) +- `bservice_ids` (List of Number) +- `compute_ids` (List of Number) - `created_time` (Number) - `deletable` (Boolean) - `description` (String) +- `extnet_ids` (List of Number) - `gid` (Number) - `guid` (Number) - `id` (String) The ID of this resource. +- `k8s_ids` (List of Number) +- `lb_ids` (List of Number) - `name` (String) - `node_ids` (List of Number) - `status` (String) - `updated_time` (Number) +- `vins_ids` (List of Number) ### Nested Schema for `timeouts` diff --git a/docs/data-sources/disk.md b/docs/data-sources/disk.md index 9e2acef5..9b95a1b2 100644 --- a/docs/data-sources/disk.md +++ b/docs/data-sources/disk.md @@ -64,7 +64,9 @@ description: |- - `size_used` (Number) Number of used space, in GB - `snapshots` (List of Object) (see [below for nested schema](#nestedatt--snapshots)) - `status` (String) Disk status +- `storage_policy_id` (Number) Storage policy ID - `tech_status` (String) Technical status of the disk +- `to_clean` (Boolean) - `type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp' - `updated_by` (String) - `updated_time` (Number) diff --git a/docs/data-sources/disk_list.md b/docs/data-sources/disk_list.md index 92e57439..4b8a51d8 100644 --- a/docs/data-sources/disk_list.md +++ b/docs/data-sources/disk_list.md @@ -29,6 +29,7 @@ description: |- - `size` (Number) Page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `status` (String) Find by status +- `storage_policy_id` (Number) storage policy ID - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `type` (String) type of the disks @@ -91,7 +92,9 @@ Read-Only: - `size_used` (Number) - `snapshots` (List of Object) (see [below for nested schema](#nestedobjatt--items--snapshots)) - `status` (String) +- `storage_policy_id` (Number) - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) - `updated_by` (String) - `updated_time` (Number) diff --git a/docs/data-sources/disk_list_deleted.md b/docs/data-sources/disk_list_deleted.md index 32b91432..1839b113 100644 --- a/docs/data-sources/disk_list_deleted.md +++ b/docs/data-sources/disk_list_deleted.md @@ -88,7 +88,9 @@ Read-Only: - `size_used` (Number) - `snapshots` (List of Object) (see [below for nested schema](#nestedobjatt--items--snapshots)) - `status` (String) +- `storage_policy_id` (Number) - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) - `updated_by` (String) - `updated_time` (Number) diff --git a/docs/data-sources/disk_list_unattached.md b/docs/data-sources/disk_list_unattached.md index f8ab8333..3257df3d 100644 --- a/docs/data-sources/disk_list_unattached.md +++ b/docs/data-sources/disk_list_unattached.md @@ -27,6 +27,7 @@ description: |- - `size` (Number) Page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `status` (String) Find by status +- `storage_policy_id` (Number) storage policy ID - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `type` (String) type of the disks diff --git a/docs/data-sources/extnet_list.md b/docs/data-sources/extnet_list.md index cc620499..bcdf894e 100644 --- a/docs/data-sources/extnet_list.md +++ b/docs/data-sources/extnet_list.md @@ -29,6 +29,7 @@ description: |- - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `vlan_id` (Number) Find by VLAN ID - `vnfdev_id` (Number) Find by VnfDEV ID +- `zone_id` (Number) Zone ID ### Read-Only diff --git a/docs/data-sources/image.md b/docs/data-sources/image.md index 44519f5b..a04e705e 100644 --- a/docs/data-sources/image.md +++ b/docs/data-sources/image.md @@ -60,7 +60,9 @@ description: |- - `size` (Number) - `snapshot_id` (String) - `status` (String) +- `storage_policy_id` (Number) - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) - `unc_path` (String) - `username` (String) diff --git a/docs/data-sources/image_list.md b/docs/data-sources/image_list.md index 2ac12192..025d2ede 100644 --- a/docs/data-sources/image_list.md +++ b/docs/data-sources/image_list.md @@ -32,6 +32,7 @@ description: |- - `size` (Number) page size - `sort_by` (String) sort by one of supported fields, format +|-(field) - `status` (String) Filter by status +- `storage_policy_id` (Number) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `type_image` (String) Filter by image type @@ -71,6 +72,7 @@ Read-Only: - `sep_id` (Number) - `size` (Number) - `status` (String) +- `storage_policy_id` (Number) - `type` (String) - `username` (String) - `virtual` (Boolean) diff --git a/docs/data-sources/k8s_list.md b/docs/data-sources/k8s_list.md index 5c0882cd..73ad1290 100644 --- a/docs/data-sources/k8s_list.md +++ b/docs/data-sources/k8s_list.md @@ -30,6 +30,7 @@ description: |- - `status` (String) Filter by status - `tech_status` (String) Filter by tech. status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only diff --git a/docs/data-sources/k8s_list_deleted.md b/docs/data-sources/k8s_list_deleted.md index 6c10da26..d4ac8ab2 100644 --- a/docs/data-sources/k8s_list_deleted.md +++ b/docs/data-sources/k8s_list_deleted.md @@ -28,6 +28,7 @@ description: |- - `sort_by` (String) sort by one of supported fields, format +|-(field) - `tech_status` (String) Filter by tech. status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only diff --git a/docs/data-sources/kvmvm.md b/docs/data-sources/kvmvm.md index 5d6e2340..ed5f2416 100644 --- a/docs/data-sources/kvmvm.md +++ b/docs/data-sources/kvmvm.md @@ -34,6 +34,7 @@ description: |- - `anti_affinity_rules` (List of Object) (see [below for nested schema](#nestedatt--anti_affinity_rules)) - `arch` (String) - `auto_start_w_node` (Boolean) +- `boot_image_id` (Number) - `boot_order` (List of String) - `boot_type` (String) - `bootdisk_size` (Number) @@ -78,6 +79,7 @@ description: |- - `numa_affinity` (String) - `numa_node_id` (Number) - `os_users` (List of Object) (see [below for nested schema](#nestedatt--os_users)) +- `os_version` (String) - `pci_devices` (List of Number) - `pinned` (Boolean) - `preferred_cpu` (List of Number) @@ -233,7 +235,9 @@ Read-Only: - `size_used` (Number) - `snapshots` (List of Object) (see [below for nested schema](#nestedobjatt--disks--snapshots)) - `status` (String) +- `storage_policy_id` (Number) - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) @@ -293,6 +297,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flip_group_id` (Number) - `guid` (String) @@ -309,6 +314,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `trunk_tags` (String) - `type` (String) diff --git a/docs/data-sources/kvmvm_audits.md b/docs/data-sources/kvmvm_audits.md index e538e2b4..12f77bf7 100644 --- a/docs/data-sources/kvmvm_audits.md +++ b/docs/data-sources/kvmvm_audits.md @@ -21,10 +21,20 @@ description: |- ### Optional +- `call` (String) +- `max_status_code` (Number) +- `min_status_code` (Number) +- `page` (Number) +- `size` (Number) +- `sort_by` (String) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `timestamp_at` (Number) +- `timestamp_to` (Number) +- `user` (String) ### Read-Only +- `entry_count` (Number) - `id` (String) The ID of this resource. - `items` (List of Object) (see [below for nested schema](#nestedatt--items)) diff --git a/docs/data-sources/kvmvm_list.md b/docs/data-sources/kvmvm_list.md index 364aae79..56938238 100644 --- a/docs/data-sources/kvmvm_list.md +++ b/docs/data-sources/kvmvm_list.md @@ -33,6 +33,7 @@ description: |- - `status` (String) Find by status - `tech_status` (String) Find by tech status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only @@ -63,6 +64,7 @@ Read-Only: - `anti_affinity_rules` (List of Object) (see [below for nested schema](#nestedobjatt--items--anti_affinity_rules)) - `arch` (String) - `auto_start_w_node` (Boolean) +- `boot_image_id` (Number) - `boot_order` (List of String) - `boot_type` (String) - `bootdisk_size` (Number) @@ -101,6 +103,7 @@ Read-Only: - `network_interface_naming` (String) - `numa_affinity` (String) - `numa_node_id` (Number) +- `os_version` (String) - `pinned` (Boolean) - `preferred_cpu` (List of Number) - `qemu_guest` (List of Object) (see [below for nested schema](#nestedobjatt--items--qemu_guest)) @@ -184,6 +187,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flip_group_id` (Number) - `guid` (String) @@ -200,6 +204,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--items--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `trunk_tags` (String) - `type` (String) diff --git a/docs/data-sources/kvmvm_list_deleted.md b/docs/data-sources/kvmvm_list_deleted.md index 600485a5..9650d5e6 100644 --- a/docs/data-sources/kvmvm_list_deleted.md +++ b/docs/data-sources/kvmvm_list_deleted.md @@ -61,6 +61,7 @@ Read-Only: - `anti_affinity_rules` (List of Object) (see [below for nested schema](#nestedobjatt--items--anti_affinity_rules)) - `arch` (String) - `auto_start_w_node` (Boolean) +- `boot_image_id` (Number) - `boot_order` (List of String) - `boot_type` (String) - `bootdisk_size` (Number) @@ -99,6 +100,7 @@ Read-Only: - `network_interface_naming` (String) - `numa_affinity` (String) - `numa_node_id` (Number) +- `os_version` (String) - `pinned` (Boolean) - `preferred_cpu` (List of Number) - `qemu_guest` (List of Object) (see [below for nested schema](#nestedobjatt--items--qemu_guest)) @@ -182,6 +184,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flip_group_id` (Number) - `guid` (String) @@ -198,6 +201,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--items--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `trunk_tags` (String) - `type` (String) diff --git a/docs/data-sources/lb_list.md b/docs/data-sources/lb_list.md index 9c878f61..8c24a5d7 100644 --- a/docs/data-sources/lb_list.md +++ b/docs/data-sources/lb_list.md @@ -30,6 +30,7 @@ description: |- - `status` (String) Filter by Status - `tech_status` (String) Filter by TechStatus - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `zone_id` (Number) Zone ID ### Read-Only diff --git a/docs/data-sources/resgroup.md b/docs/data-sources/resgroup.md index 00adb396..c6320fb8 100644 --- a/docs/data-sources/resgroup.md +++ b/docs/data-sources/resgroup.md @@ -51,6 +51,7 @@ description: |- - `sdn_access_group_id` (String) - `secret` (String) - `status` (String) +- `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) - `updated_by` (String) - `updated_time` (Number) @@ -90,3 +91,12 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (Set of Object) (see [below for nested schema](#nestedobjatt--resource_limits--storage_policy)) + + +### Nested Schema for `resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/data-sources/rg_list.md b/docs/data-sources/rg_list.md index 8b60250b..c7584514 100644 --- a/docs/data-sources/rg_list.md +++ b/docs/data-sources/rg_list.md @@ -76,6 +76,7 @@ Read-Only: - `sdn_access_group_id` (String) - `secret` (String) - `status` (String) +- `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) - `updated_by` (String) - `updated_time` (Number) @@ -107,3 +108,12 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (Set of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits--storage_policy)) + + +### Nested Schema for `items.resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/data-sources/rg_list_deleted.md b/docs/data-sources/rg_list_deleted.md index 4d5f1fec..d6e062e5 100644 --- a/docs/data-sources/rg_list_deleted.md +++ b/docs/data-sources/rg_list_deleted.md @@ -73,6 +73,7 @@ Read-Only: - `rg_id` (Number) - `secret` (String) - `status` (String) +- `storage_policy_ids` (List of Number) - `uniq_pools` (List of String) - `updated_by` (String) - `updated_time` (Number) @@ -104,3 +105,12 @@ Read-Only: - `cu_m` (Number) - `cu_np` (Number) - `gpu_units` (Number) +- `storage_policy` (Set of Object) (see [below for nested schema](#nestedobjatt--items--resource_limits--storage_policy)) + + +### Nested Schema for `items.resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/data-sources/sdn_access_group.md b/docs/data-sources/sdn_access_group.md new file mode 100644 index 00000000..56398685 --- /dev/null +++ b/docs/data-sources/sdn_access_group.md @@ -0,0 +1,50 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_access_group Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_access_group (Data Source) + + + + + + +## Schema + +### Required + +- `access_group_id` (String) The unique access group ID + +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `comment` (String) Comment description +- `created_at` (String) Creation timestamp +- `display_name` (String) Display name +- `id` (String) The ID of this resource. +- `net_object_access_group` (List of Object) Net object access group configuration (see [below for nested schema](#nestedatt--net_object_access_group)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `net_object_access_group` + +Read-Only: + +- `access_group_id` (String) +- `id` (String) +- `version_id` (Number) diff --git a/docs/data-sources/sdn_access_group_list.md b/docs/data-sources/sdn_access_group_list.md new file mode 100644 index 00000000..5b00925a --- /dev/null +++ b/docs/data-sources/sdn_access_group_list.md @@ -0,0 +1,78 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_access_group_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_access_group_list (Data Source) + + + + + + +## Schema + +### Optional + +- `created_from` (String) filter by the lower limit of the creation date +- `created_to` (String) filter by the upper limit of the creation date +- `deleted` (Boolean) filter by deleted/not deleted group +- `display_name` (String) filter by display name +- `enabled` (Boolean) filter by enabled/disabled group +- `page` (Number) Page number +- `per_page` (Number) Items per page +- `sort_by` (String) sort by one of supported fields +- `sort_order` (String) sort order +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `id` (String) The ID of this resource. +- `items` (List of Object) List of access groups (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `comment` (String) +- `created_at` (String) +- `default_security_policy` (List of Object) (see [below for nested schema](#nestedobjatt--items--default_security_policy)) +- `display_name` (String) +- `id` (String) +- `net_object_access_group` (List of Object) (see [below for nested schema](#nestedobjatt--items--net_object_access_group)) + + +### Nested Schema for `items.default_security_policy` + +Read-Only: + +- `access_group_id` (String) +- `default_acl_drop` (String) +- `default_open_session_drop` (Boolean) +- `description` (String) +- `display_name` (String) +- `id` (String) +- `version_id` (Number) + + + +### Nested Schema for `items.net_object_access_group` + +Read-Only: + +- `access_group_id` (String) +- `id` (String) +- `version_id` (Number) diff --git a/docs/data-sources/sdn_access_group_user_list.md b/docs/data-sources/sdn_access_group_user_list.md new file mode 100644 index 00000000..3381f5ad --- /dev/null +++ b/docs/data-sources/sdn_access_group_user_list.md @@ -0,0 +1,63 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_access_group_user_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_access_group_user_list (Data Source) + + + + + + +## Schema + +### Required + +- `access_group_id` (String) filter by access group id + +### Optional + +- `access_group_role` (String) filter by access group role +- `created_by` (String) who created the user +- `created_from` (String) filter by the lower limit of the creation date +- `created_to` (String) filter by the upper limit of the creation date +- `deleted` (Boolean) delete filter +- `deleted_by` (String) who deleted the user +- `disabled_by` (String) who disabled the user +- `display_name` (String) filter by display name +- `enabled` (Boolean) filter by inclusion +- `global_role` (String) filter by global role +- `login` (String) filter by user login +- `page` (Number) result page number +- `per_page` (Number) number of results per page +- `sort_by` (String) sort by one of supported fields +- `sort_order` (String) sorting order +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `id` (String) The ID of this resource. +- `items` (List of Object) List of users (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `display_name` (String) +- `id` (String) +- `login` (String) +- `role_id` (String) diff --git a/docs/data-sources/sdn_default_security_policy_list.md b/docs/data-sources/sdn_default_security_policy_list.md new file mode 100644 index 00000000..35addcc1 --- /dev/null +++ b/docs/data-sources/sdn_default_security_policy_list.md @@ -0,0 +1,149 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_default_security_policy_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_default_security_policy_list (Data Source) + + + + + + +## Schema + +### Optional + +- `access_group_id` (String) id of the access group +- `page` (Number) result page number +- `per_page` (Number) number of results per page +- `sort_by` (String) sort by one of the supported fields +- `sort_order` (String) sorting order +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `id` (String) The ID of this resource. +- `items` (List of Object) List of default security policies (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `access_group_id` (String) +- `created_at` (String) +- `default_acl_drop` (String) +- `default_open_session_drop` (Boolean) +- `description` (String) +- `display_name` (String) +- `id` (String) +- `locked_at` (String) +- `security_rules` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_rules)) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--status)) +- `version_id` (Number) + + +### Nested Schema for `items.security_rules` + +Read-Only: + +- `access_group_id` (String) +- `action` (String) +- `description` (String) +- `destination_net_object` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_rules--destination_net_object)) +- `direction` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `filter` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_rules--filter)) +- `id` (String) +- `log_enabled` (Boolean) +- `log_name` (String) +- `log_severity` (String) +- `priority` (Number) +- `security_policy_id` (String) +- `source_net_object` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_rules--source_net_object)) +- `statistics_enabled` (Boolean) +- `version_id` (Number) + + +### Nested Schema for `items.security_rules.destination_net_object` + +Read-Only: + +- `display_name` (String) +- `net_address_pool_id` (String) +- `net_object_group_id` (String) + + + +### Nested Schema for `items.security_rules.filter` + +Read-Only: + +- `filters` (List of Object) (see [below for nested schema](#nestedobjatt--items--security_rules--filter--filters)) +- `name` (String) + + +### Nested Schema for `items.security_rules.filter.filters` + +Read-Only: + +- `all` (Boolean) +- `arp` (Boolean) +- `dhcp` (Boolean) +- `expression` (String) +- `icmp` (Boolean) +- `ip` (Boolean) +- `ip_v4` (Boolean) +- `ip_v6` (Boolean) +- `keep_opened_sessions` (Boolean) +- `nd` (Boolean) +- `tcp` (Boolean) +- `tcp_dst_ports` (List of String) +- `udp` (Boolean) +- `udp_dst_ports` (List of String) + + + + +### Nested Schema for `items.security_rules.source_net_object` + +Read-Only: + +- `display_name` (String) +- `net_address_pool_id` (String) +- `net_object_group_id` (String) + + + + +### Nested Schema for `items.status` + +Read-Only: + +- `common` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--status--hypervisors)) + + +### Nested Schema for `items.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `status` (String) +- `synced_at` (String) diff --git a/docs/data-sources/sdn_logical_port.md b/docs/data-sources/sdn_logical_port.md new file mode 100644 index 00000000..9a1d4387 --- /dev/null +++ b/docs/data-sources/sdn_logical_port.md @@ -0,0 +1,88 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_logical_port Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_logical_port (Data Source) + + + + + + +## Schema + +### Required + +- `logical_port_id` (String) ID of the logical port to use + +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `access_group_id` (String) ID of the access group +- `access_group_name` (String) Name of the access group +- `adapter_mac` (String) MAC address of the adapter +- `address_detection` (Boolean) If the adapter address detection is enabled +- `bindings` (List of Object) (see [below for nested schema](#nestedatt--bindings)) +- `created_at` (String) Creation time of the logical port +- `description` (String) Description of the logical port +- `display_name` (String) Display name of the logical port +- `enabled` (Boolean) If the logical port is enabled +- `hypervisor` (String) ID of the hypervisor +- `hypervisor_display_name` (String) Display name of the hypervisor +- `id` (String) The ID of this resource. +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedatt--status)) +- `unique_identifier` (String) Unique identifier of the logical port +- `updated_at` (String) Update time the logical port +- `version_id` (Number) Version ID of the logical port + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `is_excluded_from_firewall` (Boolean) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `status` + +Read-Only: + +- `common` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) + + +### Nested Schema for `status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `status` (String) +- `synced_at` (String) diff --git a/docs/data-sources/sdn_logical_port_get_by_unique_identifier.md b/docs/data-sources/sdn_logical_port_get_by_unique_identifier.md new file mode 100644 index 00000000..0fbeb7cb --- /dev/null +++ b/docs/data-sources/sdn_logical_port_get_by_unique_identifier.md @@ -0,0 +1,87 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_logical_port_get_by_unique_identifier Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_logical_port_get_by_unique_identifier (Data Source) + + + + + + +## Schema + +### Required + +- `unique_identifier` (String) Unique ID of the logical port to use + +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `access_group_id` (String) ID of the access group +- `access_group_name` (String) Name of the access group +- `adapter_mac` (String) MAC address of the adapter +- `address_detection` (Boolean) If the adapter address detection is enabled +- `bindings` (List of Object) (see [below for nested schema](#nestedatt--bindings)) +- `created_at` (String) Creation time of the logical port +- `description` (String) Description of the logical port +- `display_name` (String) Display name of the logical port +- `enabled` (Boolean) If the logical port is enabled +- `hypervisor` (String) ID of the hypervisor +- `hypervisor_display_name` (String) Display name of the hypervisor +- `id` (String) The ID of this resource. +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedatt--status)) +- `updated_at` (String) Update time the logical port +- `version_id` (Number) Version ID of the logical port + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `is_excluded_from_firewall` (Boolean) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `status` + +Read-Only: + +- `common` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) + + +### Nested Schema for `status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `status` (String) +- `synced_at` (String) diff --git a/docs/data-sources/sdn_logical_port_list.md b/docs/data-sources/sdn_logical_port_list.md new file mode 100644 index 00000000..4540a130 --- /dev/null +++ b/docs/data-sources/sdn_logical_port_list.md @@ -0,0 +1,111 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_logical_port_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_logical_port_list (Data Source) + + + + + + +## Schema + +### Optional + +- `access_group_id` (String) Access Group ID +- `adapter_mac` (String) Adapter mac +- `address_detection` (Boolean) +- `created_from` (String) +- `created_to` (String) +- `display_name` (String) Display name +- `enabled` (Boolean) +- `external_network_id` (String) External Network ID +- `hypervisor` (String) Hypervisor +- `hypervisor_display_name` (String) Hypervisor display name +- `live_migration_target_hv` (String) Live migration target HV +- `page` (Number) +- `per_page` (Number) +- `port_security` (Boolean) +- `segment_display_name` (String) Segment display name +- `segment_id` (String) Segment ID +- `sort_by` (String) +- `sort_order` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `unique_identifier` (String) Unique identifier + +### Read-Only + +- `id` (String) The ID of this resource. +- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `adapter_mac` (String) +- `address_detection` (Boolean) +- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--items--bindings)) +- `created_at` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) +- `hypervisor` (String) +- `hypervisor_display_name` (String) +- `id` (String) +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--status)) +- `unique_identifier` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `is_excluded_from_firewall` (Boolean) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `items.status` + +Read-Only: + +- `common` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--status--hypervisors)) + + +### Nested Schema for `items.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `status` (String) +- `synced_at` (String) diff --git a/docs/data-sources/sdn_segment.md b/docs/data-sources/sdn_segment.md new file mode 100644 index 00000000..c86933ee --- /dev/null +++ b/docs/data-sources/sdn_segment.md @@ -0,0 +1,117 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_segment Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_segment (Data Source) + + + + + + +## Schema + +### Required + +- `segment_id` (String) + +### Optional + +- `access_group_id` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `access_group_name` (String) +- `created_at` (String) +- `description` (String) +- `dhcp_v4` (List of Object) (see [below for nested schema](#nestedatt--dhcp_v4)) +- `dhcp_v6` (List of Object) (see [below for nested schema](#nestedatt--dhcp_v6)) +- `display_name` (String) +- `enabled` (Boolean) +- `id` (String) The ID of this resource. +- `logical_ports_info` (List of Object) (see [below for nested schema](#nestedatt--logical_ports_info)) +- `routers_info` (List of Object) (see [below for nested schema](#nestedatt--routers_info)) +- `status` (List of Object) (see [below for nested schema](#nestedatt--status)) +- `subnet_v4` (String) +- `subnet_v6` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `dhcp_v4` + +Read-Only: + +- `dns` (List of String) +- `enabled` (Boolean) +- `excluded_address_ranges` (List of String) +- `gateway` (String) +- `id` (String) +- `lease_time` (Number) +- `server_ip` (String) +- `server_mac` (String) + + + +### Nested Schema for `dhcp_v6` + +Read-Only: + +- `address_prefix` (String) +- `dns` (List of String) +- `enabled` (Boolean) +- `id` (String) +- `lease_time` (Number) +- `server_mac` (String) + + + +### Nested Schema for `logical_ports_info` + +Read-Only: + +- `display_name` (String) +- `id` (String) + + + +### Nested Schema for `routers_info` + +Read-Only: + +- `display_name` (String) +- `id` (String) + + + +### Nested Schema for `status` + +Read-Only: + +- `common` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) + + +### Nested Schema for `status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `status` (String) +- `synced_at` (String) diff --git a/docs/data-sources/sdn_segment_get_status.md b/docs/data-sources/sdn_segment_get_status.md new file mode 100644 index 00000000..b030c111 --- /dev/null +++ b/docs/data-sources/sdn_segment_get_status.md @@ -0,0 +1,39 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_segment_get_status Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_segment_get_status (Data Source) + + + + + + +## Schema + +### Required + +- `segment_id` (String) + +### Optional + +- `detailed` (Boolean) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `version_id` (Number) + +### Read-Only + +- `id` (String) The ID of this resource. +- `status` (String) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) diff --git a/docs/data-sources/sdn_segment_list.md b/docs/data-sources/sdn_segment_list.md new file mode 100644 index 00000000..1f539985 --- /dev/null +++ b/docs/data-sources/sdn_segment_list.md @@ -0,0 +1,135 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_segment_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_segment_list (Data Source) + + + + + + +## Schema + +### Optional + +- `access_group_id` (String) find by access group id +- `created_from` (String) find by created date +- `created_to` (String) find by created date +- `display_name` (String) find by display name +- `enabled` (Boolean) find by enabled status +- `is_synced` (Boolean) does core currently believe that its data is synchronized with the data in the OVN? +- `page` (Number) Page number +- `per_page` (Number) Items per page +- `sort_by` (String) sort by one of supported fields +- `sort_order` (String) sort order +- `subnet` (String) IPv4 or IPv6 subnet for the current segment +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `updated_from` (String) find by updated date +- `updated_to` (String) find by updated date + +### Read-Only + +- `entry_count` (Number) entry count +- `id` (String) The ID of this resource. +- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `access_group_id` (String) +- `access_group_name` (String) +- `created_at` (String) +- `description` (String) +- `dhcp_v4` (List of Object) (see [below for nested schema](#nestedobjatt--items--dhcp_v4)) +- `dhcp_v6` (List of Object) (see [below for nested schema](#nestedobjatt--items--dhcp_v6)) +- `display_name` (String) +- `enabled` (Boolean) +- `id` (String) +- `logical_ports_info` (List of Object) (see [below for nested schema](#nestedobjatt--items--logical_ports_info)) +- `routers_info` (List of Object) (see [below for nested schema](#nestedobjatt--items--routers_info)) +- `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--status)) +- `subnet_v4` (String) +- `subnet_v6` (String) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `items.dhcp_v4` + +Read-Only: + +- `dns` (List of String) +- `enabled` (Boolean) +- `excluded_address_ranges` (List of String) +- `gateway` (String) +- `id` (String) +- `lease_time` (Number) +- `server_ip` (String) +- `server_mac` (String) + + + +### Nested Schema for `items.dhcp_v6` + +Read-Only: + +- `address_prefix` (String) +- `dns` (List of String) +- `enabled` (Boolean) +- `id` (String) +- `lease_time` (Number) +- `server_mac` (String) + + + +### Nested Schema for `items.logical_ports_info` + +Read-Only: + +- `display_name` (String) +- `id` (String) + + + +### Nested Schema for `items.routers_info` + +Read-Only: + +- `display_name` (String) +- `id` (String) + + + +### Nested Schema for `items.status` + +Read-Only: + +- `common` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--items--status--hypervisors)) + + +### Nested Schema for `items.status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `status` (String) +- `synced_at` (String) diff --git a/docs/data-sources/security_group.md b/docs/data-sources/security_group.md new file mode 100644 index 00000000..c4c9e224 --- /dev/null +++ b/docs/data-sources/security_group.md @@ -0,0 +1,58 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_security_group Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_security_group (Data Source) + + + + + + +## Schema + +### Required + +- `security_group_id` (Number) + +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `account_id` (Number) +- `created_at` (Number) +- `created_by` (String) +- `description` (String) +- `id` (String) The ID of this resource. +- `name` (String) +- `rules` (List of Object) (see [below for nested schema](#nestedatt--rules)) +- `updated_at` (Number) +- `updated_by` (String) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `rules` + +Read-Only: + +- `direction` (String) +- `ethertype` (String) +- `id` (Number) +- `port_range_max` (Number) +- `port_range_min` (Number) +- `protocol` (String) +- `remote_ip_prefix` (String) diff --git a/docs/data-sources/security_group_list.md b/docs/data-sources/security_group_list.md new file mode 100644 index 00000000..1f7bd583 --- /dev/null +++ b/docs/data-sources/security_group_list.md @@ -0,0 +1,74 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_security_group_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_security_group_list (Data Source) + + + + + + +## Schema + +### Optional + +- `account_id` (Number) +- `by_id` (Number) +- `created_max` (Number) +- `created_min` (Number) +- `desc` (String) +- `name` (String) +- `page` (Number) +- `size` (Number) +- `sort_by` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `updated_max` (Number) +- `updated_min` (Number) + +### Read-Only + +- `entry_count` (Number) +- `id` (String) The ID of this resource. +- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `account_id` (Number) +- `created_at` (Number) +- `created_by` (String) +- `description` (String) +- `name` (String) +- `rules` (List of Object) (see [below for nested schema](#nestedobjatt--items--rules)) +- `security_group_id` (Number) +- `updated_at` (Number) +- `updated_by` (String) + + +### Nested Schema for `items.rules` + +Read-Only: + +- `direction` (String) +- `ethertype` (String) +- `id` (Number) +- `port_range_max` (Number) +- `port_range_min` (Number) +- `protocol` (String) +- `remote_ip_prefix` (String) diff --git a/docs/data-sources/storage_policy.md b/docs/data-sources/storage_policy.md new file mode 100644 index 00000000..06f2c5d5 --- /dev/null +++ b/docs/data-sources/storage_policy.md @@ -0,0 +1,61 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_storage_policy Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_storage_policy (Data Source) + + + + + + +## Schema + +### Required + +- `storage_policy_id` (Number) + +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `access_seps_pools` (List of Object) (see [below for nested schema](#nestedatt--access_seps_pools)) +- `description` (String) +- `guid` (Number) +- `id` (String) The ID of this resource. +- `limit_iops` (Number) +- `name` (String) +- `status` (String) +- `usage` (List of Object) (see [below for nested schema](#nestedatt--usage)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `access_seps_pools` + +Read-Only: + +- `pool_names` (List of String) +- `sep_id` (Number) + + + +### Nested Schema for `usage` + +Read-Only: + +- `accounts` (List of Number) +- `resgroups` (List of Number) diff --git a/docs/data-sources/storage_policy_list.md b/docs/data-sources/storage_policy_list.md new file mode 100644 index 00000000..dd232580 --- /dev/null +++ b/docs/data-sources/storage_policy_list.md @@ -0,0 +1,78 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_storage_policy_list Data Source - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_storage_policy_list (Data Source) + + + + + + +## Schema + +### Optional + +- `account_id` (Number) +- `by_id` (Number) +- `desc` (String) +- `limit_iops` (Number) +- `name` (String) +- `page` (Number) +- `pool_name` (String) +- `resgroup_id` (Number) +- `sep_id` (Number) +- `size` (Number) +- `sort_by` (String) +- `status` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `entry_count` (Number) +- `id` (String) The ID of this resource. +- `items` (List of Object) (see [below for nested schema](#nestedatt--items)) + + +### Nested Schema for `timeouts` + +Optional: + +- `default` (String) +- `read` (String) + + + +### Nested Schema for `items` + +Read-Only: + +- `access_seps_pools` (List of Object) (see [below for nested schema](#nestedobjatt--items--access_seps_pools)) +- `description` (String) +- `guid` (Number) +- `limit_iops` (Number) +- `name` (String) +- `status` (String) +- `storage_policy_id` (Number) +- `usage` (List of Object) (see [below for nested schema](#nestedobjatt--items--usage)) + + +### Nested Schema for `items.access_seps_pools` + +Read-Only: + +- `pool_names` (List of String) +- `sep_id` (Number) + + + +### Nested Schema for `items.usage` + +Read-Only: + +- `accounts` (List of Number) +- `resgroups` (List of Number) diff --git a/docs/data-sources/vins.md b/docs/data-sources/vins.md index a7e68e88..cae66d63 100644 --- a/docs/data-sources/vins.md +++ b/docs/data-sources/vins.md @@ -103,6 +103,7 @@ Read-Only: - `gid` (Number) - `guid` (Number) - `interfaces` (List of Object) (see [below for nested schema](#nestedobjatt--vnf_dev--interfaces)) +- `live_migration_job_id` (Number) - `lock_status` (String) - `milestones` (Number) - `status` (String) @@ -112,6 +113,7 @@ Read-Only: - `vnc_password` (String) - `vnf_id` (Number) - `vnf_name` (String) +- `zone_id` (Number) ### Nested Schema for `vnf_dev.config` @@ -153,6 +155,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flipgroup_id` (Number) - `guid` (String) @@ -169,6 +172,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--vnf_dev--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `type` (String) - `vnfs` (List of Number) @@ -231,6 +235,7 @@ Read-Only: - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.dhcp.config` @@ -309,9 +314,11 @@ Read-Only: - `owner_id` (Number) - `owner_type` (String) - `pure_virtual` (Boolean) +- `routes` (List of Object) (see [below for nested schema](#nestedobjatt--vnfs--gw--routes)) - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.gw.config` @@ -354,6 +361,19 @@ Read-Only: + +### Nested Schema for `vnfs.gw.routes` + +Read-Only: + +- `compute_ids` (List of Number) +- `destination` (String) +- `gateway` (String) +- `guid` (String) +- `netmask` (String) +- `route_id` (Number) + + ### Nested Schema for `vnfs.nat` @@ -373,9 +393,11 @@ Read-Only: - `owner_id` (Number) - `owner_type` (String) - `pure_virtual` (Boolean) +- `routes` (List of Object) (see [below for nested schema](#nestedobjatt--vnfs--nat--routes)) - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.nat.config` @@ -417,3 +439,17 @@ Read-Only: - `dev_id` (Number) - `iface01` (String) - `iface02` (String) + + + + +### Nested Schema for `vnfs.nat.routes` + +Read-Only: + +- `compute_ids` (List of Number) +- `destination` (String) +- `gateway` (String) +- `guid` (String) +- `netmask` (String) +- `route_id` (Number) diff --git a/docs/data-sources/vins_list.md b/docs/data-sources/vins_list.md index d1dd7bca..f1a81a0e 100644 --- a/docs/data-sources/vins_list.md +++ b/docs/data-sources/vins_list.md @@ -29,6 +29,7 @@ description: |- - `status` (String) sort by status - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `vnf_dev_id` (Number) Filter by VNF Device id +- `zone_id` (Number) Zone ID ### Read-Only diff --git a/docs/data-sources/zone.md b/docs/data-sources/zone.md index 5a0081a5..08b72907 100644 --- a/docs/data-sources/zone.md +++ b/docs/data-sources/zone.md @@ -25,16 +25,23 @@ description: |- ### Read-Only +- `account_ids` (List of Number) +- `bservice_ids` (List of Number) +- `compute_ids` (List of Number) - `created_time` (Number) - `deletable` (Boolean) - `description` (String) +- `extnet_ids` (List of Number) - `gid` (Number) - `guid` (Number) - `id` (String) The ID of this resource. +- `k8s_ids` (List of Number) +- `lb_ids` (List of Number) - `name` (String) - `node_ids` (List of Number) - `status` (String) - `updated_time` (Number) +- `vins_ids` (List of Number) ### Nested Schema for `timeouts` diff --git a/docs/index.md b/docs/index.md index d324b72b..4df9c205 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,6 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "decort Provider" -subcategory: "" description: |- --- diff --git a/docs/resources/account.md b/docs/resources/account.md index b667c638..3cda1654 100644 --- a/docs/resources/account.md +++ b/docs/resources/account.md @@ -31,13 +31,11 @@ description: |- - `send_access_emails` (Boolean) if true send emails when a user is granted access to resources - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `users` (Block List) (see [below for nested schema](#nestedblock--users)) -- `zone_ids` (List of Number) ### Read-Only - `account_id` (Number) - `acl` (List of Object) (see [below for nested schema](#nestedatt--acl)) -- `ckey` (String) - `company` (String) - `companyurl` (String) - `compute_features` (List of String) @@ -54,12 +52,13 @@ description: |- - `guid` (Number) - `id` (String) The ID of this resource. - `machines` (List of Object) (see [below for nested schema](#nestedatt--machines)) -- `service_account` (Boolean) - `status` (String) +- `storage_policy_ids` (List of Number) - `updated_time` (Number) - `version` (Number) - `vins` (List of Number) - `vinses` (Number) +- `zone_ids` (List of Number) ### Nested Schema for `resource_limits` @@ -73,6 +72,20 @@ Optional: - `cu_np` (Number) - `gpu_units` (Number) +Read-Only: + +- `cu_dm` (Number) +- `storage_policy` (List of Object) (see [below for nested schema](#nestedatt--resource_limits--storage_policy)) + + +### Nested Schema for `resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) + + ### Nested Schema for `timeouts` diff --git a/docs/resources/bservice_group.md b/docs/resources/bservice_group.md index f988f527..1f180334 100644 --- a/docs/resources/bservice_group.md +++ b/docs/resources/bservice_group.md @@ -21,16 +21,17 @@ description: |- - `compgroup_name` (String) name of the Compute Group to add - `cpu` (Number) compute CPU number. All computes in the group have the same CPU count - `disk` (Number) compute boot disk size in GB -- `driver` (String) compute driver like a KVM_X86, etc. - `image_id` (Number) OS image ID to create computes from - `ram` (Number) compute RAM volume in MB. All computes in the group have the same RAM volume - `service_id` (Number) ID of the Basic Service to add a group to +- `storage_policy_id` (Number) storage policy id of compute. The rules of the specified storage policy will be used. ### Optional - `chipset` (String) - `cloud_init` (String) Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases. - `compgroup_id` (Number) +- `driver` (String) compute driver like a KVM_X86, etc. - `extnets` (List of Number) list of external networks to connect computes to - `force_stop` (Boolean) force stop Compute Group - `force_update` (Boolean) force resize Compute Group diff --git a/docs/resources/cb_account.md b/docs/resources/cb_account.md index 42d347e7..3ea83b18 100644 --- a/docs/resources/cb_account.md +++ b/docs/resources/cb_account.md @@ -35,15 +35,15 @@ description: |- - `resource_limits` (Block List, Max: 1) (see [below for nested schema](#nestedblock--resource_limits)) - `restore` (Boolean) restore a deleted account - `send_access_emails` (Boolean) if true send emails when a user is granted access to resources +- `storage_policy` (Block Set) (see [below for nested schema](#nestedblock--storage_policy)) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `uniq_pools` (List of String) - `users` (Block List) (see [below for nested schema](#nestedblock--users)) -- `zone_ids` (List of Number) +- `zone_ids` (Set of Number) ### Read-Only - `acl` (List of Object) (see [below for nested schema](#nestedatt--acl)) -- `ckey` (String) - `company` (String) - `companyurl` (String) - `created_by` (String) @@ -76,6 +76,25 @@ Optional: Read-Only: - `cu_d` (Number) +- `storage_policy` (List of Object) (see [below for nested schema](#nestedatt--resource_limits--storage_policy)) + + +### Nested Schema for `resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) + + + + +### Nested Schema for `storage_policy` + +Required: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/resources/cb_cdrom_image.md b/docs/resources/cb_cdrom_image.md index 5c29ed96..2bfc274b 100644 --- a/docs/resources/cb_cdrom_image.md +++ b/docs/resources/cb_cdrom_image.md @@ -18,6 +18,7 @@ description: |- ### Required - `name` (String) Name of the rescue disk +- `storage_policy_id` (Number) ID of the storage policy - `url` (String) URL where to download ISO from ### Optional @@ -26,9 +27,7 @@ description: |- - `architecture` (String) binary architecture of this image, one of X86_64 - `bootable` (Boolean) Does this image boot OS - `computeci_id` (Number) -- `drivers` (List of String) List of types of compute suitable for image. Example: [ "KVM_X86" ] - `enabled` (Boolean) -- `enabled_stacks` (List of Number) - `hot_resize` (Boolean) Does this machine supports hot resize - `password_dl` (String) password for upload binary media - `pool_name` (String) pool for image create @@ -44,6 +43,7 @@ description: |- - `ckey` (String) - `deleted_time` (Number) - `desc` (String) +- `drivers` (List of String) - `gid` (Number) - `guid` (Number) - `history` (List of Object) (see [below for nested schema](#nestedatt--history)) @@ -64,6 +64,7 @@ description: |- - `snapshot_id` (String) snapshot id - `status` (String) status - `tech_status` (String) tech atatus +- `to_clean` (Boolean) - `unc_path` (String) unc path - `version` (String) version diff --git a/docs/resources/cb_disk.md b/docs/resources/cb_disk.md index b126584f..9857560e 100644 --- a/docs/resources/cb_disk.md +++ b/docs/resources/cb_disk.md @@ -20,12 +20,12 @@ description: |- - `account_id` (Number) - `disk_name` (String) - `size_max` (Number) +- `storage_policy_id` (Number) ### Optional - `desc` (String) - `detach` (Boolean) detach disk from machine first -- `iops` (Number) max IOPS disk can perform - `iotune` (Block List, Max: 1) (see [below for nested schema](#nestedblock--iotune)) - `node_ids` (Set of Number) - `permanently` (Boolean) whether to completely delete the disk, works only with non attached disks @@ -78,6 +78,7 @@ description: |- - `snapshots` (List of Object) (see [below for nested schema](#nestedatt--snapshots)) - `status` (String) - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp' - `updated_by` (String) - `updated_time` (Number) diff --git a/docs/resources/cb_dpdknet.md b/docs/resources/cb_dpdknet.md index f3d84c0a..d6a162d7 100644 --- a/docs/resources/cb_dpdknet.md +++ b/docs/resources/cb_dpdknet.md @@ -26,6 +26,7 @@ description: |- - `account_access` (List of Number) List of accounts with access - `desc` (String) Description of DPDK network +- `enable_secgroups` (Boolean) enable security groups - `enabled` (Boolean) Enabled or disabled DPDK network - `rg_access` (List of Number) List of resource groups with access - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) diff --git a/docs/resources/cb_extnet.md b/docs/resources/cb_extnet.md index a8f44c32..84bdb25d 100644 --- a/docs/resources/cb_extnet.md +++ b/docs/resources/cb_extnet.md @@ -29,6 +29,7 @@ description: |- - `desc` (String) Optional description - `dns` (List of String) List of DNS addresses - `enable` (Boolean) Disable/Enable extnet +- `enable_secgroups` (Boolean) enable security groups - `end_ip` (String) End of IP range to be explicitly included - `excluded_ips` (Set of String) IPs to exclude in current extnet pool - `excluded_ips_range` (Block Set) Range of IPs to exclude in current extnet pool (see [below for nested schema](#nestedblock--excluded_ips_range)) diff --git a/docs/resources/cb_image.md b/docs/resources/cb_image.md index 166891ea..9cd87c83 100644 --- a/docs/resources/cb_image.md +++ b/docs/resources/cb_image.md @@ -20,6 +20,7 @@ description: |- - `boot_type` (String) Boot type of image bios or uefi - `image_type` (String) Image type linux, windows or other - `name` (String) Name of the rescue disk +- `storage_policy_id` (Number) ID of the storage policy - `url` (String) URL where to download media from ### Optional @@ -27,9 +28,7 @@ description: |- - `account_id` (Number) AccountId to make the image exclusive - `bootable` (Boolean) Does this image boot OS - `computeci_id` (Number) -- `drivers` (List of String) List of types of compute suitable for image. Example: [ "KVM_X86" ] - `enabled` (Boolean) -- `enabled_stacks` (List of Number) - `hot_resize` (Boolean) Does this machine supports hot resize - `network_interface_naming` (String) select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming - `password` (String) Optional password for the image @@ -49,6 +48,7 @@ description: |- - `cd_presented_to` (String) - `deleted_time` (Number) - `desc` (String) +- `drivers` (List of String) - `gid` (Number) - `guid` (Number) - `history` (List of Object) (see [below for nested schema](#nestedatt--history)) @@ -68,6 +68,7 @@ description: |- - `snapshot_id` (String) snapshot id - `status` (String) status - `tech_status` (String) tech atatus +- `to_clean` (Boolean) - `unc_path` (String) unc path - `version` (String) version diff --git a/docs/resources/cb_image_from_blank_compute.md b/docs/resources/cb_image_from_blank_compute.md index 71180031..c4d49828 100644 --- a/docs/resources/cb_image_from_blank_compute.md +++ b/docs/resources/cb_image_from_blank_compute.md @@ -29,7 +29,6 @@ description: |- - `bootable` (Boolean) Does this image boot OS - `computeci_id` (Number) - `enabled` (Boolean) -- `enabled_stacks` (List of Number) - `hot_resize` (Boolean) Does this machine supports hot resize - `network_interface_naming` (String) select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming - `password` (String) Optional password for the image @@ -66,6 +65,7 @@ description: |- - `snapshot_id` (String) snapshot id - `status` (String) - `tech_status` (String) +- `to_clean` (Boolean) - `unc_path` (String) - `url` (String) - `version` (String) diff --git a/docs/resources/cb_image_from_platform_disk.md b/docs/resources/cb_image_from_platform_disk.md index 1c1af90a..e91fb854 100644 --- a/docs/resources/cb_image_from_platform_disk.md +++ b/docs/resources/cb_image_from_platform_disk.md @@ -19,7 +19,6 @@ description: |- - `boot_type` (String) Boot type of image BIOS or UEFI - `disk_id` (Number) Disk Id -- `drivers` (List of String) List of types of compute suitable for image. Example: [ "KVM_X86" ] - `image_type` (String) Image type linux, windows or unknown - `name` (String) Name of the rescue disk @@ -30,7 +29,6 @@ description: |- - `bootable` (Boolean) Does this image boot OS - `computeci_id` (Number) - `enabled` (Boolean) -- `enabled_stacks` (List of Number) - `hot_resize` (Boolean) Does this machine supports hot resize - `network_interface_naming` (String) select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming - `password` (String) Optional password for the image @@ -46,6 +44,7 @@ description: |- - `cd_presented_to` (String) - `deleted_time` (Number) - `desc` (String) +- `drivers` (List of String) - `gid` (Number) - `guid` (Number) - `history` (List of Object) (see [below for nested schema](#nestedatt--history)) @@ -66,6 +65,7 @@ description: |- - `snapshot_id` (String) snapshot id - `status` (String) - `tech_status` (String) +- `to_clean` (Boolean) - `unc_path` (String) - `url` (String) - `version` (String) diff --git a/docs/resources/cb_k8ci.md b/docs/resources/cb_k8ci.md index ce210452..f2013736 100644 --- a/docs/resources/cb_k8ci.md +++ b/docs/resources/cb_k8ci.md @@ -17,14 +17,12 @@ description: |- ### Required -- `master_driver` (String) - `master_image_id` (Number) - `max_master_count` (Number) - `max_worker_count` (Number) - `name` (String) K8CI name - `network_plugins` (List of String) - `version` (String) -- `worker_driver` (String) - `worker_image_id` (Number) ### Optional diff --git a/docs/resources/cb_k8s_cp.md b/docs/resources/cb_k8s_cp.md index 85e62292..af6be1ab 100644 --- a/docs/resources/cb_k8s_cp.md +++ b/docs/resources/cb_k8s_cp.md @@ -21,6 +21,7 @@ description: |- - `name` (String) Name of the cluster. - `network_plugin` (String) Network plugin to be used - `rg_id` (Number) Resource group ID that this instance belongs to. +- `storage_policy_id` (Number) ID of the storage policy ### Optional diff --git a/docs/resources/cb_k8s_wg.md b/docs/resources/cb_k8s_wg.md index ebde9644..ef3aec5f 100644 --- a/docs/resources/cb_k8s_wg.md +++ b/docs/resources/cb_k8s_wg.md @@ -19,6 +19,7 @@ description: |- - `k8s_id` (Number) ID of k8s instance. - `name` (String) Name of the worker group. +- `storage_policy_id` (Number) ID of the storage policy ### Optional diff --git a/docs/resources/cb_kvmvm.md b/docs/resources/cb_kvmvm.md index d25ea249..1ef2494d 100644 --- a/docs/resources/cb_kvmvm.md +++ b/docs/resources/cb_kvmvm.md @@ -18,10 +18,10 @@ description: |- ### Required - `cpu` (Number) Number of CPUs to allocate to this compute instance. -- `driver` (String) Hardware architecture of this compute instance. - `name` (String) Name of this compute. Compute names are case sensitive and must be unique in the resource group. - `ram` (Number) Amount of RAM in MB to allocate to this compute instance. - `rg_id` (Number) ID of the resource group where this compute should be deployed. +- `storage_policy_id` (Number) Storage policy id of compute. The rules of the specified storage policy will be used. ### Optional @@ -55,6 +55,7 @@ description: |- - `network` (Block Set) Optional network connection(s) for this compute. You may specify several network blocks, one for each connection. (see [below for nested schema](#nestedblock--network)) - `network_interface_naming` (String) Name of netfowrk interface. - `numa_affinity` (String) Rule for VM placement with NUMA affinity. +- `os_version` (String) the OS version installed on the VM - `pause` (Boolean) - `pci_devices` (Set of Number) ID of the connected pci devices - `permanently` (Boolean) @@ -65,6 +66,7 @@ description: |- - `reset` (Boolean) - `restore` (Boolean) - `rollback` (Block Set, Max: 1) (see [below for nested schema](#nestedblock--rollback)) +- `security_groups` (Block Set) list of security group IDs to apply to this interface (see [below for nested schema](#nestedblock--security_groups)) - `sep_id` (Number) ID of SEP to create bootDisk on. Uses image's sepId if not set. - `snapshot` (Block Set) (see [below for nested schema](#nestedblock--snapshot)) - `stack_id` (Number) ID of stack to start compute @@ -83,6 +85,7 @@ description: |- - `affinity_weight` (Number) - `arch` (String) - `boot_disk_id` (Number) This compute instance boot disk ID. +- `boot_image_id` (Number) - `boot_order` (List of String) - `cd_image_id` (Number) - `clone_reference` (Number) @@ -95,6 +98,7 @@ description: |- - `deleted_by` (String) - `deleted_time` (Number) - `devices` (String) +- `driver` (String) - `gid` (Number) - `guid` (Number) - `id` (String) The ID of this resource. @@ -178,6 +182,7 @@ Required: - `disk_name` (String) Name for disk - `size` (Number) Disk size in GiB +- `storage_policy_id` (Number) Storage policy id of disk. The rules of the specified storage policy will be used. Optional: @@ -196,6 +201,7 @@ Read-Only: - `shareable` (Boolean) - `size_max` (Number) - `size_used` (Number) +- `to_clean` (Boolean) @@ -226,6 +232,7 @@ Required: Optional: +- `enabled` (Boolean) network enable flag - `ip_address` (String) Optional IP address to assign to this connection. This IP should belong to the selected network and free for use. - `mac` (String) MAC address associated with this connection. MAC address is assigned automatically. - `mtu` (Number) Maximum transmission unit, used only for DPDK type, must be 1-9216 @@ -259,6 +266,20 @@ Required: - `label` (String) + +### Nested Schema for `security_groups` + +Required: + +- `net_id` (Number) ID of the network +- `net_type` (String) Type of the network +- `security_groups` (Set of Number) + +Optional: + +- `enable_secgroups` (Boolean) + + ### Nested Schema for `snapshot` @@ -319,6 +340,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flip_group_id` (Number) - `guid` (String) @@ -335,6 +357,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `trunk_tags` (String) - `type` (String) diff --git a/docs/resources/cb_rg.md b/docs/resources/cb_rg.md index a9aea38e..21fcb73a 100644 --- a/docs/resources/cb_rg.md +++ b/docs/resources/cb_rg.md @@ -40,6 +40,7 @@ description: |- - `resource_limits` (Block List, Max: 1) (see [below for nested schema](#nestedblock--resource_limits)) - `restore` (Boolean) restore deleted rg - `sdn_access_group_id` (String) ID of the SDN access group +- `storage_policy` (Block Set) (see [below for nested schema](#nestedblock--storage_policy)) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `uniq_pools` (List of String) @@ -60,6 +61,7 @@ description: |- - `rg_id` (Number) - `secret` (String) - `status` (String) Current status of this resource group. +- `storage_policy_ids` (List of Number) - `updated_by` (String) - `updated_time` (Number) - `vins` (List of Number) List of VINs deployed in this resource group. @@ -101,6 +103,28 @@ Read-Only: - `cu_d` (Number) - `gpu_units` (Number) +- `storage_policy` (Set of Object) (see [below for nested schema](#nestedatt--resource_limits--storage_policy)) + + +### Nested Schema for `resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) + + + + +### Nested Schema for `storage_policy` + +Required: + +- `id` (Number) + +Optional: + +- `limit` (Number) diff --git a/docs/resources/cb_security_group.md b/docs/resources/cb_security_group.md new file mode 100644 index 00000000..119b871b --- /dev/null +++ b/docs/resources/cb_security_group.md @@ -0,0 +1,67 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_cb_security_group Resource - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_cb_security_group (Resource) + + + + + + +## Schema + +### Required + +- `account_id` (Number) +- `name` (String) + +### Optional + +- `description` (String) +- `rules` (Block Set) (see [below for nested schema](#nestedblock--rules)) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `created_at` (Number) +- `created_by` (String) +- `id` (String) The ID of this resource. +- `security_group_id` (Number) +- `updated_at` (Number) +- `updated_by` (String) + + +### Nested Schema for `rules` + +Required: + +- `direction` (String) + +Optional: + +- `ethertype` (String) +- `port_range_max` (Number) +- `port_range_min` (Number) +- `protocol` (String) +- `remote_ip_prefix` (String) + +Read-Only: + +- `id` (Number) + + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `default` (String) +- `delete` (String) +- `read` (String) +- `update` (String) diff --git a/docs/resources/cb_storage_policy.md b/docs/resources/cb_storage_policy.md new file mode 100644 index 00000000..98a76b76 --- /dev/null +++ b/docs/resources/cb_storage_policy.md @@ -0,0 +1,65 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_cb_storage_policy Resource - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_cb_storage_policy (Resource) + + + + + + +## Schema + +### Required + +- `access_seps_pools` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--access_seps_pools)) +- `name` (String) + +### Optional + +- `description` (String) +- `enabled` (Boolean) +- `limit_iops` (Number) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `guid` (Number) +- `id` (String) The ID of this resource. +- `status` (String) +- `storage_policy_id` (Number) +- `usage` (List of Object) (see [below for nested schema](#nestedatt--usage)) + + +### Nested Schema for `access_seps_pools` + +Required: + +- `pool_name` (String) +- `sep_id` (Number) + + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `default` (String) +- `delete` (String) +- `read` (String) +- `update` (String) + + + +### Nested Schema for `usage` + +Read-Only: + +- `accounts` (List of Number) +- `resgroups` (List of Number) diff --git a/docs/resources/cb_vins.md b/docs/resources/cb_vins.md index 6033bccf..10e01c12 100644 --- a/docs/resources/cb_vins.md +++ b/docs/resources/cb_vins.md @@ -26,6 +26,7 @@ description: |- - `description` (String) Optional user-defined text description of this ViNS. - `dns` (Set of String) - `enable` (Boolean) enable for enable/disable requests +- `enable_secgroups` (Boolean) enable security groups - `ext_ip` (String) - `ext_net_id` (Number) - `force` (Boolean) force for delete request @@ -160,6 +161,7 @@ Read-Only: - `guid` (Number) - `id` (Number) - `interfaces` (List of Object) (see [below for nested schema](#nestedobjatt--vnf_dev--interfaces)) +- `live_migration_job_id` (Number) - `lock_status` (String) - `meta` (List of String) - `milestones` (Number) @@ -169,6 +171,7 @@ Read-Only: - `type` (String) - `vins` (List of Number) - `vnc_password` (String) +- `zone_id` (Number) ### Nested Schema for `vnf_dev.config` @@ -210,6 +213,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flipgroup_id` (Number) - `guid` (String) @@ -225,6 +229,8 @@ Read-Only: - `node_id` (Number) - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--vnf_dev--interfaces--qos)) +- `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `type` (String) - `vnfs` (List of Number) @@ -284,9 +290,11 @@ Read-Only: - `owner_id` (Number) - `owner_type` (String) - `pure_virtual` (Boolean) +- `routes` (List of Object) (see [below for nested schema](#nestedobjatt--vnfs--dhcp--routes)) - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.dhcp.config` @@ -333,6 +341,19 @@ Read-Only: + +### Nested Schema for `vnfs.dhcp.routes` + +Read-Only: + +- `compute_ids` (List of Number) +- `destination` (String) +- `gateway` (String) +- `guid` (String) +- `netmask` (String) +- `route_id` (Number) + + ### Nested Schema for `vnfs.gw` @@ -353,9 +374,11 @@ Read-Only: - `owner_id` (Number) - `owner_type` (String) - `pure_virtual` (Boolean) +- `routes` (List of Object) (see [below for nested schema](#nestedobjatt--vnfs--gw--routes)) - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.gw.config` @@ -398,6 +421,19 @@ Read-Only: + +### Nested Schema for `vnfs.gw.routes` + +Read-Only: + +- `compute_ids` (List of Number) +- `destination` (String) +- `gateway` (String) +- `guid` (String) +- `netmask` (String) +- `route_id` (Number) + + ### Nested Schema for `vnfs.nat` @@ -418,9 +454,11 @@ Read-Only: - `owner_id` (Number) - `owner_type` (String) - `pure_virtual` (Boolean) +- `routes` (List of Object) (see [below for nested schema](#nestedobjatt--vnfs--nat--routes)) - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.nat.config` @@ -462,3 +500,17 @@ Read-Only: - `dev_id` (Number) - `iface01` (String) - `iface02` (String) + + + + +### Nested Schema for `vnfs.nat.routes` + +Read-Only: + +- `compute_ids` (List of Number) +- `destination` (String) +- `gateway` (String) +- `guid` (String) +- `netmask` (String) +- `route_id` (Number) diff --git a/docs/resources/cb_virtual_image.md b/docs/resources/cb_virtual_image.md index 1fb95300..d152cee7 100644 --- a/docs/resources/cb_virtual_image.md +++ b/docs/resources/cb_virtual_image.md @@ -26,7 +26,6 @@ description: |- - `bootable` (Boolean) Does this image boot OS - `computeci_id` (Number) - `enabled` (Boolean) -- `enabled_stacks` (List of Number) - `hot_resize` (Boolean) Does this machine supports hot resize - `password` (String) Optional password for the image - `shared_with` (List of Number) @@ -63,6 +62,7 @@ description: |- - `snapshot_id` (String) snapshot id - `status` (String) status - `tech_status` (String) tech atatus +- `to_clean` (Boolean) - `unc_path` (String) unc path - `url` (String) URL where to download media from - `version` (String) version diff --git a/docs/resources/disk.md b/docs/resources/disk.md index c61749a3..caa26054 100644 --- a/docs/resources/disk.md +++ b/docs/resources/disk.md @@ -20,6 +20,7 @@ description: |- - `account_id` (Number) The unique ID of the subscriber-owner of the disk - `disk_name` (String) Name of disk - `size_max` (Number) Size in GB +- `storage_policy_id` (Number) ID storage policy under which the disk will be created ### Optional @@ -65,6 +66,7 @@ description: |- - `snapshots` (List of Object) (see [below for nested schema](#nestedatt--snapshots)) - `status` (String) Disk status - `tech_status` (String) Technical status of the disk +- `to_clean` (Boolean) - `type` (String) The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp' - `updated_by` (String) - `updated_time` (Number) diff --git a/docs/resources/image.md b/docs/resources/image.md index 3cf97749..19503747 100644 --- a/docs/resources/image.md +++ b/docs/resources/image.md @@ -19,8 +19,8 @@ description: |- - `account_id` (Number) AccountId to make the image exclusive - `boot_type` (String) Boot type of image bios or uefi -- `drivers` (List of String) - `name` (String) Name of the rescue disk +- `storage_policy_id` (Number) ID of the storage policy - `type` (String) Image type linux, windows or unknown - `url` (String) URL where to download media from @@ -48,6 +48,7 @@ description: |- - `compute_ci_id` (Number) - `deleted_time` (Number) - `desc` (String) +- `drivers` (List of String) - `enabled` (Boolean) - `gid` (Number) - `guid` (Number) @@ -67,6 +68,7 @@ description: |- - `snapshot_id` (String) - `status` (String) - `tech_status` (String) +- `to_clean` (Boolean) - `unc_path` (String) - `version` (String) diff --git a/docs/resources/image_from_blank_compute.md b/docs/resources/image_from_blank_compute.md index 7e457624..179de0dd 100644 --- a/docs/resources/image_from_blank_compute.md +++ b/docs/resources/image_from_blank_compute.md @@ -65,6 +65,7 @@ description: |- - `snapshot_id` (String) - `status` (String) - `tech_status` (String) +- `to_clean` (Boolean) - `unc_path` (String) - `version` (String) diff --git a/docs/resources/image_from_platform_disk.md b/docs/resources/image_from_platform_disk.md index 127e2aa3..ea4c816b 100644 --- a/docs/resources/image_from_platform_disk.md +++ b/docs/resources/image_from_platform_disk.md @@ -19,7 +19,6 @@ description: |- - `boot_type` (String) Boot type of image BIOS or UEFI - `disk_id` (Number) Disk Id -- `drivers` (List of String) List of types of compute suitable for image. Example: [ "KVM_X86" ] - `name` (String) Name of the rescue disk - `type` (String) Image type linux, windows or unknown @@ -43,6 +42,7 @@ description: |- - `compute_ci_id` (Number) - `deleted_time` (Number) - `desc` (String) +- `drivers` (List of String) - `enabled` (Boolean) - `gid` (Number) - `guid` (Number) @@ -65,6 +65,7 @@ description: |- - `snapshot_id` (String) - `status` (String) - `tech_status` (String) +- `to_clean` (Boolean) - `unc_path` (String) - `version` (String) diff --git a/docs/resources/image_virtual.md b/docs/resources/image_virtual.md index d24f0ff6..a38b9d85 100644 --- a/docs/resources/image_virtual.md +++ b/docs/resources/image_virtual.md @@ -22,11 +22,11 @@ description: |- ### Optional +- `account_id` (Number) account_id - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) ### Read-Only -- `account_id` (Number) - `acl` (String) - `architecture` (String) - `boot_type` (String) @@ -60,7 +60,9 @@ description: |- - `size` (Number) - `snapshot_id` (String) - `status` (String) +- `storage_policy_id` (Number) - `tech_status` (String) +- `to_clean` (Boolean) - `type` (String) - `unc_path` (String) - `username` (String) diff --git a/docs/resources/k8s.md b/docs/resources/k8s.md index 030ce268..6807812b 100644 --- a/docs/resources/k8s.md +++ b/docs/resources/k8s.md @@ -21,6 +21,7 @@ description: |- - `name` (String) Name of the cluster. - `network_plugin` (String) Network plugin to be used - `rg_id` (Number) Resource group ID that this instance belongs to. +- `storage_policy_id` (Number) ID of the storage policy - `wg_name` (String) Name for first worker group created with cluster. ### Optional diff --git a/docs/resources/k8s_cp.md b/docs/resources/k8s_cp.md index 842cf8b9..5339fc0a 100644 --- a/docs/resources/k8s_cp.md +++ b/docs/resources/k8s_cp.md @@ -21,6 +21,7 @@ description: |- - `name` (String) Name of the cluster. - `network_plugin` (String) Network plugin to be used - `rg_id` (Number) Resource group ID that this instance belongs to. +- `storage_policy_id` (Number) ID of the storage policy ### Optional diff --git a/docs/resources/k8s_wg.md b/docs/resources/k8s_wg.md index 0edfc26d..40f6646f 100644 --- a/docs/resources/k8s_wg.md +++ b/docs/resources/k8s_wg.md @@ -19,6 +19,7 @@ description: |- - `k8s_id` (Number) ID of k8s instance. - `name` (String) Name of the worker group. +- `storage_policy_id` (Number) ID of the storage policy ### Optional diff --git a/docs/resources/kvmvm.md b/docs/resources/kvmvm.md index a3bc3798..4a23588d 100644 --- a/docs/resources/kvmvm.md +++ b/docs/resources/kvmvm.md @@ -18,10 +18,10 @@ description: |- ### Required - `cpu` (Number) Number of CPUs to allocate to this compute instance. -- `driver` (String) Hardware architecture of this compute instance. - `name` (String) Name of this compute. Compute names are case sensitive and must be unique in the resource group. - `ram` (Number) Amount of RAM in MB to allocate to this compute instance. - `rg_id` (Number) ID of the resource group where this compute should be deployed. +- `storage_policy_id` (Number) Storage policy id of compute. The rules of the specified storage policy will be used. ### Optional @@ -52,6 +52,7 @@ description: |- - `network` (Block Set) Optional network connection(s) for this compute. You may specify several network blocks, one for each connection. (see [below for nested schema](#nestedblock--network)) - `network_interface_naming` (String) Name of netfowrk interface. - `numa_affinity` (String) Rule for VM placement with NUMA affinity. +- `os_version` (String) the OS version installed on the VM - `pause` (Boolean) - `pci_devices` (Set of Number) ID of the connected pci devices - `permanently` (Boolean) @@ -62,6 +63,7 @@ description: |- - `reset` (Boolean) - `restore` (Boolean) - `rollback` (Block Set, Max: 1) (see [below for nested schema](#nestedblock--rollback)) +- `security_groups` (Block Set) list of security group IDs to apply to this interface (see [below for nested schema](#nestedblock--security_groups)) - `sep_id` (Number) ID of SEP to create bootDisk on. Uses image's sepId if not set. - `snapshot` (Block Set) (see [below for nested schema](#nestedblock--snapshot)) - `snapshot_delete_async` (Boolean) @@ -80,6 +82,7 @@ description: |- - `arch` (String) - `boot_disk` (Set of Object) (see [below for nested schema](#nestedatt--boot_disk)) - `boot_disk_id` (Number) This compute instance boot disk ID. +- `boot_image_id` (Number) - `boot_order` (List of String) - `cd_image_id` (Number) - `clone_reference` (Number) @@ -91,6 +94,7 @@ description: |- - `deleted_by` (String) - `deleted_time` (Number) - `devices` (String) +- `driver` (String) - `gid` (Number) - `guid` (Number) - `id` (String) The ID of this resource. @@ -172,6 +176,7 @@ Required: - `disk_name` (String) Name for disk - `size` (Number) Disk size in GiB +- `storage_policy_id` (Number) Storage policy id of disk. The rules of the specified storage policy will be used. Optional: @@ -189,6 +194,7 @@ Read-Only: - `shareable` (Boolean) - `size_max` (Number) - `size_used` (Number) +- `to_clean` (Boolean) @@ -201,6 +207,7 @@ Required: Optional: +- `enabled` (Boolean) network enable flag - `ip_address` (String) Optional IP address to assign to this connection. This IP should belong to the selected network and free for use. - `mac` (String) MAC address associated with this connection. MAC address is assigned automatically. - `mtu` (Number) Maximum transmission unit, used only for DPDK type, must be 1-9216 @@ -230,6 +237,20 @@ Required: - `label` (String) + +### Nested Schema for `security_groups` + +Required: + +- `net_id` (Number) ID of the network +- `net_type` (String) Type of the network +- `security_groups` (Set of Number) + +Optional: + +- `enable_secgroups` (Boolean) + + ### Nested Schema for `snapshot` @@ -286,6 +307,8 @@ Read-Only: - `size` (Number) - `size_max` (Number) - `size_used` (Number) +- `storage_policy_id` (Number) +- `to_clean` (Boolean) @@ -297,6 +320,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flip_group_id` (Number) - `guid` (String) @@ -313,6 +337,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `trunk_tags` (String) - `type` (String) diff --git a/docs/resources/resgroup.md b/docs/resources/resgroup.md index 0635944c..46f38fe0 100644 --- a/docs/resources/resgroup.md +++ b/docs/resources/resgroup.md @@ -37,6 +37,7 @@ description: |- - `quota` (Block List, Max: 1) Quota settings for this resource group. (see [below for nested schema](#nestedblock--quota)) - `restore` (Boolean) - `sdn_access_group_id` (String) ID of the SDN access group +- `storage_policy` (Block Set) (see [below for nested schema](#nestedblock--storage_policy)) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `uniq_pools` (List of String) @@ -58,9 +59,11 @@ description: |- - `lock_status` (String) - `milestones` (Number) - `res_types` (List of String) +- `resource_limits` (List of Object) (see [below for nested schema](#nestedatt--resource_limits)) - `rg_id` (Number) - `secret` (String) - `status` (String) Current status of this resource group. +- `storage_policy_ids` (List of Number) - `updated_by` (String) - `updated_time` (Number) - `vins` (List of Number) List of VINs deployed in this resource group. @@ -104,6 +107,18 @@ Read-Only: - `gpu_units` (Number) Limit on the total number of virtual GPUs this resource group can use. + +### Nested Schema for `storage_policy` + +Required: + +- `id` (Number) + +Optional: + +- `limit` (Number) + + ### Nested Schema for `timeouts` @@ -127,3 +142,26 @@ Read-Only: - `status` (String) - `type` (String) - `user_group_id` (String) + + + +### Nested Schema for `resource_limits` + +Read-Only: + +- `cu_c` (Number) +- `cu_d` (Number) +- `cu_dm` (Number) +- `cu_i` (Number) +- `cu_m` (Number) +- `cu_np` (Number) +- `gpu_units` (Number) +- `storage_policy` (Set of Object) (see [below for nested schema](#nestedobjatt--resource_limits--storage_policy)) + + +### Nested Schema for `resource_limits.storage_policy` + +Read-Only: + +- `id` (Number) +- `limit` (Number) diff --git a/docs/resources/sdn_access_group.md b/docs/resources/sdn_access_group.md new file mode 100644 index 00000000..813cae55 --- /dev/null +++ b/docs/resources/sdn_access_group.md @@ -0,0 +1,80 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_access_group Resource - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_access_group (Resource) + + + + + + +## Schema + +### Required + +- `comment` (String) description (comment) of the group +- `display_name` (String) group name + +### Optional + +- `default_security_policy` (Block List, Max: 1) Default security policy configuration (see [below for nested schema](#nestedblock--default_security_policy)) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `users` (Block List) managing users who are part of a group (see [below for nested schema](#nestedblock--users)) + +### Read-Only + +- `created_at` (String) Creation timestamp +- `id` (String) The ID of this resource. +- `net_object_access_group` (List of Object) Net object access group configuration (see [below for nested schema](#nestedatt--net_object_access_group)) + + +### Nested Schema for `default_security_policy` + +Optional: + +- `default_acl_drop` (String) Default ACL drop action +- `default_open_session_drop` (Boolean) Default open session drop flag + +Read-Only: + +- `access_group_id` (String) Policy access group ID +- `description` (String) Policy description +- `display_name` (String) Policy display name +- `id` (String) Policy unique identifier +- `version_id` (Number) Policy version identifier + + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `default` (String) +- `delete` (String) +- `read` (String) +- `update` (String) + + + +### Nested Schema for `users` + +Required: + +- `access_group_role_id` (String) id of the assigned role +- `user_id` (String) user ID + + + +### Nested Schema for `net_object_access_group` + +Read-Only: + +- `access_group_id` (String) +- `id` (String) +- `version_id` (Number) diff --git a/docs/resources/sdn_logical_port.md b/docs/resources/sdn_logical_port.md new file mode 100644 index 00000000..53a259ed --- /dev/null +++ b/docs/resources/sdn_logical_port.md @@ -0,0 +1,110 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_logical_port Resource - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_logical_port (Resource) + + + + + + +## Schema + +### Required + +- `access_group_id` (String) Access Group ID +- `description` (String) Description +- `display_name` (String) Display Name +- `enabled` (Boolean) Whether the logical port should be enabled +- `hypervisor` (String) Hypervisor +- `is_excluded_from_firewall` (Boolean) +- `port_security` (Boolean) Whether the port security is enabled +- `segment_id` (String) Segment ID + +### Optional + +- `adapter_mac` (String) Adapter MAC address +- `force` (Boolean) +- `logical_port_addresses` (Block List) (see [below for nested schema](#nestedblock--logical_port_addresses)) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `unique_identifier` (String) Unique identifier of the logical port + +### Read-Only + +- `access_group_name` (String) Name of the access group +- `address_detection` (Boolean) +- `bindings` (List of Object) (see [below for nested schema](#nestedatt--bindings)) +- `created_at` (String) +- `external_network_id` (String) +- `hypervisor_display_name` (String) +- `id` (String) ID of the logical port +- `live_migration_target_hv` (String) +- `status` (List of Object) (see [below for nested schema](#nestedatt--status)) +- `version_id` (Number) Version ID of the logical port + + +### Nested Schema for `logical_port_addresses` + +Required: + +- `ip` (String) IP address of the logical port +- `ip_type` (String) +- `is_primary` (Boolean) + +Optional: + +- `is_discovered` (Boolean) +- `mac` (String) + + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `default` (String) +- `delete` (String) +- `read` (String) +- `update` (String) + + + +### Nested Schema for `bindings` + +Read-Only: + +- `address_detection` (Boolean) +- `created_at` (String) +- `id` (String) +- `is_excluded_from_firewall` (Boolean) +- `port_security` (Boolean) +- `segment_display_name` (String) +- `segment_id` (String) +- `updated_at` (String) +- `version_id` (Number) + + + +### Nested Schema for `status` + +Read-Only: + +- `common` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) + + +### Nested Schema for `status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `status` (String) +- `synced_at` (String) diff --git a/docs/resources/sdn_segment.md b/docs/resources/sdn_segment.md new file mode 100644 index 00000000..624f6b2f --- /dev/null +++ b/docs/resources/sdn_segment.md @@ -0,0 +1,132 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_sdn_segment Resource - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_sdn_segment (Resource) + + + + + + +## Schema + +### Required + +- `access_group_id` (String) +- `description` (String) +- `display_name` (String) +- `enabled` (Boolean) + +### Optional + +- `dhcp_v4` (Block List, Max: 1) (see [below for nested schema](#nestedblock--dhcp_v4)) +- `dhcp_v6` (Block List, Max: 1) (see [below for nested schema](#nestedblock--dhcp_v6)) +- `force` (Boolean) +- `subnet_v4` (String) +- `subnet_v6` (String) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `access_group_name` (String) +- `created_at` (String) +- `id` (String) The ID of this resource. +- `logical_ports_info` (List of Object) (see [below for nested schema](#nestedatt--logical_ports_info)) +- `routers_info` (List of Object) (see [below for nested schema](#nestedatt--routers_info)) +- `status` (List of Object) (see [below for nested schema](#nestedatt--status)) +- `updated_at` (String) +- `version_id` (Number) + + +### Nested Schema for `dhcp_v4` + +Required: + +- `enabled` (Boolean) +- `gateway` (String) +- `server_ip` (String) + +Optional: + +- `dns` (List of String) +- `excluded_address_ranges` (List of String) +- `lease_time` (Number) +- `server_mac` (String) + +Read-Only: + +- `id` (String) + + + +### Nested Schema for `dhcp_v6` + +Required: + +- `address_prefix` (String) +- `enabled` (Boolean) + +Optional: + +- `dns` (List of String) +- `lease_time` (Number) +- `server_mac` (String) + +Read-Only: + +- `id` (String) + + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `default` (String) +- `delete` (String) +- `read` (String) +- `update` (String) + + + +### Nested Schema for `logical_ports_info` + +Read-Only: + +- `display_name` (String) +- `id` (String) + + + +### Nested Schema for `routers_info` + +Read-Only: + +- `display_name` (String) +- `id` (String) + + + +### Nested Schema for `status` + +Read-Only: + +- `common` (String) +- `hypervisors` (List of Object) (see [below for nested schema](#nestedobjatt--status--hypervisors)) + + +### Nested Schema for `status.hypervisors` + +Read-Only: + +- `display_name` (String) +- `hypervisor_status` (String) +- `name` (String) +- `status` (String) +- `synced_at` (String) diff --git a/docs/resources/security_group.md b/docs/resources/security_group.md new file mode 100644 index 00000000..8b18029f --- /dev/null +++ b/docs/resources/security_group.md @@ -0,0 +1,67 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "decort_security_group Resource - terraform-provider-decort" +subcategory: "" +description: |- + +--- + +# decort_security_group (Resource) + + + + + + +## Schema + +### Required + +- `account_id` (Number) +- `name` (String) + +### Optional + +- `description` (String) +- `rules` (Block Set) (see [below for nested schema](#nestedblock--rules)) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + +### Read-Only + +- `created_at` (Number) +- `created_by` (String) +- `id` (String) The ID of this resource. +- `security_group_id` (Number) +- `updated_at` (Number) +- `updated_by` (String) + + +### Nested Schema for `rules` + +Required: + +- `direction` (String) + +Optional: + +- `ethertype` (String) +- `port_range_max` (Number) +- `port_range_min` (Number) +- `protocol` (String) +- `remote_ip_prefix` (String) + +Read-Only: + +- `id` (Number) + + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `default` (String) +- `delete` (String) +- `read` (String) +- `update` (String) diff --git a/docs/resources/vins.md b/docs/resources/vins.md index 7e2b2d89..a934b42a 100644 --- a/docs/resources/vins.md +++ b/docs/resources/vins.md @@ -158,6 +158,7 @@ Read-Only: - `gid` (Number) - `guid` (Number) - `interfaces` (List of Object) (see [below for nested schema](#nestedobjatt--vnf_dev--interfaces)) +- `live_migration_job_id` (Number) - `lock_status` (String) - `milestones` (Number) - `status` (String) @@ -167,6 +168,7 @@ Read-Only: - `vnc_password` (String) - `vnf_id` (Number) - `vnf_name` (String) +- `zone_id` (Number) ### Nested Schema for `vnf_dev.config` @@ -208,6 +210,7 @@ Read-Only: - `conn_id` (Number) - `conn_type` (String) - `def_gw` (String) +- `enable_secgroups` (Boolean) - `enabled` (Boolean) - `flipgroup_id` (Number) - `guid` (String) @@ -224,6 +227,7 @@ Read-Only: - `pci_slot` (Number) - `qos` (List of Object) (see [below for nested schema](#nestedobjatt--vnf_dev--interfaces--qos)) - `sdn_interface_id` (String) +- `security_groups` (List of Number) - `target` (String) - `type` (String) - `vnfs` (List of Number) @@ -286,6 +290,7 @@ Read-Only: - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.dhcp.config` @@ -364,9 +369,11 @@ Read-Only: - `owner_id` (Number) - `owner_type` (String) - `pure_virtual` (Boolean) +- `routes` (List of Object) (see [below for nested schema](#nestedobjatt--vnfs--gw--routes)) - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.gw.config` @@ -409,6 +416,19 @@ Read-Only: + +### Nested Schema for `vnfs.gw.routes` + +Read-Only: + +- `compute_ids` (List of Number) +- `destination` (String) +- `gateway` (String) +- `guid` (String) +- `netmask` (String) +- `route_id` (Number) + + ### Nested Schema for `vnfs.nat` @@ -428,9 +448,11 @@ Read-Only: - `owner_id` (Number) - `owner_type` (String) - `pure_virtual` (Boolean) +- `routes` (List of Object) (see [below for nested schema](#nestedobjatt--vnfs--nat--routes)) - `status` (String) - `tech_status` (String) - `type` (String) +- `zone_id` (Number) ### Nested Schema for `vnfs.nat.config` @@ -472,3 +494,17 @@ Read-Only: - `dev_id` (Number) - `iface01` (String) - `iface02` (String) + + + + +### Nested Schema for `vnfs.nat.routes` + +Read-Only: + +- `compute_ids` (List of Number) +- `destination` (String) +- `gateway` (String) +- `guid` (String) +- `netmask` (String) +- `route_id` (Number) diff --git a/go.mod b/go.mod index f695b772..f03ca8fc 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,15 @@ module repository.basistech.ru/BASIS/terraform-provider-decort -go 1.20 +go 1.24.0 require ( - github.com/google/uuid v1.4.0 - github.com/hashicorp/terraform-plugin-docs v0.19.4 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 + github.com/google/uuid v1.6.0 + github.com/hashicorp/go-cty v1.5.0 + github.com/hashicorp/terraform-plugin-docs v0.24.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 github.com/sirupsen/logrus v1.9.0 - golang.org/x/net v0.23.0 - repository.basistech.ru/BASIS/decort-golang-sdk v1.12.1 + golang.org/x/net v0.44.0 + repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10 ) require ( @@ -17,45 +18,45 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.0 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect - github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect + github.com/ProtonMail/go-crypto v1.1.6 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect - github.com/cloudflare/circl v1.3.7 // indirect + github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect + github.com/cloudflare/circl v1.6.1 // indirect github.com/fatih/color v1.16.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/gabriel-vasile/mimetype v1.4.10 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.15.4 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-cmp v0.6.0 // indirect + github.com/go-playground/validator/v10 v10.28.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/go-cmp v0.7.0 // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/hashicorp/cli v1.1.6 // indirect + github.com/hashicorp/cli v1.1.7 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-plugin v1.7.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.7.0 // indirect - github.com/hashicorp/hc-install v0.7.0 // indirect - github.com/hashicorp/hcl/v2 v2.19.1 // indirect + github.com/hashicorp/hc-install v0.9.2 // indirect + github.com/hashicorp/hcl/v2 v2.24.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.21.0 // indirect - github.com/hashicorp/terraform-json v0.22.1 // indirect - github.com/hashicorp/terraform-plugin-go v0.22.0 // indirect + github.com/hashicorp/terraform-exec v0.24.0 // indirect + github.com/hashicorp/terraform-json v0.27.2 // indirect + github.com/hashicorp/terraform-plugin-go v0.29.0 // indirect github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect - github.com/hashicorp/terraform-registry-address v0.2.3 // indirect + github.com/hashicorp/terraform-registry-address v0.4.0 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect - github.com/hashicorp/yamux v0.1.1 // indirect + github.com/hashicorp/yamux v0.1.2 // indirect github.com/huandu/xstrings v1.4.0 // indirect github.com/imdario/mergo v0.3.15 // indirect - github.com/leodido/go-urn v1.2.4 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect @@ -70,19 +71,22 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/yuin/goldmark v1.7.1 // indirect + github.com/yuin/goldmark v1.7.7 // indirect github.com/yuin/goldmark-meta v1.1.0 // indirect - github.com/zclconf/go-cty v1.14.4 // indirect + github.com/zclconf/go-cty v1.17.0 // indirect go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect - golang.org/x/crypto v0.21.0 // indirect + go.uber.org/mock v0.6.0 // indirect + golang.org/x/crypto v0.42.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.15.0 // indirect + golang.org/x/mod v0.28.0 // indirect + golang.org/x/sync v0.17.0 // indirect + golang.org/x/sys v0.36.0 // indirect + golang.org/x/text v0.30.0 // indirect + golang.org/x/tools v0.37.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect - google.golang.org/grpc v1.61.1 // indirect - google.golang.org/protobuf v1.32.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect + google.golang.org/grpc v1.75.1 // indirect + google.golang.org/protobuf v1.36.9 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 54175227..c9956042 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0= @@ -9,9 +10,10 @@ github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7Y github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= -github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw= +github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= @@ -21,51 +23,66 @@ github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I= -github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= -github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= -github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= -github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/avrEXE= +github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw= +github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c= +github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0= +github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= +github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= +github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= +github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0= +github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM= +github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU= +github.com/go-git/go-git/v5 v5.14.0 h1:/MD3lCrGjCen5WfEAzKg00MJJffKhC8gzS80ycmCi60= +github.com/go-git/go-git/v5 v5.14.0/go.mod h1:Z5Xhoia5PcWA3NF8vRLURn9E5FRhSl7dGj9ItW3Wk5k= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs= -github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688= +github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/cli v1.1.6 h1:CMOV+/LJfL1tXCOKrgAX0uRKnzjj/mpmqNXloRSy2K8= -github.com/hashicorp/cli v1.1.6/go.mod h1:MPon5QYlgjjo0BSoAiN0ESeT5fRzDjVRp+uioJ0piz4= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/cli v1.1.7 h1:/fZJ+hNdwfTSfsxMBa9WWMlfjUZbX8/LnUxgAd7lCVU= +github.com/hashicorp/cli v1.1.7/go.mod h1:e6Mfpga9OCT1vqzFuoGZiiF/KaG9CbUfO5s3ghU3YgU= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -74,44 +91,46 @@ github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuD github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= -github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-cty v1.5.0 h1:EkQ/v+dDNUqnuVpmS5fPqyY71NXVgT5gf32+57xY8g0= +github.com/hashicorp/go-cty v1.5.0/go.mod h1:lFUCG5kd8exDobgSfyj4ONE/dc822kiYMguVKdHGMLM= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= -github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/go-plugin v1.7.0 h1:YghfQH/0QmPNc/AZMTFE3ac8fipZyZECHdDPshfk+mA= +github.com/hashicorp/go-plugin v1.7.0/go.mod h1:BExt6KEaIYx804z8k4gRzRLEvxKVb+kn0NMcihqOqb8= +github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= +github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= -github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= -github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= -github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/hashicorp/hc-install v0.9.2 h1:v80EtNX4fCVHqzL9Lg/2xkp62bbvQMnvPQ0G+OmtO24= +github.com/hashicorp/hc-install v0.9.2/go.mod h1:XUqBQNnuT4RsxoxiM9ZaUk0NX8hi2h+Lb6/c0OZnC/I= +github.com/hashicorp/hcl/v2 v2.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE= +github.com/hashicorp/hcl/v2 v2.24.0/go.mod h1:oGoO1FIQYfn/AgyOhlg9qLC6/nOJPX3qGbkZpYAcqfM= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ= -github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= -github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= -github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= -github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c= -github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA= -github.com/hashicorp/terraform-plugin-go v0.22.0 h1:1OS1Jk5mO0f5hrziWJGXXIxBrMe2j/B8E+DVGw43Xmc= -github.com/hashicorp/terraform-plugin-go v0.22.0/go.mod h1:mPULV91VKss7sik6KFEcEu7HuTogMLLO/EvWCuFkRVE= +github.com/hashicorp/terraform-exec v0.24.0 h1:mL0xlk9H5g2bn0pPF6JQZk5YlByqSqrO5VoaNtAf8OE= +github.com/hashicorp/terraform-exec v0.24.0/go.mod h1:lluc/rDYfAhYdslLJQg3J0oDqo88oGQAdHR+wDqFvo4= +github.com/hashicorp/terraform-json v0.27.2 h1:BwGuzM6iUPqf9JYM/Z4AF1OJ5VVJEEzoKST/tRDBJKU= +github.com/hashicorp/terraform-json v0.27.2/go.mod h1:GzPLJ1PLdUG5xL6xn1OXWIjteQRT2CNT9o/6A9mi9hE= +github.com/hashicorp/terraform-plugin-docs v0.24.0 h1:YNZYd+8cpYclQyXbl1EEngbld8w7/LPOm99GD5nikIU= +github.com/hashicorp/terraform-plugin-docs v0.24.0/go.mod h1:YLg+7LEwVmRuJc0EuCw0SPLxuQXw5mW8iJ5ml/kvi+o= +github.com/hashicorp/terraform-plugin-go v0.29.0 h1:1nXKl/nSpaYIUBU1IG/EsDOX0vv+9JxAltQyDMpq5mU= +github.com/hashicorp/terraform-plugin-go v0.29.0/go.mod h1:vYZbIyvxyy0FWSmDHChCqKvI40cFTDGSb3D8D70i9GM= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= -github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= -github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 h1:mlAq/OrMlg04IuJT7NpefI1wwtdpWudnEmjuQs04t/4= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1/go.mod h1:GQhpKVvvuwzD79e8/NZ+xzj+ZpWovdPAe8nfV/skwNU= +github.com/hashicorp/terraform-registry-address v0.4.0 h1:S1yCGomj30Sao4l5BMPjTGZmCNzuv7/GDTDX99E9gTk= +github.com/hashicorp/terraform-registry-address v0.4.0/go.mod h1:LRS1Ay0+mAiRkUyltGT+UHWkIqTFvigGn/LbMshfflE= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= -github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= -github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= +github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8= +github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns= github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= @@ -119,23 +138,26 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= +github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94= +github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= @@ -154,34 +176,35 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4= +github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= +github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -190,35 +213,54 @@ github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21 github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= -github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark v1.7.7 h1:5m9rrB1sW3JUMToKFQfb+FGt1U7r57IHu5GrYrG2nqU= +github.com/yuin/goldmark v1.7.7/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= -github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= -github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.17.0 h1:seZvECve6XX4tmnvRzWtJNHdscMtYEx5R7bnnVyd/d0= +github.com/zclconf/go-cty v1.17.0/go.mod h1:wqFzcImaLTI6A5HfsRwB0nj5n0MRZFwmey8YoFPPs3U= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw= go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= +go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= +go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= +go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= +go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= +go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= +go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= +go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= +go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= +go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI= +golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U= +golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= +golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= +golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -230,48 +272,51 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= +golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= +golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE= +golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= -google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY= -google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 h1:pFyd6EwwL2TqFf8emdthzeX+gZE1ElRq3iM8pui4KBY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI= +google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw= +google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -repository.basistech.ru/BASIS/decort-golang-sdk v1.12.1 h1:kd7P/A53hsIW2BttrbQ1fuHAYOsbWv8EKfElkPfl9qQ= -repository.basistech.ru/BASIS/decort-golang-sdk v1.12.1/go.mod h1:OaUynHHuSjWMzpfyoL4au6oLcUogqUkPPBKA15pbHWo= +repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10 h1:7RLk2Vjl6evKo4dLxlxiQCrRJSSlUwLztO3ZE/uBt+8= +repository.basistech.ru/BASIS/decort-golang-sdk v1.12.10/go.mod h1:S/f7GxwWcE88eFpORV+I9xqEf8zDW5srQHpG2XQCLZM= diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 226f3593..42faa5ce 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -36,6 +36,7 @@ import ( "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -430,3 +431,19 @@ func (config *ControllerCfg) CloudBroker() *cloudbroker.CloudBroker { return &cloudbroker.CloudBroker{} } } + +func (config *ControllerCfg) SDN() *sdn.SDN { + switch config.auth_mode_code { + case MODE_LEGACY: + client, _ := config.caller.(*decort.LegacyDecortClient) + return client.SDN() + case MODE_DECS3O: + client, _ := config.caller.(*decort.DecortClient) + return client.SDN() + case MODE_BVS: + client, _ := config.caller.(*decort.BVSDecortClient) + return client.SDN() + default: + return &sdn.SDN{} + } +} diff --git a/internal/provider/data_sources_map.go b/internal/provider/data_sources_map.go index b4bc89a6..13510628 100644 --- a/internal/provider/data_sources_map.go +++ b/internal/provider/data_sources_map.go @@ -35,13 +35,19 @@ import ( "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/rg" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/secgroup" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/sep" "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/stpolicy" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/trunk" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vfpool" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/zone" + accessgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/access_group" + defaultsecuritypolicy "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/default_security_policy" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/logicalports" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/segments" cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account" cb_audit "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/audit" @@ -58,8 +64,10 @@ import ( cb_node "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/node" 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_secgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/secgroup" 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_stpolicy "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/stpolicy" cb_trunk "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/trunk" cb_user "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/user" cb_vfpool "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vfpool" @@ -72,6 +80,7 @@ func newDataSourcesMap() map[string]*schema.Resource { return map[string]*schema.Resource{ "decort_account": account.DataSourceAccount(), "decort_audit": audit.DataSourceAudit(), + "decort_audit_list": audit.DataSourceAuditList(), "decort_resgroup": rg.DataSourceResgroup(), "decort_kvmvm": kvmvm.DataSourceCompute(), "decort_kvmvm_list": kvmvm.DataSourceComputeList(), @@ -165,6 +174,10 @@ func newDataSourcesMap() map[string]*schema.Resource { "decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(), "decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(), "decort_sep_and_pools_available_list": sep.DataSourceAvailableSEPAndPoolsList(), + "decort_storage_policy": stpolicy.DataSourceStoragePolicy(), + "decort_storage_policy_list": stpolicy.DataSourceStoragePolicyList(), + "decort_security_group": secgroup.DataSourceSecurityGroup(), + "decort_security_group_list": secgroup.DataSourceSecurityGroupList(), "decort_trunk": trunk.DataSourceTrunk(), "decort_trunk_list": trunk.DataSourceTrunkList(), "decort_zone": zone.DataSourceZone(), @@ -262,8 +275,12 @@ func newDataSourcesMap() map[string]*schema.Resource { "decort_cb_lb_list_deleted": cb_lb.DataSourceLBListDeleted(), "decort_cb_flipgroup_list": cb_flipgroup.DataSourceFlipgroupList(), "decort_cb_flipgroup": cb_flipgroup.DataSourceFlipgroup(), + "decort_cb_security_group": cb_secgroup.DataSourceSecurityGroup(), + "decort_cb_security_group_list": cb_secgroup.DataSourceSecurityGroupList(), "decort_cb_stack_list": cb_stack.DataSourceStacksList(), "decort_cb_stack": cb_stack.DataSourceStack(), + "decort_cb_storage_policy": cb_stpolicy.DataSourceStoragePolicy(), + "decort_cb_storage_policy_list": cb_stpolicy.DataSourceStoragePolicyList(), "decort_cb_trunk": cb_trunk.DataSourceTrunk(), "decort_cb_trunk_list": cb_trunk.DataSourceTrunkList(), "decort_cb_user": cb_user.DataSourceUser(), @@ -292,5 +309,17 @@ func newDataSourcesMap() map[string]*schema.Resource { "decort_cb_k8s_computes": cb_k8s.DataSourceK8sComputes(), "decort_cb_zone": cb_zone.DataSourceZone(), "decort_cb_zone_list": cb_zone.DataSourceZoneList(), + + "decort_sdn_access_group": accessgroup.DataSourceAccessGroup(), + "decort_sdn_access_group_list": accessgroup.DataSourceAccessGroupList(), + "decort_sdn_access_group_user_list": accessgroup.DataSourceAccessGroupUserList(), + "decort_sdn_default_security_policy_list": defaultsecuritypolicy.DataSourceDefaultSecurityPolicyList(), + "decort_sdn_segment": segments.DataSourceSegment(), + "decort_sdn_segment_list": segments.DataSourceSegmentList(), + "decort_sdn_segment_get_status": segments.DataSourceSegmentGetStatus(), + + "decort_sdn_logical_port": logicalports.DataSourceLogicalPort(), + "decort_sdn_logical_port_get_by_unique_identifier": logicalports.DataSourceLogicalPortByUniqueID(), + "decort_sdn_logical_port_list": logicalports.DataSourceLogicalPortList(), } } diff --git a/internal/provider/resource_map.go b/internal/provider/resource_map.go index f589d3d2..ff3d60cf 100644 --- a/internal/provider/resource_map.go +++ b/internal/provider/resource_map.go @@ -32,8 +32,12 @@ import ( "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/rg" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/secgroup" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins" + accessgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/access_group" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/logicalports" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/sdn/segments" 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" @@ -47,7 +51,9 @@ import ( cb_lb "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/lb" 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_secgroup "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/secgroup" cb_sep "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/sep" + cb_stpolicy "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/stpolicy" cb_trunk "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/trunk" cb_user "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/user" cb_vfpool "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/vfpool" @@ -82,6 +88,7 @@ func newResourcesMap() map[string]*schema.Resource { "decort_lb_frontend_bind": lb.ResourceLBFrontendBind(), "decort_flipgroup": flipgroup.ResourceFlipgroup(), "decort_vins_static_route": vins.ResourceStaticRoute(), + "decort_security_group": secgroup.ResourceSecurityGroup(), "decort_cb_account": cb_account.ResourceAccount(), "decort_cb_dpdknet": cb_dpdknet.ResourceDPDKNet(), @@ -111,9 +118,15 @@ func newResourcesMap() map[string]*schema.Resource { "decort_cb_lb_frontend": cb_lb.ResourceLBFrontend(), "decort_cb_lb_frontend_bind": cb_lb.ResourceLBFrontendBind(), "decort_cb_rg": cb_rg.ResourceResgroup(), + "decort_cb_storage_policy": cb_stpolicy.ResourceStoragePolicy(), + "decort_cb_security_group": cb_secgroup.ResourceSecurityGroup(), "decort_cb_trunk": cb_trunk.ResourceTrunk(), "decort_cb_user": cb_user.ResourceUser(), "decort_cb_vfpool": cb_vfpool.ResourceVFPool(), "decort_cb_zone": cb_zone.ResourceZone(), + + "decort_sdn_segment": segments.ResourceSegment(), + "decort_sdn_access_group": accessgroup.ResourceAccessGroup(), + "decort_sdn_logical_port": logicalports.ResourceLogicalPort(), } } diff --git a/internal/service/cloudapi/account/data_source_account.go b/internal/service/cloudapi/account/data_source_account.go index 3b3d8b11..bcc1d347 100644 --- a/internal/service/cloudapi/account/data_source_account.go +++ b/internal/service/cloudapi/account/data_source_account.go @@ -127,6 +127,22 @@ func resourceLimitsSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, } return res @@ -288,17 +304,6 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { // Schema: resourcesSchemaMake(), // }, // }, - "ckey": { - Type: schema.TypeString, - Computed: true, - }, - "meta": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, "zone_ids": { Type: schema.TypeList, Computed: true, @@ -388,10 +393,6 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, - "service_account": { - Type: schema.TypeBool, - Computed: true, - }, "status": { Type: schema.TypeString, Computed: true, @@ -437,6 +438,13 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, } return res } diff --git a/internal/service/cloudapi/account/data_source_account_get_resource_consumption.go b/internal/service/cloudapi/account/data_source_account_get_resource_consumption.go index b672116f..439c33d2 100644 --- a/internal/service/cloudapi/account/data_source_account_get_resource_consumption.go +++ b/internal/service/cloudapi/account/data_source_account_get_resource_consumption.go @@ -116,6 +116,22 @@ func dataSourceResourceLimitsSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, } return res diff --git a/internal/service/cloudapi/account/data_source_account_list.go b/internal/service/cloudapi/account/data_source_account_list.go index c1d2bf7b..e2d7c265 100644 --- a/internal/service/cloudapi/account/data_source_account_list.go +++ b/internal/service/cloudapi/account/data_source_account_list.go @@ -55,6 +55,7 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} { "account_name": acc.Name, "status": acc.Status, "updated_time": acc.UpdatedTime, + "zone_ids": acc.ZoneIDs, } res = append(res, temp) } @@ -129,6 +130,11 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, @@ -201,6 +207,13 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "zone_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, }, }, }, diff --git a/internal/service/cloudapi/account/data_source_account_resource_consumption_list.go b/internal/service/cloudapi/account/data_source_account_resource_consumption_list.go index 120f9ec4..99ab961a 100644 --- a/internal/service/cloudapi/account/data_source_account_resource_consumption_list.go +++ b/internal/service/cloudapi/account/data_source_account_resource_consumption_list.go @@ -139,6 +139,35 @@ func dataSourceAccResourceSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + + "policies": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "disk_size": { + Type: schema.TypeFloat, + Computed: true, + }, + "disk_size_max": { + Type: schema.TypeFloat, + Computed: true, + }, + "seps": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: dataSourceSepsSchemaMake(), + }, + }, + }, + }, + }, + "ram": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudapi/account/flattens.go b/internal/service/cloudapi/account/flattens.go index 5703ad00..fcab67e3 100644 --- a/internal/service/cloudapi/account/flattens.go +++ b/internal/service/cloudapi/account/flattens.go @@ -8,8 +8,8 @@ import ( func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error { d.Set("dc_location", acc.DCLocation) d.Set("desc", acc.Description) + //TODO // d.Set("resources", flattenAccResources(acc.Resources)) - d.Set("ckey", acc.CKey) d.Set("acl", flattenAccAcl(acc.ACL)) d.Set("company", acc.Company) d.Set("companyurl", acc.CompanyURL) @@ -37,6 +37,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error { d.Set("cpu_allocation_parameter", acc.CPUAllocationParameter) d.Set("cpu_allocation_ratio", acc.CPUAllocationRatio) d.Set("default_zone_id", acc.DefaultZoneID) + d.Set("storage_policy_ids", acc.StoragePolicyIDs) d.Set("zone_ids", flattenZones(acc.ZoneIDs)) if username, ok := d.GetOk("username"); ok { @@ -48,6 +49,44 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error { return nil } +func flattenAccountResource(d *schema.ResourceData, acc account.RecordAccount) error { + d.Set("dc_location", acc.DCLocation) + d.Set("desc", acc.Description) + //TODO + // d.Set("resources", flattenAccResources(acc.Resources)) + d.Set("acl", flattenAccAcl(acc.ACL)) + d.Set("company", acc.Company) + d.Set("companyurl", acc.CompanyURL) + d.Set("compute_features", acc.ComputeFeatures) + d.Set("created_by", acc.CreatedBy) + d.Set("created_time", acc.CreatedTime) + d.Set("deactivation_time", acc.DeactivationTime) + d.Set("desc", acc.Description) + d.Set("deleted_by", acc.DeletedBy) + d.Set("deleted_time", acc.DeletedTime) + d.Set("displayname", acc.DisplayName) + d.Set("enable", flattenEnabled(acc.Status)) + d.Set("guid", acc.GUID) + d.Set("account_id", acc.ID) + d.Set("account_name", acc.Name) + d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits)) + d.Set("send_access_emails", acc.SendAccessEmails) + d.Set("status", acc.Status) + d.Set("updated_time", acc.UpdatedTime) + d.Set("version", acc.Version) + d.Set("vins", acc.VINS) + d.Set("vinses", acc.VINSes) + d.Set("computes", flattenAccComputes(acc.Computes)) + d.Set("machines", flattenAccMachines(acc.Machines)) + d.Set("cpu_allocation_parameter", acc.CPUAllocationParameter) + d.Set("cpu_allocation_ratio", acc.CPUAllocationRatio) + d.Set("default_zone_id", acc.DefaultZoneID) + d.Set("storage_policy_ids", acc.StoragePolicyIDs) + d.Set("zone_ids", flattenZonesInResource(acc.ZoneIDs)) + + return nil +} + func flattenEnabled(status string) bool { return status == "CONFIRMED" } @@ -100,20 +139,32 @@ func flattenResourceConsumption(d *schema.ResourceData, acc *account.RecordResou func flattenAccResourceLimits(rl account.ResourceLimits) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "cu_c": rl.CUC, - "cu_d": rl.CUD, - "cu_dm": rl.CUDM, - "cu_i": rl.CUI, - "cu_m": rl.CUM, - "cu_np": rl.CUNP, - "gpu_units": rl.GPUUnits, + "cu_c": rl.CUC, + "cu_d": rl.CUD, + "cu_dm": rl.CUDM, + "cu_i": rl.CUI, + "cu_m": rl.CUM, + "cu_np": rl.CUNP, + "gpu_units": rl.GPUUnits, + "storage_policy": flattenSTPolicy(rl.StoragePolicy), } res = append(res, temp) - return res } +func flattenSTPolicy(ast []account.StoragePolicyItem) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(ast)) + for _, item := range ast { + temp := map[string]interface{}{ + "id": item.ID, + "limit": item.Limit, + } + res = append(res, temp) + } + return res +} + // func flattenAccResources(r account.Resources) []map[string]interface{} { // res := make([]map[string]interface{}, 0) // temp := map[string]interface{}{ @@ -151,11 +202,26 @@ func flattenAccResource(r account.Resource) []map[string]interface{} { "gpu": r.GPU, "ram": r.RAM, "seps": flattenAccountSeps(r.SEPs), + "policies": flattenAccountPolicies(r.Policies), } res = append(res, temp) return res } +func flattenAccountPolicies(policies map[string]account.Policy) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + for k, dataVal := range policies { + temp := map[string]interface{}{ + "id": k, + "disk_size": dataVal.DiskSize, + "disk_size_max": dataVal.DiskSizeMax, + "seps": flattenAccountSeps(dataVal.SEPs), + } + res = append(res, temp) + } + return res +} + func flattenAccResourceConsumption(lrc *account.ListResourceConsumption) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(lrc.Data)) for _, rc := range lrc.Data { @@ -180,3 +246,11 @@ func flattenZones(zones []account.ZoneID) []map[string]interface{} { } return res } + +func flattenZonesInResource(zones []account.ZoneID) []int64 { + res := make([]int64, 0) + for _, zone := range zones { + res = append(res, zone.ID) + } + return res +} diff --git a/internal/service/cloudapi/account/resource_account.go b/internal/service/cloudapi/account/resource_account.go index ef4d879c..9e6595d8 100644 --- a/internal/service/cloudapi/account/resource_account.go +++ b/internal/service/cloudapi/account/resource_account.go @@ -100,7 +100,7 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interfac } } - flattenAccount(d, *acc) + flattenAccountResource(d, *acc) return nil } @@ -495,7 +495,6 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { }, "zone_ids": { Type: schema.TypeList, - Optional: true, Computed: true, Elem: &schema.Schema{ Type: schema.TypeInt, @@ -535,6 +534,10 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Optional: true, Computed: true, }, + "cu_dm": { + Type: schema.TypeFloat, + Computed: true, + }, "cu_i": { Type: schema.TypeFloat, Optional: true, @@ -555,6 +558,22 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Optional: true, Computed: true, }, + "storage_policy": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -573,17 +592,6 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { // Schema: resourcesSchemaMake(), // }, // }, - "ckey": { - Type: schema.TypeString, - Computed: true, - }, - // "meta": { - // Type: schema.TypeList, - // Computed: true, - // Elem: &schema.Schema{ - // Type: schema.TypeString, - // }, - // }, "acl": { Type: schema.TypeList, Computed: true, @@ -634,10 +642,6 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, - "service_account": { - Type: schema.TypeBool, - Computed: true, - }, "status": { Type: schema.TypeString, Computed: true, @@ -683,6 +687,13 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, } } diff --git a/internal/service/cloudapi/account/utility_account_list.go b/internal/service/cloudapi/account/utility_account_list.go index f483a316..48a68d10 100644 --- a/internal/service/cloudapi/account/utility_account_list.go +++ b/internal/service/cloudapi/account/utility_account_list.go @@ -73,6 +73,10 @@ func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData req.SortBy = sortBy.(string) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } + log.Debugf("utilityAccountListCheckPresence: load account list") accountList, err := c.CloudAPI().Account().List(ctx, req) if err != nil { diff --git a/internal/service/cloudapi/audit/data_source_audit.go b/internal/service/cloudapi/audit/data_source_audit.go index bc31a4dd..e7f8145b 100644 --- a/internal/service/cloudapi/audit/data_source_audit.go +++ b/internal/service/cloudapi/audit/data_source_audit.go @@ -75,7 +75,7 @@ func dataSourceAuditSchemaMake() map[string]*schema.Schema { Required: true, Description: "audit guid", }, - + "args": { Type: schema.TypeString, Computed: true, @@ -84,6 +84,10 @@ func dataSourceAuditSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "correlation_id": { + Type: schema.TypeString, + Computed: true, + }, "guid": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/cloudapi/audit/data_source_audit_list.go b/internal/service/cloudapi/audit/data_source_audit_list.go new file mode 100644 index 00000000..fe5cb753 --- /dev/null +++ b/internal/service/cloudapi/audit/data_source_audit_list.go @@ -0,0 +1,244 @@ +/* +Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Sergey Kisil, + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud +Orchestration Technology) with Terraform by Hashicorp. + +Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki +*/ + +package audit + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceAuditListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + auditList, err := utilityAuditListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenAuditList(auditList)) + d.Set("entry_count", auditList.EntryCount) + + return nil +} + +func DataSourceAuditList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceAuditListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceAuditListSchemaMake(), + } +} + +func dataSourceAuditListSchemaMake() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "timestamp_at": { + Type: schema.TypeInt, + Optional: true, + Description: "find all audits after point in time (unixtime)", + }, + "timestamp_to": { + Type: schema.TypeInt, + Optional: true, + Description: "find all audits before point in time (unixtime)", + }, + "user": { + Type: schema.TypeString, + Optional: true, + Description: "find by user (Mongo RegExp supported)", + }, + "call": { + Type: schema.TypeString, + Optional: true, + Description: "find by api endpoint (Mongo RegExp supported)", + }, + "min_status_code": { + Type: schema.TypeInt, + Optional: true, + Description: "find by HTTP min status code", + }, + "max_status_code": { + Type: schema.TypeInt, + Optional: true, + Description: "find by HTTP max status code", + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + Description: "sort by one of supported fields, format +|-(field)", + }, + "page": { + Type: schema.TypeInt, + Optional: true, + Description: "page number", + }, + "request_id": { + Type: schema.TypeString, + Optional: true, + Description: "request id", + }, + "size": { + Type: schema.TypeInt, + Optional: true, + Description: "page size", + }, + "resgroup_id": { + Type: schema.TypeInt, + Optional: true, + }, + "compute_id": { + Type: schema.TypeInt, + Optional: true, + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + }, + "vins_id": { + Type: schema.TypeInt, + Optional: true, + }, + "service_id": { + Type: schema.TypeInt, + Optional: true, + }, + "k8s_id": { + Type: schema.TypeInt, + Optional: true, + }, + "flipgroup_id": { + Type: schema.TypeInt, + Optional: true, + }, + "lb_id": { + Type: schema.TypeInt, + Optional: true, + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + }, + "exclude_audit_lines": { + Type: schema.TypeBool, + Optional: true, + }, + "items": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeInt, + Computed: true, + }, + "compute_id": { + Type: schema.TypeInt, + Computed: true, + }, + "resgroup_id": { + Type: schema.TypeInt, + Computed: true, + }, + "call": { + Type: schema.TypeString, + Computed: true, + }, + "correlation_id": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "responsetime": { + Type: schema.TypeFloat, + Computed: true, + }, + "status_code": { + Type: schema.TypeInt, + Computed: true, + }, + "timestamp": { + Type: schema.TypeFloat, + Computed: true, + }, + "user": { + Type: schema.TypeString, + Computed: true, + }, + "ttl": { + Type: schema.TypeString, + Computed: true, + }, + "args": { + Type: schema.TypeString, + Computed: true, + }, + "kwargs": { + Type: schema.TypeString, + Computed: true, + }, + "result": { + Type: schema.TypeString, + Computed: true, + }, + "timestamp_end": { + Type: schema.TypeFloat, + Computed: true, + }, + "remote_addr": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "entry_count": { + Type: schema.TypeInt, + Computed: true, + Description: "entry count", + }, + } +} diff --git a/internal/service/cloudapi/audit/flattens.go b/internal/service/cloudapi/audit/flattens.go index fd2117c8..c51bfaf1 100644 --- a/internal/service/cloudapi/audit/flattens.go +++ b/internal/service/cloudapi/audit/flattens.go @@ -43,6 +43,7 @@ func flattenAudit(d *schema.ResourceData, au *audit.RecordAudit) { d.Set("args", au.Arguments) d.Set("call", au.Call) + d.Set("correlation_id", au.CorrelationID) d.Set("guid", au.GUID) d.Set("kwargs", au.Kwargs) d.Set("remote_addr", au.RemoteAddr) @@ -54,3 +55,26 @@ func flattenAudit(d *schema.ResourceData, au *audit.RecordAudit) { d.Set("timestamp_end", au.TimestampEnd) d.Set("user", au.User) } + +func flattenAuditList(au *audit.ListAudits) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(au.Data)) + for _, item := range au.Data { + temp := map[string]interface{}{ + "args": item.Args, + "call": item.Call, + "correlation_id": item.CorrelationID, + "guid": item.GUID, + "kwargs": item.Kwargs, + "remote_addr": item.RemoteAddr, + "result": item.Result, + "responsetime": item.ResponseTime, + "status_code": item.StatusCode, + "timestamp": item.Timestamp, + "timestamp_end": item.TimestampEnd, + "ttl": item.TTL, + "user": item.User, + } + res = append(res, temp) + } + return res +} diff --git a/internal/service/cloudapi/audit/utility_audit_list.go b/internal/service/cloudapi/audit/utility_audit_list.go new file mode 100644 index 00000000..fe099a56 --- /dev/null +++ b/internal/service/cloudapi/audit/utility_audit_list.go @@ -0,0 +1,117 @@ +/* +Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Sergey Kisil, + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud +Orchestration Technology) with Terraform by Hashicorp. + +Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki +*/ + +package audit + +import ( + "context" + + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/audit" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func utilityAuditListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*audit.ListAudits, error) { + c := m.(*controller.ControllerCfg) + req := audit.ListRequest{} + + if timestampAt, ok := d.GetOk("timestamp_at"); ok { + req.TimestampAt = uint64(timestampAt.(int)) + } + if timestampTo, ok := d.GetOk("timestamp_to"); ok { + req.TimestampTo = uint64(timestampTo.(int)) + } + if user, ok := d.GetOk("user"); ok { + req.User = user.(string) + } + if call, ok := d.GetOk("call"); ok { + req.Call = call.(string) + } + if minStatusCode, ok := d.GetOk("min_status_code"); ok { + req.MinStatusCode = uint64(minStatusCode.(int)) + } + if maxStatusCode, ok := d.GetOk("max_status_code"); ok { + req.MaxStatusCode = uint64(maxStatusCode.(int)) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if Page, ok := d.GetOk("page"); ok { + req.Page = uint64(Page.(int)) + } + if RequestID, ok := d.GetOk("request_id"); ok { + req.RequestID = RequestID.(string) + } + if Size, ok := d.GetOk("size"); ok { + req.Size = uint64(Size.(int)) + } + if resgroupID, ok := d.GetOk("resgroup_id"); ok { + req.RGID = uint64(resgroupID.(int)) + } + if computeID, ok := d.GetOk("compute_id"); ok { + req.ComputeID = uint64(computeID.(int)) + } + if accountID, ok := d.GetOk("account_id"); ok { + req.AccountID = uint64(accountID.(int)) + } + if vinsID, ok := d.GetOk("vins_id"); ok { + req.VINSID = uint64(vinsID.(int)) + } + if serviceID, ok := d.GetOk("service_id"); ok { + req.ServiceID = uint64(serviceID.(int)) + } + if k8sID, ok := d.GetOk("k8s_id"); ok { + req.K8SID = uint64(k8sID.(int)) + } + if flipgroupID, ok := d.GetOk("flipgroup_id"); ok { + req.FLIPGroupID = uint64(flipgroupID.(int)) + } + if lbID, ok := d.GetOk("lb_id"); ok { + req.LBID = uint64(lbID.(int)) + } + if sepID, ok := d.GetOk("sep_id"); ok { + req.SEPID = uint64(sepID.(int)) + } + if excludeAuditLines, ok := d.GetOk("exclude_audit_lines"); ok { + req.ExcludeAuditLines = excludeAuditLines.(bool) + } + + log.Debugf("utilityAuditListCheckPresence: load audit list") + auditList, err := c.CloudAPI().Audit().List(ctx, req) + if err != nil { + return nil, err + } + + return auditList, nil +} diff --git a/internal/service/cloudapi/bservice/data_source_bservice_list.go b/internal/service/cloudapi/bservice/data_source_bservice_list.go index 7a98fad0..0974b53a 100644 --- a/internal/service/cloudapi/bservice/data_source_bservice_list.go +++ b/internal/service/cloudapi/bservice/data_source_bservice_list.go @@ -147,6 +147,11 @@ func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudapi/bservice/resource_bservice_group.go b/internal/service/cloudapi/bservice/resource_bservice_group.go index 11bc9f87..4dd24a54 100644 --- a/internal/service/cloudapi/bservice/resource_bservice_group.go +++ b/internal/service/cloudapi/bservice/resource_bservice_group.go @@ -51,14 +51,15 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData c := m.(*controller.ControllerCfg) req := bservice.GroupAddRequest{ - ServiceID: uint64(d.Get("service_id").(int)), - Name: d.Get("compgroup_name").(string), - Count: uint64(d.Get("comp_count").(int)), - CPU: uint64(d.Get("cpu").(int)), - RAM: uint64(d.Get("ram").(int)), - Disk: uint64(d.Get("disk").(int)), - ImageID: uint64(d.Get("image_id").(int)), - Driver: d.Get("driver").(string), + ServiceID: uint64(d.Get("service_id").(int)), + Name: d.Get("compgroup_name").(string), + Count: uint64(d.Get("comp_count").(int)), + CPU: uint64(d.Get("cpu").(int)), + RAM: uint64(d.Get("ram").(int)), + Disk: uint64(d.Get("disk").(int)), + ImageID: uint64(d.Get("image_id").(int)), + Driver: d.Get("driver").(string), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } if role, ok := d.GetOk("role"); ok { @@ -396,10 +397,10 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema { Required: true, Description: "OS image ID to create computes from", }, - "driver": { - Type: schema.TypeString, + "storage_policy_id": { + Type: schema.TypeInt, Required: true, - Description: "compute driver like a KVM_X86, etc.", + Description: "storage policy id of compute. The rules of the specified storage policy will be used.", }, ///4.4.0 "sep_id": { @@ -425,6 +426,12 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema { ValidateFunc: validation.StringInSlice([]string{"i440fx", "Q35"}, false), Default: "i440fx", }, + "driver": { + Type: schema.TypeString, + Optional: true, + Description: "compute driver like a KVM_X86, etc.", + Default: "KVM_X86", + }, /// "role": { Type: schema.TypeString, diff --git a/internal/service/cloudapi/bservice/utility_bservice_list.go b/internal/service/cloudapi/bservice/utility_bservice_list.go index 5bb17844..8519d276 100644 --- a/internal/service/cloudapi/bservice/utility_bservice_list.go +++ b/internal/service/cloudapi/bservice/utility_bservice_list.go @@ -85,6 +85,9 @@ func utilityBasicServiceListCheckPresence(ctx context.Context, d *schema.Resourc if acc_name, ok := d.GetOk("account_name"); ok { req.AccountName = acc_name.(string) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } log.Debugf("utilityBasicServiceListCheckPresence") basicServiceList, err := c.CloudAPI().BService().List(ctx, req) diff --git a/internal/service/cloudapi/disks/data_source_disk.go b/internal/service/cloudapi/disks/data_source_disk.go index f569b9a6..86feb8c0 100644 --- a/internal/service/cloudapi/disks/data_source_disk.go +++ b/internal/service/cloudapi/disks/data_source_disk.go @@ -439,6 +439,11 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Disk status", }, + "storage_policy_id": { + Type: schema.TypeFloat, + Computed: true, + Description: "Storage policy ID", + }, "tech_status": { Type: schema.TypeString, Computed: true, @@ -462,6 +467,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, } return rets diff --git a/internal/service/cloudapi/disks/data_source_disk_list.go b/internal/service/cloudapi/disks/data_source_disk_list.go index 4cf849c2..776efec2 100644 --- a/internal/service/cloudapi/disks/data_source_disk_list.go +++ b/internal/service/cloudapi/disks/data_source_disk_list.go @@ -123,6 +123,11 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "storage_policy_id": { + Type: schema.TypeInt, + Optional: true, + Description: "storage policy ID ", + }, "items": { Type: schema.TypeList, Computed: true, @@ -508,6 +513,11 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Disk status", }, + "storage_policy_id": { + Type: schema.TypeFloat, + Computed: true, + Description: "Storage policy ID", + }, "tech_status": { Type: schema.TypeString, Computed: true, @@ -531,6 +541,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudapi/disks/data_source_disk_list_unattached.go b/internal/service/cloudapi/disks/data_source_disk_list_unattached.go index ecb9a80c..f73a178e 100644 --- a/internal/service/cloudapi/disks/data_source_disk_list_unattached.go +++ b/internal/service/cloudapi/disks/data_source_disk_list_unattached.go @@ -128,6 +128,11 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "storage_policy_id": { + Type: schema.TypeInt, + Optional: true, + Description: "storage policy ID ", + }, "items": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudapi/disks/data_source_list_deleted.go b/internal/service/cloudapi/disks/data_source_list_deleted.go index a2a10ffc..f45a712c 100644 --- a/internal/service/cloudapi/disks/data_source_list_deleted.go +++ b/internal/service/cloudapi/disks/data_source_list_deleted.go @@ -494,6 +494,11 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Disk status", }, + "storage_policy_id": { + Type: schema.TypeFloat, + Computed: true, + Description: "Storage policy ID", + }, "tech_status": { Type: schema.TypeString, Computed: true, @@ -517,6 +522,10 @@ func dataSourceDiskDeletedListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudapi/disks/flattens.go b/internal/service/cloudapi/disks/flattens.go index 522e4f7e..8e51249f 100644 --- a/internal/service/cloudapi/disks/flattens.go +++ b/internal/service/cloudapi/disks/flattens.go @@ -120,11 +120,13 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("shareable", disk.Shareable) d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots)) d.Set("status", disk.Status) + d.Set("storage_policy_id", disk.StoragePolicyID) d.Set("tech_status", disk.TechStatus) d.Set("type", disk.Type) d.Set("vmid", disk.VMID) d.Set("updated_by", disk.UpdatedBy) d.Set("updated_time", disk.UpdatedTime) + d.Set("to_clean", disk.ToClean) } func flattenDiskReplication(rep disks.ItemReplication) []map[string]interface{} { @@ -214,50 +216,52 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { for _, disk := range dl.Data { diskAcl, _ := json.Marshal(disk.ACL) temp := map[string]interface{}{ - "account_id": disk.AccountID, - "account_name": disk.AccountName, - "acl": string(diskAcl), - "computes": flattenDiskComputes(disk.Computes), - "created_by": disk.CreatedBy, - "created_time": disk.CreatedTime, - "deleted_by": disk.DeletedBy, - "deleted_time": disk.DeletedTime, - "desc": disk.Description, - "destruction_time": disk.DestructionTime, - "devicename": disk.DeviceName, - "gid": disk.GID, - "disk_id": disk.ID, - "image_id": disk.ImageID, - "images": disk.Images, - "iotune": flattenIOTune(disk.IOTune), - "machine_id": disk.MachineID, - "machine_name": disk.MachineName, - "milestones": disk.Milestones, - "disk_name": disk.Name, - "order": disk.Order, - "params": disk.Params, - "parent_id": disk.ParentID, - "pci_slot": disk.PCISlot, - "pool": disk.Pool, - "present_to": disk.PresentTo, - "purge_time": disk.PurgeTime, - "replication": flattenDiskReplication(disk.Replication), - "res_id": disk.ResID, - "res_name": disk.ResName, - "role": disk.Role, - "sep_id": disk.SepID, - "sep_type": disk.SepType, - "shareable": disk.Shareable, - "size_available": disk.SizeAvailable, - "size_max": disk.SizeMax, - "size_used": disk.SizeUsed, - "snapshots": flattenDiskSnapshotList(disk.Snapshots), - "status": disk.Status, - "tech_status": disk.TechStatus, - "type": disk.Type, - "vmid": disk.VMID, - "updated_by": disk.UpdatedBy, - "updated_time": disk.UpdatedTime, + "account_id": disk.AccountID, + "account_name": disk.AccountName, + "acl": string(diskAcl), + "computes": flattenDiskComputes(disk.Computes), + "created_by": disk.CreatedBy, + "created_time": disk.CreatedTime, + "deleted_by": disk.DeletedBy, + "deleted_time": disk.DeletedTime, + "desc": disk.Description, + "destruction_time": disk.DestructionTime, + "devicename": disk.DeviceName, + "gid": disk.GID, + "disk_id": disk.ID, + "image_id": disk.ImageID, + "images": disk.Images, + "iotune": flattenIOTune(disk.IOTune), + "machine_id": disk.MachineID, + "machine_name": disk.MachineName, + "milestones": disk.Milestones, + "disk_name": disk.Name, + "order": disk.Order, + "params": disk.Params, + "parent_id": disk.ParentID, + "pci_slot": disk.PCISlot, + "pool": disk.Pool, + "present_to": disk.PresentTo, + "purge_time": disk.PurgeTime, + "replication": flattenDiskReplication(disk.Replication), + "res_id": disk.ResID, + "res_name": disk.ResName, + "role": disk.Role, + "sep_id": disk.SepID, + "sep_type": disk.SepType, + "shareable": disk.Shareable, + "size_available": disk.SizeAvailable, + "size_max": disk.SizeMax, + "size_used": disk.SizeUsed, + "snapshots": flattenDiskSnapshotList(disk.Snapshots), + "status": disk.Status, + "storage_policy_id": disk.StoragePolicyID, + "tech_status": disk.TechStatus, + "type": disk.Type, + "vmid": disk.VMID, + "updated_by": disk.UpdatedBy, + "updated_time": disk.UpdatedTime, + "to_clean": disk.ToClean, } res = append(res, temp) } diff --git a/internal/service/cloudapi/disks/resource_disk.go b/internal/service/cloudapi/disks/resource_disk.go index 11aae807..f6be06e4 100644 --- a/internal/service/cloudapi/disks/resource_disk.go +++ b/internal/service/cloudapi/disks/resource_disk.go @@ -62,6 +62,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface req.AccountID = uint64(d.Get("account_id").(int)) req.Name = d.Get("disk_name").(string) + req.StoragePolicyID = uint64(d.Get("storage_policy_id").(int)) req.Size = uint64(d.Get("size_max").(int)) if sepId, ok := d.GetOk("sep_id"); ok { @@ -235,6 +236,18 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface } } + if d.HasChange("storage_policy_id") { + req := disks.ChangeDiskStoragePolicyRequest{ + DiskID: disk.ID, + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), + } + + _, err := c.CloudAPI().Disks().ChangeDiskStoragePolicy(ctx, req) + if err != nil { + return diag.FromErr(err) + } + } + if d.HasChange("size_max") { oldSize, newSize := d.GetChange("size_max") if oldSize.(int) < newSize.(int) { @@ -353,6 +366,11 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { //ForceNew: true, Description: "The unique ID of the subscriber-owner of the disk", }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID storage policy under which the disk will be created", + }, "created_by": { Type: schema.TypeString, Computed: true, @@ -776,6 +794,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, } return rets diff --git a/internal/service/cloudapi/disks/utility_disk_list.go b/internal/service/cloudapi/disks/utility_disk_list.go index eab6d699..951cffd7 100644 --- a/internal/service/cloudapi/disks/utility_disk_list.go +++ b/internal/service/cloudapi/disks/utility_disk_list.go @@ -86,6 +86,9 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok { + req.StoragePolicyID = uint64(storagePolicyID.(int)) + } log.Debugf("utilityDiskListCheckPresence: load disk list") diskList, err := c.CloudAPI().Disks().List(ctx, req) diff --git a/internal/service/cloudapi/disks/utility_disk_list_unattached.go b/internal/service/cloudapi/disks/utility_disk_list_unattached.go index 8c9f59cb..d640c41d 100644 --- a/internal/service/cloudapi/disks/utility_disk_list_unattached.go +++ b/internal/service/cloudapi/disks/utility_disk_list_unattached.go @@ -46,6 +46,9 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok { + req.StoragePolicyID = uint64(storagePolicyID.(int)) + } log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list") unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req) diff --git a/internal/service/cloudapi/extnet/data_source_extnet_list.go b/internal/service/cloudapi/extnet/data_source_extnet_list.go index 46f3e494..cc16db24 100644 --- a/internal/service/cloudapi/extnet/data_source_extnet_list.go +++ b/internal/service/cloudapi/extnet/data_source_extnet_list.go @@ -112,6 +112,11 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Name of the openVswitch bridge", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudapi/extnet/utility_extnet_list.go b/internal/service/cloudapi/extnet/utility_extnet_list.go index c9a39bd7..902720b2 100644 --- a/internal/service/cloudapi/extnet/utility_extnet_list.go +++ b/internal/service/cloudapi/extnet/utility_extnet_list.go @@ -76,10 +76,12 @@ func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData, if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } - if ovsBridge, ok := d.GetOk("ovs_bridge"); ok { req.OVSBridge = ovsBridge.(string) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } log.Debugf("utilityExtnetListCheckPresence") extnetList, err := c.CloudAPI().ExtNet().List(ctx, req) diff --git a/internal/service/cloudapi/image/data_source_image_list.go b/internal/service/cloudapi/image/data_source_image_list.go index 025f5cbb..9ff16046 100644 --- a/internal/service/cloudapi/image/data_source_image_list.go +++ b/internal/service/cloudapi/image/data_source_image_list.go @@ -127,6 +127,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "page number", }, + "storage_policy_id": { + Type: schema.TypeInt, + Optional: true, + }, "size": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/cloudapi/image/flattens.go b/internal/service/cloudapi/image/flattens.go index 376db113..eb52215b 100644 --- a/internal/service/cloudapi/image/flattens.go +++ b/internal/service/cloudapi/image/flattens.go @@ -60,7 +60,9 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) { d.Set("size", img.Size) d.Set("snapshot_id", img.SnapshotID) d.Set("status", img.Status) + d.Set("storage_policy_id", img.StoragePolicyID) d.Set("tech_status", img.TechStatus) + d.Set("to_clean", img.ToClean) d.Set("type", img.Type) d.Set("username", img.Username) d.Set("version", img.Version) @@ -86,6 +88,7 @@ func flattenImageList(il *image.ListImages) []map[string]interface{} { "sep_id": img.SepID, "size": img.Size, "status": img.Status, + "storage_policy_id": img.StoragePolicyID, "type": img.Type, "username": img.Username, "virtual": img.Virtual, diff --git a/internal/service/cloudapi/image/image_ds_subresource.go b/internal/service/cloudapi/image/image_ds_subresource.go index 26d5a4a0..7e353aa7 100644 --- a/internal/service/cloudapi/image/image_ds_subresource.go +++ b/internal/service/cloudapi/image/image_ds_subresource.go @@ -206,10 +206,18 @@ func dataSourceImageExtendSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_id": { + Type: schema.TypeInt, + Computed: true, + }, "tech_status": { Type: schema.TypeString, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, "type": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/cloudapi/image/image_item_subresource.go b/internal/service/cloudapi/image/image_item_subresource.go index 65f7a109..a6cdb2ab 100644 --- a/internal/service/cloudapi/image/image_item_subresource.go +++ b/internal/service/cloudapi/image/image_item_subresource.go @@ -1,137 +1,141 @@ -/* -Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. -Authors: -Petr Krutov, -Stanislav Solovev, -Kasim Baybikov, - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/* -Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud -Orchestration Technology) with Terraform by Hashicorp. - -Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort - -Please see README.md to learn where to place source code so that it -builds seamlessly. - -Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki -*/ - -package image - -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - -func dataSourceImageSchemaMake() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "account_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Owner account id", - }, - "architecture": { - Type: schema.TypeString, - Computed: true, - Description: "Image architecture", - }, - "boot_type": { - Type: schema.TypeString, - Computed: true, - Description: "Boot image type", - }, - "bootable": { - Type: schema.TypeBool, - Computed: true, - Description: "Flag, true if image is bootable, otherwise - false", - }, - "cdrom": { - Type: schema.TypeBool, - Computed: true, - Description: "Flag, true if image is cdrom image, otherwise - false", - }, - "desc": { - Type: schema.TypeString, - Computed: true, - Description: "Image description", - }, - "drivers": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Description: "Image drivers", - }, - "hot_resize": { - Type: schema.TypeBool, - Computed: true, - Description: "Flag, true if image supports hot resize, else if not", - }, - "image_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Image id", - }, - "link_to": { - Type: schema.TypeInt, - Computed: true, - Description: "For virtual images, id image, which current image linked", - }, - "image_name": { - Type: schema.TypeString, - Computed: true, - Description: "Image name", - }, - "network_interface_naming": { - Type: schema.TypeString, - Computed: true, - }, - "pool_name": { - Type: schema.TypeString, - Computed: true, - Description: "Image pool", - }, - "sep_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Image storage endpoint id", - }, - "size": { - Type: schema.TypeInt, - Computed: true, - Description: "Image size", - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "Image status", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Image type", - }, - "username": { - Type: schema.TypeString, - Computed: true, - Description: "username", - }, - "virtual": { - Type: schema.TypeBool, - Computed: true, - Description: "True if image is virtula, otherwise - else", - }, - } -} +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, +Kasim Baybikov, + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud +Orchestration Technology) with Terraform by Hashicorp. + +Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki +*/ + +package image + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func dataSourceImageSchemaMake() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Owner account id", + }, + "architecture": { + Type: schema.TypeString, + Computed: true, + Description: "Image architecture", + }, + "boot_type": { + Type: schema.TypeString, + Computed: true, + Description: "Boot image type", + }, + "bootable": { + Type: schema.TypeBool, + Computed: true, + Description: "Flag, true if image is bootable, otherwise - false", + }, + "cdrom": { + Type: schema.TypeBool, + Computed: true, + Description: "Flag, true if image is cdrom image, otherwise - false", + }, + "desc": { + Type: schema.TypeString, + Computed: true, + Description: "Image description", + }, + "drivers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "Image drivers", + }, + "hot_resize": { + Type: schema.TypeBool, + Computed: true, + Description: "Flag, true if image supports hot resize, else if not", + }, + "image_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Image id", + }, + "link_to": { + Type: schema.TypeInt, + Computed: true, + Description: "For virtual images, id image, which current image linked", + }, + "image_name": { + Type: schema.TypeString, + Computed: true, + Description: "Image name", + }, + "network_interface_naming": { + Type: schema.TypeString, + Computed: true, + }, + "pool_name": { + Type: schema.TypeString, + Computed: true, + Description: "Image pool", + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Image storage endpoint id", + }, + "size": { + Type: schema.TypeInt, + Computed: true, + Description: "Image size", + }, + "status": { + Type: schema.TypeString, + Computed: true, + Description: "Image status", + }, + "storage_policy_id": { + Type: schema.TypeInt, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Image type", + }, + "username": { + Type: schema.TypeString, + Computed: true, + Description: "username", + }, + "virtual": { + Type: schema.TypeBool, + Computed: true, + Description: "True if image is virtula, otherwise - else", + }, + } +} diff --git a/internal/service/cloudapi/image/image_rs_subresource.go b/internal/service/cloudapi/image/image_rs_subresource.go index 9afdda33..d3f3cd7d 100644 --- a/internal/service/cloudapi/image/image_rs_subresource.go +++ b/internal/service/cloudapi/image/image_rs_subresource.go @@ -35,7 +35,6 @@ package image import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs" ) func resourceImageSchemaMake(sch map[string]*schema.Schema) map[string]*schema.Schema { @@ -73,6 +72,12 @@ func resourceImageSchemaMake(sch map[string]*schema.Schema) map[string]*schema.S Description: "Image type linux, windows or unknown", } + sch["storage_policy_id"] = &schema.Schema{ + Type: schema.TypeInt, + Required: true, + Description: "ID of the storage policy", + } + sch["hot_resize"] = &schema.Schema{ Type: schema.TypeBool, Optional: true, @@ -126,16 +131,6 @@ func resourceImageSchemaMake(sch map[string]*schema.Schema) map[string]*schema.S Description: "storage endpoint provider ID", } - sch["drivers"] = &schema.Schema{ - Type: schema.TypeList, - Required: true, - StateFunc: statefuncs.StateFuncToUpper, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringInSlice([]string{"KVM_X86"}, false), - }, - } - sch["network_interface_naming"] = &schema.Schema{ Type: schema.TypeString, Optional: true, diff --git a/internal/service/cloudapi/image/image_virtual_rs_subresource.go b/internal/service/cloudapi/image/image_virtual_rs_subresource.go index e565407c..c1823136 100644 --- a/internal/service/cloudapi/image/image_virtual_rs_subresource.go +++ b/internal/service/cloudapi/image/image_virtual_rs_subresource.go @@ -50,6 +50,13 @@ func resourceImageVirtualSchemaMake(sch map[string]*schema.Schema) map[string]*s Description: "ID of real image to link this virtual image to upon creation", } + sch["account_id"] = &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "account_id", + } + sch["image_id"] = &schema.Schema{ Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudapi/image/resource_image.go b/internal/service/cloudapi/image/resource_image.go index db57231e..723126e2 100644 --- a/internal/service/cloudapi/image/resource_image.go +++ b/internal/service/cloudapi/image/resource_image.go @@ -63,20 +63,14 @@ func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interfac c := m.(*controller.ControllerCfg) req := image.CreateRequest{ - AccountID: uint64(d.Get("account_id").(int)), - Name: d.Get("name").(string), - URL: d.Get("url").(string), - BootType: d.Get("boot_type").(string), - ImageType: d.Get("type").(string), + AccountID: uint64(d.Get("account_id").(int)), + Name: d.Get("name").(string), + URL: d.Get("url").(string), + BootType: d.Get("boot_type").(string), + ImageType: d.Get("type").(string), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } - drivers := []string{} - for _, driver := range d.Get("drivers").([]interface{}) { - drivers = append(drivers, driver.(string)) - } - - req.Drivers = drivers - if hotresize, ok := d.GetOk("hot_resize"); ok { req.HotResize = hotresize.(bool) } diff --git a/internal/service/cloudapi/image/resource_image_from_blank_compute.go b/internal/service/cloudapi/image/resource_image_from_blank_compute.go index 26d11021..d27ec9ed 100644 --- a/internal/service/cloudapi/image/resource_image_from_blank_compute.go +++ b/internal/service/cloudapi/image/resource_image_from_blank_compute.go @@ -490,6 +490,10 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, "version": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/cloudapi/image/resource_image_from_platform_disk.go b/internal/service/cloudapi/image/resource_image_from_platform_disk.go index fd588dad..78bef7de 100644 --- a/internal/service/cloudapi/image/resource_image_from_platform_disk.go +++ b/internal/service/cloudapi/image/resource_image_from_platform_disk.go @@ -48,7 +48,6 @@ import ( "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/status" ) @@ -95,11 +94,6 @@ func resourceImageFromPlatformDiskCreate(ctx context.Context, d *schema.Resource if poolName, ok := d.GetOk("pool_name"); ok { req.PoolName = poolName.(string) } - if driversInterface, ok := d.GetOk("drivers"); ok { - for _, d := range driversInterface.([]interface{}) { - req.Drivers = append(req.Drivers, d.(string)) - } - } if hotresize, ok := d.GetOk("hot_resize"); ok { req.HotResize = hotresize.(bool) } @@ -320,16 +314,6 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { Computed: true, Description: "pool for image create", }, - "drivers": { - Type: schema.TypeList, - Required: true, - Elem: &schema.Schema{ - StateFunc: statefuncs.StateFuncToUpper, - ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86"}, false), // observe case while validating - Type: schema.TypeString, - }, - Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]", - }, "bootable": { Type: schema.TypeBool, Optional: true, @@ -385,6 +369,13 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "drivers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "enabled": { Type: schema.TypeBool, Computed: true, @@ -483,6 +474,10 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, "version": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/cloudapi/image/resource_image_virtual.go b/internal/service/cloudapi/image/resource_image_virtual.go index e2ab61d9..db61e227 100644 --- a/internal/service/cloudapi/image/resource_image_virtual.go +++ b/internal/service/cloudapi/image/resource_image_virtual.go @@ -49,8 +49,9 @@ func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m i c := m.(*controller.ControllerCfg) req := image.CreateVirtualRequest{ - Name: d.Get("name").(string), - TargetID: uint64(d.Get("link_to").(int)), + Name: d.Get("name").(string), + TargetID: uint64(d.Get("link_to").(int)), + AccountID: uint64(d.Get("account_id").(int)), } imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req) diff --git a/internal/service/cloudapi/image/utility_image_list.go b/internal/service/cloudapi/image/utility_image_list.go index f0685118..42ec57e4 100644 --- a/internal/service/cloudapi/image/utility_image_list.go +++ b/internal/service/cloudapi/image/utility_image_list.go @@ -103,6 +103,9 @@ func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, if enabled, ok := d.GetOkExists("enabled"); ok { req.Enabled = enabled.(bool) } + if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok { + req.StoragePolicyID = uint64(storagePolicyID.(int)) + } log.Debugf("utilityImageListCheckPresence: load image list") imageList, err := c.CloudAPI().Image().List(ctx, req) diff --git a/internal/service/cloudapi/k8s/data_source_k8s_list.go b/internal/service/cloudapi/k8s/data_source_k8s_list.go index 7adff403..b65cc561 100644 --- a/internal/service/cloudapi/k8s/data_source_k8s_list.go +++ b/internal/service/cloudapi/k8s/data_source_k8s_list.go @@ -192,6 +192,11 @@ func createK8sListSchema() map[string]*schema.Schema { Type: schema.TypeInt, Optional: true, }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, diff --git a/internal/service/cloudapi/k8s/resource_k8s.go b/internal/service/cloudapi/k8s/resource_k8s.go index 596887d6..e1301150 100644 --- a/internal/service/cloudapi/k8s/resource_k8s.go +++ b/internal/service/cloudapi/k8s/resource_k8s.go @@ -92,6 +92,7 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{ createReq.K8SCIID = uint64(d.Get("k8sci_id").(int)) createReq.WorkerGroupName = d.Get("wg_name").(string) createReq.NetworkPlugin = d.Get("network_plugin").(string) + createReq.StoragePolicyID = uint64(d.Get("storage_policy_id").(int)) var masterNode K8sNodeRecord if masters, ok := d.GetOk("masters"); ok { @@ -665,6 +666,11 @@ func resourceK8sSchemaMake() map[string]*schema.Schema { Description: "Network plugin to be used", ValidateFunc: validation.StringInSlice([]string{"flannel", "weavenet", "calico"}, true), }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the storage policy", + }, "zone_id": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/cloudapi/k8s/resource_k8s_cp.go b/internal/service/cloudapi/k8s/resource_k8s_cp.go index 561c3bb2..381071c7 100644 --- a/internal/service/cloudapi/k8s/resource_k8s_cp.go +++ b/internal/service/cloudapi/k8s/resource_k8s_cp.go @@ -95,6 +95,7 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac createReq.K8SCIID = uint64(d.Get("k8sci_id").(int)) createReq.WorkerGroupName = "temp" createReq.NetworkPlugin = d.Get("network_plugin").(string) + createReq.StoragePolicyID = uint64(d.Get("storage_policy_id").(int)) if zoneID, ok := d.GetOk("zone_id"); ok { createReq.ZoneID = uint64(zoneID.(int)) @@ -680,6 +681,11 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema { Description: "Network plugin to be used", ValidateFunc: validation.StringInSlice([]string{"flannel", "weavenet", "calico"}, true), }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the storage policy", + }, "zone_id": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/cloudapi/k8s/resource_k8s_wg.go b/internal/service/cloudapi/k8s/resource_k8s_wg.go index 323fc75c..ebda4cf2 100644 --- a/internal/service/cloudapi/k8s/resource_k8s_wg.go +++ b/internal/service/cloudapi/k8s/resource_k8s_wg.go @@ -65,14 +65,15 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac c := m.(*controller.ControllerCfg) req := k8s.WorkersGroupAddRequest{ - K8SID: uint64(d.Get("k8s_id").(int)), - Name: d.Get("name").(string), - WorkerNum: uint64(d.Get("num").(int)), - WorkerCPU: uint64(d.Get("cpu").(int)), - WorkerRAM: uint64(d.Get("ram").(int)), - WorkerSEPID: uint64(d.Get("worker_sep_id").(int)), - WorkerSEPPool: d.Get("worker_sep_pool").(string), - Chipset: d.Get("chipset").(string), + K8SID: uint64(d.Get("k8s_id").(int)), + Name: d.Get("name").(string), + WorkerNum: uint64(d.Get("num").(int)), + WorkerCPU: uint64(d.Get("cpu").(int)), + WorkerRAM: uint64(d.Get("ram").(int)), + WorkerSEPID: uint64(d.Get("worker_sep_id").(int)), + WorkerSEPPool: d.Get("worker_sep_pool").(string), + Chipset: d.Get("chipset").(string), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } labels, _ := d.Get("labels").([]interface{}) @@ -276,6 +277,12 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema { Description: "Name of the worker group.", }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the storage policy", + }, + "num": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/cloudapi/k8s/utility_k8ci.go b/internal/service/cloudapi/k8s/utility_k8ci.go index 55fda582..bc651b3a 100644 --- a/internal/service/cloudapi/k8s/utility_k8ci.go +++ b/internal/service/cloudapi/k8s/utility_k8ci.go @@ -55,12 +55,6 @@ func utilityK8CIListCheckPresence(ctx context.Context, d *schema.ResourceData, m if status, ok := d.GetOk("status"); ok { req.Status = status.(string) } - if worker_driver, ok := d.GetOk("worker_driver"); ok { - req.WorkerDriver = worker_driver.(string) - } - if master_driver, ok := d.GetOk("master_driver"); ok { - req.MasterDriver = master_driver.(string) - } if network_plugin, ok := d.GetOk("network_plugin"); ok { req.NetworkPlugins = network_plugin.(string) } diff --git a/internal/service/cloudapi/k8s/utility_k8s.go b/internal/service/cloudapi/k8s/utility_k8s.go index b5372454..a040e944 100644 --- a/internal/service/cloudapi/k8s/utility_k8s.go +++ b/internal/service/cloudapi/k8s/utility_k8s.go @@ -278,6 +278,9 @@ func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } k8sList, err := c.CloudAPI().K8S().List(ctx, req) if err != nil { diff --git a/internal/service/cloudapi/kvmvm/data_source_compute.go b/internal/service/cloudapi/kvmvm/data_source_compute.go index af9f19cc..ceb7ddd7 100644 --- a/internal/service/cloudapi/kvmvm/data_source_compute.go +++ b/internal/service/cloudapi/kvmvm/data_source_compute.go @@ -441,6 +441,10 @@ func computeListDisksSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_id": { + Type: schema.TypeInt, + Computed: true, + }, "tech_status": { Type: schema.TypeString, Computed: true, @@ -449,6 +453,10 @@ func computeListDisksSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, } } @@ -495,6 +503,10 @@ func computeInterfacesSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "flip_group_id": { Type: schema.TypeInt, Computed: true, @@ -561,6 +573,13 @@ func computeInterfacesSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "security_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "target": { Type: schema.TypeString, Computed: true, @@ -726,6 +745,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "boot_image_id": { + Type: schema.TypeInt, + Computed: true, + }, "cd_image_id": { Type: schema.TypeInt, Computed: true, @@ -1125,6 +1148,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "os_version": { + Type: schema.TypeString, + Computed: true, + }, } } diff --git a/internal/service/cloudapi/kvmvm/data_source_compute_audits.go b/internal/service/cloudapi/kvmvm/data_source_compute_audits.go index b8390bdc..fd6a97f7 100644 --- a/internal/service/cloudapi/kvmvm/data_source_compute_audits.go +++ b/internal/service/cloudapi/kvmvm/data_source_compute_audits.go @@ -50,6 +50,7 @@ func dataSourceComputeAuditsRead(ctx context.Context, d *schema.ResourceData, m id := uuid.New() d.SetId(id.String()) d.Set("items", flattenComputeAudits(computeAudits)) + d.Set("entry_count", computeAudits.EntryCount) return nil } @@ -59,6 +60,42 @@ func dataSourceComputeAuditsSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Required: true, }, + "timestamp_at": { + Type: schema.TypeInt, + Optional: true, + }, + "timestamp_to": { + Type: schema.TypeInt, + Optional: true, + }, + "user": { + Type: schema.TypeString, + Optional: true, + }, + "call": { + Type: schema.TypeString, + Optional: true, + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + }, + "page": { + Type: schema.TypeInt, + Optional: true, + }, + "size": { + Type: schema.TypeInt, + Optional: true, + }, + "min_status_code": { + Type: schema.TypeInt, + Optional: true, + }, + "max_status_code": { + Type: schema.TypeInt, + Optional: true, + }, "items": { Type: schema.TypeList, @@ -88,6 +125,10 @@ func dataSourceComputeAuditsSchemaMake() map[string]*schema.Schema { }, }, }, + "entry_count": { + Type: schema.TypeInt, + Computed: true, + }, } } diff --git a/internal/service/cloudapi/kvmvm/data_source_compute_list.go b/internal/service/cloudapi/kvmvm/data_source_compute_list.go index 918f1444..ebed8034 100644 --- a/internal/service/cloudapi/kvmvm/data_source_compute_list.go +++ b/internal/service/cloudapi/kvmvm/data_source_compute_list.go @@ -136,6 +136,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "boot_image_id": { + Type: schema.TypeInt, + Computed: true, + }, "cd_image_id": { Type: schema.TypeInt, Computed: true, @@ -273,6 +277,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "os_version": { + Type: schema.TypeString, + Computed: true, + }, "pinned": { Type: schema.TypeBool, Computed: true, @@ -514,6 +522,11 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema { Default: false, Description: "If set to true, ignores any VMs associated with any k8s cluster", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudapi/kvmvm/flattens.go b/internal/service/cloudapi/kvmvm/flattens.go index 06e8f2e1..ce3efd36 100644 --- a/internal/service/cloudapi/kvmvm/flattens.go +++ b/internal/service/cloudapi/kvmvm/flattens.go @@ -75,6 +75,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface "conn_type": interfaceItem.ConnType, "def_gw": interfaceItem.DefGW, "enabled": interfaceItem.Enabled, + "enable_secgroups": interfaceItem.EnableSecGroups, "flip_group_id": interfaceItem.FLIPGroupID, "guid": interfaceItem.GUID, "ip_address": interfaceItem.IPAddress, @@ -88,6 +89,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface "node_id": interfaceItem.NodeID, "pci_slot": interfaceItem.PCISlot, "qos": flattenQOS(interfaceItem.QOS), + "security_groups": interfaceItem.SecGroups, "sdn_interface_id": interfaceItem.SDNInterfaceID, "target": interfaceItem.Target, "type": interfaceItem.Type, @@ -177,38 +179,40 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} customFields, _ := json.Marshal(compute.CustomFields) devices, _ := json.Marshal(compute.Devices) temp := map[string]interface{}{ - "acl": flattenListACL(compute.ACL), - "account_id": compute.AccountID, - "account_name": compute.AccountName, - "affinity_label": compute.AffinityLabel, - "affinity_rules": flattenListRules(compute.AffinityRules), - "affinity_weight": compute.AffinityWeight, - "anti_affinity_rules": flattenListRules(compute.AntiAffinityRules), - "arch": compute.Architecture, - "auto_start_w_node": compute.AutoStart, - "boot_order": compute.BootOrder, - "bootdisk_size": compute.BootDiskSize, - "chipset": compute.Chipset, - "cd_image_id": compute.CdImageId, - "clone_reference": compute.CloneReference, - "clones": compute.Clones, - "computeci_id": compute.ComputeCIID, - "cpu_pin": compute.CPUPin, - "cpus": compute.CPU, - "created_by": compute.CreatedBy, - "created_time": compute.CreatedTime, - "custom_fields": string(customFields), - "deleted_by": compute.DeletedBy, - "deleted_time": compute.DeletedTime, - "desc": compute.Description, - "devices": string(devices), - "disks": flattenDisks(compute.Disks), - "driver": compute.Driver, - "gid": compute.GID, - "guid": compute.GUID, - "hp_backed": compute.HPBacked, - "compute_id": compute.ID, - "image_id": compute.ImageID, + "acl": flattenListACL(compute.ACL), + "account_id": compute.AccountID, + "account_name": compute.AccountName, + "affinity_label": compute.AffinityLabel, + "affinity_rules": flattenListRules(compute.AffinityRules), + "affinity_weight": compute.AffinityWeight, + "anti_affinity_rules": flattenListRules(compute.AntiAffinityRules), + "arch": compute.Architecture, + "auto_start_w_node": compute.AutoStart, + "boot_order": compute.BootOrder, + "bootdisk_size": compute.BootDiskSize, + "boot_image_id": compute.BootImageID, + "chipset": compute.Chipset, + "cd_image_id": compute.CdImageId, + "clone_reference": compute.CloneReference, + "clones": compute.Clones, + "computeci_id": compute.ComputeCIID, + "cpu_pin": compute.CPUPin, + "cpus": compute.CPU, + "created_by": compute.CreatedBy, + "created_time": compute.CreatedTime, + "custom_fields": string(customFields), + "deleted_by": compute.DeletedBy, + "deleted_time": compute.DeletedTime, + "desc": compute.Description, + "devices": string(devices), + "disks": flattenDisks(compute.Disks), + "driver": compute.Driver, + "gid": compute.GID, + "guid": compute.GUID, + "hp_backed": compute.HPBacked, + "compute_id": compute.ID, + //TODO + // "image_id": compute.ImageID, "interfaces": flattenInterfaces(compute.Interfaces), "live_migration_job_id": compute.LiveMigrationJobID, "lock_status": compute.LockStatus, @@ -220,33 +224,36 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} "need_reboot": compute.NeedReboot, "numa_affinity": compute.NumaAffinity, "numa_node_id": compute.NumaNodeId, + "os_version": compute.OSVersion, // "pinned": compute.Pinned, - "preferred_cpu": compute.PreferredCPU, - "qemu_guest": flattenQemuQuest(compute.QemuQuest), - "ram": compute.RAM, - "reference_id": compute.ReferenceID, - "registered": compute.Registered, - "res_name": compute.ResName, - "reserved_node_cpus": compute.ReservedNodeCpus, - "rg_id": compute.RGID, - "rg_name": compute.RGName, - "snap_sets": flattenSnapSets(compute.SnapSets), - "stateless_sep_id": compute.StatelessSepID, - "stateless_sep_type": compute.StatelessSepType, - "status": compute.Status, - "tags": flattenTags(compute.Tags), - "tech_status": compute.TechStatus, - "total_disk_size": compute.TotalDiskSize, - "updated_by": compute.UpdatedBy, - "updated_time": compute.UpdatedTime, - "user_managed": compute.UserManaged, - "vgpus": compute.VGPUs, - "vins_connected": compute.VINSConnected, - "virtual_image_id": compute.VirtualImageID, + "preferred_cpu": compute.PreferredCPU, + "qemu_guest": flattenQemuQuest(compute.QemuQuest), + "ram": compute.RAM, + "reference_id": compute.ReferenceID, + "registered": compute.Registered, + "res_name": compute.ResName, + "reserved_node_cpus": compute.ReservedNodeCpus, + "rg_id": compute.RGID, + "rg_name": compute.RGName, + "snap_sets": flattenSnapSets(compute.SnapSets), + "stateless_sep_id": compute.StatelessSepID, + "stateless_sep_type": compute.StatelessSepType, + "status": compute.Status, + "tags": flattenTags(compute.Tags), + "tech_status": compute.TechStatus, + "total_disk_size": compute.TotalDiskSize, + "updated_by": compute.UpdatedBy, + "updated_time": compute.UpdatedTime, + "user_managed": compute.UserManaged, + "vgpus": compute.VGPUs, + "vins_connected": compute.VINSConnected, + //TODO + // "virtual_image_id": compute.VirtualImageID, "loader_type": compute.LoaderType, "boot_type": compute.BootType, "hot_resize": compute.HotResize, "network_interface_naming": compute.NetworkInterfaceNaming, + "zone_id": compute.ZoneID, } res = append(res, temp) } @@ -258,18 +265,20 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{} res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "disk_name": bootDisk.Name, - "disk_id": bootDisk.ID, - "disk_type": bootDisk.Type, - "sep_id": bootDisk.SepID, - "shareable": bootDisk.Shareable, - "size_max": bootDisk.SizeMax, - "size_used": bootDisk.SizeUsed, - "pool": bootDisk.Pool, - "desc": bootDisk.Description, - "image_id": bootDisk.ImageID, - "size": bootDisk.SizeMax, - "present_to": bootDisk.PresentTo, + "disk_name": bootDisk.Name, + "disk_id": bootDisk.ID, + "disk_type": bootDisk.Type, + "sep_id": bootDisk.SepID, + "shareable": bootDisk.Shareable, + "size_max": bootDisk.SizeMax, + "size_used": bootDisk.SizeUsed, + "pool": bootDisk.Pool, + "desc": bootDisk.Description, + "image_id": bootDisk.ImageID, + "size": bootDisk.SizeMax, + "present_to": bootDisk.PresentTo, + "storage_policy_id": bootDisk.StoragePolicyID, + "to_clean": bootDisk.ToClean, } res = append(res, temp) @@ -298,19 +307,20 @@ func flattenComputeDisksDemo(disksList compute.ListComputeDisks, disksBlocks, ex pernamentlyValue := disksBlocks[indexDataDisks].(map[string]interface{})["permanently"].(bool) temp := map[string]interface{}{ - "disk_name": disk.Name, - "disk_id": disk.ID, - "disk_type": disk.Type, - "sep_id": disk.SepID, - "shareable": disk.Shareable, - "size_max": disk.SizeMax, - "size_used": disk.SizeUsed, - "pool": disk.Pool, - "desc": disk.Description, - "image_id": disk.ImageID, - "size": disk.SizeMax, - "permanently": pernamentlyValue, - "present_to": disk.PresentTo, + "disk_name": disk.Name, + "disk_id": disk.ID, + "disk_type": disk.Type, + "sep_id": disk.SepID, + "shareable": disk.Shareable, + "size_max": disk.SizeMax, + "size_used": disk.SizeUsed, + "pool": disk.Pool, + "desc": disk.Description, + "image_id": disk.ImageID, + "size": disk.SizeMax, + "permanently": pernamentlyValue, + "present_to": disk.PresentTo, + "storage_policy_id": disk.StoragePolicyID, } res = append(res, temp) indexDataDisks++ @@ -331,6 +341,7 @@ func flattenNetwork(networks []interface{}, interfaces compute.ListInterfaces) [ "mtu": network.MTU, "sdn_interface_id": network.SDNInterfaceID, "weight": flattenNetworkWeight(networks, network.NetID, network.NetType), + "enabled": network.Enabled, } res = append(res, temp) } @@ -381,6 +392,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc d.Set("boot_disk_size", bootDisk.SizeMax) d.Set("boot_disk", flattenBootDisk(bootDisk)) d.Set("boot_disk_id", bootDisk.ID) + d.Set("boot_image_id", computeRec.BootImageID) d.Set("cd_image_id", computeRec.CdImageId) d.Set("sep_id", bootDisk.SepID) d.Set("pool", bootDisk.Pool) @@ -404,11 +416,12 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc d.Set("gid", computeRec.GID) d.Set("guid", computeRec.GUID) d.Set("compute_id", computeRec.ID) - if computeRec.VirtualImageID != 0 { - d.Set("image_id", computeRec.VirtualImageID) - } else { - d.Set("image_id", computeRec.ImageID) - } + //TODO + // if computeRec.VirtualImageID != 0 { + // d.Set("image_id", computeRec.VirtualImageID) + // } else { + // d.Set("image_id", computeRec.ImageID) + // } d.Set("interfaces", flattenInterfaces(computeRec.Interfaces)) d.Set("lock_status", computeRec.LockStatus) d.Set("manager_id", computeRec.ManagerID) @@ -446,8 +459,9 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc d.Set("user_managed", computeRec.UserManaged) d.Set("vnc_password", computeRec.VNCPassword) d.Set("vgpus", flattenVGPUs(computeRec.VGPUs)) - d.Set("virtual_image_id", computeRec.VirtualImageID) - d.Set("virtual_image_name", computeRec.VirtualImageName) + //TODO + // d.Set("virtual_image_id", computeRec.VirtualImageID) + // d.Set("virtual_image_name", computeRec.VirtualImageName) d.Set("loader_type", computeRec.LoaderType) d.Set("boot_type", computeRec.BootType) d.Set("hot_resize", computeRec.HotResize) @@ -467,6 +481,8 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc d.Set("network", flattenNetwork(d.Get("network").(*schema.Set).List(), computeRec.Interfaces)) d.Set("pci_devices", flattenPCI(*pciList)) + d.Set("os_version", computeRec.OSVersion) + return nil } @@ -581,8 +597,10 @@ func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interf "size_used": disk.SizeUsed, "snapshots": flattenSnapshots(disk.Snapshots), "status": disk.Status, + "storage_policy_id": disk.StoragePolicyID, "tech_status": disk.TechStatus, "type": disk.Type, + "to_clean": disk.ToClean, } res = append(res, temp) } @@ -638,6 +656,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute d.Set("chipset", computeRec.Chipset) d.Set("boot_order", computeRec.BootOrder) d.Set("bootdisk_size", computeRec.BootDiskSize) + d.Set("boot_image_id", computeRec.BootImageID) d.Set("cd_image_id", computeRec.CdImageId) d.Set("clone_reference", computeRec.CloneReference) d.Set("clones", computeRec.Clones) @@ -698,14 +717,16 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute d.Set("userdata", string(userdata)) d.Set("vnc_password", computeRec.VNCPassword) d.Set("vgpus", flattenVGPUs(computeRec.VGPUs)) - d.Set("virtual_image_id", computeRec.VirtualImageID) - d.Set("virtual_image_name", computeRec.VirtualImageName) + //TODO + // d.Set("virtual_image_id", computeRec.VirtualImageID) + // d.Set("virtual_image_name", computeRec.VirtualImageName) d.Set("pci_devices", flattenPCI(*pciList)) d.Set("loader_type", computeRec.LoaderType) d.Set("boot_type", computeRec.BootType) d.Set("hot_resize", computeRec.HotResize) d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming) d.Set("zone_id", computeRec.ZoneID) + d.Set("os_version", computeRec.OSVersion) } func flattenPCI(pciList compute.ListPCIDevices) []uint64 { @@ -719,8 +740,8 @@ func flattenPCI(pciList compute.ListPCIDevices) []uint64 { } func flattenComputeAudits(computeAudits compute.ListAudits) []map[string]interface{} { - res := make([]map[string]interface{}, 0, len(computeAudits)) - for _, computeAudit := range computeAudits { + res := make([]map[string]interface{}, 0, len(computeAudits.Data)) + for _, computeAudit := range computeAudits.Data { temp := map[string]interface{}{ "call": computeAudit.Call, "responsetime": computeAudit.ResponseTime, diff --git a/internal/service/cloudapi/kvmvm/models.go b/internal/service/cloudapi/kvmvm/models.go new file mode 100644 index 00000000..2a63815f --- /dev/null +++ b/internal/service/cloudapi/kvmvm/models.go @@ -0,0 +1,10 @@ +package kvmvm + +type updatedNetwork struct { + DetachMap []map[string]interface{} + ChangeIPMap []map[string]interface{} + ChangeMacMap []map[string]interface{} + ChangeMTUMap []map[string]interface{} + AttachMap []map[string]interface{} + EnableMap []map[string]interface{} +} diff --git a/internal/service/cloudapi/kvmvm/network_subresource.go b/internal/service/cloudapi/kvmvm/network_subresource.go index 065e92b6..1ce9e7db 100644 --- a/internal/service/cloudapi/kvmvm/network_subresource.go +++ b/internal/service/cloudapi/kvmvm/network_subresource.go @@ -177,6 +177,13 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema { DiffSuppressFunc: networkSubresIPAddreDiffSupperss, Description: "unique_identifier of LogicalPort on SDN side", }, + + "enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "network enable flag", + }, } return rets } diff --git a/internal/service/cloudapi/kvmvm/resource_compute.go b/internal/service/cloudapi/kvmvm/resource_compute.go index 2dbc948a..bf6fb420 100644 --- a/internal/service/cloudapi/kvmvm/resource_compute.go +++ b/internal/service/cloudapi/kvmvm/resource_compute.go @@ -35,6 +35,8 @@ package kvmvm import ( "context" + "errors" + "fmt" "sort" "strconv" "strings" @@ -172,6 +174,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf NetID: uint64(netInterfaceVal["net_id"].(int)), } + if enabledNetwork(d.GetRawConfig().GetAttr("network"), reqInterface.NetID, reqInterface.NetType) { + reqInterface.Enabled = netInterfaceVal["enabled"].(bool) + } + if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" { reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int)) } @@ -204,8 +210,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf for _, elem := range disks.([]interface{}) { diskVal := elem.(map[string]interface{}) reqDataDisk := kvmx86.DataDisk{ - DiskName: diskVal["disk_name"].(string), - Size: uint64(diskVal["size"].(int)), + DiskName: diskVal["disk_name"].(string), + Size: uint64(diskVal["size"].(int)), + StoragePolicyID: uint64(diskVal["storage_policy_id"].(int)), } if sepId, ok := diskVal["sep_id"]; ok { reqDataDisk.SepID = uint64(sepId.(int)) @@ -235,14 +242,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } var computeId uint64 - driver := d.Get("driver").(string) createReqX86.RGID = uint64(d.Get("rg_id").(int)) createReqX86.Name = d.Get("name").(string) createReqX86.CPU = uint64(d.Get("cpu").(int)) createReqX86.RAM = uint64(d.Get("ram").(int)) - - createReqX86.Driver = driver + createReqX86.StoragePolicyID = uint64(d.Get("storage_policy_id").(int)) if image, ok := d.GetOk("image_id"); ok { createReqX86.ImageID = uint64(image.(int)) @@ -278,6 +283,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } } + if osVersion, ok := d.GetOk("os_version"); ok { + createReqX86.OSVersion = osVersion.(string) + } + log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86") apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86) if err != nil { @@ -289,6 +298,11 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf warnings := dc.Warnings{} + simpleCompRec, err := utilityComputeCheckPresence(ctx, d, m) + if err != nil { + warnings.Add(err) + } + cleanup := false defer func() { if cleanup { @@ -312,7 +326,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf loaderType, loaderTypeOk := d.GetOk("loader_type") bootType, bootTypeOk := d.GetOk("boot_type") - hotResize, hotResizeOk := d.GetOk("hot_resize") + hotResize, hotResizeOk := d.GetOkExists("hot_resize") networkInterfaceNaming, networkInterfaceNamingOk := d.GetOk("network_interface_naming") if loaderTypeOk { @@ -388,14 +402,42 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } } - if d.Get("pin_to_stack").(bool) { - req := compute.PinToStackRequest{ - ComputeID: computeId, - } - req.AutoStart = d.Get("auto_start_w_node").(bool) - _, err := c.CloudAPI().Compute().PinToStack(ctx, req) - if err != nil { - warnings.Add(err) + if secGroups, ok := d.GetOk("security_groups"); ok { + if secGroups.(*schema.Set).Len() > 0 { + sgl := secGroups.(*schema.Set).List() + for _, elem := range sgl { + secGroupsMap := elem.(map[string]interface{}) + + netType := secGroupsMap["net_type"].(string) + netId := uint64(secGroupsMap["net_id"].(int)) + var mac string + for _, iface := range simpleCompRec.Interfaces { + if iface.NetID == netId && iface.NetType == netType { + mac = iface.MAC + break + } + } + if mac == "" { + warnings.Add(errors.New(fmt.Sprintf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))) + continue + } + secGroupsIDs := make([]uint64, 0) + for _, id := range secGroupsMap["security_groups"].(*schema.Set).List() { + secGroupsIDs = append(secGroupsIDs, uint64(id.(int))) + } + log.Debugf("resourceComputeCreate: Configure security groups interface parameters on Network with type %s and id %d", netType, netId) + req := compute.ChangeSecGroupsRequest{ + ComputeID: computeId, + Interface: mac, + SecGroups: secGroupsIDs, + EnableSecGroups: secGroupsMap["enable_secgroups"].(bool), + } + + _, err := c.CloudAPI().Compute().ChangeSecGroups(ctx, req) + if err != nil { + warnings.Add(err) + } + } } } @@ -418,6 +460,22 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } } + if d.Get("pin_to_stack").(bool) { + if !d.Get("started").(bool) { + warnings.Add(errors.New("cannot pin to stack a VM, VM should be started")) + } + if d.Get("started").(bool) { + req := compute.PinToStackRequest{ + ComputeID: computeId, + } + req.AutoStart = d.Get("auto_start_w_node").(bool) + _, err = c.CloudAPI().Compute().PinToStack(ctx, req) + if err != nil { + warnings.Add(err) + } + } + } + if affinityLabel, ok := d.GetOk("affinity_label"); ok { req := compute.AffinityLabelSetRequest{ ComputeID: computeId, @@ -899,21 +957,36 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf } } if !oldPin.(bool) { + if !d.Get("started").(bool) { + return diag.Errorf("Cannot pin to stack a VM, that is not started") + } + reqToStart := compute.StartRequest{ + ComputeID: computeRec.ID, + } + _, err := c.CloudAPI().Compute().Start(ctx, reqToStart) + if err != nil { + return diag.FromErr(err) + } + req := compute.PinToStackRequest{ ComputeID: computeRec.ID, } req.AutoStart = d.Get("auto_start_w_node").(bool) - _, err := c.CloudAPI().Compute().PinToStack(ctx, req) + _, err = c.CloudAPI().Compute().PinToStack(ctx, req) if err != nil { return diag.FromErr(err) } } } - // Note bene: numa_affinity, cpu_pin, cpu, ram and hp_backed are not allowed to be changed for compute in STARTED tech status. - // If STARTED, we need to stop it before update + // Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status. var isStopRequired bool - if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu", "cpu", "ram") && d.Get("started").(bool) { + if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu", "hot_resize") && d.Get("started").(bool) { + isStopRequired = true + } + + old, new := d.GetChange("cpu") + if old.(int) > new.(int) && d.Get("started").(bool) && d.Get("force_resize").(bool) { isStopRequired = true } if isStopRequired { @@ -989,7 +1062,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf "loader_type", "boot_type", "hot_resize", - "network_interface_naming") { + "network_interface_naming", + "os_version") { req := compute.UpdateRequest{ ComputeID: computeRec.ID, } @@ -1041,6 +1115,10 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf req.NetworkInterfaceNaming = d.Get("network_interface_naming").(string) } + if d.HasChange("os_version") { + req.OSVersion = d.Get("os_version").(string) + } + // perform update if _, err := c.CloudAPI().Compute().Update(ctx, req); err != nil { return diag.FromErr(err) @@ -1062,18 +1140,26 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf } } + if d.HasChange("security_groups") { + err = utilityComputeSecGroupsConfigure(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + } + if d.HasChange("disks") { deletedDisks := make([]interface{}, 0) addedDisks := make([]interface{}, 0) resizedDisks := make([]interface{}, 0) renamedDisks := make([]interface{}, 0) + changeStoragePolicyDisks := make([]interface{}, 0) oldDisks, newDisks := d.GetChange("disks") oldConv := oldDisks.([]interface{}) newConv := newDisks.([]interface{}) for _, el := range oldConv { - if !isContainsDisk(newConv, el) && !isRenameDisk(newConv, el) && !isResizeDisk(newConv, el) { + if !isContainsDisk(newConv, el) && !isRenameDisk(newConv, el) && !isResizeDisk(newConv, el) && !isChangeStoragePolicy(newConv, el) { flag := false extraDisks := d.Get("extra_disks").(*schema.Set).List() delDisk := el.(map[string]interface{}) @@ -1104,19 +1190,12 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf if isRenameDisk(oldConv, el) { renamedDisks = append(renamedDisks, el) } + if isChangeStoragePolicy(oldConv, el) { + changeStoragePolicyDisks = append(changeStoragePolicyDisks, el) + } } if len(deletedDisks) > 0 { - stopReq := compute.StopRequest{ - ComputeID: computeRec.ID, - Force: false, - } - - _, err := c.CloudAPI().Compute().Stop(ctx, stopReq) - if err != nil { - return diag.FromErr(err) - } - for _, disk := range deletedDisks { diskConv := disk.(map[string]interface{}) if diskConv["disk_type"].(string) == "B" { @@ -1136,14 +1215,6 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf return diag.FromErr(err) } } - req := compute.StartRequest{ - ComputeID: computeRec.ID, - AltBootID: 0, - } - _, err = c.CloudAPI().Compute().Start(ctx, req) - if err != nil { - return diag.FromErr(err) - } } if len(addedDisks) > 0 { @@ -1153,9 +1224,10 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf continue } req := compute.DiskAddRequest{ - ComputeID: computeRec.ID, - DiskName: diskConv["disk_name"].(string), - Size: uint64(diskConv["size"].(int)), + ComputeID: computeRec.ID, + DiskName: diskConv["disk_name"].(string), + Size: uint64(diskConv["size"].(int)), + StoragePolicyID: uint64(diskConv["storage_policy_id"].(int)), } if diskConv["sep_id"].(int) != 0 { @@ -1214,6 +1286,22 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf } } } + + if len(changeStoragePolicyDisks) > 0 { + for _, disk := range changeStoragePolicyDisks { + diskConv := disk.(map[string]interface{}) + + req := disks.ChangeDiskStoragePolicyRequest{ + DiskID: uint64(diskConv["disk_id"].(int)), + StoragePolicyID: uint64(diskConv["storage_policy_id"].(int)), + } + + _, err := c.CloudAPI().Disks().ChangeDiskStoragePolicy(ctx, req) + if err != nil { + return diag.FromErr(err) + } + } + } } if d.HasChange("affinity_label") { @@ -1650,9 +1738,10 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf if oldImage.(int) != newImage.(int) { req := compute.RedeployRequest{ - ComputeID: computeRec.ID, - ImageID: uint64(newImage.(int)), - DataDisks: "KEEP", + ComputeID: computeRec.ID, + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), + ImageID: uint64(newImage.(int)), + DataDisks: "KEEP", } if diskSize, ok := d.GetOk("boot_disk_size"); ok { @@ -1665,6 +1754,10 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf req.ForceStop = forceStop.(bool) } + if osVersion, ok := d.GetOk("os_version"); ok { + req.OSVersion = osVersion.(string) + } + _, err := c.CloudAPI().Compute().Redeploy(ctx, req) if err != nil { return diag.FromErr(err) @@ -1758,6 +1851,18 @@ func isRenameDisk(els []interface{}, el interface{}) bool { return false } +func isChangeStoragePolicy(els []interface{}, el interface{}) bool { + for _, elOld := range els { + elOldConv := elOld.(map[string]interface{}) + elConv := el.(map[string]interface{}) + if elOldConv["disk_id"].(int) == elConv["disk_id"].(int) && + elOldConv["storage_policy_id"].(int) != elConv["storage_policy_id"].(int) { + return true + } + } + return false +} + func isContainsDisk(els []interface{}, el interface{}) bool { for _, elOld := range els { elOldConv := elOld.(map[string]interface{}) @@ -1848,6 +1953,11 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema { Required: true, Description: "Disk size in GiB", }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "Storage policy id of disk. The rules of the specified storage policy will be used.", + }, "sep_id": { Type: schema.TypeInt, Computed: true, @@ -1908,6 +2018,10 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, } return rets } @@ -2002,14 +2116,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { ValidateFunc: validation.IntAtLeast(1), Description: "ID of the resource group where this compute should be deployed.", }, - "driver": { - Type: schema.TypeString, - Required: true, - // ForceNew: true, - StateFunc: statefuncs.StateFuncToUpper, - ValidateFunc: validation.StringInSlice([]string{"KVM_X86"}, false), // observe case while validating - Description: "Hardware architecture of this compute instance.", - }, "cpu": { Type: schema.TypeInt, Required: true, @@ -2025,6 +2131,11 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { ), Description: "Amount of RAM in MB to allocate to this compute instance.", }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "Storage policy id of compute. The rules of the specified storage policy will be used.", + }, "boot_type": { Type: schema.TypeString, Optional: true, @@ -2158,6 +2269,10 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { Schema: disksSubresourceSchemaMake(), }, }, + "boot_image_id": { + Type: schema.TypeInt, + Computed: true, + }, "sep_id": { Type: schema.TypeInt, Optional: true, @@ -2377,6 +2492,46 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { Description: "ID of the connected pci devices", }, + "security_groups": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "net_type": { + Type: schema.TypeString, + Required: true, + StateFunc: statefuncs.StateFuncToUpper, + ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK"}, false), // observe case while validating + Description: "Type of the network", + }, + "net_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the network", + }, + "security_groups": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "enable_secgroups": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + }, + }, + Description: "list of security group IDs to apply to this interface", + }, + "os_version": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "the OS version installed on the VM", + }, + // The rest are Compute properties, which are "computed" once it is created "account_id": { Type: schema.TypeInt, @@ -2451,6 +2606,10 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "driver": { + Type: schema.TypeString, + Computed: true, + }, "guid": { Type: schema.TypeInt, Computed: true, @@ -2701,7 +2860,7 @@ func ResourceCompute() *schema.Resource { CustomizeDiff: func(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error { if diff.HasChanges() || diff.HasChanges("chipset", "pin_to_stack", "auto_start_w_node", "network", "affinity_rules", "anti_affinity_rules", - "extra_disks", "tags", "port_forwarding", "user_access", "snapshot", "pci_devices", "preferred_cpu") { + "extra_disks", "tags", "port_forwarding", "user_access", "snapshot", "pci_devices", "preferred_cpu", "security_groups") { diff.SetNewComputed("updated_time") diff.SetNewComputed("updated_by") } diff --git a/internal/service/cloudapi/kvmvm/utility_compute.go b/internal/service/cloudapi/kvmvm/utility_compute.go index e3d975a9..a0fb6f18 100644 --- a/internal/service/cloudapi/kvmvm/utility_compute.go +++ b/internal/service/cloudapi/kvmvm/utility_compute.go @@ -34,10 +34,13 @@ package kvmvm import ( "context" + "errors" + "fmt" "regexp" "sort" "strconv" + "github.com/hashicorp/go-cty/cty" log "github.com/sirupsen/logrus" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" @@ -164,13 +167,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData oldList := oldSet.(*schema.Set).List() newList := newSet.(*schema.Set).List() - detachMap, changeIpMap, changeMacMap, changeMTUMap, attachMap := differenceNetwork(oldList, newList) + updateNetwork := differenceNetwork(oldList, newList) apiErrCount := 0 var lastSavedError error - log.Debugf("utilityComputeNetworksConfigure: detach set has %d items for Compute ID %s", len(detachMap), d.Id()) - for _, netData := range detachMap { + log.Debugf("utilityComputeNetworksConfigure: detach set has %d items for Compute ID %s", len(updateNetwork.DetachMap), d.Id()) + for _, netData := range updateNetwork.DetachMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.NetDetachRequest{ ComputeID: computeId, @@ -187,8 +190,8 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } - log.Debugf("utilityComputeNetworksConfigure: changeIp set has %d items for Compute ID %s", len(changeIpMap), d.Id()) - for _, netData := range changeIpMap { + log.Debugf("utilityComputeNetworksConfigure: changeIp set has %d items for Compute ID %s", len(updateNetwork.ChangeIPMap), d.Id()) + for _, netData := range updateNetwork.ChangeIPMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.ChangeIPRequest{ ComputeID: computeId, @@ -208,7 +211,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData needStart := false - if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 || hasDPDKnetwork(attachMap) || len(changeMacMap) != 0 { + if oldSet.(*schema.Set).Len() == len(updateNetwork.DetachMap) || oldSet.(*schema.Set).Len() == 0 || hasDPDKnetwork(updateNetwork.AttachMap) || len(updateNetwork.ChangeMacMap) != 0 { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) if err := utilityComputeStop(ctx, computeId, m); err != nil { apiErrCount++ @@ -219,8 +222,8 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } - log.Debugf("utilityComputeNetworksConfigure: changeMac set has %d items for Compute ID %s", len(changeMacMap), d.Id()) - for _, netData := range changeMacMap { + log.Debugf("utilityComputeNetworksConfigure: changeMac set has %d items for Compute ID %s", len(updateNetwork.ChangeMacMap), d.Id()) + for _, netData := range updateNetwork.ChangeMacMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.ChangeMACRequest{ ComputeID: computeId, @@ -237,9 +240,9 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } - sort.Slice(attachMap, func(i, j int) bool { - weightI := attachMap[i]["weight"].(int) - weightJ := attachMap[j]["weight"].(int) + sort.Slice(updateNetwork.AttachMap, func(i, j int) bool { + weightI := updateNetwork.AttachMap[i]["weight"].(int) + weightJ := updateNetwork.AttachMap[j]["weight"].(int) if weightI == 0 { return false } @@ -249,8 +252,8 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData return weightI < weightJ }) - log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", len(attachMap), d.Id()) - for _, netData := range attachMap { + log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", len(updateNetwork.AttachMap), d.Id()) + for _, netData := range updateNetwork.AttachMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.NetAttachRequest{ ComputeID: computeId, @@ -270,7 +273,11 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData req.SDNInterfaceID = netData["sdn_interface_id"].(string) } - if req.NetType == "DPDK" { + if enabledNetwork(d.GetRawConfig().GetAttr("network"), req.NetID, req.NetType) { + req.Enabled = netData["enabled"].(bool) + } + + if req.NetType == "DPDK" || req.NetType == "EXTNET" { req.MTU = uint64(netData["mtu"].(int)) } @@ -291,8 +298,8 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } - log.Debugf("utilityComputeNetworksConfigure: changeMTU set has %d items for Compute ID %s", len(changeMTUMap), d.Id()) - for _, netData := range changeMTUMap { + log.Debugf("utilityComputeNetworksConfigure: changeMTU set has %d items for Compute ID %s", len(updateNetwork.ChangeMTUMap), d.Id()) + for _, netData := range updateNetwork.ChangeMTUMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.ChangeMTURequest{ ComputeID: computeId, @@ -309,6 +316,28 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } + log.Debugf("utilityComputeNetworksConfigure: enableMap set has %d items for Compute ID %s", len(updateNetwork.EnableMap), d.Id()) + for _, netData := range updateNetwork.EnableMap { + computeId, _ := strconv.ParseUint(d.Id(), 10, 64) + req := compute.ChangeLinkStateRequest{ + ComputeID: computeId, + Interface: netData["mac"].(string), + State: "off", + } + + if netData["enabled"].(bool) { + req.State = "on" + } + + _, err := c.CloudAPI().Compute().ChangeLinkState(ctx, req) + if err != nil { + log.Errorf("utilityComputeNetworksConfigure: failed to change link state network ID %d of type %s from Compute ID %s: %s", + netData["net_id"].(int), netData["net_type"].(string), d.Id(), err) + apiErrCount++ + lastSavedError = err + } + } + if apiErrCount > 0 { log.Errorf("utilityComputeNetworksConfigure: there were %d error(s) when managing networks of Compute ID %s. Last error was: %s", apiErrCount, d.Id(), lastSavedError) @@ -318,6 +347,75 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData return nil } +func utilityComputeSecGroupsConfigure(ctx context.Context, d *schema.ResourceData, m interface{}) error { + c := m.(*controller.ControllerCfg) + + computeId, _ := strconv.ParseUint(d.Id(), 10, 64) + simpleCompRec, err := utilityComputeCheckPresence(ctx, d, m) + if err != nil { + return err + } + + apiErrCount := 0 + var lastSavedError error + + oldSecGroups, newSecGroups := d.GetChange("security_groups") + updateSecGroups := (newSecGroups.(*schema.Set).Difference(oldSecGroups.(*schema.Set))).List() + + log.Debugf("utilityComputeSecGroupsConfigure: update security groups has %d items for Compute ID %s", len(updateSecGroups), d.Id()) + if len(updateSecGroups) > 0 { + for _, elem := range updateSecGroups { + secGroupsMap := elem.(map[string]interface{}) + + netType := secGroupsMap["net_type"].(string) + netId := uint64(secGroupsMap["net_id"].(int)) + var mac string + for _, iface := range simpleCompRec.Interfaces { + if iface.NetID == netId && iface.NetType == netType { + mac = iface.MAC + break + } + } + if mac == "" { + log.Errorf("utilityComputeSecGroupsConfigure: Network with type %s and id %d is not connected to the compute %s", + netType, netId, d.Id()) + apiErrCount++ + lastSavedError = errors.New(fmt.Sprintf("utilityComputeSecGroupsConfigure: Network with type %s and id %d is not connected to the compute %s", + netType, netId, d.Id())) + continue + } + secGroupsIDs := make([]uint64, 0) + for _, id := range secGroupsMap["security_groups"].(*schema.Set).List() { + secGroupsIDs = append(secGroupsIDs, uint64(id.(int))) + } + log.Debugf("utilityComputeSecGroupsConfigure: Configure security groups interface parameters on Network with type %s and id %d", netType, netId) + req := compute.ChangeSecGroupsRequest{ + ComputeID: computeId, + Interface: mac, + SecGroups: secGroupsIDs, + } + + if secGroupsMap["enable_secgroups"] != nil { + req.EnableSecGroups = secGroupsMap["enable_secgroups"].(bool) + } + + _, err := c.CloudAPI().Compute().ChangeSecGroups(ctx, req) + if err != nil { + apiErrCount++ + lastSavedError = err + } + } + } + + if apiErrCount > 0 { + log.Errorf("utilityComputeSecGroupsConfigure: there were %d error(s) when managing security groups of Compute ID %s. Last error was: %s", + apiErrCount, d.Id(), lastSavedError) + return lastSavedError + } + + return nil +} + func hasDPDKnetwork(networkAttachMap []map[string]interface{}) bool { for _, elem := range networkAttachMap { if elem["net_type"].(string) == "DPDK" { @@ -407,12 +505,13 @@ func utilityComputeUpdatePciDevices(ctx context.Context, d *schema.ResourceData, return nil } -func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, changeMacMap, changeMTUMap, attachMap []map[string]interface{}) { - attachMap = make([]map[string]interface{}, 0) - changeIpMap = make([]map[string]interface{}, 0) - changeMacMap = make([]map[string]interface{}, 0) - changeMTUMap = make([]map[string]interface{}, 0) - detachMap = make([]map[string]interface{}, 0) +func differenceNetwork(oldList, newList []interface{}) *updatedNetwork { + attachMap := make([]map[string]interface{}, 0) + changeIpMap := make([]map[string]interface{}, 0) + changeMacMap := make([]map[string]interface{}, 0) + changeMTUMap := make([]map[string]interface{}, 0) + detachMap := make([]map[string]interface{}, 0) + enableMap := make([]map[string]interface{}, 0) for _, oldNetwork := range oldList { oldMap := oldNetwork.(map[string]interface{}) found := false @@ -430,6 +529,13 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, if (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "DPDK") && (newMap["mtu"] != oldMap["mtu"] && newMap["mtu"].(int) != 0) { changeMTUMap = append(changeMTUMap, newMap) } + if newMap["enabled"].(bool) != oldMap["enabled"].(bool) { + mac, _ := newMap["mac"].(string) + if mac == "" { + newMap["mac"] = oldMap["mac"] + } + enableMap = append(enableMap, newMap) + } } if found { break @@ -457,7 +563,16 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, attachMap = append(attachMap, newMap) } - return + res := updatedNetwork{ + DetachMap: detachMap, + ChangeIPMap: changeIpMap, + ChangeMacMap: changeMacMap, + ChangeMTUMap: changeMTUMap, + AttachMap: attachMap, + EnableMap: enableMap, + } + + return &res } func compareNetwork(newMap, oldMap map[string]interface{}) bool { @@ -485,3 +600,25 @@ func utilityComputeUpdateZoneID(ctx context.Context, d *schema.ResourceData, m i return nil } + +func enabledNetwork(rawNetworkConfig cty.Value, netID uint64, netType string) bool { + for _, netConfigVal := range rawNetworkConfig.AsValueSlice() { + if netConfigVal.IsNull() { + continue + } + + netConfig := netConfigVal.AsValueMap() + + tempID, _ := netConfig["net_id"].AsBigFloat().Int64() + configNetID := uint64(tempID) + + configNetType := netConfig["net_type"].AsString() + + if configNetID == netID && configNetType == netType { + enabledVal := netConfig["enabled"] + return !enabledVal.IsNull() + } + } + + return false +} diff --git a/internal/service/cloudapi/kvmvm/utility_compute_audits.go b/internal/service/cloudapi/kvmvm/utility_compute_audits.go index c1524f48..0ee19293 100644 --- a/internal/service/cloudapi/kvmvm/utility_compute_audits.go +++ b/internal/service/cloudapi/kvmvm/utility_compute_audits.go @@ -45,10 +45,37 @@ func utilityComputeAuditsCheckPresence(ctx context.Context, d *schema.ResourceDa req := compute.AuditsRequest{ ComputeID: uint64(d.Get("compute_id").(int)), } + if timestampAt, ok := d.GetOk("timestamp_at"); ok { + req.TimestampAT = uint64(timestampAt.(int)) + } + if timestampTo, ok := d.GetOk("timestamp_to"); ok { + req.TimestampTO = uint64(timestampTo.(int)) + } + if user, ok := d.GetOk("user"); ok { + req.User = user.(string) + } + if call, ok := d.GetOk("call"); ok { + req.Call = call.(string) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + if size, ok := d.GetOk("size"); ok { + req.Size = uint64(size.(int)) + } + if minStatusCode, ok := d.GetOk("min_status_code"); ok { + req.MinStatusCode = uint64(minStatusCode.(int)) + } + if maxStatusCode, ok := d.GetOk("max_status_code"); ok { + req.MaxStatusCode = uint64(maxStatusCode.(int)) + } computeAudits, err := c.CloudAPI().Compute().Audits(ctx, req) if err != nil { - return nil, err + return compute.ListAudits{}, err } - return computeAudits, nil + return *computeAudits, nil } diff --git a/internal/service/cloudapi/kvmvm/utility_compute_list.go b/internal/service/cloudapi/kvmvm/utility_compute_list.go index 4bc4d595..2bc96b57 100644 --- a/internal/service/cloudapi/kvmvm/utility_compute_list.go +++ b/internal/service/cloudapi/kvmvm/utility_compute_list.go @@ -86,6 +86,9 @@ func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.Resource if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } listComputes, err := c.CloudAPI().Compute().List(ctx, req) if err != nil { diff --git a/internal/service/cloudapi/lb/lb_data_subresource.go b/internal/service/cloudapi/lb/lb_data_subresource.go index 7d87b16b..5682275f 100644 --- a/internal/service/cloudapi/lb/lb_data_subresource.go +++ b/internal/service/cloudapi/lb/lb_data_subresource.go @@ -175,6 +175,11 @@ func dsLBListSchemaMake() map[string]*schema.Schema { Optional: true, Default: 0, }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudapi/lb/utility_lb_list.go b/internal/service/cloudapi/lb/utility_lb_list.go index 501752ff..2433aa58 100644 --- a/internal/service/cloudapi/lb/utility_lb_list.go +++ b/internal/service/cloudapi/lb/utility_lb_list.go @@ -92,6 +92,9 @@ func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m i if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } log.Debugf("utilityLBListCheckPresence: load lb list") lbList, err := c.CloudAPI().LB().List(ctx, req) diff --git a/internal/service/cloudapi/rg/data_source_rg.go b/internal/service/cloudapi/rg/data_source_rg.go index c66f85ec..9e436859 100644 --- a/internal/service/cloudapi/rg/data_source_rg.go +++ b/internal/service/cloudapi/rg/data_source_rg.go @@ -269,6 +269,23 @@ func resourceLimitsSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Required: true, + }, + "limit": { + Type: schema.TypeInt, + Optional: true, + }, + }, + }, + }, } return res @@ -418,6 +435,13 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, } return res } diff --git a/internal/service/cloudapi/rg/data_source_rg_list.go b/internal/service/cloudapi/rg/data_source_rg_list.go index 4dcd5658..24e988ab 100644 --- a/internal/service/cloudapi/rg/data_source_rg_list.go +++ b/internal/service/cloudapi/rg/data_source_rg_list.go @@ -265,6 +265,13 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, }, }, }, diff --git a/internal/service/cloudapi/rg/data_source_rg_list_deleted.go b/internal/service/cloudapi/rg/data_source_rg_list_deleted.go index b07ab7ad..46fe82b4 100644 --- a/internal/service/cloudapi/rg/data_source_rg_list_deleted.go +++ b/internal/service/cloudapi/rg/data_source_rg_list_deleted.go @@ -250,6 +250,13 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, }, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, }, }, }, diff --git a/internal/service/cloudapi/rg/flattens.go b/internal/service/cloudapi/rg/flattens.go index d604715d..ce821500 100644 --- a/internal/service/cloudapi/rg/flattens.go +++ b/internal/service/cloudapi/rg/flattens.go @@ -94,6 +94,7 @@ func flattenResgroup(d *schema.ResourceData, details rg.RecordResourceGroup) err d.Set("account_name", details.AccountName) d.Set("acl", flattenRgAcl(details.ACL)) d.Set("compute_features", details.ComputeFeatures) + d.Set("storage_policy", flattenRgStoragePolicy(details.ResourceLimits.StoragePolicies)) d.Set("vms", details.Computes) d.Set("created_by", details.CreatedBy) d.Set("created_time", details.CreatedTime) @@ -116,6 +117,8 @@ func flattenResgroup(d *schema.ResourceData, details rg.RecordResourceGroup) err d.Set("cpu_allocation_parameter", details.CPUAllocationParameter) d.Set("cpu_allocation_ratio", details.CPUAllocationRatio) d.Set("sdn_access_group_id", details.SDNAccessGroupID) + d.Set("resource_limits", flattenRgResourceLimits(details.ResourceLimits)) + d.Set("storage_policy_ids", details.StoragePolicyIDs) return nil } @@ -204,6 +207,7 @@ func flattenRg(d *schema.ResourceData, itemRg rg.RecordResourceGroup) { d.Set("cpu_allocation_parameter", itemRg.CPUAllocationParameter) d.Set("cpu_allocation_ratio", itemRg.CPUAllocationRatio) d.Set("sdn_access_group_id", itemRg.SDNAccessGroupID) + d.Set("storage_policy_ids", itemRg.StoragePolicyIDs) } func flattenRgAudits(rgAudits rg.ListAudits) []map[string]interface{} { @@ -257,6 +261,7 @@ func flattenRgList(rgl *rg.ListResourceGroups) []map[string]interface{} { "cpu_allocation_parameter": rg.CPUAllocationParameter, "cpu_allocation_ratio": rg.CPUAllocationRatio, "sdn_access_group_id": rg.SDNAccessGroupID, + "storage_policy_ids": rg.StoragePolicyIDs, } res = append(res, temp) } @@ -282,19 +287,34 @@ func flattenRgAcl(rgAcls rg.ListACL) []map[string]interface{} { func flattenRgResourceLimits(rl rg.ResourceLimits) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "cu_c": rl.CUC, - "cu_d": rl.CUD, - "cu_i": rl.CUI, - "cu_m": rl.CUM, - "cu_dm": rl.CUDM, - "cu_np": rl.CUNP, - "gpu_units": rl.GPUUnits, + "cu_c": rl.CUC, + "cu_d": rl.CUD, + "cu_i": rl.CUI, + "cu_m": rl.CUM, + "cu_dm": rl.CUDM, + "cu_np": rl.CUNP, + "gpu_units": rl.GPUUnits, + "storage_policy": flattenRgStoragePolicy(rl.StoragePolicies), } res = append(res, temp) return res } +func flattenRgStoragePolicy(spList []rg.StoragePolicy) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(spList)) + for _, sp := range spList { + temp := map[string]interface{}{ + "id": sp.ID, + "limit": sp.Limit, + } + + res = append(res, temp) + } + + return res +} + func flattenRules(list rg.ListRules) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(list)) for _, rule := range list { diff --git a/internal/service/cloudapi/rg/resource_rg.go b/internal/service/cloudapi/rg/resource_rg.go index 86b889a7..e3ef5b6d 100644 --- a/internal/service/cloudapi/rg/resource_rg.go +++ b/internal/service/cloudapi/rg/resource_rg.go @@ -164,6 +164,27 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter req.SDNAccessGroupID = sdnAccessGroupID.(string) } + if storagePolicies, ok := d.GetOk("storage_policy"); ok { + var id uint64 + var limit int + + if storagePolicies.(*schema.Set).Len() > 0 { + spList := storagePolicies.(*schema.Set).List() + for _, spInterface := range spList { + sps := spInterface.(map[string]interface{}) + id = uint64(sps["id"].(int)) + limit = sps["limit"].(int) + + spModel := rg.StoragePolicy{ + ID: id, + Limit: limit, + } + + req.StoragePolicies = append(req.StoragePolicies, spModel) + } + } + } + apiResp, err := c.CloudAPI().RG().Create(ctx, req) if err != nil { return diag.FromErr(err) @@ -404,7 +425,16 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter return diag.FromErr(fmt.Errorf("resourceResgroupUpdate: RG ID %s: changing ext_net_id for existing RG is not allowed", d.Id())) } - if d.HasChanges("name", "quota", "description", "uniq_pools") { + needUpdateSP := false + if d.HasChange("storage_policy") { + needUpdate, err := utilityRGUpdateStPolicy(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + needUpdateSP = needUpdate + } + + if d.HasChanges("name", "quota", "description", "uniq_pools") || needUpdateSP { if err := utilityUpdateRG(ctx, d, m, rgData.ID); err != nil { return diag.FromErr(err) } @@ -655,7 +685,6 @@ func ResourceRgSchemaMake() map[string]*schema.Schema { }, }, }, - "def_net": { Type: schema.TypeSet, Optional: true, @@ -677,7 +706,24 @@ func ResourceRgSchemaMake() map[string]*schema.Schema { }, }, }, - + "storage_policy": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Required: true, + }, + "limit": { + Type: schema.TypeInt, + Optional: true, + Default: -1, + }, + }, + }, + }, "description": { Type: schema.TypeString, Optional: true, @@ -835,6 +881,65 @@ func ResourceRgSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "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, + }, + "storage_policy": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + }, + }, } } @@ -863,6 +968,10 @@ func ResourceResgroup() *schema.Resource { if diff.HasChange("def_net") { diff.SetNewComputed("def_net_id") } + if diff.HasChange("storage_policy") { + diff.SetNewComputed("storage_policy_ids") + diff.SetNewComputed("resource_limits") + } if diff.HasChanges() { diff.SetNewComputed("updated_by") diff.SetNewComputed("updated_time") diff --git a/internal/service/cloudapi/rg/utility_rg.go b/internal/service/cloudapi/rg/utility_rg.go index d47dde19..b172abae 100644 --- a/internal/service/cloudapi/rg/utility_rg.go +++ b/internal/service/cloudapi/rg/utility_rg.go @@ -124,6 +124,31 @@ func utilityUpdateRG(ctx context.Context, d *schema.ResourceData, m interface{}, } } + if d.HasChange("storage_policy") { + log.Debugf("resourceResgroupUpdate: storage policies specified.") + + if storagePolicies, ok := d.GetOk("storage_policy"); ok { + var id uint64 + var limit int + + if storagePolicies.(*schema.Set).Len() > 0 { + spList := storagePolicies.(*schema.Set).List() + for _, spInterface := range spList { + sps := spInterface.(map[string]interface{}) + id = uint64(sps["id"].(int)) + limit = sps["limit"].(int) + + spModel := rg.StoragePolicy{ + ID: id, + Limit: limit, + } + + req.StoragePolicies = append(req.StoragePolicies, spModel) + } + } + } + } + if d.HasChange("description") { log.Debugf("resourceResgroupUpdate: description specified - looking for deltas from the old settings.") req.Description = d.Get("description").(string) @@ -139,9 +164,112 @@ func utilityUpdateRG(ctx context.Context, d *schema.ResourceData, m interface{}, } } + _, _, updateStPolicy := utilityGetStoragePolicyUpdate(ctx, d, m) + if len(updateStPolicy) != 0 { + storagePolicies := make([]rg.StoragePolicy, 0, len(updateStPolicy)) + for _, stPolicyVal := range updateStPolicy { + reqStPolicy := rg.StoragePolicy{ + ID: uint64(stPolicyVal["id"].(int)), + Limit: stPolicyVal["limit"].(int), + } + + storagePolicies = append(storagePolicies, reqStPolicy) + } + req.StoragePolicies = storagePolicies + } + _, err := c.CloudAPI().RG().Update(ctx, req) if err != nil { return err } return nil } + +func utilityRGUpdateStPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) { + c := m.(*controller.ControllerCfg) + + rgID, _ := strconv.ParseUint(d.Id(), 10, 64) + + addSP, delSP, updateSP := utilityGetStoragePolicyUpdate(ctx, d, m) + needUpdate := len(updateSP) > 0 + + if len(addSP) > 0 { + for _, spMap := range addSP { + req := rg.AddStoragePolicyRequest{ + RGID: rgID, + StoragePolicyID: uint64(spMap["id"].(int)), + Limit: spMap["limit"].(int), + } + log.Debugf("utilityRGUpdateStPolicy: starting to add storage policy ID:%d for resource group %d", req.StoragePolicyID, req.RGID) + _, err := c.CloudAPI().RG().AddStoragePolicy(ctx, req) + if err != nil { + return needUpdate, err + } + } + } + + if len(delSP) > 0 { + for _, spMap := range delSP { + req := rg.DelStoragePolicyRequest{ + RGID: rgID, + StoragePolicyID: uint64(spMap["id"].(int)), + } + log.Debugf("utilityRGUpdateStPolicy: starting to delete storage policy ID:%d from resource group %d", req.StoragePolicyID, req.RGID) + _, err := c.CloudAPI().RG().DelStoragePolicy(ctx, req) + if err != nil { + return needUpdate, err + } + } + } + + return needUpdate, nil +} + +func utilityGetStoragePolicyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) (added, deleted, updated []map[string]interface{}) { + added = make([]map[string]interface{}, 0) + deleted = make([]map[string]interface{}, 0) + updated = make([]map[string]interface{}, 0) + oldSet, newSet := d.GetChange("storage_policy") + oldList := oldSet.(*schema.Set).List() + newList := newSet.(*schema.Set).List() + + for _, oldSP := range oldList { + oldMap := oldSP.(map[string]interface{}) + found := false + for _, newSP := range newList { + newMap := newSP.(map[string]interface{}) + if oldMap["id"] == newMap["id"] { + found = true + if oldMap["limit"] != newMap["limit"] { + updated = append(added, newMap) + } + break + } + if found { + break + } + } + if found { + continue + } + deleted = append(deleted, oldMap) + } + + for _, newSP := range newList { + newMap := newSP.(map[string]interface{}) + found := false + for _, oldSP := range oldList { + oldMap := oldSP.(map[string]interface{}) + if oldMap["id"] == newMap["id"] { + found = true + break + } + } + if found { + continue + } + added = append(added, newMap) + } + + return +} diff --git a/internal/service/cloudapi/secgroup/data_source_security_group.go b/internal/service/cloudapi/secgroup/data_source_security_group.go new file mode 100644 index 00000000..d5ba7ebd --- /dev/null +++ b/internal/service/cloudapi/secgroup/data_source_security_group.go @@ -0,0 +1,38 @@ +package secgroup + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + securityGroup, err := utilitySecurityGroupCheckPresence(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + flattenSecurityGroup(d, securityGroup) + + return nil +} + +func DataSourceSecurityGroup() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceSecurityGroupRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceSecurityGroupSchemaMake(), + } +} diff --git a/internal/service/cloudapi/secgroup/data_source_security_group_list.go b/internal/service/cloudapi/secgroup/data_source_security_group_list.go new file mode 100644 index 00000000..a2bf3e1a --- /dev/null +++ b/internal/service/cloudapi/secgroup/data_source_security_group_list.go @@ -0,0 +1,40 @@ +package secgroup + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceSecurityGroupListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + storagePolicyList, err := utilitySecurityGroupListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenSecurityGroupList(storagePolicyList)) + d.Set("entry_count", storagePolicyList.EntryCount) + + return nil +} + +func DataSourceSecurityGroupList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceSecurityGroupListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceSecurityGroupListSchemaMake(), + } +} diff --git a/internal/service/cloudapi/secgroup/flattens.go b/internal/service/cloudapi/secgroup/flattens.go new file mode 100644 index 00000000..208341db --- /dev/null +++ b/internal/service/cloudapi/secgroup/flattens.go @@ -0,0 +1,68 @@ +package secgroup + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/secgroup" +) + +func flattenSecurityGroupResource(d *schema.ResourceData, securityGroup *secgroup.RecordSecurityGroup) { + d.Set("security_group_id", securityGroup.ID) + d.Set("account_id", securityGroup.AccountID) + d.Set("name", securityGroup.Name) + d.Set("description", securityGroup.Description) + d.Set("rules", flattenRules(securityGroup.Rules)) + d.Set("created_at", securityGroup.CreatedAt) + d.Set("created_by", securityGroup.CreatedBy) + d.Set("updated_at", securityGroup.UpdatedAt) + d.Set("updated_by", securityGroup.UpdatedBy) +} + +func flattenSecurityGroupList(securityGroupList *secgroup.ListSecurityGroups) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(securityGroupList.Data)) + for _, v := range securityGroupList.Data { + temp := map[string]interface{}{ + "account_id": v.AccountID, + "name": v.Name, + "description": v.Description, + "rules": flattenRules(v.Rules), + "created_at": v.CreatedAt, + "created_by": v.CreatedBy, + "security_group_id": v.ID, + "updated_at": v.UpdatedAt, + "updated_by": v.UpdatedBy, + } + + res = append(res, temp) + } + + return res +} + +func flattenSecurityGroup(d *schema.ResourceData, securityGroup *secgroup.RecordSecurityGroup) { + d.Set("security_group_id", securityGroup.ID) + d.Set("account_id", securityGroup.AccountID) + d.Set("name", securityGroup.Name) + d.Set("description", securityGroup.Description) + d.Set("rules", flattenRules(securityGroup.Rules)) + d.Set("created_at", securityGroup.CreatedAt) + d.Set("created_by", securityGroup.CreatedBy) + d.Set("updated_at", securityGroup.UpdatedAt) + d.Set("updated_by", securityGroup.UpdatedBy) +} + +func flattenRules(rules secgroup.Rules) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(rules)) + for _, rule := range rules { + temp := map[string]interface{}{ + "id": rule.ID, + "direction": rule.Direction, + "ethertype": rule.Ethertype, + "protocol": rule.Protocol, + "port_range_min": rule.PortRangeMin, + "port_range_max": rule.PortRangeMax, + "remote_ip_prefix": rule.RemoteIPPrefix, + } + res = append(res, temp) + } + return res +} diff --git a/internal/service/cloudapi/secgroup/resource_security_group.go b/internal/service/cloudapi/secgroup/resource_security_group.go new file mode 100644 index 00000000..2ec81109 --- /dev/null +++ b/internal/service/cloudapi/secgroup/resource_security_group.go @@ -0,0 +1,146 @@ +package secgroup + +import ( + "context" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/secgroup" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc" +) + +func resourceSecurityGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSecurityGroupCreate: called with account ID %d, name %s", uint64(d.Get("account_id").(int)), d.Get("name").(string)) + + c := m.(*controller.ControllerCfg) + warnings := dc.Warnings{} + + accountID := uint64(d.Get("account_id").(int)) + name := d.Get("name").(string) + + req := secgroup.CreateRequest{ + AccountID: accountID, + Name: name, + } + + if description, ok := d.GetOk("description"); ok { + req.Description = description.(string) + } + + securityGroupID, err := c.CloudAPI().SecurityGroup().Create(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId(strconv.FormatUint(securityGroupID, 10)) + d.Set("security_group_id", securityGroupID) + + return append(warnings.Get(), resourceSecurityGroupRead(ctx, d, m)...) +} + +func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSecurityGroupRead: called with with account ID %d", uint64(d.Get("account_id").(int))) + + w := dc.Warnings{} + + securityGroupItem, err := utilitySecurityGroupCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenSecurityGroupResource(d, securityGroupItem) + + return w.Get() +} + +func resourceSecurityGroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + securityGroupID, _ := strconv.ParseUint(d.Id(), 10, 64) + + log.Debugf("resourceSecurityGroupUpdate: called security group with id %d", securityGroupID) + + c := m.(*controller.ControllerCfg) + + _, err := utilitySecurityGroupCheckPresence(ctx, d, m) + if err != nil { + + d.SetId("") + + return diag.FromErr(err) + } + + _, err = strconv.ParseInt(d.Id(), 10, 64) + if err != nil { + + d.SetId("") + + return diag.FromErr(err) + } + + if d.HasChanges("name", "description") { + + if err := utilitySecurityGroupHandleHasChanges(ctx, d, c, securityGroupID); err != nil { + return diag.FromErr(err) + } + } + + if d.HasChange("rules") { + if err := utilitySecurityGroupUpdateRules(ctx, d, c, securityGroupID); err != nil { + return diag.FromErr(err) + } + } + + return resourceSecurityGroupRead(ctx, d, m) +} + +func resourceSecurityGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSecurityGroupDelete: called with id %s", d.Id()) + + securityGroupItem, err := utilitySecurityGroupCheckPresence(ctx, d, m) + if err != nil { + + d.SetId("") + return diag.FromErr(err) + } + + c := m.(*controller.ControllerCfg) + req := secgroup.DeleteRequest{ + SecurityGroupID: securityGroupItem.ID, + } + if _, err := c.CloudAPI().SecurityGroup().Delete(ctx, req); err != nil { + return diag.FromErr(err) + } + + d.SetId("") + + return nil +} + +func ResourceSecurityGroup() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + CreateContext: resourceSecurityGroupCreate, + ReadContext: resourceSecurityGroupRead, + UpdateContext: resourceSecurityGroupUpdate, + DeleteContext: resourceSecurityGroupDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: &constants.Timeout600s, + Read: &constants.Timeout600s, + Update: &constants.Timeout600s, + Delete: &constants.Timeout600s, + Default: &constants.Timeout600s, + }, + + Schema: resourceSecurityGroupSchemaMake(), + } +} diff --git a/internal/service/cloudapi/secgroup/schema.go b/internal/service/cloudapi/secgroup/schema.go new file mode 100644 index 00000000..9e1a49fd --- /dev/null +++ b/internal/service/cloudapi/secgroup/schema.go @@ -0,0 +1,288 @@ +package secgroup + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceSecurityGroupSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeInt, + Required: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + }, + "rules": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "direction": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"inbound", "outbound"}, true), + }, + "ethertype": { + Type: schema.TypeString, + Optional: true, + Default: "IPv4", + ValidateFunc: validation.StringInSlice([]string{"IPv4", "IPv6"}, true), + }, + "protocol": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"icmp", "tcp", "udp"}, true), + }, + "port_range_min": { + Type: schema.TypeInt, + Optional: true, + }, + "port_range_max": { + Type: schema.TypeInt, + Optional: true, + }, + "remote_ip_prefix": { + Type: schema.TypeString, + Optional: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "security_group_id": { + Type: schema.TypeInt, + Computed: true, + }, + "created_at": { + Type: schema.TypeInt, + Computed: true, + }, + "updated_at": { + Type: schema.TypeInt, + Computed: true, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + } + return res +} + +func dataSourceSecurityGroupSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "security_group_id": { + Type: schema.TypeInt, + Required: true, + }, + "account_id": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "rules": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "direction": { + Type: schema.TypeString, + Computed: true, + }, + "ethertype": { + Type: schema.TypeString, + Computed: true, + }, + "protocol": { + Type: schema.TypeString, + Computed: true, + }, + "port_range_min": { + Type: schema.TypeInt, + Computed: true, + }, + "port_range_max": { + Type: schema.TypeInt, + Computed: true, + }, + "remote_ip_prefix": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "created_at": { + Type: schema.TypeInt, + Computed: true, + }, + "updated_at": { + Type: schema.TypeInt, + Computed: true, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + } + return res +} + +func dataSourceSecurityGroupListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "page": { + Type: schema.TypeInt, + Optional: true, + }, + "size": { + Type: schema.TypeInt, + Optional: true, + }, + "by_id": { + Type: schema.TypeInt, + Optional: true, + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + }, + "name": { + Type: schema.TypeString, + Optional: true, + }, + "desc": { + Type: schema.TypeString, + Optional: true, + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + }, + "created_min": { + Type: schema.TypeInt, + Optional: true, + }, + "created_max": { + Type: schema.TypeInt, + Optional: true, + }, + "updated_min": { + Type: schema.TypeInt, + Optional: true, + }, + "updated_max": { + Type: schema.TypeInt, + Optional: true, + }, + "items": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "security_group_id": { + Type: schema.TypeInt, + Computed: true, + }, + "account_id": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "rules": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "direction": { + Type: schema.TypeString, + Computed: true, + }, + "ethertype": { + Type: schema.TypeString, + Computed: true, + }, + "protocol": { + Type: schema.TypeString, + Computed: true, + }, + "port_range_min": { + Type: schema.TypeInt, + Computed: true, + }, + "port_range_max": { + Type: schema.TypeInt, + Computed: true, + }, + "remote_ip_prefix": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "created_at": { + Type: schema.TypeInt, + Computed: true, + }, + "updated_at": { + Type: schema.TypeInt, + Computed: true, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "entry_count": { + Type: schema.TypeInt, + Computed: true, + }, + } + return res +} diff --git a/internal/service/cloudapi/secgroup/utility_security_group.go b/internal/service/cloudapi/secgroup/utility_security_group.go new file mode 100644 index 00000000..bc148814 --- /dev/null +++ b/internal/service/cloudapi/secgroup/utility_security_group.go @@ -0,0 +1,95 @@ +package secgroup + +import ( + "context" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/secgroup" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilitySecurityGroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*secgroup.RecordSecurityGroup, error) { + c := m.(*controller.ControllerCfg) + req := secgroup.GetRequest{} + if d.Id() != "" { + securityGroupID, _ := strconv.ParseUint(d.Id(), 10, 64) + req.SecurityGroupID = securityGroupID + } else { + req.SecurityGroupID = uint64(d.Get("security_group_id").(int)) + } + + log.Debugf("utilitySecurityGroupCheckPresence: load security group") + securityGroup, err := c.CloudAPI().SecurityGroup().Get(ctx, req) + if err != nil { + return nil, err + } + + return securityGroup, nil +} + +func utilitySecurityGroupHandleHasChanges(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, securityGroupID uint64) error { + req := secgroup.UpdateRequest{ + SecurityGroupID: securityGroupID, + } + + if d.HasChange("name") { + name := d.Get("name").(string) + req.Name = name + } + + if d.HasChange("description") { + description := d.Get("description").(string) + req.Description = description + } + + if _, err := c.CloudAPI().SecurityGroup().Update(ctx, req); err != nil { + return err + } + + return nil +} + +func utilitySecurityGroupUpdateRules(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, securityGroupID uint64) error { + oldSet, newSet := d.GetChange("rules") + deletedRules := (oldSet.(*schema.Set).Difference(newSet.(*schema.Set))).List() + for _, deletedInterface := range deletedRules { + deletedItem := deletedInterface.(map[string]interface{}) + ruleID := uint64(deletedItem["id"].(int)) + req := secgroup.DeleteRuleRequest{ + SecurityGroupID: securityGroupID, + RuleID: ruleID, + } + if _, err := c.CloudAPI().SecurityGroup().DeleteRule(ctx, req); err != nil { + return err + } + + } + + addedRules := (newSet.(*schema.Set).Difference(oldSet.(*schema.Set))).List() + for _, addedInterface := range addedRules { + addedItem := addedInterface.(map[string]interface{}) + direction := addedItem["direction"].(string) + ethertype := addedItem["ethertype"].(string) + protocol := addedItem["protocol"].(string) + portRangeMin := uint64(addedItem["port_range_min"].(int)) + portRangeMax := uint64(addedItem["port_range_max"].(int)) + remoteIPPrefix := addedItem["remote_ip_prefix"].(string) + req := secgroup.CreateRuleRequest{ + SecurityGroupID: securityGroupID, + Direction: direction, + Ethertype: ethertype, + Protocol: protocol, + PortRangeMin: portRangeMin, + PortRangeMax: portRangeMax, + RemoteIPPrefix: remoteIPPrefix, + } + + if _, err := c.CloudAPI().SecurityGroup().CreateRule(ctx, req); err != nil { + return err + } + } + + return nil +} diff --git a/internal/service/cloudapi/secgroup/utility_security_group_list.go b/internal/service/cloudapi/secgroup/utility_security_group_list.go new file mode 100644 index 00000000..a45345d9 --- /dev/null +++ b/internal/service/cloudapi/secgroup/utility_security_group_list.go @@ -0,0 +1,60 @@ +package secgroup + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/secgroup" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilitySecurityGroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*secgroup.ListSecurityGroups, error) { + c := m.(*controller.ControllerCfg) + + req := secgroup.ListRequest{} + + if size, ok := d.GetOk("size"); ok { + req.Size = uint64(size.(int)) + } + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + if byID, ok := d.GetOk("by_id"); ok { + req.ByID = uint64(byID.(int)) + } + if accountID, ok := d.GetOk("account_id"); ok { + req.AccountID = uint64(accountID.(int)) + } + if name, ok := d.GetOk("name"); ok { + req.Name = name.(string) + } + if desc, ok := d.GetOk("desc"); ok { + req.Description = desc.(string) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if createdMin, ok := d.GetOk("created_min"); ok { + req.CreatedMin = uint64(createdMin.(int)) + } + if createdMax, ok := d.GetOk("created_max"); ok { + req.CreatedMax = uint64(createdMax.(int)) + } + if updatedMin, ok := d.GetOk("updated_min"); ok { + req.UpdatedMin = uint64(updatedMin.(int)) + } + if updatedMax, ok := d.GetOk("updated_max"); ok { + req.UpdatedMax = uint64(updatedMax.(int)) + } + + log.Debugf("utilitySecurityGroupListCheckPresence: load storage policy list") + + securityGroupList, err := c.CloudAPI().SecurityGroup().List(ctx, req) + if err != nil { + return nil, err + } + + return securityGroupList, nil + +} diff --git a/internal/service/cloudapi/stpolicy/data_source_storage_policy.go b/internal/service/cloudapi/stpolicy/data_source_storage_policy.go new file mode 100644 index 00000000..90ba6b94 --- /dev/null +++ b/internal/service/cloudapi/stpolicy/data_source_storage_policy.go @@ -0,0 +1,37 @@ +package stpolicy + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceStoragePolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + storagePolicy, err := utilityStoragePolicyCheckPresence(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + flattenStoragePolicyData(d, storagePolicy) + return nil +} + +func DataSourceStoragePolicy() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceStoragePolicyRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceStoragePolicySchemaMake(), + } +} diff --git a/internal/service/cloudapi/stpolicy/data_source_storage_policy_list.go b/internal/service/cloudapi/stpolicy/data_source_storage_policy_list.go new file mode 100644 index 00000000..73565f97 --- /dev/null +++ b/internal/service/cloudapi/stpolicy/data_source_storage_policy_list.go @@ -0,0 +1,40 @@ +package stpolicy + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceStoragePolicyListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + storagePolicyList, err := utilityStoragePolicyListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenStoragePolicyList(storagePolicyList)) + d.Set("entry_count", storagePolicyList.EntryCount) + + return nil +} + +func DataSourceStoragePolicyList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceStoragePolicyListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceStoragePolicyListSchemaMake(), + } +} diff --git a/internal/service/cloudapi/stpolicy/flattens.go b/internal/service/cloudapi/stpolicy/flattens.go new file mode 100644 index 00000000..403acdc1 --- /dev/null +++ b/internal/service/cloudapi/stpolicy/flattens.go @@ -0,0 +1,63 @@ +package stpolicy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stpolicy" +) + +func flattenStoragePolicyData(d *schema.ResourceData, storagePolicy *stpolicy.InfoStoragePolicy) { + d.Set("storage_policy_id", storagePolicy.ID) + d.Set("description", storagePolicy.Description) + d.Set("guid", storagePolicy.GUID) + d.Set("limit_iops", storagePolicy.LimitIOPS) + d.Set("name", storagePolicy.Name) + d.Set("status", storagePolicy.Status) + d.Set("access_seps_pools", flattenAccessSEPPools(storagePolicy.AccessSEPPools)) + d.Set("usage", flattenUsage(storagePolicy.Usage)) +} + +func flattenAccessSEPPools(accessSEPPools stpolicy.ListAccessSEPPools) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(accessSEPPools)) + for _, asp := range accessSEPPools { + temp := map[string]interface{}{ + "sep_id": asp.SEPID, + //TODO + //"name": asp.Name, + "pool_names": asp.PoolNames, + } + + res = append(res, temp) + } + + return res +} + +func flattenUsage(usage stpolicy.Usage) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + + temp := map[string]interface{}{ + "accounts": usage.Accounts, + "resgroups": usage.Resgroups, + } + + res = append(res, temp) + return res +} + +func flattenStoragePolicyList(storagePolicyList *stpolicy.ListStoragePolicies) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(storagePolicyList.Data)) + for _, v := range storagePolicyList.Data { + temp := map[string]interface{}{ + "storage_policy_id": v.ID, + "description": v.Description, + "guid": v.GUID, + "limit_iops": v.LimitIOPS, + "name": v.Name, + "status": v.Status, + "access_seps_pools": flattenAccessSEPPools(v.AccessSEPPools), + "usage": flattenUsage(v.Usage), + } + res = append(res, temp) + } + return res +} diff --git a/internal/service/cloudapi/stpolicy/schema.go b/internal/service/cloudapi/stpolicy/schema.go new file mode 100644 index 00000000..0c6c8817 --- /dev/null +++ b/internal/service/cloudapi/stpolicy/schema.go @@ -0,0 +1,207 @@ +package stpolicy + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func dataSourceStoragePolicySchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "limit_iops": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "access_seps_pools": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "pool_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "usage": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accounts": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "resgroups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + }, + }, + }, + } + + return res +} + +func dataSourceStoragePolicyListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeInt, + Optional: true, + }, + "page": { + Type: schema.TypeInt, + Optional: true, + }, + "size": { + Type: schema.TypeInt, + Optional: true, + }, + "by_id": { + Type: schema.TypeInt, + Optional: true, + }, + "name": { + Type: schema.TypeString, + Optional: true, + }, + "status": { + Type: schema.TypeString, + Optional: true, + }, + "desc": { + Type: schema.TypeString, + Optional: true, + }, + "limit_iops": { + Type: schema.TypeInt, + Optional: true, + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + }, + "resgroup_id": { + Type: schema.TypeInt, + Optional: true, + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + }, + "pool_name": { + Type: schema.TypeString, + Optional: true, + }, + + "items": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "limit_iops": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "access_seps_pools": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "pool_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "usage": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accounts": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "resgroups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + }, + }, + }, + }, + }, + }, + "entry_count": { + Type: schema.TypeInt, + Computed: true, + }, + } + return res +} diff --git a/internal/service/cloudapi/stpolicy/utility_storage_policy.go b/internal/service/cloudapi/stpolicy/utility_storage_policy.go new file mode 100644 index 00000000..1dea8ee4 --- /dev/null +++ b/internal/service/cloudapi/stpolicy/utility_storage_policy.go @@ -0,0 +1,29 @@ +package stpolicy + +import ( + "context" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stpolicy" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityStoragePolicyCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*stpolicy.InfoStoragePolicy, error) { + c := m.(*controller.ControllerCfg) + req := stpolicy.GetRequest{} + + if d.Id() != "" { + storagePolicyID, _ := strconv.ParseUint(d.Id(), 10, 64) + req.StoragePolicyID = storagePolicyID + } else { + req.StoragePolicyID = uint64(d.Get("storage_policy_id").(int)) + } + + storagePolicyData, err := c.CloudAPI().StPolicy().Get(ctx, req) + if err != nil { + return nil, err + } + + return storagePolicyData, nil +} diff --git a/internal/service/cloudapi/stpolicy/utility_storage_policy_list.go b/internal/service/cloudapi/stpolicy/utility_storage_policy_list.go new file mode 100644 index 00000000..2dfb220b --- /dev/null +++ b/internal/service/cloudapi/stpolicy/utility_storage_policy_list.go @@ -0,0 +1,71 @@ +package stpolicy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stpolicy" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityStoragePolicyListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*stpolicy.ListStoragePolicies, error) { + c := m.(*controller.ControllerCfg) + req := stpolicy.ListRequest{} + + if accountID, ok := d.GetOk("account_id"); ok { + req.AccountID = uint64(accountID.(int)) + } + + if size, ok := d.GetOk("size"); ok { + req.Size = uint64(size.(int)) + } + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + + if byID, ok := d.GetOk("by_id"); ok { + req.ByID = uint64(byID.(int)) + } + + if name, ok := d.GetOk("name"); ok { + req.Name = name.(string) + } + + if status, ok := d.GetOk("status"); ok { + req.Status = status.(string) + } + + if desc, ok := d.GetOk("desc"); ok { + req.Desc = desc.(string) + } + + if limitIOPS, ok := d.GetOk("limit_iops"); ok { + req.LimitIOPS = uint64(limitIOPS.(int)) + } + + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + + if resgroupID, ok := d.GetOk("resgroup_id"); ok { + req.ResgroupID = uint64(resgroupID.(int)) + } + + if SEPID, ok := d.GetOk("sep_id"); ok { + req.SepID = uint64(SEPID.(int)) + } + + if poolName, ok := d.GetOk("pool_name"); ok { + req.PoolName = poolName.(string) + } + + log.Debugf("utilityStoragePolicyListCheckPresence: load storage policy list") + + storagePolicyList, err := c.CloudAPI().StPolicy().List(ctx, req) + if err != nil { + return nil, err + } + + return storagePolicyList, nil +} diff --git a/internal/service/cloudapi/trunk/utility_trunk_list.go b/internal/service/cloudapi/trunk/utility_trunk_list.go index 5b33b0f5..68e3de1f 100644 --- a/internal/service/cloudapi/trunk/utility_trunk_list.go +++ b/internal/service/cloudapi/trunk/utility_trunk_list.go @@ -28,6 +28,9 @@ func utilityTrunkListCheckPresence(ctx context.Context, d *schema.ResourceData, if trunkTags, ok := d.GetOk("trunk_tags"); ok { req.TrunkTags = trunkTags.(string) } + if status, ok := d.GetOk("status"); ok { + req.Status = status.(string) + } if sortBy, ok := d.GetOk("sort_by"); ok { req.SortBy = sortBy.(string) } diff --git a/internal/service/cloudapi/vins/data_source_vins.go b/internal/service/cloudapi/vins/data_source_vins.go index 5fb9b9b2..f5995d67 100644 --- a/internal/service/cloudapi/vins/data_source_vins.go +++ b/internal/service/cloudapi/vins/data_source_vins.go @@ -134,6 +134,10 @@ func vnfInterfaceSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "flipgroup_id": { Type: schema.TypeInt, Computed: true, @@ -234,6 +238,13 @@ func vnfInterfaceSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "security_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "target": { Type: schema.TypeString, Computed: true, @@ -327,6 +338,10 @@ func vnfDevSchemaMake() map[string]*schema.Schema { Schema: vnfInterfaceSchemaMake(), }, }, + "live_migration_job_id": { + Type: schema.TypeInt, + Computed: true, + }, "lock_status": { Type: schema.TypeString, Computed: true, @@ -362,6 +377,10 @@ func vnfDevSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, } } @@ -554,6 +573,10 @@ func dhcpSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, } } @@ -678,6 +701,13 @@ func gwSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "routes": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: routesSchemaMake(), + }, + }, "status": { Type: schema.TypeString, Computed: true, @@ -690,6 +720,10 @@ func gwSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, } } @@ -810,6 +844,13 @@ func natSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "routes": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: routesSchemaMake(), + }, + }, "status": { Type: schema.TypeString, Computed: true, @@ -822,6 +863,10 @@ func natSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, } } diff --git a/internal/service/cloudapi/vins/data_source_vins_list.go b/internal/service/cloudapi/vins/data_source_vins_list.go index 4f51c7e5..20e8a1cf 100644 --- a/internal/service/cloudapi/vins/data_source_vins_list.go +++ b/internal/service/cloudapi/vins/data_source_vins_list.go @@ -114,6 +114,11 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudapi/vins/flattens.go b/internal/service/cloudapi/vins/flattens.go index cef37d93..db2260a5 100644 --- a/internal/service/cloudapi/vins/flattens.go +++ b/internal/service/cloudapi/vins/flattens.go @@ -91,6 +91,7 @@ func flattenInterfaces(interfaces []vins.ItemVNFInterface) []map[string]interfac "conn_type": vnfInterface.ConnType, "def_gw": vnfInterface.DefGW, "enabled": vnfInterface.Enabled, + "enable_secgroups": vnfInterface.EnableSecGroups, "flipgroup_id": vnfInterface.FLIPGroupID, "guid": vnfInterface.GUID, "ip_address": vnfInterface.IPAddress, @@ -106,6 +107,7 @@ func flattenInterfaces(interfaces []vins.ItemVNFInterface) []map[string]interfac "bus_number": vnfInterface.BusNumber, "qos": flattenQOS(vnfInterface.QOS), "sdn_interface_id": vnfInterface.SDNInterfaceID, + "security_groups": vnfInterface.SecGroups, "target": vnfInterface.Target, "type": vnfInterface.Type, "vnfs": vnfInterface.VNFs, @@ -135,25 +137,26 @@ func flattenLibvirtSettings(libvirtSettings vins.LibvirtSettings) []map[string]i func flattenVNFDev(vnfDev vins.RecordVNFDev) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "_ckey": vnfDev.CKey, - "account_id": vnfDev.AccountID, - "capabilities": vnfDev.Capabilities, - "config": flattenConfig(vnfDev.Config), //in progress - "config_saved": vnfDev.ConfigSaved, - "custom_pre_cfg": vnfDev.CustomPreConfig, - "desc": vnfDev.Description, - "gid": vnfDev.GID, - "guid": vnfDev.GUID, - "vnf_id": vnfDev.ID, - "interfaces": flattenInterfaces(vnfDev.Interfaces), - "lock_status": vnfDev.LockStatus, - "milestones": vnfDev.Milestones, - "vnf_name": vnfDev.Name, - "status": vnfDev.Status, - "tech_status": vnfDev.TechStatus, - "type": vnfDev.Type, - "vnc_password": vnfDev.VNCPassword, - "vins": vnfDev.VINS, + "_ckey": vnfDev.CKey, + "account_id": vnfDev.AccountID, + "capabilities": vnfDev.Capabilities, + "config": flattenConfig(vnfDev.Config), //in progress + "config_saved": vnfDev.ConfigSaved, + "custom_pre_cfg": vnfDev.CustomPreConfig, + "desc": vnfDev.Description, + "gid": vnfDev.GID, + "guid": vnfDev.GUID, + "vnf_id": vnfDev.ID, + "interfaces": flattenInterfaces(vnfDev.Interfaces), + "live_migration_job_id": vnfDev.LiveMigrationJobID, + "lock_status": vnfDev.LockStatus, + "milestones": vnfDev.Milestones, + "vnf_name": vnfDev.Name, + "status": vnfDev.Status, + "tech_status": vnfDev.TechStatus, + "type": vnfDev.Type, + "vnc_password": vnfDev.VNCPassword, + "vins": vnfDev.VINS, } res = append(res, temp) @@ -249,6 +252,7 @@ func flattenDHCP(dhcp vins.RecordDHCP) []map[string]interface{} { "status": dhcp.Status, "tech_status": dhcp.TechStatus, "type": dhcp.Type, + "zone_id": dhcp.ZoneID, } res = append(res, temp) @@ -285,9 +289,11 @@ func flattenGW(gw vins.RecordGW) []map[string]interface{} { "owner_id": gw.OwnerID, "owner_type": gw.OwnerType, "pure_virtual": gw.PureVirtual, + "routes": flattenStaticRoute(gw.Routes), "status": gw.Status, "tech_status": gw.TechStatus, "type": gw.Type, + "zone_id": gw.ZoneID, } res = append(res, temp) @@ -341,9 +347,11 @@ func flattenNAT(nat vins.RecordNAT) []map[string]interface{} { "owner_id": nat.OwnerID, "owner_type": nat.OwnerType, "pure_virtual": nat.PureVirtual, + "routes": flattenStaticRoute(nat.Routes), "status": nat.Status, "tech_status": nat.TechStatus, "type": nat.Type, + "zone_id": nat.ZoneID, } res = append(res, temp) diff --git a/internal/service/cloudapi/vins/utility_vins_list.go b/internal/service/cloudapi/vins/utility_vins_list.go index ab919740..3f9f4081 100644 --- a/internal/service/cloudapi/vins/utility_vins_list.go +++ b/internal/service/cloudapi/vins/utility_vins_list.go @@ -88,6 +88,9 @@ func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } log.Debugf("utilityVinsListCheckPresence") vinsList, err := c.CloudAPI().VINS().List(ctx, req) diff --git a/internal/service/cloudapi/zone/data_source_zone.go b/internal/service/cloudapi/zone/data_source_zone.go index 80126f4b..788a21fe 100644 --- a/internal/service/cloudapi/zone/data_source_zone.go +++ b/internal/service/cloudapi/zone/data_source_zone.go @@ -97,6 +97,55 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "account_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "compute_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "extnet_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "vins_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "lb_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "bservice_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "k8s_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, } } diff --git a/internal/service/cloudapi/zone/flattens.go b/internal/service/cloudapi/zone/flattens.go index 2eae26b7..fb9a5329 100644 --- a/internal/service/cloudapi/zone/flattens.go +++ b/internal/service/cloudapi/zone/flattens.go @@ -52,6 +52,13 @@ func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error { d.Set("created_time", item.CreatedTime) d.Set("updated_time", item.UpdatedTime) d.Set("node_ids", item.NodeIDs) + d.Set("account_ids", item.AccountIDs) + d.Set("compute_ids", item.ComputeIDs) + d.Set("extnet_ids", item.ExtnetIDs) + d.Set("vins_ids", item.VinsIDs) + d.Set("lb_ids", item.LBIDs) + d.Set("bservice_ids", item.BserviceIDs) + d.Set("k8s_ids", item.K8SIDs) log.Debugf("flattenZone: decoded RecordZone name %q / ID %d, complete", item.Name, item.ID) diff --git a/internal/service/cloudbroker/account/flattens.go b/internal/service/cloudbroker/account/flattens.go index ccdfc3f4..55eab85c 100644 --- a/internal/service/cloudbroker/account/flattens.go +++ b/internal/service/cloudbroker/account/flattens.go @@ -3,16 +3,13 @@ package account import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/account" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens" ) func flattenResourceAccount(d *schema.ResourceData, acc *account.RecordAccount) { d.Set("dc_location", acc.DCLocation) - d.Set("ckey", acc.CKey) d.Set("acl", flattenAccAcl(acc.ACL)) d.Set("company", acc.Company) d.Set("companyurl", acc.CompanyURL) - d.Set("compute_features", acc.ComputeFeatures) d.Set("cpu_allocation_parameter", acc.CPUAllocationParameter) d.Set("cpu_allocation_ratio", acc.CPUAllocationRatio) d.Set("created_by", acc.CreatedBy) @@ -27,6 +24,7 @@ func flattenResourceAccount(d *schema.ResourceData, acc *account.RecordAccount) d.Set("account_id", acc.ID) d.Set("account_name", acc.Name) d.Set("resource_limits", flattenRgResourceLimits(acc.ResourceLimits)) + d.Set("storage_policy", flattenSTPolicy(acc.ResourceLimits.StoragePolicies)) d.Set("resource_types", acc.ResTypes) d.Set("send_access_emails", acc.SendAccessEmails) d.Set("status", acc.Status) @@ -34,12 +32,11 @@ func flattenResourceAccount(d *schema.ResourceData, acc *account.RecordAccount) d.Set("updated_time", acc.UpdatedTime) d.Set("version", acc.Version) d.Set("vins", acc.VINS) - d.Set("zone_ids", acc.ZoneIDs) + d.Set("zone_ids", flattenZonesInResource(acc.ZoneIDs)) } func flattenDataAccount(d *schema.ResourceData, acc *account.RecordAccount) { d.Set("dc_location", acc.DCLocation) - d.Set("ckey", acc.CKey) d.Set("acl", flattenAccAcl(acc.ACL)) d.Set("company", acc.Company) d.Set("companyurl", acc.CompanyURL) @@ -142,11 +139,26 @@ func flattenAccResource(r account.Resource) []map[string]interface{} { "gpu": r.GPU, "ram": r.RAM, "seps": flattenAccountSeps(r.SEPs), + "policies": flattenAccountPolicies(r.Policies), } res = append(res, temp) return res } +func flattenAccountPolicies(policies map[string]account.Policy) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + for k, dataVal := range policies { + temp := map[string]interface{}{ + "id": k, + "disk_size": dataVal.DiskSize, + "disk_size_max": dataVal.DiskSizeMax, + "seps": flattenAccountSeps(dataVal.SEPs), + } + res = append(res, temp) + } + return res +} + func flattenAccAcl(acls []account.ACLWithEmails) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(acls)) for _, acls := range acls { @@ -172,19 +184,32 @@ func flattenAccAcl(acls []account.ACLWithEmails) []map[string]interface{} { func flattenRgResourceLimits(rl account.ResourceLimits) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "cu_c": rl.CuC, - "cu_d": rl.CuD, - "cu_dm": rl.CuDM, - "cu_i": rl.CuI, - "cu_m": rl.CuM, - "cu_np": rl.CuNP, - "gpu_units": rl.GPUUnits, + "cu_c": rl.CuC, + "cu_d": rl.CuD, + "cu_dm": rl.CuDM, + "cu_i": rl.CuI, + "cu_m": rl.CuM, + "cu_np": rl.CuNP, + "gpu_units": rl.GPUUnits, + "storage_policy": flattenSTPolicy(rl.StoragePolicies), } res = append(res, temp) return res } +func flattenSTPolicy(ast []account.StoragePolicy) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(ast)) + for _, item := range ast { + temp := map[string]interface{}{ + "id": item.ID, + "limit": item.Limit, + } + res = append(res, temp) + } + return res +} + func flattenRgAcl(rgAcls []account.ACL) []map[string]interface{} { res := make([]map[string]interface{}, len(rgAcls)) for _, rgAcl := range rgAcls { @@ -206,8 +231,6 @@ func flattenListDeleted(al *account.ListAccounts) []map[string]interface{} { for _, acc := range al.Data { temp := map[string]interface{}{ "dc_location": acc.DCLocation, - "ckey": acc.CKey, - "meta": flattens.FlattenMeta(acc.Meta), "acl": flattenRgAcl(acc.ACL), "company": acc.Company, "companyurl": acc.CompanyURL, @@ -228,6 +251,7 @@ func flattenListDeleted(al *account.ListAccounts) []map[string]interface{} { "resource_types": acc.ResTypes, "send_access_emails": acc.SendAccessEmails, "status": acc.Status, + "storage_policy_ids": acc.StoragePolicyIDs, "uniq_pools": acc.UniqPools, "default_zone_id": acc.DefaultZoneID, "zone_ids": acc.ZoneIDs, @@ -245,8 +269,6 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} { for _, acc := range al.Data { temp := map[string]interface{}{ "dc_location": acc.DCLocation, - "ckey": acc.CKey, - "meta": flattens.FlattenMeta(acc.Meta), "acl": flattenRgAcl(acc.ACL), "company": acc.Company, "companyurl": acc.CompanyURL, @@ -267,6 +289,7 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} { "resource_types": acc.ResTypes, "send_access_emails": acc.SendAccessEmails, "status": acc.Status, + "storage_policy_ids": acc.StoragePolicyIDs, "uniq_pools": acc.UniqPools, "default_zone_id": acc.DefaultZoneID, "zone_ids": acc.ZoneIDs, @@ -452,3 +475,11 @@ func flattenZones(zones []account.ZoneID) []map[string]interface{} { } return res } + +func flattenZonesInResource(zones []account.ZoneID) []int64 { + res := make([]int64, 0) + for _, zone := range zones { + res = append(res, zone.ID) + } + return res +} diff --git a/internal/service/cloudbroker/account/resource_account.go b/internal/service/cloudbroker/account/resource_account.go index a3dfe1d1..fa77ac6a 100644 --- a/internal/service/cloudbroker/account/resource_account.go +++ b/internal/service/cloudbroker/account/resource_account.go @@ -144,6 +144,23 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interf } } + if stPolicy, ok := d.GetOk("storage_policy"); ok { + sp := stPolicy.(*schema.Set).List() + storagePolicies := make([]account.StoragePolicy, 0) + for _, elem := range sp { + stPolicyVal := elem.(map[string]interface{}) + + reqStPolicy := account.StoragePolicy{ + ID: uint64(stPolicyVal["id"].(int)), + Limit: stPolicyVal["limit"].(int), + } + + storagePolicies = append(storagePolicies, reqStPolicy) + } + req.StoragePolicies = storagePolicies + + } + if compFeaturesInterface, ok := d.GetOk("compute_features"); ok { compFeaturesInterfaces := compFeaturesInterface.(*schema.Set).List() @@ -372,7 +389,16 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf } } - if d.HasChanges("account_name", "send_access_emails", "uniq_pools", "resource_limits", "desc", "default_zone_id") { + needUpdateSP := false + if d.HasChange("storage_policy") { + needUpdate, err := utilityAccountUpdateStPolicy(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + needUpdateSP = needUpdate + } + + if d.HasChanges("account_name", "send_access_emails", "uniq_pools", "resource_limits", "desc", "default_zone_id") || needUpdateSP { if err := utilityAccountUpdate(ctx, d, m); err != nil { return diag.FromErr(err) } @@ -411,14 +437,18 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf if d.HasChange("zone_ids") { old, new := d.GetChange("zone_ids") - //toAddSet := old.(*schema.Set).Difference(new.(*schema.Set)) - toRemoveSet := new.(*schema.Set).Difference(old.(*schema.Set)) + toRemoveSet := old.(*schema.Set).Difference(new.(*schema.Set)) + toAddSet := new.(*schema.Set).Difference(old.(*schema.Set)) - /*if err := utilityZoneIDsUpdate(ctx, d, m, toAddSet); err != nil { - return diag.FromErr(err) - }*/ - if err := utilityZoneIDsRemove(ctx, d, m, toRemoveSet); err != nil { - return diag.FromErr(err) + if len(toAddSet.List()) > 0 { + if err := utilityZoneIDsAdd(ctx, d, m, toAddSet); err != nil { + return diag.FromErr(err) + } + } + if len(toRemoveSet.List()) > 0 { + if err := utilityZoneIDsRemove(ctx, d, m, toRemoveSet); err != nil { + return diag.FromErr(err) + } } } diff --git a/internal/service/cloudbroker/account/schema.go b/internal/service/cloudbroker/account/schema.go index 39fba592..0685f600 100644 --- a/internal/service/cloudbroker/account/schema.go +++ b/internal/service/cloudbroker/account/schema.go @@ -39,7 +39,7 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Description: "if true send emails when a user is granted access to resources", }, "zone_ids": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Computed: true, Elem: &schema.Schema{ @@ -148,6 +148,39 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { Optional: true, Computed: true, }, + "storage_policy": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "storage_policy": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Required: true, + }, + "limit": { + Type: schema.TypeInt, + Required: true, + }, }, }, }, @@ -168,17 +201,6 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { 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, @@ -523,17 +545,6 @@ func dataSourceAccountListDeletedSchemaMake() map[string]*schema.Schema { 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, @@ -662,6 +673,22 @@ func dataSourceAccountListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -680,6 +707,13 @@ func dataSourceAccountListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "default_zone_id": { Type: schema.TypeInt, Computed: true, @@ -998,6 +1032,50 @@ func dataSourceAccountResourceConsumptionGetSchemaMake() map[string]*schema.Sche Type: schema.TypeInt, Computed: true, }, + "policies": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "disk_size": { + Type: schema.TypeFloat, + Computed: true, + }, + "disk_size_max": { + Type: schema.TypeFloat, + 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, + }, + }, + }, + }, + }, + }, + }, "ram": { Type: schema.TypeInt, Computed: true, @@ -1058,6 +1136,50 @@ func dataSourceAccountResourceConsumptionGetSchemaMake() map[string]*schema.Sche Type: schema.TypeInt, Computed: true, }, + "policies": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "disk_size": { + Type: schema.TypeFloat, + Computed: true, + }, + "disk_size_max": { + Type: schema.TypeFloat, + 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, + }, + }, + }, + }, + }, + }, + }, "ram": { Type: schema.TypeInt, Computed: true, @@ -1167,6 +1289,11 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, @@ -1176,17 +1303,6 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema { 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, @@ -1319,6 +1435,22 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -1337,6 +1469,13 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "uniq_pools": { Type: schema.TypeList, Computed: true, @@ -1417,6 +1556,50 @@ func dataSourceAccountResourceConsumptionListSchemaMake() map[string]*schema.Sch Type: schema.TypeInt, Computed: true, }, + "policies": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "disk_size": { + Type: schema.TypeFloat, + Computed: true, + }, + "disk_size_max": { + Type: schema.TypeFloat, + 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, + }, + }, + }, + }, + }, + }, + }, "ram": { Type: schema.TypeInt, Computed: true, @@ -1477,6 +1660,50 @@ func dataSourceAccountResourceConsumptionListSchemaMake() map[string]*schema.Sch Type: schema.TypeInt, Computed: true, }, + "policies": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "disk_size": { + Type: schema.TypeFloat, + Computed: true, + }, + "disk_size_max": { + Type: schema.TypeFloat, + 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, + }, + }, + }, + }, + }, + }, + }, "ram": { Type: schema.TypeInt, Computed: true, @@ -1961,16 +2188,12 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, - "ckey": { - Type: schema.TypeString, - Computed: true, - }, "default_zone_id": { Type: schema.TypeInt, Computed: true, }, "zone_ids": { - Type: schema.TypeList, + Type: schema.TypeSet, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -2116,6 +2339,22 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -2156,6 +2395,13 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, } } diff --git a/internal/service/cloudbroker/account/utility_account.go b/internal/service/cloudbroker/account/utility_account.go index 55a722a9..791d638c 100644 --- a/internal/service/cloudbroker/account/utility_account.go +++ b/internal/service/cloudbroker/account/utility_account.go @@ -211,7 +211,8 @@ func utilityAccountUpdate(ctx context.Context, d *schema.ResourceData, m interfa accountId, _ := strconv.ParseUint(d.Id(), 10, 64) req := account.UpdateRequest{ - AccountID: accountId, + AccountID: accountId, + SendAccessEmails: d.Get("send_access_emails").(bool), } if d.HasChange("account_name") { @@ -222,18 +223,14 @@ func utilityAccountUpdate(ctx context.Context, d *schema.ResourceData, m interfa req.Description = d.Get("desc").(string) } - if d.HasChange("send_access_emails") { - req.SendAccessEmails = d.Get("send_access_emails").(bool) - } - if d.HasChange("default_zone_id") { req.DefaultZoneID = uint64(d.Get("default_zone_id").(int)) } if d.HasChange("uniq_pools") { - uniq_pools := d.Get("uniq_pools").([]interface{}) + uniqPools := d.Get("uniq_pools").([]interface{}) - for _, pool := range uniq_pools { + for _, pool := range uniqPools { req.UniqPools = append(req.UniqPools, pool.(string)) } } @@ -292,6 +289,20 @@ func utilityAccountUpdate(ctx context.Context, d *schema.ResourceData, m interfa } } + _, _, updateStPolicy := utilityGetStoragePolicyUpdate(ctx, d, m) + if len(updateStPolicy) != 0 { + storagePolicies := make([]account.StoragePolicy, 0, len(updateStPolicy)) + for _, stPolicyVal := range updateStPolicy { + reqStPolicy := account.StoragePolicy{ + ID: uint64(stPolicyVal["id"].(int)), + Limit: stPolicyVal["limit"].(int), + } + + storagePolicies = append(storagePolicies, reqStPolicy) + } + req.StoragePolicies = storagePolicies + } + _, err := c.CloudBroker().Account().Update(ctx, req) if err != nil { return err @@ -300,6 +311,95 @@ func utilityAccountUpdate(ctx context.Context, d *schema.ResourceData, m interfa return nil } +func utilityAccountUpdateStPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) { + c := m.(*controller.ControllerCfg) + + accountId, _ := strconv.ParseUint(d.Id(), 10, 64) + + addSP, delSP, updateSP := utilityGetStoragePolicyUpdate(ctx, d, m) + needUpdate := len(updateSP) > 0 + + if len(addSP) > 0 { + for _, spMap := range addSP { + req := account.AddStoragePolicyRequest{ + AccountID: accountId, + StoragePolicyID: uint64(spMap["id"].(int)), + Limit: spMap["limit"].(int), + } + log.Debugf("utilityAccountUpdateStPolicy: starting to add storage policy ID:%d for account %d", req.StoragePolicyID, req.AccountID) + _, err := c.CloudBroker().Account().AddStoragePolicy(ctx, req) + if err != nil { + return needUpdate, err + } + } + } + + if len(delSP) > 0 { + for _, spMap := range delSP { + req := account.DelStoragePolicyRequest{ + AccountID: accountId, + StoragePolicyID: uint64(spMap["id"].(int)), + } + log.Debugf("utilityAccountUpdateStPolicy: starting to delete storage policy ID:%d from account %d", req.StoragePolicyID, req.AccountID) + _, err := c.CloudBroker().Account().DelStoragePolicy(ctx, req) + if err != nil { + return needUpdate, err + } + } + } + + return needUpdate, nil +} + +func utilityGetStoragePolicyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) (added, deleted, updated []map[string]interface{}) { + added = make([]map[string]interface{}, 0) + deleted = make([]map[string]interface{}, 0) + updated = make([]map[string]interface{}, 0) + oldSet, newSet := d.GetChange("storage_policy") + oldList := oldSet.(*schema.Set).List() + newList := newSet.(*schema.Set).List() + + for _, oldSP := range oldList { + oldMap := oldSP.(map[string]interface{}) + found := false + for _, newSP := range newList { + newMap := newSP.(map[string]interface{}) + if oldMap["id"] == newMap["id"] { + found = true + if oldMap["limit"] != newMap["limit"] { + updated = append(added, newMap) + } + break + } + if found { + break + } + } + if found { + continue + } + deleted = append(deleted, oldMap) + } + + for _, newSP := range newList { + newMap := newSP.(map[string]interface{}) + found := false + for _, oldSP := range oldList { + oldMap := oldSP.(map[string]interface{}) + if oldMap["id"] == newMap["id"] { + found = true + break + } + } + if found { + continue + } + added = append(added, newMap) + } + + return +} + func utilityAccountAvailiableTemplatesUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, afterCreate bool) error { c := m.(*controller.ControllerCfg) diff --git a/internal/service/cloudbroker/account/utility_account_list.go b/internal/service/cloudbroker/account/utility_account_list.go index 1811a345..c7b242aa 100644 --- a/internal/service/cloudbroker/account/utility_account_list.go +++ b/internal/service/cloudbroker/account/utility_account_list.go @@ -72,6 +72,10 @@ func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData req.Status = status.(string) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } + log.Debugf("utilityAccountListCheckPresence: load account list") accountList, err := c.CloudBroker().Account().List(ctx, req) if err != nil { diff --git a/internal/service/cloudbroker/audit/flattens.go b/internal/service/cloudbroker/audit/flattens.go index f014ccaf..9da6cde7 100644 --- a/internal/service/cloudbroker/audit/flattens.go +++ b/internal/service/cloudbroker/audit/flattens.go @@ -43,6 +43,7 @@ func flattenAudit(d *schema.ResourceData, au *audit.RecordAudit) { d.Set("args", au.Arguments) d.Set("call", au.Call) + d.Set("correlation_id", au.CorrelationID) d.Set("guid", au.GUID) d.Set("kwargs", au.Kwargs) d.Set("remote_addr", au.RemoteAddr) @@ -60,19 +61,19 @@ func flattenAuditList(au *audit.ListAudits) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(au.Data)) for _, item := range au.Data { temp := map[string]interface{}{ - "args": item.Args, - "call": item.Call, - "guid": item.GUID, - "kwargs": item.Kwargs, - "remote_addr": item.RemoteAddr, - "result": item.Result, - "responsetime": item.ResponseTime, - "status_code": item.StatusCode, - "tags": item.Tags, - "timestamp": item.Timestamp, - "timestamp_end": item.TimestampEnd, - "ttl": item.TTL, - "user": item.User, + "args": item.Args, + "call": item.Call, + "correlation_id": item.CorrelationID, + "guid": item.GUID, + "kwargs": item.Kwargs, + "remote_addr": item.RemoteAddr, + "result": item.Result, + "responsetime": item.ResponseTime, + "status_code": item.StatusCode, + "timestamp": item.Timestamp, + "timestamp_end": item.TimestampEnd, + "ttl": item.TTL, + "user": item.User, } res = append(res, temp) } diff --git a/internal/service/cloudbroker/audit/schema.go b/internal/service/cloudbroker/audit/schema.go index f2f672ff..0856a62e 100644 --- a/internal/service/cloudbroker/audit/schema.go +++ b/internal/service/cloudbroker/audit/schema.go @@ -18,6 +18,10 @@ func dataSourceAuditSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "correlation_id": { + Type: schema.TypeString, + Computed: true, + }, "guid": { Type: schema.TypeString, Computed: true, @@ -42,10 +46,11 @@ func dataSourceAuditSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, - "tags": { - Type: schema.TypeString, - Computed: true, - }, + //TODO + //"tags": { + // Type: schema.TypeString, + // Computed: true, + //}, "timestamp": { Type: schema.TypeFloat, Computed: true, @@ -117,6 +122,50 @@ func dataSourceAuditListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "page size", }, + "resgroup_id": { + Type: schema.TypeInt, + Optional: true, + }, + "compute_id": { + Type: schema.TypeInt, + Optional: true, + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + }, + "vins_id": { + Type: schema.TypeInt, + Optional: true, + }, + "service_id": { + Type: schema.TypeInt, + Optional: true, + }, + "k8s_id": { + Type: schema.TypeInt, + Optional: true, + }, + "flipgroup_id": { + Type: schema.TypeInt, + Optional: true, + }, + "lb_id": { + Type: schema.TypeInt, + Optional: true, + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + }, + "node_id": { + Type: schema.TypeInt, + Optional: true, + }, + "exclude_audit_lines": { + Type: schema.TypeBool, + Optional: true, + }, "items": { Type: schema.TypeList, Computed: true, @@ -126,6 +175,10 @@ func dataSourceAuditListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "correlation_id": { + Type: schema.TypeString, + Computed: true, + }, "guid": { Type: schema.TypeString, Computed: true, @@ -170,10 +223,6 @@ func dataSourceAuditListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, - "tags": { - Type: schema.TypeString, - Computed: true, - }, }, }, }, diff --git a/internal/service/cloudbroker/audit/utility_audit_list.go b/internal/service/cloudbroker/audit/utility_audit_list.go index 83e4d520..ab86a782 100644 --- a/internal/service/cloudbroker/audit/utility_audit_list.go +++ b/internal/service/cloudbroker/audit/utility_audit_list.go @@ -76,6 +76,39 @@ func utilityAuditListCheckPresence(ctx context.Context, d *schema.ResourceData, if Size, ok := d.GetOk("size"); ok { req.Size = uint64(Size.(int)) } + if resgroupID, ok := d.GetOk("resgroup_id"); ok { + req.RGID = uint64(resgroupID.(int)) + } + if computeID, ok := d.GetOk("compute_id"); ok { + req.ComputeID = uint64(computeID.(int)) + } + if accountID, ok := d.GetOk("account_id"); ok { + req.AccountID = uint64(accountID.(int)) + } + if vinsID, ok := d.GetOk("vins_id"); ok { + req.VINSID = uint64(vinsID.(int)) + } + if serviceID, ok := d.GetOk("service_id"); ok { + req.ServiceID = uint64(serviceID.(int)) + } + if k8sID, ok := d.GetOk("k8s_id"); ok { + req.K8SID = uint64(k8sID.(int)) + } + if flipgroupID, ok := d.GetOk("flipgroup_id"); ok { + req.FLIPGroupID = uint64(flipgroupID.(int)) + } + if lbID, ok := d.GetOk("lb_id"); ok { + req.LBID = uint64(lbID.(int)) + } + if sepID, ok := d.GetOk("sep_id"); ok { + req.SEPID = uint64(sepID.(int)) + } + if nodeID, ok := d.GetOk("node_id"); ok { + req.NodeID = uint64(nodeID.(int)) + } + if excludeAuditLines, ok := d.GetOk("exclude_audit_lines"); ok { + req.ExcludeAuditLines = excludeAuditLines.(bool) + } log.Debugf("utilityAuditListCheckPresence: load audit list") auditList, err := c.CloudBroker().Audit().List(ctx, req) diff --git a/internal/service/cloudbroker/disks/flattens.go b/internal/service/cloudbroker/disks/flattens.go index 9540bbc3..11d811d9 100644 --- a/internal/service/cloudbroker/disks/flattens.go +++ b/internal/service/cloudbroker/disks/flattens.go @@ -58,11 +58,13 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) { d.Set("size_used", disk.SizeUsed) d.Set("snapshots", flattendDiskSnapshotList(disk.Snapshots)) d.Set("status", disk.Status) + d.Set("storage_policy_id", disk.StoragePolicyID) d.Set("tech_status", disk.TechStatus) d.Set("type", disk.Type) d.Set("vmid", disk.VMID) d.Set("updated_by", disk.UpdatedBy) d.Set("updated_time", disk.UpdatedTime) + d.Set("to_clean", disk.ToClean) } func flattenDiskReplica(d *schema.ResourceData, disk *disks.RecordDisk, statusReplication string) { @@ -224,11 +226,13 @@ func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} { "size_used": disk.SizeUsed, "snapshots": flattendDiskSnapshotList(disk.Snapshots), "status": disk.Status, + "storage_policy_id": disk.StoragePolicyID, "tech_status": disk.TechStatus, "type": disk.Type, "vmid": disk.VMID, "updated_by": disk.UpdatedBy, "updated_time": disk.UpdatedTime, + "to_clean": disk.ToClean, } res = append(res, temp) } diff --git a/internal/service/cloudbroker/disks/resource_disk.go b/internal/service/cloudbroker/disks/resource_disk.go index 6eac205b..5642fb29 100644 --- a/internal/service/cloudbroker/disks/resource_disk.go +++ b/internal/service/cloudbroker/disks/resource_disk.go @@ -57,19 +57,16 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface } req := disks.CreateRequest{ - AccountID: uint64(d.Get("account_id").(int)), - Name: d.Get("disk_name").(string), - Size: uint64(d.Get("size_max").(int)), + AccountID: uint64(d.Get("account_id").(int)), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), + Name: d.Get("disk_name").(string), + Size: uint64(d.Get("size_max").(int)), } if desc, ok := d.GetOk("desc"); ok { req.Description = desc.(string) } - if iops, ok := d.GetOk("iops"); ok { - req.IOPS = uint64(iops.(int)) - } - if sepID, ok := d.GetOk("sep_id"); ok { req.SEPID = uint64(sepID.(int)) } @@ -202,6 +199,12 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface } } + if d.HasChange("storage_policy_id") { + if err := resourceDiskChangeStoragePolicyID(ctx, d, m); err != nil { + return diag.FromErr(err) + } + } + if d.HasChange("size_max") { oldSize, newSize := d.GetChange("size_max") if oldSize.(int) > newSize.(int) { @@ -297,8 +300,6 @@ func resourceDiskChangeIotune(ctx context.Context, d *schema.ResourceData, m int if _, ok := iotune["total_iops_sec"]; ok { req.IOPS = uint64(iotune["total_iops_sec"].(int)) - } else if _, ok := d.GetOk("iops"); ok { - req.IOPS = uint64(d.Get("iops").(int)) } _, err := c.CloudBroker().Disks().LimitIO(ctx, req) @@ -351,6 +352,16 @@ func resourceDiskChangeSize(ctx context.Context, d *schema.ResourceData, m inter return err } +func resourceDiskChangeStoragePolicyID(ctx context.Context, d *schema.ResourceData, m interface{}) error { + c := m.(*controller.ControllerCfg) + + _, err := c.CloudBroker().Disks().ChangeDiskStoragePolicy(ctx, disks.ChangeDiskStoragePolicyRequest{ + DiskID: uint64(d.Get("disk_id").(int)), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), + }) + return err +} + func resourceDiskChangeNodes(ctx context.Context, d *schema.ResourceData, m interface{}, afterCreate bool) error { c := m.(*controller.ControllerCfg) diskID := uint64(d.Get("disk_id").(int)) diff --git a/internal/service/cloudbroker/disks/schema.go b/internal/service/cloudbroker/disks/schema.go index 781e081d..204a4603 100644 --- a/internal/service/cloudbroker/disks/schema.go +++ b/internal/service/cloudbroker/disks/schema.go @@ -333,6 +333,11 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_id": { + Type: schema.TypeFloat, + Computed: true, + Description: "Storage policy ID", + }, "tech_status": { Type: schema.TypeString, Computed: true, @@ -353,6 +358,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, } return rets @@ -425,6 +434,11 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "storage_policy_id": { + Type: schema.TypeInt, + Optional: true, + Description: "storage policy ID ", + }, "items": { Type: schema.TypeList, Computed: true, @@ -757,6 +771,11 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_id": { + Type: schema.TypeFloat, + Computed: true, + Description: "Storage policy ID", + }, "tech_status": { Type: schema.TypeString, Computed: true, @@ -777,6 +796,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, @@ -1172,6 +1195,11 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_id": { + Type: schema.TypeFloat, + Computed: true, + Description: "Storage policy ID", + }, "tech_status": { Type: schema.TypeString, Computed: true, @@ -1192,6 +1220,10 @@ func dataSourceDiskListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, @@ -1358,6 +1390,11 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "storage_policy_id": { + Type: schema.TypeInt, + Optional: true, + Description: "storage policy ID ", + }, "items": { Type: schema.TypeList, Computed: true, @@ -1863,6 +1900,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Required: true, //ForceNew: true, }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + }, "created_by": { Type: schema.TypeString, Computed: true, @@ -1889,11 +1930,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Computed: true, Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'", }, - "iops": { - Type: schema.TypeInt, - Optional: true, - Description: "max IOPS disk can perform", - }, "sep_id": { Type: schema.TypeInt, Optional: true, @@ -2252,6 +2288,10 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, } return rets diff --git a/internal/service/cloudbroker/disks/utility_disk_list.go b/internal/service/cloudbroker/disks/utility_disk_list.go index d453b131..64028a9b 100644 --- a/internal/service/cloudbroker/disks/utility_disk_list.go +++ b/internal/service/cloudbroker/disks/utility_disk_list.go @@ -85,6 +85,9 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok { + req.StoragePolicyID = uint64(storagePolicyID.(int)) + } log.Debugf("utilityDiskListCheckPresence: load disk list") diskList, err := c.CloudBroker().Disks().List(ctx, req) diff --git a/internal/service/cloudbroker/disks/utility_disk_list_unattached.go b/internal/service/cloudbroker/disks/utility_disk_list_unattached.go index 414f6d58..91a0bdb5 100644 --- a/internal/service/cloudbroker/disks/utility_disk_list_unattached.go +++ b/internal/service/cloudbroker/disks/utility_disk_list_unattached.go @@ -46,6 +46,9 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok { + req.StoragePolicyID = uint64(storagePolicyID.(int)) + } log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list") unattachedList, err := c.CloudBroker().Disks().ListUnattached(ctx, req) diff --git a/internal/service/cloudbroker/dpdknet/flattens.go b/internal/service/cloudbroker/dpdknet/flattens.go index 49f6003e..eb7584db 100644 --- a/internal/service/cloudbroker/dpdknet/flattens.go +++ b/internal/service/cloudbroker/dpdknet/flattens.go @@ -19,24 +19,26 @@ func flattenDPDKNet(d *schema.ResourceData, dpdk *dpdk.RecordDPDKNet) { d.Set("vlan_id", dpdk.VlanID) d.Set("compute_ids", dpdk.ComputeIDs) d.Set("updated_time", dpdk.UpdatedTime) + d.Set("enable_secgroups", dpdk.EnableSecGroups) } func flattenDPDKNetList(list *dpdk.ListDPDKNet) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(list.Data)) for _, dpdk := range list.Data { temp := map[string]interface{}{ - "dpdk_id": dpdk.ID, - "account_access": dpdk.AccountAccess, - "desc": dpdk.Description, - "gid": dpdk.GID, - "guid": dpdk.GUID, - "name": dpdk.Name, - "rg_access": dpdk.RGAccess, - "status": dpdk.Status, - "ovs_bridge": dpdk.OVSBridge, - "vlan_id": dpdk.VlanID, - "compute_ids": dpdk.ComputeIDs, - "updated_time": dpdk.UpdatedTime, + "dpdk_id": dpdk.ID, + "account_access": dpdk.AccountAccess, + "desc": dpdk.Description, + "enable_secgroups": dpdk.EnableSecGroups, + "gid": dpdk.GID, + "guid": dpdk.GUID, + "name": dpdk.Name, + "rg_access": dpdk.RGAccess, + "status": dpdk.Status, + "ovs_bridge": dpdk.OVSBridge, + "vlan_id": dpdk.VlanID, + "compute_ids": dpdk.ComputeIDs, + "updated_time": dpdk.UpdatedTime, } res = append(res, temp) } diff --git a/internal/service/cloudbroker/dpdknet/resource_dpdk.go b/internal/service/cloudbroker/dpdknet/resource_dpdk.go index 05adf300..17f5353e 100644 --- a/internal/service/cloudbroker/dpdknet/resource_dpdk.go +++ b/internal/service/cloudbroker/dpdknet/resource_dpdk.go @@ -93,6 +93,17 @@ func resourceDPDKNetCreate(ctx context.Context, d *schema.ResourceData, m interf warnings.Add(err) } + if d.Get("enable_secgroups").(bool) { + req := dpdk.UpdateRequest{ + DPDKID: dpdkID, + EnableSecGroups: true, + } + _, err := c.CloudBroker().DPDKNet().Update(ctx, req) + if err != nil { + warnings.Add(err) + } + } + return append(warnings.Get(), resourceDPDKNetRead(ctx, d, m)...) } @@ -167,7 +178,7 @@ func resourceDPDKNetUpdate(ctx context.Context, d *schema.ResourceData, m interf } } - if d.HasChanges("name", "desc", "vlan_id", "ovs_bridge", "account_access", "rg_access") { + if d.HasChanges("name", "desc", "vlan_id", "ovs_bridge", "account_access", "rg_access", "enable_secgroups") { if err := utilityDPDKNetUpdate(ctx, d, m); err != nil { return diag.FromErr(err) } diff --git a/internal/service/cloudbroker/dpdknet/schema.go b/internal/service/cloudbroker/dpdknet/schema.go index a2d38609..9c2aeab1 100644 --- a/internal/service/cloudbroker/dpdknet/schema.go +++ b/internal/service/cloudbroker/dpdknet/schema.go @@ -161,6 +161,10 @@ func dataSourceDPDKNetListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Description of DPDK network", }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "gid": { Type: schema.TypeInt, Computed: true, @@ -275,6 +279,12 @@ func resourceDPDKNetSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Enabled or disabled DPDK network", }, + "enable_secgroups": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "enable security groups", + }, "guid": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudbroker/dpdknet/utility_dpdk.go b/internal/service/cloudbroker/dpdknet/utility_dpdk.go index 0b9ee104..6057cafb 100644 --- a/internal/service/cloudbroker/dpdknet/utility_dpdk.go +++ b/internal/service/cloudbroker/dpdknet/utility_dpdk.go @@ -148,6 +148,10 @@ func utilityDPDKNetUpdate(ctx context.Context, d *schema.ResourceData, m interfa } } + if d.HasChange("enable_secgroups") { + req.EnableSecGroups = d.Get("enable_secgroups").(bool) + } + if _, err := c.CloudBroker().DPDKNet().Update(ctx, req); err != nil { return err } diff --git a/internal/service/cloudbroker/extnet/flattens.go b/internal/service/cloudbroker/extnet/flattens.go index 080ee6a5..0cb6d610 100644 --- a/internal/service/cloudbroker/extnet/flattens.go +++ b/internal/service/cloudbroker/extnet/flattens.go @@ -51,11 +51,12 @@ func flattenListExtnet(extList *extnet.ListExtNet) []map[string]interface{} { "free_ips": item.FreeIPs, "gid": item.GID, "guid": item.GUID, + "enable_secgroups": item.EnableSecGroups, "extnet_id": item.ID, "ipcidr": item.IPCIDR, "milestones": item.Milestones, "name": item.Name, - "network_ids": item.NetworkIDs, + "network_ids": flattenNetworkIDs(item.NetworkIDs), "ovs_bridge": item.OVSBridge, "pre_reservations_num": item.PreReservationsNum, "pri_vnfdev_id": item.PriVNFDevID, @@ -143,6 +144,7 @@ func flattenRecordExtnetResource(d *schema.ResourceData, recNet *extnet.RecordEx d.Set("reservations", flattenExtnetReservations(recNet.Reservations)) d.Set("routes", flattenStaticRouteList(staticRouteList)) d.Set("zone_id", recNet.ZoneID) + d.Set("enable_secgroups", recNet.EnableSecGroups) } func flattenExtnetExcluded(ers extnet.ListReservations) []map[string]interface{} { diff --git a/internal/service/cloudbroker/extnet/resource_extnet.go b/internal/service/cloudbroker/extnet/resource_extnet.go index 267e4abf..1c0126a6 100644 --- a/internal/service/cloudbroker/extnet/resource_extnet.go +++ b/internal/service/cloudbroker/extnet/resource_extnet.go @@ -133,7 +133,7 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa } if mtu, ok := d.GetOk("mtu"); ok { - req.MTU = mtu.(uint) + req.MTU = uint(mtu.(int)) } log.Debugf("cloudbroker: Sent create request") @@ -234,6 +234,18 @@ func resourceExtnetCreate(ctx context.Context, d *schema.ResourceData, m interfa } } + if d.Get("enable_secgroups").(bool) { + log.Debugf("resourceExtnetCreate: trying to enable secgroups for extnet with ID %d", netID) + req := extnet.UpdateRequest{ + NetID: netID, + EnableSecGroups: true, + } + _, err := c.CloudBroker().ExtNet().Update(ctx, req) + if err != nil { + w.Add(err) + } + } + return resourceExtnetRead(ctx, d, m) } diff --git a/internal/service/cloudbroker/extnet/schema.go b/internal/service/cloudbroker/extnet/schema.go index 481ccdeb..1d13e0c5 100644 --- a/internal/service/cloudbroker/extnet/schema.go +++ b/internal/service/cloudbroker/extnet/schema.go @@ -65,6 +65,11 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, @@ -130,6 +135,10 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "extnet_id": { Type: schema.TypeInt, Computed: true, @@ -700,6 +709,12 @@ func resourceExtnetSchemaMake() map[string]*schema.Schema { Optional: true, Computed: true, }, + "enable_secgroups": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "enable security groups", + }, "dns": { Type: schema.TypeList, Optional: true, diff --git a/internal/service/cloudbroker/extnet/utility_extnet_list.go b/internal/service/cloudbroker/extnet/utility_extnet_list.go index 1ce23d64..7f9faac3 100644 --- a/internal/service/cloudbroker/extnet/utility_extnet_list.go +++ b/internal/service/cloudbroker/extnet/utility_extnet_list.go @@ -86,6 +86,10 @@ func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData, req.Size = uint64(size.(int)) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } + res, err := c.CloudBroker().ExtNet().List(ctx, req) if err != nil { return nil, err diff --git a/internal/service/cloudbroker/extnet/utility_extnet_resource.go b/internal/service/cloudbroker/extnet/utility_extnet_resource.go index 3e8d3474..99f3bfd3 100644 --- a/internal/service/cloudbroker/extnet/utility_extnet_resource.go +++ b/internal/service/cloudbroker/extnet/utility_extnet_resource.go @@ -119,7 +119,11 @@ func handleBasicUpdate(ctx context.Context, d *schema.ResourceData, c *controlle doBasicUpdate = true } if d.HasChange("mtu") { - basiUpdateReq.MTU = d.Get("mtu").(uint64) + basiUpdateReq.MTU = uint64(d.Get("mtu").(int)) + doBasicUpdate = true + } + if d.HasChange("enable_secgroups") { + basiUpdateReq.EnableSecGroups = d.Get("enable_secgroups").(bool) doBasicUpdate = true } diff --git a/internal/service/cloudbroker/image/flattens.go b/internal/service/cloudbroker/image/flattens.go index c110a071..e6eb48de 100644 --- a/internal/service/cloudbroker/image/flattens.go +++ b/internal/service/cloudbroker/image/flattens.go @@ -49,7 +49,9 @@ func flattenImage(d *schema.ResourceData, img *image.RecordImage) { d.Set("size", img.Size) d.Set("snapshot_id", img.SnapshotID) d.Set("status", img.Status) + d.Set("storage_policy_id", img.StoragePolicyID) d.Set("tech_status", img.TechStatus) + d.Set("to_clean", img.ToClean) d.Set("image_type", img.Type) d.Set("url", img.URL) d.Set("username", img.Username) @@ -128,7 +130,9 @@ func flattenImageList(il *image.ListImages) []map[string]interface{} { "size": item.Size, "snapshot_id": item.SnapshotID, "status": item.Status, + "storage_policy_id": item.StoragePolicyID, "tech_status": item.TechStatus, + "to_clean": item.ToClean, "image_type": item.Type, "url": item.URL, "username": item.Username, diff --git a/internal/service/cloudbroker/image/resource_cdrom_image.go b/internal/service/cloudbroker/image/resource_cdrom_image.go index 1fa8689a..92abeb05 100644 --- a/internal/service/cloudbroker/image/resource_cdrom_image.go +++ b/internal/service/cloudbroker/image/resource_cdrom_image.go @@ -48,16 +48,11 @@ func resourceCDROMImageCreate(ctx context.Context, d *schema.ResourceData, m int log.Debugf("resourceCDROMImageCreate: called for image %s", d.Get("name").(string)) c := m.(*controller.ControllerCfg) req := image.CreateCDROMImageRequest{ - Name: d.Get("name").(string), - URL: d.Get("url").(string), + Name: d.Get("name").(string), + URL: d.Get("url").(string), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } - drivers := []string{} - for _, driver := range d.Get("drivers").([]interface{}) { - drivers = append(drivers, driver.(string)) - } - req.Drivers = drivers - if username, ok := d.GetOk("username_dl"); ok { req.UsernameDL = username.(string) } @@ -168,13 +163,6 @@ func resourceCDROMImageUpdate(ctx context.Context, d *schema.ResourceData, m int } } - if d.HasChange("enabled_stacks") { - err := resourceImageUpdateNodes(ctx, d, m) - if err != nil { - return diag.FromErr(err) - } - } - if d.HasChanges("name", "password_dl", "username_dl", "account_id", "bootable", "hot_resize") { err := resourceImageCDROMEdit(ctx, d, m) if err != nil { diff --git a/internal/service/cloudbroker/image/resource_image.go b/internal/service/cloudbroker/image/resource_image.go index 08c0f1f8..82a6d1c8 100644 --- a/internal/service/cloudbroker/image/resource_image.go +++ b/internal/service/cloudbroker/image/resource_image.go @@ -204,13 +204,6 @@ func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interfac } } - if d.HasChange("enabled_stacks") { - err := resourceImageUpdateNodes(ctx, d, m) - if err != nil { - return diag.FromErr(err) - } - } - if d.HasChanges("name", "username", "password", "account_id", "bootable", "hot_resize", "network_interface_naming") { err := resourceImageEdit(ctx, d, m) if err != nil { @@ -327,27 +320,6 @@ func resourceImageChangeComputeci(ctx context.Context, d *schema.ResourceData, m return nil } -func resourceImageUpdateNodes(ctx context.Context, d *schema.ResourceData, m interface{}) error { - log.Debugf("resourceImageUpdateNodes: called for %s, id: %s", d.Get("name").(string), d.Id()) - c := m.(*controller.ControllerCfg) - req := image.UpdateNodesRequest{ - ImageID: uint64(d.Get("image_id").(int)), - } - enabledStacks := []uint64{} - for _, stack := range d.Get("enabled_stacks").([]interface{}) { - enabledStacks = append(enabledStacks, uint64(stack.(int))) - } - - req.EnabledStacks = enabledStacks - - _, err := c.CloudBroker().Image().UpdateNodes(ctx, req) - if err != nil { - return err - } - - return nil -} - func resourceImageEdit(ctx context.Context, d *schema.ResourceData, m interface{}) error { log.Debugf("resourceImageEdit: called for %s, id: %s", d.Get("name").(string), d.Id()) c := m.(*controller.ControllerCfg) diff --git a/internal/service/cloudbroker/image/resource_image_from_blank_compute.go b/internal/service/cloudbroker/image/resource_image_from_blank_compute.go index 714a6d23..406a3ca6 100644 --- a/internal/service/cloudbroker/image/resource_image_from_blank_compute.go +++ b/internal/service/cloudbroker/image/resource_image_from_blank_compute.go @@ -235,13 +235,6 @@ func resourceImageFromBlankComputeUpdate(ctx context.Context, d *schema.Resource } } - if d.HasChange("enabled_stacks") { - err := resourceImageUpdateNodes(ctx, d, m) - if err != nil { - return diag.FromErr(err) - } - } - if d.HasChanges("name", "username", "password", "account_id", "bootable", "hot_resize", "network_interface_naming") { err := resourceImageEdit(ctx, d, m) if err != nil { diff --git a/internal/service/cloudbroker/image/resource_image_from_platform_disk.go b/internal/service/cloudbroker/image/resource_image_from_platform_disk.go index 6a52a95d..c9515e4e 100644 --- a/internal/service/cloudbroker/image/resource_image_from_platform_disk.go +++ b/internal/service/cloudbroker/image/resource_image_from_platform_disk.go @@ -78,11 +78,7 @@ func resourceImageFromPlatformDiskCreate(ctx context.Context, d *schema.Resource if poolName, ok := d.GetOk("pool_name"); ok { req.PoolName = poolName.(string) } - if driversInterface, ok := d.GetOk("drivers"); ok { - for _, d := range driversInterface.([]interface{}) { - req.Drivers = append(req.Drivers, d.(string)) - } - } + if hotresize, ok := d.GetOk("hot_resize"); ok { req.HotResize = hotresize.(bool) } @@ -241,13 +237,6 @@ func resourceImageFromPlatformDiskUpdate(ctx context.Context, d *schema.Resource } } - if d.HasChange("enabled_stacks") { - err := resourceImageUpdateNodes(ctx, d, m) - if err != nil { - return diag.FromErr(err) - } - } - if d.HasChanges("name", "username", "password", "account_id", "bootable", "hot_resize", "network_interface_naming") { err := resourceImageEdit(ctx, d, m) if err != nil { diff --git a/internal/service/cloudbroker/image/resource_virtual_image.go b/internal/service/cloudbroker/image/resource_virtual_image.go index 9ebc2446..68ba353e 100644 --- a/internal/service/cloudbroker/image/resource_virtual_image.go +++ b/internal/service/cloudbroker/image/resource_virtual_image.go @@ -49,8 +49,9 @@ func resourceVirtualImageCreate(ctx context.Context, d *schema.ResourceData, m i c := m.(*controller.ControllerCfg) req := image.CreateVirtualRequest{ - Name: d.Get("name").(string), - TargetID: uint64(d.Get("link_to").(int)), + Name: d.Get("name").(string), + TargetID: uint64(d.Get("link_to").(int)), + AccountID: uint64(d.Get("account_id").(int)), } imageId, err := c.CloudBroker().Image().CreateVirtual(ctx, req) @@ -147,13 +148,6 @@ func resourceVirtualImageUpdate(ctx context.Context, d *schema.ResourceData, m i } } - if d.HasChange("enabled_stacks") { - err := resourceImageUpdateNodes(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 { diff --git a/internal/service/cloudbroker/image/schema.go b/internal/service/cloudbroker/image/schema.go index 4be234fd..684922b7 100644 --- a/internal/service/cloudbroker/image/schema.go +++ b/internal/service/cloudbroker/image/schema.go @@ -34,7 +34,6 @@ package image import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs" ) func dataSourceImageListStacksSchemaMake() map[string]*schema.Schema { @@ -404,6 +403,10 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "find by enabled True or False", }, + "storage_policy_id": { + Type: schema.TypeInt, + Optional: true, + }, "items": { Type: schema.TypeList, Computed: true, @@ -624,6 +627,14 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "status", }, + "storage_policy_id": { + Type: schema.TypeInt, + Computed: true, + }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, "tech_status": { Type: schema.TypeString, Computed: true, @@ -882,10 +893,18 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema { Computed: true, Description: "status", }, + "storage_policy_id": { + Type: schema.TypeInt, + Computed: true, + }, "tech_status": { Type: schema.TypeString, Computed: true, - Description: "tech atatus", + Description: "tech status", + }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, }, "image_type": { Type: schema.TypeString, @@ -922,13 +941,10 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema { Required: true, Description: "URL where to download ISO from", }, - "drivers": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]", + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the storage policy", }, "hot_resize": { Type: schema.TypeBool, @@ -996,13 +1012,6 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, - "enabled_stacks": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, "unc_path": { Type: schema.TypeString, Computed: true, @@ -1047,6 +1056,13 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema { Computed: true, Description: "Boot type of image bios or uefi", }, + "drivers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "gid": { Type: schema.TypeInt, Computed: true, @@ -1132,6 +1148,10 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema { Computed: true, Description: "tech atatus", }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, "version": { Type: schema.TypeString, Computed: true, @@ -1187,15 +1207,10 @@ func resourceImageSchemaMake() map[string]*schema.Schema { Required: true, Description: "Image type linux, windows or other", }, - "drivers": { - Type: schema.TypeList, - Optional: true, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringInSlice([]string{"KVM_X86"}, false), - }, - Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]", + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the storage policy", }, "hot_resize": { Type: schema.TypeBool, @@ -1279,13 +1294,6 @@ func resourceImageSchemaMake() map[string]*schema.Schema { Default: false, Description: "Create image from a media identified by URL (in synchronous mode)", }, - "enabled_stacks": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, "shared_with": { Type: schema.TypeList, Optional: true, @@ -1329,6 +1337,13 @@ func resourceImageSchemaMake() map[string]*schema.Schema { }, }, }, + "drivers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "gid": { Type: schema.TypeInt, Computed: true, @@ -1413,6 +1428,10 @@ func resourceImageSchemaMake() map[string]*schema.Schema { Computed: true, Description: "tech atatus", }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, "version": { Type: schema.TypeString, Computed: true, @@ -1506,13 +1525,6 @@ func resourceVirtualImageSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, - "enabled_stacks": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, "unc_path": { Type: schema.TypeString, @@ -1684,6 +1696,10 @@ func resourceVirtualImageSchemaMake() map[string]*schema.Schema { Computed: true, Description: "tech atatus", }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, "image_type": { Type: schema.TypeString, Computed: true, @@ -1784,13 +1800,6 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema { Optional: true, Computed: true, }, - "enabled_stacks": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, "shared_with": { Type: schema.TypeList, Optional: true, @@ -1956,6 +1965,10 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, "url": { Type: schema.TypeString, Computed: true, @@ -2018,16 +2031,6 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { Computed: true, Description: "storage endpoint provider ID", }, - "drivers": { - Type: schema.TypeList, - Required: true, - Elem: &schema.Schema{ - StateFunc: statefuncs.StateFuncToUpper, - ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86"}, false), // observe case while validating - Type: schema.TypeString, - }, - Description: "List of types of compute suitable for image. Example: [ \"KVM_X86\" ]", - }, "pool_name": { Type: schema.TypeString, Optional: true, @@ -2062,13 +2065,6 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { Optional: true, Computed: true, }, - "enabled_stacks": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, "shared_with": { Type: schema.TypeList, Optional: true, @@ -2135,6 +2131,13 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "drivers": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "gid": { Type: schema.TypeInt, Computed: true, @@ -2223,6 +2226,10 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, "url": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/cloudbroker/image/utility_image_list.go b/internal/service/cloudbroker/image/utility_image_list.go index b824f1ef..1b8cde5e 100644 --- a/internal/service/cloudbroker/image/utility_image_list.go +++ b/internal/service/cloudbroker/image/utility_image_list.go @@ -90,6 +90,9 @@ func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, if enabled, ok := d.GetOkExists("enabled"); ok { req.Enabled = enabled.(bool) } + if storagePolicyID, ok := d.GetOk("storage_policy_id"); ok { + req.StoragePolicyID = uint64(storagePolicyID.(int)) + } log.Debugf("utilityImageListCheckPresence: load image list") imageList, err := c.CloudBroker().Image().List(ctx, req) if err != nil { diff --git a/internal/service/cloudbroker/image/utility_resource_create.go b/internal/service/cloudbroker/image/utility_resource_create.go index b1afc99e..4f32a6eb 100644 --- a/internal/service/cloudbroker/image/utility_resource_create.go +++ b/internal/service/cloudbroker/image/utility_resource_create.go @@ -40,18 +40,11 @@ import ( func CreateRequest(ctx context.Context, d *schema.ResourceData, m interface{}, url string) (image.CreateRequest, error) { req := image.CreateRequest{ - Name: d.Get("name").(string), - URL: url, - BootType: d.Get("boot_type").(string), - ImageType: d.Get("image_type").(string), - } - - if _, ok := d.GetOk("drivers"); ok { - drivers := []string{} - for _, driver := range d.Get("drivers").([]interface{}) { - drivers = append(drivers, driver.(string)) - } - req.Drivers = drivers + Name: d.Get("name").(string), + URL: url, + BootType: d.Get("boot_type").(string), + ImageType: d.Get("image_type").(string), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } if hotresize, ok := d.GetOk("hot_resize"); ok { diff --git a/internal/service/cloudbroker/k8ci/flattens.go b/internal/service/cloudbroker/k8ci/flattens.go index 20245c53..1613c65f 100644 --- a/internal/service/cloudbroker/k8ci/flattens.go +++ b/internal/service/cloudbroker/k8ci/flattens.go @@ -50,7 +50,6 @@ func flattenK8CIListItems(list *k8ci.ListK8CI) []map[string]interface{} { "guid": item.GUID, "k8ci_id": item.ID, "lb_image_id": item.LBImageID, - "master_driver": item.MasterDriver, "master_image_id": item.MasterImageID, "max_master_count": item.MaxMasterCount, "max_worker_count": item.MaxWorkerCount, @@ -58,7 +57,6 @@ func flattenK8CIListItems(list *k8ci.ListK8CI) []map[string]interface{} { "shared_with": item.SharedWith, "status": item.Status, "version": item.Version, - "worker_driver": item.WorkerDriver, "worker_image_id": item.WorkerImageID, } res = append(res, temp) @@ -75,7 +73,6 @@ func flattenK8CIItems(d *schema.ResourceData, data *k8ci.RecordK8CI) error { d.Set("guid", data.GUID) d.Set("k8ci_id", data.ID) d.Set("lb_image_id", data.LBImageID) - d.Set("master_driver", data.MasterDriver) d.Set("master_image_id", data.MasterImageID) d.Set("max_master_count", data.MaxMasterCount) d.Set("max_worker_count", data.MaxWorkerCount) @@ -85,7 +82,6 @@ func flattenK8CIItems(d *schema.ResourceData, data *k8ci.RecordK8CI) error { d.Set("shared_with", data.SharedWith) d.Set("status", data.Status) d.Set("version", data.Version) - d.Set("worker_driver", data.WorkerDriver) d.Set("worker_image_id", data.WorkerImageID) return nil diff --git a/internal/service/cloudbroker/k8ci/resource_k8ci.go b/internal/service/cloudbroker/k8ci/resource_k8ci.go index 2eee5c33..e890c37f 100644 --- a/internal/service/cloudbroker/k8ci/resource_k8ci.go +++ b/internal/service/cloudbroker/k8ci/resource_k8ci.go @@ -59,8 +59,6 @@ func resourceK8CICreate(ctx context.Context, d *schema.ResourceData, m interface req := k8ci.CreateRequest{ Name: d.Get("name").(string), Version: d.Get("version").(string), - MasterDriver: d.Get("master_driver").(string), - WorkerDriver: d.Get("worker_driver").(string), MaxMasterCount: uint64(d.Get("max_master_count").(int)), MaxWorkerCount: uint64(d.Get("max_worker_count").(int)), MasterImageID: uint64(d.Get("master_image_id").(int)), diff --git a/internal/service/cloudbroker/k8ci/schema.go b/internal/service/cloudbroker/k8ci/schema.go index 57b52883..4c628196 100644 --- a/internal/service/cloudbroker/k8ci/schema.go +++ b/internal/service/cloudbroker/k8ci/schema.go @@ -61,10 +61,6 @@ func dataSourceK8CISchemaMake() map[string]*schema.Schema { Computed: true, Description: "LB Image ID", }, - "master_driver": { - Type: schema.TypeString, - Computed: true, - }, "master_image_id": { Type: schema.TypeInt, Computed: true, @@ -137,16 +133,6 @@ func dataSourceK8CIListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Filter by status", }, - "worker_driver": { - Type: schema.TypeString, - Optional: true, - Description: "Filter by worker driver", - }, - "master_driver": { - Type: schema.TypeString, - Optional: true, - Description: "Filter by master driver", - }, "network_plugin": { Type: schema.TypeString, Optional: true, @@ -206,10 +192,6 @@ func dataSourceK8CIListSchemaMake() map[string]*schema.Schema { Computed: true, Description: "LB Image ID", }, - "master_driver": { - Type: schema.TypeString, - Computed: true, - }, "master_image_id": { Type: schema.TypeInt, Computed: true, @@ -243,10 +225,6 @@ func dataSourceK8CIListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, - "worker_driver": { - Type: schema.TypeString, - Computed: true, - }, "worker_image_id": { Type: schema.TypeInt, Computed: true, @@ -273,16 +251,6 @@ func dataSourceK8CIListDeletedSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Filter by name", }, - "worker_driver": { - Type: schema.TypeString, - Optional: true, - Description: "Filter by worker driver", - }, - "master_driver": { - Type: schema.TypeString, - Optional: true, - Description: "Filter by master driver", - }, "network_plugin": { Type: schema.TypeString, Optional: true, @@ -336,10 +304,6 @@ func dataSourceK8CIListDeletedSchemaMake() map[string]*schema.Schema { Computed: true, Description: "LB Image ID", }, - "master_driver": { - Type: schema.TypeString, - Computed: true, - }, "master_image_id": { Type: schema.TypeInt, Computed: true, @@ -373,10 +337,6 @@ func dataSourceK8CIListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, - "worker_driver": { - Type: schema.TypeString, - Computed: true, - }, "worker_image_id": { Type: schema.TypeInt, Computed: true, @@ -402,10 +362,6 @@ func resourceK8CISchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Required: true, }, - "master_driver": { - Type: schema.TypeString, - Required: true, - }, "master_image_id": { Type: schema.TypeInt, Required: true, @@ -422,10 +378,6 @@ func resourceK8CISchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Required: true, }, - "worker_driver": { - Type: schema.TypeString, - Required: true, - }, "network_plugins": { Type: schema.TypeList, Required: true, diff --git a/internal/service/cloudbroker/k8ci/utility_k8ci_list.go b/internal/service/cloudbroker/k8ci/utility_k8ci_list.go index 9c976c6c..23c4c7e0 100644 --- a/internal/service/cloudbroker/k8ci/utility_k8ci_list.go +++ b/internal/service/cloudbroker/k8ci/utility_k8ci_list.go @@ -56,12 +56,6 @@ func utilityK8CIListCheckPresence(ctx context.Context, d *schema.ResourceData, m if status, ok := d.GetOk("status"); ok { req.Status = status.(string) } - if worker_driver, ok := d.GetOk("worker_driver"); ok { - req.WorkerDriver = worker_driver.(string) - } - if master_driver, ok := d.GetOk("master_driver"); ok { - req.MasterDriver = master_driver.(string) - } if network_plugin, ok := d.GetOk("network_plugin"); ok { req.NetworkPlugins = network_plugin.(string) } diff --git a/internal/service/cloudbroker/k8ci/utility_k8ci_list_deleted.go b/internal/service/cloudbroker/k8ci/utility_k8ci_list_deleted.go index f530e3e7..efd62dc4 100644 --- a/internal/service/cloudbroker/k8ci/utility_k8ci_list_deleted.go +++ b/internal/service/cloudbroker/k8ci/utility_k8ci_list_deleted.go @@ -53,12 +53,6 @@ func utilityK8CIListDeletedCheckPresence(ctx context.Context, d *schema.Resource if name, ok := d.GetOk("name"); ok { req.Name = name.(string) } - if worker_driver, ok := d.GetOk("worker_driver"); ok { - req.WorkerDriver = worker_driver.(string) - } - if master_driver, ok := d.GetOk("master_driver"); ok { - req.MasterDriver = master_driver.(string) - } if network_plugin, ok := d.GetOk("network_plugin"); ok { req.NetworkPlugins = network_plugin.(string) } diff --git a/internal/service/cloudbroker/k8s/resource_k8s_cp.go b/internal/service/cloudbroker/k8s/resource_k8s_cp.go index 7b6bba7b..7db650a5 100644 --- a/internal/service/cloudbroker/k8s/resource_k8s_cp.go +++ b/internal/service/cloudbroker/k8s/resource_k8s_cp.go @@ -68,6 +68,7 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac K8CIID: uint64(d.Get("k8sci_id").(int)), WorkerGroupName: "temp", NetworkPlugin: d.Get("network_plugin").(string), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } if num, ok := d.GetOk("num"); ok { diff --git a/internal/service/cloudbroker/k8s/resource_k8s_wg.go b/internal/service/cloudbroker/k8s/resource_k8s_wg.go index 30734afe..e3c02d60 100644 --- a/internal/service/cloudbroker/k8s/resource_k8s_wg.go +++ b/internal/service/cloudbroker/k8s/resource_k8s_wg.go @@ -58,14 +58,15 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac } req := k8s.WorkersGroupAddRequest{ - K8SID: uint64(d.Get("k8s_id").(int)), - Name: d.Get("name").(string), - WorkerNum: uint64(d.Get("num").(int)), - WorkerCPU: uint64(d.Get("cpu").(int)), - WorkerRAM: uint64(d.Get("ram").(int)), - WorkerSEPID: uint64(d.Get("worker_sep_id").(int)), - WorkerSEPPool: d.Get("worker_sep_pool").(string), - Chipset: d.Get("chipset").(string), + K8SID: uint64(d.Get("k8s_id").(int)), + Name: d.Get("name").(string), + WorkerNum: uint64(d.Get("num").(int)), + WorkerCPU: uint64(d.Get("cpu").(int)), + WorkerRAM: uint64(d.Get("ram").(int)), + WorkerSEPID: uint64(d.Get("worker_sep_id").(int)), + WorkerSEPPool: d.Get("worker_sep_pool").(string), + Chipset: d.Get("chipset").(string), + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } if d.Get("disk") == nil { diff --git a/internal/service/cloudbroker/k8s/schema.go b/internal/service/cloudbroker/k8s/schema.go index 4aac5ab9..ecb1242e 100644 --- a/internal/service/cloudbroker/k8s/schema.go +++ b/internal/service/cloudbroker/k8s/schema.go @@ -471,6 +471,11 @@ func dataSourceK8sListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, @@ -1355,6 +1360,11 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema { Description: "Network plugin to be used", ValidateFunc: validation.StringInSlice([]string{"flannel", "weavenet", "calico"}, true), }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the storage policy", + }, "zone_id": { Type: schema.TypeInt, Optional: true, @@ -1771,6 +1781,11 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema { Required: true, Description: "Name of the worker group.", }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the storage policy", + }, "num": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/cloudbroker/k8s/utility_k8s_list.go b/internal/service/cloudbroker/k8s/utility_k8s_list.go index 509587ed..9025a856 100644 --- a/internal/service/cloudbroker/k8s/utility_k8s_list.go +++ b/internal/service/cloudbroker/k8s/utility_k8s_list.go @@ -79,6 +79,9 @@ func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } k8sList, err := c.CloudBroker().K8S().List(ctx, req) if err != nil { diff --git a/internal/service/cloudbroker/kvmvm/data_source_compute_audits.go b/internal/service/cloudbroker/kvmvm/data_source_compute_audits.go index 892c74f9..77f833d5 100644 --- a/internal/service/cloudbroker/kvmvm/data_source_compute_audits.go +++ b/internal/service/cloudbroker/kvmvm/data_source_compute_audits.go @@ -50,6 +50,7 @@ func dataSourceComputeAuditsRead(ctx context.Context, d *schema.ResourceData, m id := uuid.New() d.SetId(id.String()) d.Set("items", flattenComputeAudits(computeAudits)) + d.Set("entry_count", computeAudits.EntryCount) return nil } diff --git a/internal/service/cloudbroker/kvmvm/flattens.go b/internal/service/cloudbroker/kvmvm/flattens.go index 5c183ce9..d2f95068 100644 --- a/internal/service/cloudbroker/kvmvm/flattens.go +++ b/internal/service/cloudbroker/kvmvm/flattens.go @@ -39,6 +39,7 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p d.Set("boot_disk_id", bootDisk.ID) // we intentionally use the SizeMax field, do not change it until the BootDiskSize field is fixed on the platform d.Set("boot_disk_size", bootDisk.SizeMax) + d.Set("boot_image_id", bootDisk.ImageID) d.Set("chipset", computeRec.Chipset) d.Set("cd_image_id", computeRec.CdImageId) d.Set("clone_reference", computeRec.CloneReference) @@ -96,14 +97,16 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p d.Set("user_managed", computeRec.UserManaged) d.Set("vnc_password", computeRec.VNCPassword) d.Set("vgpus", flattenVGPUs(computeRec.VGPUs)) - d.Set("virtual_image_id", computeRec.VirtualImageID) - d.Set("virtual_image_name", computeRec.VirtualImageName) + //TODO + // d.Set("virtual_image_id", computeRec.VirtualImageID) + // d.Set("virtual_image_name", computeRec.VirtualImageName) d.Set("pci_devices", flattenPCI(*pciList)) d.Set("loader_type", computeRec.LoaderType) d.Set("boot_type", computeRec.BootType) d.Set("hot_resize", computeRec.HotResize) d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming) d.Set("zone_id", computeRec.ZoneID) + d.Set("os_version", computeRec.OSVersion) return nil } @@ -169,6 +172,7 @@ func flattenInterfaces(ifaces compute.ListInterfaces) []map[string]interface{} { "conn_type": iface.ConnType, "def_gw": iface.DefGW, "enabled": iface.Enabled, + "enable_secgroups": iface.EnableSecGroups, "flip_group_id": iface.FLIPGroupID, "guid": iface.GUID, "ip_address": iface.IPAddress, @@ -183,6 +187,7 @@ func flattenInterfaces(ifaces compute.ListInterfaces) []map[string]interface{} { "pci_slot": iface.PCISlot, "qos": flattenQOS(iface.QOS), "sdn_interface_id": iface.SDNInterfaceID, + "security_groups": iface.SecGroups, "target": iface.Target, "type": iface.Type, "trunk_tags": iface.TrunkTags, @@ -241,20 +246,22 @@ func flattenComputeDisks(disksList compute.ListDisks, disksBlocks, extraDisks [] nodeIds := disksBlocks[indexDataDisks].(map[string]interface{})["node_ids"].(*schema.Set) temp := map[string]interface{}{ - "disk_name": disk.Name, - "node_ids": nodeIds, - "size": disk.SizeMax, - "sep_id": disk.SEPID, - "disk_type": disk.Type, - "pool": disk.Pool, - "desc": disk.Description, - "image_id": disk.ImageID, - "disk_id": disk.ID, - "shareable": disk.Shareable, - "size_used": disk.SizeUsed, - "size_max": disk.SizeMax, - "permanently": pernamentlyValue, - "present_to": disk.PresentTo, + "disk_name": disk.Name, + "node_ids": nodeIds, + "size": disk.SizeMax, + "sep_id": disk.SEPID, + "disk_type": disk.Type, + "pool": disk.Pool, + "desc": disk.Description, + "image_id": disk.ImageID, + "disk_id": disk.ID, + "shareable": disk.Shareable, + "size_used": disk.SizeUsed, + "size_max": disk.SizeMax, + "permanently": pernamentlyValue, + "present_to": disk.PresentTo, + "storage_policy_id": disk.StoragePolicyID, + "to_clean": disk.ToClean, } res = append(res, temp) indexDataDisks++ @@ -296,77 +303,79 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} devices, _ := json.Marshal(computeItem.Devices) userData, _ := json.Marshal(computeItem.Userdata) temp := map[string]interface{}{ - "acl": flattenListACLInterface(computeItem.ACL), - "account_id": computeItem.AccountID, - "account_name": computeItem.AccountName, - "affinity_label": computeItem.AffinityLabel, - "affinity_rules": flattenListRules(computeItem.AffinityRules), - "affinity_weight": computeItem.AffinityWeight, - "anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules), - "arch": computeItem.Arch, - "auto_start_w_node": computeItem.AutoStart, - "chipset": computeItem.Chipset, - "cd_image_id": computeItem.CdImageId, - "boot_order": computeItem.BootOrder, - "bootdisk_size": computeItem.BootDiskSize, - "clone_reference": computeItem.CloneReference, - "clones": computeItem.Clones, - "computeci_id": computeItem.ComputeCIID, - "cpus": computeItem.CPUs, - "created_by": computeItem.CreatedBy, - "created_time": computeItem.CreatedTime, - "custom_fields": string(customFields), - "deleted_by": computeItem.DeletedBy, - "deleted_time": computeItem.DeletedTime, - "desc": computeItem.Description, - "devices": string(devices), - "disks": flattenDisks(computeItem.Disks), - "driver": computeItem.Driver, - "gid": computeItem.GID, - "guid": computeItem.GUID, - "hp_backed": computeItem.HPBacked, - "compute_id": computeItem.ID, - "cpu_pin": computeItem.CPUPin, - "image_id": computeItem.ImageID, - "interfaces": flattenInterfaces(computeItem.Interfaces), - "live_migration_job_id": computeItem.LiveMigrationJobID, - "lock_status": computeItem.LockStatus, - "manager_id": computeItem.ManagerID, - "manager_type": computeItem.ManagerType, - "migrationjob": computeItem.MigrationJob, - "milestones": computeItem.Milestones, - "nid": computeItem.NID, - "name": computeItem.Name, - "need_reboot": computeItem.NeedReboot, - "numa_affinity": computeItem.NumaAffinity, - "numa_node_id": computeItem.NumaNodeId, - "os_users": flattenOSUsers(computeItem.OSUsers), - "pinned": computeItem.PinnedToStack, - "preferred_cpu": computeItem.PreferredCPU, - "qemu_guest": flattenQemuQuest(computeItem.QemuQuest), - "ram": computeItem.RAM, - "reference_id": computeItem.ReferenceID, - "registered": computeItem.Registered, - "res_name": computeItem.ResName, - "reserved_node_cpus": computeItem.ReservedNodeCpus, - "rg_id": computeItem.RGID, - "rg_name": computeItem.RGName, - "snap_sets": flattenSnapSets(computeItem.SnapSets), - "stack_id": computeItem.StackID, - "stack_name": computeItem.StackName, - "stateless_sep_id": computeItem.StatelessSEPID, - "stateless_sep_type": computeItem.StatelessSEPType, - "status": computeItem.Status, - "tags": flattenTags(computeItem.Tags), - "tech_status": computeItem.TechStatus, - "total_disk_size": computeItem.TotalDiskSize, - "updated_by": computeItem.UpdatedBy, - "updated_time": computeItem.UpdatedTime, - "user_data": string(userData), - "user_managed": computeItem.UserManaged, - "vgpus": computeItem.VGPUs, - "vins_connected": computeItem.VINSConnected, - "virtual_image_id": computeItem.VirtualImageID, + "acl": flattenListACLInterface(computeItem.ACL), + "account_id": computeItem.AccountID, + "account_name": computeItem.AccountName, + "affinity_label": computeItem.AffinityLabel, + "affinity_rules": flattenListRules(computeItem.AffinityRules), + "affinity_weight": computeItem.AffinityWeight, + "anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules), + "arch": computeItem.Arch, + "auto_start_w_node": computeItem.AutoStart, + "chipset": computeItem.Chipset, + "cd_image_id": computeItem.CdImageId, + "boot_order": computeItem.BootOrder, + "boot_image_id": computeItem.BootImageID, + "bootdisk_size": computeItem.BootDiskSize, + "clone_reference": computeItem.CloneReference, + "clones": computeItem.Clones, + "computeci_id": computeItem.ComputeCIID, + "cpus": computeItem.CPUs, + "created_by": computeItem.CreatedBy, + "created_time": computeItem.CreatedTime, + "custom_fields": string(customFields), + "deleted_by": computeItem.DeletedBy, + "deleted_time": computeItem.DeletedTime, + "desc": computeItem.Description, + "devices": string(devices), + "disks": flattenDisks(computeItem.Disks), + "driver": computeItem.Driver, + "gid": computeItem.GID, + "guid": computeItem.GUID, + "hp_backed": computeItem.HPBacked, + "compute_id": computeItem.ID, + "cpu_pin": computeItem.CPUPin, + "interfaces": flattenInterfaces(computeItem.Interfaces), + "live_migration_job_id": computeItem.LiveMigrationJobID, + "lock_status": computeItem.LockStatus, + "manager_id": computeItem.ManagerID, + "manager_type": computeItem.ManagerType, + "migrationjob": computeItem.MigrationJob, + "milestones": computeItem.Milestones, + "nid": computeItem.NID, + "name": computeItem.Name, + "need_reboot": computeItem.NeedReboot, + "numa_affinity": computeItem.NumaAffinity, + "numa_node_id": computeItem.NumaNodeId, + "os_users": flattenOSUsers(computeItem.OSUsers), + "os_version": computeItem.OSVersion, + "pinned": computeItem.PinnedToStack, + "preferred_cpu": computeItem.PreferredCPU, + "qemu_guest": flattenQemuQuest(computeItem.QemuQuest), + "ram": computeItem.RAM, + "reference_id": computeItem.ReferenceID, + "registered": computeItem.Registered, + "res_name": computeItem.ResName, + "reserved_node_cpus": computeItem.ReservedNodeCpus, + "rg_id": computeItem.RGID, + "rg_name": computeItem.RGName, + "snap_sets": flattenSnapSets(computeItem.SnapSets), + "stack_id": computeItem.StackID, + "stack_name": computeItem.StackName, + "stateless_sep_id": computeItem.StatelessSEPID, + "stateless_sep_type": computeItem.StatelessSEPType, + "status": computeItem.Status, + "tags": flattenTags(computeItem.Tags), + "tech_status": computeItem.TechStatus, + "total_disk_size": computeItem.TotalDiskSize, + "updated_by": computeItem.UpdatedBy, + "updated_time": computeItem.UpdatedTime, + "user_data": string(userData), + "user_managed": computeItem.UserManaged, + "vgpus": computeItem.VGPUs, + "vins_connected": computeItem.VINSConnected, + //TODO + // "virtual_image_id": computeItem.VirtualImageID, "loader_type": computeItem.LoaderType, "boot_type": computeItem.BootType, "hot_resize": computeItem.HotResize, @@ -386,74 +395,78 @@ func flattenDeletedComputeList(computes *compute.ListDeletedComputes) []map[stri devices, _ := json.Marshal(computeItem.Devices) userData, _ := json.Marshal(computeItem.Userdata) temp := map[string]interface{}{ - "acl": flattenListACLInterface(computeItem.ACL), - "account_id": computeItem.AccountID, - "account_name": computeItem.AccountName, - "affinity_label": computeItem.AffinityLabel, - "affinity_rules": flattenListRules(computeItem.AffinityRules), - "affinity_weight": computeItem.AffinityWeight, - "anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules), - "arch": computeItem.Arch, - "auto_start_w_node": computeItem.AutoStart, - "chipset": computeItem.Chipset, - "cd_image_id": computeItem.CdImageId, - "boot_order": computeItem.BootOrder, - "bootdisk_size": computeItem.BootDiskSize, - "clone_reference": computeItem.CloneReference, - "clones": computeItem.Clones, - "computeci_id": computeItem.ComputeCIID, - "cpus": computeItem.CPUs, - "created_by": computeItem.CreatedBy, - "created_time": computeItem.CreatedTime, - "custom_fields": string(customFields), - "deleted_by": computeItem.DeletedBy, - "deleted_time": computeItem.DeletedTime, - "desc": computeItem.Description, - "devices": string(devices), - "disks": flattenDisks(computeItem.Disks), - "driver": computeItem.Driver, - "gid": computeItem.GID, - "guid": computeItem.GUID, - "hp_backed": computeItem.HPBacked, - "compute_id": computeItem.ID, - "cpu_pin": computeItem.CPUPin, - "image_id": computeItem.ImageID, - "interfaces": flattenInterfaces(computeItem.Interfaces), - "lock_status": computeItem.LockStatus, - "manager_id": computeItem.ManagerID, - "manager_type": computeItem.ManagerType, - "migrationjob": computeItem.MigrationJob, - "milestones": computeItem.Milestones, - "name": computeItem.Name, - "need_reboot": computeItem.NeedReboot, - "numa_affinity": computeItem.NumaAffinity, - "numa_node_id": computeItem.NumaNodeId, - "os_users": flattenOSUsers(computeItem.OSUsers), - "pinned": computeItem.PinnedToStack, - "preferred_cpu": computeItem.PreferredCPU, - "ram": computeItem.RAM, - "reference_id": computeItem.ReferenceID, - "registered": computeItem.Registered, - "res_name": computeItem.ResName, - "reserved_node_cpus": computeItem.ReservedNodeCpus, - "rg_id": computeItem.RGID, - "rg_name": computeItem.RGName, - "snap_sets": flattenSnapSets(computeItem.SnapSets), - "stack_id": computeItem.StackID, - "stack_name": computeItem.StackName, - "stateless_sep_id": computeItem.StatelessSEPID, - "stateless_sep_type": computeItem.StatelessSEPType, - "status": computeItem.Status, - "tags": flattenTags(computeItem.Tags), - "tech_status": computeItem.TechStatus, - "total_disk_size": computeItem.TotalDiskSize, - "updated_by": computeItem.UpdatedBy, - "updated_time": computeItem.UpdatedTime, - "user_data": string(userData), - "user_managed": computeItem.UserManaged, - "vgpus": computeItem.VGPUs, - "vins_connected": computeItem.VINSConnected, - "virtual_image_id": computeItem.VirtualImageID, + "acl": flattenListACLInterface(computeItem.ACL), + "account_id": computeItem.AccountID, + "account_name": computeItem.AccountName, + "affinity_label": computeItem.AffinityLabel, + "affinity_rules": flattenListRules(computeItem.AffinityRules), + "affinity_weight": computeItem.AffinityWeight, + "anti_affinity_rules": flattenListRules(computeItem.AntiAffinityRules), + "arch": computeItem.Arch, + "auto_start_w_node": computeItem.AutoStart, + "chipset": computeItem.Chipset, + "cd_image_id": computeItem.CdImageId, + "boot_order": computeItem.BootOrder, + "bootdisk_size": computeItem.BootDiskSize, + "boot_image_id": computeItem.BootImageID, + "clone_reference": computeItem.CloneReference, + "clones": computeItem.Clones, + "computeci_id": computeItem.ComputeCIID, + "cpus": computeItem.CPUs, + "created_by": computeItem.CreatedBy, + "created_time": computeItem.CreatedTime, + "custom_fields": string(customFields), + "deleted_by": computeItem.DeletedBy, + "deleted_time": computeItem.DeletedTime, + "desc": computeItem.Description, + "devices": string(devices), + "disks": flattenDisks(computeItem.Disks), + "driver": computeItem.Driver, + "gid": computeItem.GID, + "guid": computeItem.GUID, + "hp_backed": computeItem.HPBacked, + "compute_id": computeItem.ID, + "cpu_pin": computeItem.CPUPin, + //TODO + // "image_id": computeItem.ImageID, + "interfaces": flattenInterfaces(computeItem.Interfaces), + "lock_status": computeItem.LockStatus, + "manager_id": computeItem.ManagerID, + "manager_type": computeItem.ManagerType, + "migrationjob": computeItem.MigrationJob, + "milestones": computeItem.Milestones, + "name": computeItem.Name, + "need_reboot": computeItem.NeedReboot, + "numa_affinity": computeItem.NumaAffinity, + "numa_node_id": computeItem.NumaNodeId, + "os_users": flattenOSUsers(computeItem.OSUsers), + "os_version": computeItem.OSVersion, + "pinned": computeItem.PinnedToStack, + "preferred_cpu": computeItem.PreferredCPU, + "ram": computeItem.RAM, + "reference_id": computeItem.ReferenceID, + "registered": computeItem.Registered, + "res_name": computeItem.ResName, + "reserved_node_cpus": computeItem.ReservedNodeCpus, + "rg_id": computeItem.RGID, + "rg_name": computeItem.RGName, + "snap_sets": flattenSnapSets(computeItem.SnapSets), + "stack_id": computeItem.StackID, + "stack_name": computeItem.StackName, + "stateless_sep_id": computeItem.StatelessSEPID, + "stateless_sep_type": computeItem.StatelessSEPType, + "status": computeItem.Status, + "tags": flattenTags(computeItem.Tags), + "tech_status": computeItem.TechStatus, + "total_disk_size": computeItem.TotalDiskSize, + "updated_by": computeItem.UpdatedBy, + "updated_time": computeItem.UpdatedTime, + "user_data": string(userData), + "user_managed": computeItem.UserManaged, + "vgpus": computeItem.VGPUs, + "vins_connected": computeItem.VINSConnected, + //TODO + // "virtual_image_id": computeItem.VirtualImageID, "loader_type": computeItem.LoaderType, "boot_type": computeItem.BootType, "hot_resize": computeItem.HotResize, @@ -544,8 +557,8 @@ func flattenDisks(disks []compute.InfoDisk) []map[string]interface{} { } func flattenComputeAudits(computeAudits compute.ListDetailedAudits) []map[string]interface{} { - res := make([]map[string]interface{}, 0, len(computeAudits)) - for _, computeAudit := range computeAudits { + res := make([]map[string]interface{}, 0, len(computeAudits.Data)) + for _, computeAudit := range computeAudits.Data { temp := map[string]interface{}{ "call": computeAudit.Call, "responsetime": computeAudit.ResponseTime, @@ -723,6 +736,7 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute d.Set("arch", compFacts.Arch) d.Set("auto_start_w_node", compFacts.AutoStart) d.Set("boot_order", compFacts.BootOrder) + d.Set("boot_image_id", compFacts.ImageID) d.Set("chipset", compFacts.Chipset) d.Set("cd_image_id", compFacts.CdImageId) d.Set("clone_reference", compFacts.CloneReference) @@ -785,14 +799,16 @@ func flattenDataCompute(d *schema.ResourceData, compFacts *compute.RecordCompute d.Set("user_managed", compFacts.UserManaged) d.Set("vnc_password", compFacts.VNCPassword) d.Set("vgpus", flattenVGPUs(compFacts.VGPUs)) - d.Set("virtual_image_id", compFacts.VirtualImageID) - d.Set("virtual_image_name", compFacts.VirtualImageName) + //TODO + // d.Set("virtual_image_id", compFacts.VirtualImageID) + // d.Set("virtual_image_name", compFacts.VirtualImageName) d.Set("pci_devices", flattenPCI(*pciList)) d.Set("loader_type", compFacts.LoaderType) d.Set("boot_type", compFacts.BootType) d.Set("hot_resize", compFacts.HotResize) d.Set("network_interface_naming", compFacts.NetworkInterfaceNaming) d.Set("zone_id", compFacts.ZoneID) + d.Set("os_version", compFacts.OSVersion) //extra fields setting bootDisk := findBootDisk(compFacts.Disks) if bootDisk != nil { @@ -823,6 +839,7 @@ func parseComputeInterfacesToNetworks(networks []interface{}, ifaces compute.Lis elem["mtu"] = value.MTU elem["sdn_interface_id"] = value.SDNInterfaceID elem["weight"] = flattenNetworkWeight(networks, value.NetID, value.NetType) + elem["enabled"] = value.Enabled result = append(result, elem) } @@ -886,8 +903,10 @@ func flattenDisk(diskList compute.ListDisks) []map[string]interface{} { "size_used": disk.SizeUsed, "snapshots": flattendDiskSnapshotList(disk.Snapshots), "status": disk.Status, + "storage_policy_id": disk.StoragePolicyID, "tech_status": disk.TechStatus, "type": disk.Type, + "to_clean": disk.ToClean, } res = append(res, temp) } diff --git a/internal/service/cloudbroker/kvmvm/models.go b/internal/service/cloudbroker/kvmvm/models.go new file mode 100644 index 00000000..2a63815f --- /dev/null +++ b/internal/service/cloudbroker/kvmvm/models.go @@ -0,0 +1,10 @@ +package kvmvm + +type updatedNetwork struct { + DetachMap []map[string]interface{} + ChangeIPMap []map[string]interface{} + ChangeMacMap []map[string]interface{} + ChangeMTUMap []map[string]interface{} + AttachMap []map[string]interface{} + EnableMap []map[string]interface{} +} diff --git a/internal/service/cloudbroker/kvmvm/resource_compute.go b/internal/service/cloudbroker/kvmvm/resource_compute.go index dd7498c4..cce221b6 100644 --- a/internal/service/cloudbroker/kvmvm/resource_compute.go +++ b/internal/service/cloudbroker/kvmvm/resource_compute.go @@ -34,6 +34,8 @@ package kvmvm import ( "context" + "errors" + "fmt" "sort" "strconv" "strings" @@ -116,6 +118,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf NetID: uint64(netInterfaceVal["net_id"].(int)), } + if enabledNetwork(d.GetRawConfig().GetAttr("network"), reqInterface.NetID, reqInterface.NetType) { + reqInterface.Enabled = netInterfaceVal["enabled"].(bool) + } + if reqInterface.NetType == "DPDK" || reqInterface.NetType == "EXTNET" { reqInterface.MTU = uint64(netInterfaceVal["mtu"].(int)) } @@ -148,8 +154,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf for _, elem := range disks.([]interface{}) { diskVal := elem.(map[string]interface{}) reqDataDisk := kvmx86.DataDisk{ - DiskName: diskVal["disk_name"].(string), - Size: uint64(diskVal["size"].(int)), + DiskName: diskVal["disk_name"].(string), + Size: uint64(diskVal["size"].(int)), + StoragePolicyID: uint64(diskVal["storage_policy_id"].(int)), } if sepId, ok := diskVal["sep_id"]; ok { reqDataDisk.SepID = uint64(sepId.(int)) @@ -178,12 +185,12 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } var computeId uint64 - driver := d.Get("driver").(string) createReqX86.RGID = uint64(d.Get("rg_id").(int)) createReqX86.Name = d.Get("name").(string) createReqX86.CPU = uint64(d.Get("cpu").(int)) createReqX86.RAM = uint64(d.Get("ram").(int)) + createReqX86.StoragePolicyID = uint64(d.Get("storage_policy_id").(int)) if image, ok := d.GetOk("image_id"); ok { createReqX86.ImageID = uint64(image.(int)) @@ -192,8 +199,6 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf createReqX86.WithoutBootDisk = withoutBootDisk.(bool) } - createReqX86.Driver = driver - if custom_fields, ok := d.GetOk("custom_fields"); ok { val := custom_fields.(string) val = strings.ReplaceAll(val, "\\", "") @@ -221,6 +226,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } } + if osVersion, ok := d.GetOk("os_version"); ok { + createReqX86.OSVersion = osVersion.(string) + } + log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86") apiResp, err := c.CloudBroker().KVMX86().Create(ctx, createReqX86) if err != nil { @@ -260,7 +269,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf loaderType, loaderTypeOk := d.GetOk("loader_type") bootType, bootTypeOk := d.GetOk("boot_type") - hotResize, hotResizeOk := d.GetOk("hot_resize") + hotResize, hotResizeOk := d.GetOkExists("hot_resize") networkInterfaceNaming, networkInterfaceNamingOk := d.GetOk("network_interface_naming") if loaderTypeOk { @@ -370,6 +379,10 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf break } } + if mac == "" { + warnings.Add(errors.New(fmt.Sprintf("add libvirt virtio: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))) + continue + } log.Debugf("resourceComputeCreate: Configure libvirt virtio interface parameters on Network with type %s and id %d", netType, netId) req := compute.SetNetConfigRequest{ ComputeID: computeId, @@ -390,6 +403,45 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf } } + if secGroups, ok := d.GetOk("security_groups"); ok { + if secGroups.(*schema.Set).Len() > 0 { + sgl := secGroups.(*schema.Set).List() + for _, elem := range sgl { + secGroupsMap := elem.(map[string]interface{}) + + netType := secGroupsMap["net_type"].(string) + netId := uint64(secGroupsMap["net_id"].(int)) + var mac string + for _, iface := range simpleCompRec.Interfaces { + if iface.NetID == netId && iface.NetType == netType { + mac = iface.MAC + break + } + } + if mac == "" { + warnings.Add(errors.New(fmt.Sprintf("add security groups: Network with type %s and id %d is not connected to the compute %d", netType, netId, computeId))) + continue + } + secGroupsIDs := make([]uint64, 0) + for _, id := range secGroupsMap["security_groups"].(*schema.Set).List() { + secGroupsIDs = append(secGroupsIDs, uint64(id.(int))) + } + log.Debugf("resourceComputeCreate: Configure security groups interface parameters on Network with type %s and id %d", netType, netId) + req := compute.ChangeSecGroupsRequest{ + ComputeID: computeId, + Interface: mac, + SecGroups: secGroupsIDs, + EnableSecGroups: secGroupsMap["enable_secgroups"].(bool), + } + + _, err := c.CloudBroker().Compute().ChangeSecGroups(ctx, req) + if err != nil { + warnings.Add(err) + } + } + } + } + if start, ok := d.GetOk("started"); ok && start.(bool) { req := compute.StartRequest{ComputeID: computeId} log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId) @@ -767,7 +819,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf "loader_type", "boot_type", "hot_resize", - "network_interface_naming") { + "network_interface_naming", + "os_version") { if err := utilityComputeUpdate(ctx, d, m); err != nil { return diag.FromErr(err) } @@ -780,6 +833,13 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf } } + if d.HasChange("security_groups") { + err = utilityComputeSecGroupsConfigure(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + } + if d.HasChange("disks") { if err := utilityComputeUpdateDisks(ctx, d, m); err != nil { return diag.FromErr(err) @@ -938,7 +998,7 @@ func ResourceCompute() *schema.Resource { CustomizeDiff: func(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error { if diff.HasChanges() || diff.HasChanges("chipset", "pin_to_stack", "auto_start_w_node", "libvirt_settings", "network", "affinity_rules", "anti_affinity_rules", - "extra_disks", "tags", "port_forwarding", "user_access", "snapshot", "pci_devices", "preferred_cpu") { + "extra_disks", "tags", "port_forwarding", "user_access", "snapshot", "pci_devices", "preferred_cpu", "security_groups") { diff.SetNewComputed("updated_time") diff.SetNewComputed("updated_by") } diff --git a/internal/service/cloudbroker/kvmvm/schema.go b/internal/service/cloudbroker/kvmvm/schema.go index 52e5c134..0a0abbf9 100644 --- a/internal/service/cloudbroker/kvmvm/schema.go +++ b/internal/service/cloudbroker/kvmvm/schema.go @@ -145,6 +145,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, }, }, + "boot_image_id": { + Type: schema.TypeInt, + Computed: true, + }, "chipset": { Type: schema.TypeString, Computed: true, @@ -510,6 +514,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_id": { + Type: schema.TypeInt, + Computed: true, + }, "tech_status": { Type: schema.TypeString, Computed: true, @@ -518,6 +526,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, @@ -577,6 +589,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "flip_group_id": { Type: schema.TypeInt, Computed: true, @@ -702,6 +718,13 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "security_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "vnfs": { Type: schema.TypeList, Computed: true, @@ -796,6 +819,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema { }, }, }, + "os_version": { + Type: schema.TypeString, + Computed: true, + }, "pinned": { Type: schema.TypeInt, Computed: true, @@ -1142,11 +1169,6 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Find by stack ID", }, - "image_id": { - Type: schema.TypeInt, - Optional: true, - Description: "Find by image ID", - }, "cd_image_id": { Type: schema.TypeInt, Optional: true, @@ -1179,6 +1201,11 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Optional: true, }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "ignore_k8s": { Type: schema.TypeBool, Optional: true, @@ -1321,6 +1348,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "boot_image_id": { + Type: schema.TypeInt, + Computed: true, + }, "chipset": { Type: schema.TypeString, Computed: true, @@ -1449,6 +1480,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "flip_group_id": { Type: schema.TypeInt, Computed: true, @@ -1561,6 +1596,13 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "security_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "target": { Type: schema.TypeString, Computed: true, @@ -1651,6 +1693,10 @@ func dataSourceComputeListSchemaMake() map[string]*schema.Schema { }, }, }, + "os_version": { + Type: schema.TypeString, + Computed: true, + }, "pinned": { Type: schema.TypeInt, Computed: true, @@ -2061,6 +2107,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "boot_image_id": { + Type: schema.TypeInt, + Computed: true, + }, "chipset": { Type: schema.TypeString, Computed: true, @@ -2185,6 +2235,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "flip_group_id": { Type: schema.TypeInt, Computed: true, @@ -2297,6 +2351,13 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "security_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "target": { Type: schema.TypeString, Computed: true, @@ -2379,6 +2440,10 @@ func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema { }, }, }, + "os_version": { + Type: schema.TypeString, + Computed: true, + }, "pinned": { Type: schema.TypeInt, Computed: true, @@ -2561,6 +2626,42 @@ func dataSourceComputeAuditsSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Required: true, }, + "timestamp_at": { + Type: schema.TypeInt, + Optional: true, + }, + "timestamp_to": { + Type: schema.TypeInt, + Optional: true, + }, + "user": { + Type: schema.TypeString, + Optional: true, + }, + "call": { + Type: schema.TypeString, + Optional: true, + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + }, + "page": { + Type: schema.TypeInt, + Optional: true, + }, + "size": { + Type: schema.TypeInt, + Optional: true, + }, + "min_status_code": { + Type: schema.TypeInt, + Optional: true, + }, + "max_status_code": { + Type: schema.TypeInt, + Optional: true, + }, "items": { Type: schema.TypeList, @@ -2590,6 +2691,10 @@ func dataSourceComputeAuditsSchemaMake() map[string]*schema.Schema { }, }, }, + "entry_count": { + Type: schema.TypeInt, + Computed: true, + }, } } @@ -3226,13 +3331,6 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { ValidateFunc: validation.IntAtLeast(1), Description: "ID of the resource group where this compute should be deployed.", }, - "driver": { - Type: schema.TypeString, - Required: true, - StateFunc: statefuncs.StateFuncToUpper, - ValidateFunc: validation.StringInSlice([]string{"KVM_X86"}, false), // observe case while validating - Description: "Hardware architecture of this compute instance.", - }, "cpu": { Type: schema.TypeInt, Required: true, @@ -3248,6 +3346,11 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { ), Description: "Amount of RAM in MB to allocate to this compute instance.", }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "Storage policy id of compute. The rules of the specified storage policy will be used.", + }, "image_id": { Type: schema.TypeInt, Optional: true, @@ -3386,6 +3489,12 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { DiffSuppressFunc: networkSubresIPAddreDiffSupperss, Description: "unique_identifier of LogicalPort on SDN side", }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "network enable flag", + }, }, }, Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.", @@ -3443,6 +3552,40 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Description: "Configure libvirt virtio interface parameters. You can only delete values locally. Data on the platform cannot be deleted.", }, + "security_groups": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "net_type": { + Type: schema.TypeString, + Required: true, + StateFunc: statefuncs.StateFuncToUpper, + ValidateFunc: validation.StringInSlice([]string{"VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK"}, false), // observe case while validating + Description: "Type of the network", + }, + "net_id": { + Type: schema.TypeInt, + Required: true, + Description: "ID of the network", + }, + "security_groups": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "enable_secgroups": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + }, + }, + Description: "list of security group IDs to apply to this interface", + }, + "affinity_label": { Type: schema.TypeString, Optional: true, @@ -3541,6 +3684,11 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Required: true, Description: "Disk size in GiB", }, + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + Description: "Storage policy id of disk. The rules of the specified storage policy will be used.", + }, "sep_id": { Type: schema.TypeInt, Computed: true, @@ -3608,6 +3756,10 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Computed: true, }, + "to_clean": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, @@ -3841,6 +3993,12 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { ValidateFunc: validation.StringInSlice([]string{"eth", "ens"}, false), Description: "Name of netfowrk interface.", }, + "os_version": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "the OS version installed on the VM", + }, // Computed properties "account_id": { Type: schema.TypeInt, @@ -3904,6 +4062,10 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Computed: true, Description: "This compute instance boot disk ID.", }, + "boot_image_id": { + Type: schema.TypeInt, + Computed: true, + }, "cd_image_id": { Type: schema.TypeInt, Computed: true, @@ -3943,6 +4105,10 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "driver": { + Type: schema.TypeString, + Computed: true, + }, "gid": { Type: schema.TypeInt, Computed: true, @@ -3980,6 +4146,10 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeBool, Computed: true, }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "flip_group_id": { Type: schema.TypeInt, Computed: true, @@ -4092,6 +4262,13 @@ func resourceComputeSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "security_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "target": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/cloudbroker/kvmvm/utility_compute.go b/internal/service/cloudbroker/kvmvm/utility_compute.go index 81119a94..e0aba1a5 100644 --- a/internal/service/cloudbroker/kvmvm/utility_compute.go +++ b/internal/service/cloudbroker/kvmvm/utility_compute.go @@ -39,6 +39,7 @@ import ( "strconv" "strings" + "github.com/hashicorp/go-cty/cty" log "github.com/sirupsen/logrus" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/compute" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks" @@ -111,7 +112,13 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa c := m.(*controller.ControllerCfg) computeId, _ := strconv.ParseUint(d.Id(), 10, 64) - if d.Get("started").(bool) { + var isStopRequired bool + + old, new := d.GetChange("cpu") + if d.Get("started").(bool) && (old.(int) > new.(int)) && d.Get("force_resize").(bool) { + isStopRequired = true + } + if isStopRequired { stopReq := compute.StopRequest{ ComputeID: computeId, Force: false, @@ -176,7 +183,7 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa } } - if d.Get("started").(bool) { + if isStopRequired { if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil { return err } @@ -227,6 +234,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in addedDisks := make([]interface{}, 0) resizedDisks := make([]interface{}, 0) renamedDisks := make([]interface{}, 0) + changeStoragePolicyDisks := make([]interface{}, 0) presentNewDisks := make([]interface{}, 0) presentOldDisks := make([]interface{}, 0) @@ -241,7 +249,7 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in presentOldDisks = append(presentOldDisks, el) } // !isRenameDisk(newConv, el) && !isResizeDisk(newConv, el) are required in case two or more disks are being created and their disk_id is the same (=0) - if !isContainsDisk(newConv, el) && !isRenameDisk(newConv, el) && !isResizeDisk(newConv, el) { + if !isContainsDisk(newConv, el) && !isRenameDisk(newConv, el) && !isResizeDisk(newConv, el) && !isChangeStoragePolicy(newConv, el) { flag := false extraDisks := d.Get("extra_disks").(*schema.Set).List() delDisk := el.(map[string]interface{}) @@ -272,19 +280,12 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in if isRenameDisk(oldConv, el) { renamedDisks = append(renamedDisks, el) } + if isChangeStoragePolicy(oldConv, el) { + changeStoragePolicyDisks = append(changeStoragePolicyDisks, el) + } } if len(deletedDisks) > 0 { - stopReq := compute.StopRequest{ - ComputeID: computeId, - Force: false, - } - - _, err := c.CloudBroker().Compute().Stop(ctx, stopReq) - if err != nil { - return err - } - for _, disk := range deletedDisks { diskConv := disk.(map[string]interface{}) if diskConv["disk_type"].(string) == "B" { @@ -302,14 +303,6 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in return err } } - req := compute.StartRequest{ - ComputeID: computeId, - AltBootID: 0, - } - _, err = c.CloudBroker().Compute().Start(ctx, req) - if err != nil { - return err - } } if len(addedDisks) > 0 { @@ -319,9 +312,10 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in continue } req := compute.DiskAddRequest{ - ComputeID: computeId, - DiskName: diskConv["disk_name"].(string), - Size: uint64(diskConv["size"].(int)), + ComputeID: computeId, + DiskName: diskConv["disk_name"].(string), + Size: uint64(diskConv["size"].(int)), + StoragePolicyID: uint64(diskConv["storage_policy_id"].(int)), } if diskConv["sep_id"].(int) != 0 { req.SepID = uint64(diskConv["sep_id"].(int)) @@ -399,6 +393,21 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in } } } + if len(changeStoragePolicyDisks) > 0 { + for _, disk := range changeStoragePolicyDisks { + diskConv := disk.(map[string]interface{}) + + req := disks.ChangeDiskStoragePolicyRequest{ + DiskID: uint64(diskConv["disk_id"].(int)), + StoragePolicyID: uint64(diskConv["storage_policy_id"].(int)), + } + + _, err := c.CloudBroker().Disks().ChangeDiskStoragePolicy(ctx, req) + if err != nil { + return err + } + } + } for i := range presentNewDisks { newDisk := presentNewDisks[i].(map[string]interface{}) @@ -589,12 +598,12 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData oldList := oldSet.(*schema.Set).List() newList := newSet.(*schema.Set).List() - detachMap, changeIpMap, changeMacMap, changeMTUMap, attachMap := differenceNetwork(oldList, newList) + updateNetwork := differenceNetwork(oldList, newList) apiErrCount := 0 var lastSavedError error - log.Debugf("utilityComputeNetworksConfigure: detach set has %d items for Compute ID %s", len(detachMap), d.Id()) - for _, netData := range detachMap { + log.Debugf("utilityComputeNetworksConfigure: detach set has %d items for Compute ID %s", len(updateNetwork.DetachMap), d.Id()) + for _, netData := range updateNetwork.DetachMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.NetDetachRequest{ ComputeID: computeId, @@ -611,8 +620,8 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } - log.Debugf("utilityComputeNetworksConfigure: changeIp set has %d items for Compute ID %s", len(changeIpMap), d.Id()) - for _, netData := range changeIpMap { + log.Debugf("utilityComputeNetworksConfigure: changeIp set has %d items for Compute ID %s", len(updateNetwork.ChangeIPMap), d.Id()) + for _, netData := range updateNetwork.ChangeIPMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.ChangeIPRequest{ ComputeID: computeId, @@ -634,9 +643,9 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData oldLibvirtSet, newLibvirtSet := d.GetChange("libvirt_settings") addedLibvirtSettings := (newLibvirtSet.(*schema.Set).Difference(oldLibvirtSet.(*schema.Set))).List() - libvirtSettingsMap := addAttachedNetwork(addedLibvirtSettings, newLibvirtSet.(*schema.Set).List(), attachMap) + libvirtSettingsMap := addAttachedNetwork(addedLibvirtSettings, newLibvirtSet.(*schema.Set).List(), updateNetwork.AttachMap) - if oldSet.(*schema.Set).Len() == len(detachMap) || oldSet.(*schema.Set).Len() == 0 || len(libvirtSettingsMap) > 0 || hasDPDKnetwork(attachMap) || len(changeMacMap) > 0 { + if oldSet.(*schema.Set).Len() == len(updateNetwork.DetachMap) || oldSet.(*schema.Set).Len() == 0 || len(libvirtSettingsMap) > 0 || hasDPDKnetwork(updateNetwork.AttachMap) || len(updateNetwork.ChangeMacMap) > 0 { if err := utilityComputeStop(ctx, d, m); err != nil { apiErrCount++ lastSavedError = err @@ -646,8 +655,8 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } - log.Debugf("utilityComputeNetworksConfigure: changeMac set has %d items for Compute ID %s", len(changeMacMap), d.Id()) - for _, netData := range changeMacMap { + log.Debugf("utilityComputeNetworksConfigure: changeMac set has %d items for Compute ID %s", len(updateNetwork.ChangeMacMap), d.Id()) + for _, netData := range updateNetwork.ChangeMacMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.ChangeMACRequest{ ComputeID: computeId, @@ -664,9 +673,9 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } - sort.Slice(attachMap, func(i, j int) bool { - weightI := attachMap[i]["weight"].(int) - weightJ := attachMap[j]["weight"].(int) + sort.Slice(updateNetwork.AttachMap, func(i, j int) bool { + weightI := updateNetwork.AttachMap[i]["weight"].(int) + weightJ := updateNetwork.AttachMap[j]["weight"].(int) if weightI == 0 { return false } @@ -675,8 +684,8 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } return weightI < weightJ }) - log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", len(attachMap), d.Id()) - for _, netData := range attachMap { + log.Debugf("utilityComputeNetworksConfigure: attach set has %d items for Compute ID %s", len(updateNetwork.AttachMap), d.Id()) + for _, netData := range updateNetwork.AttachMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.NetAttachRequest{ ComputeID: computeId, @@ -696,7 +705,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData req.MACAddr = netData["mac"].(string) } - if req.NetType == "DPDK" { + if req.NetType == "DPDK" || req.NetType == "EXTNET" { req.MTU = uint64(netData["mtu"].(int)) } @@ -724,7 +733,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } if computeRec != nil { - log.Debugf("utilityComputeNetworksConfigure: libvirt virtio set has %d items for Compute ID %s", len(attachMap), d.Id()) + log.Debugf("utilityComputeNetworksConfigure: libvirt virtio set has %d items for Compute ID %s", len(libvirtSettingsMap), d.Id()) for _, libvirtSetting := range libvirtSettingsMap { netType := libvirtSetting["net_type"].(string) netId := uint64(libvirtSetting["net_id"].(int)) @@ -766,8 +775,8 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } - log.Debugf("utilityComputeNetworksConfigure: changeMTU set has %d items for Compute ID %s", len(changeMTUMap), d.Id()) - for _, netData := range changeMTUMap { + log.Debugf("utilityComputeNetworksConfigure: changeMTU set has %d items for Compute ID %s", len(updateNetwork.ChangeMTUMap), d.Id()) + for _, netData := range updateNetwork.ChangeMTUMap { computeId, _ := strconv.ParseUint(d.Id(), 10, 64) req := compute.ChangeMTURequest{ ComputeID: computeId, @@ -784,6 +793,28 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData } } + log.Debugf("utilityComputeNetworksConfigure: enableMap set has %d items for Compute ID %s", len(updateNetwork.EnableMap), d.Id()) + for _, netData := range updateNetwork.EnableMap { + computeId, _ := strconv.ParseUint(d.Id(), 10, 64) + req := compute.ChangeLinkStateRequest{ + ComputeID: computeId, + Interface: netData["mac"].(string), + State: "off", + } + + if netData["enabled"].(bool) { + req.State = "on" + } + + _, err := c.CloudBroker().Compute().ChangeLinkState(ctx, req) + if err != nil { + log.Errorf("utilityComputeNetworksConfigure: failed to change link state network ID %d of type %s from Compute ID %s: %s", + netData["net_id"].(int), netData["net_type"].(string), d.Id(), err) + apiErrCount++ + lastSavedError = err + } + } + if apiErrCount > 0 { log.Errorf("utilityComputeNetworksConfigure: there were %d error(s) when managing networks of Compute ID %s. Last error was: %s", apiErrCount, d.Id(), lastSavedError) @@ -793,12 +824,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData return nil } -func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, changeMacMap, changeMTUMap, attachMap []map[string]interface{}) { - attachMap = make([]map[string]interface{}, 0) - changeIpMap = make([]map[string]interface{}, 0) - changeMacMap = make([]map[string]interface{}, 0) - changeMTUMap = make([]map[string]interface{}, 0) - detachMap = make([]map[string]interface{}, 0) +func differenceNetwork(oldList, newList []interface{}) *updatedNetwork { + attachMap := make([]map[string]interface{}, 0) + changeIpMap := make([]map[string]interface{}, 0) + changeMacMap := make([]map[string]interface{}, 0) + changeMTUMap := make([]map[string]interface{}, 0) + detachMap := make([]map[string]interface{}, 0) + enableMap := make([]map[string]interface{}, 0) for _, oldNetwork := range oldList { oldMap := oldNetwork.(map[string]interface{}) found := false @@ -816,6 +848,13 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, if (newMap["net_type"].(string) == "EXTNET" || newMap["net_type"].(string) == "DPDK") && (newMap["mtu"] != oldMap["mtu"] && newMap["mtu"].(int) != 0) { changeMTUMap = append(changeMTUMap, newMap) } + if newMap["enabled"].(bool) != oldMap["enabled"].(bool) { + mac, _ := newMap["mac"].(string) + if mac == "" { + newMap["mac"] = oldMap["mac"] + } + enableMap = append(enableMap, newMap) + } } if found { break @@ -843,7 +882,16 @@ func differenceNetwork(oldList, newList []interface{}) (detachMap, changeIpMap, attachMap = append(attachMap, newMap) } - return + res := updatedNetwork{ + DetachMap: detachMap, + ChangeIPMap: changeIpMap, + ChangeMacMap: changeMacMap, + ChangeMTUMap: changeMTUMap, + AttachMap: attachMap, + EnableMap: enableMap, + } + + return &res } func compareNetwork(newMap, oldMap map[string]interface{}) bool { @@ -893,6 +941,75 @@ func addAttachedNetwork(addedLibvirtSettings []interface{}, newLibvirtSettings [ return } +func utilityComputeSecGroupsConfigure(ctx context.Context, d *schema.ResourceData, m interface{}) error { + c := m.(*controller.ControllerCfg) + + computeId, _ := strconv.ParseUint(d.Id(), 10, 64) + simpleCompRec, err := utilityComputeCheckPresence(ctx, d, m) + if err != nil { + return err + } + + apiErrCount := 0 + var lastSavedError error + + oldSecGroups, newSecGroups := d.GetChange("security_groups") + updateSecGroups := (newSecGroups.(*schema.Set).Difference(oldSecGroups.(*schema.Set))).List() + + log.Debugf("utilityComputeSecGroupsConfigure: update security groups has %d items for Compute ID %s", len(updateSecGroups), d.Id()) + if len(updateSecGroups) > 0 { + for _, elem := range updateSecGroups { + secGroupsMap := elem.(map[string]interface{}) + + netType := secGroupsMap["net_type"].(string) + netId := uint64(secGroupsMap["net_id"].(int)) + var mac string + for _, iface := range simpleCompRec.Interfaces { + if iface.NetID == netId && iface.NetType == netType { + mac = iface.MAC + break + } + } + if mac == "" { + log.Errorf("utilityComputeSecGroupsConfigure: Network with type %s and id %d is not connected to the compute %s", + netType, netId, d.Id()) + apiErrCount++ + lastSavedError = errors.New(fmt.Sprintf("utilityComputeSecGroupsConfigure: Network with type %s and id %d is not connected to the compute %s", + netType, netId, d.Id())) + continue + } + secGroupsIDs := make([]uint64, 0) + for _, id := range secGroupsMap["security_groups"].(*schema.Set).List() { + secGroupsIDs = append(secGroupsIDs, uint64(id.(int))) + } + log.Debugf("utilityComputeSecGroupsConfigure: Configure security groups interface parameters on Network with type %s and id %d", netType, netId) + req := compute.ChangeSecGroupsRequest{ + ComputeID: computeId, + Interface: mac, + SecGroups: secGroupsIDs, + } + + if secGroupsMap["enable_secgroups"] != nil { + req.EnableSecGroups = secGroupsMap["enable_secgroups"].(bool) + } + + _, err := c.CloudBroker().Compute().ChangeSecGroups(ctx, req) + if err != nil { + apiErrCount++ + lastSavedError = err + } + } + } + + if apiErrCount > 0 { + log.Errorf("utilityComputeSecGroupsConfigure: there were %d error(s) when managing security groups of Compute ID %s. Last error was: %s", + apiErrCount, d.Id(), lastSavedError) + return lastSavedError + } + + return nil +} + func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) error { c := m.(*controller.ControllerCfg) @@ -931,6 +1048,10 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa req.NetworkInterfaceNaming = d.Get("network_interface_naming").(string) } + if d.HasChange("os_version") { + req.OSVersion = d.Get("os_version").(string) + } + req.CPUPin = d.Get("cpu_pin").(bool) req.HPBacked = d.Get("hp_backed").(bool) req.AutoStart = d.Get("auto_start_w_node").(bool) @@ -954,7 +1075,7 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa // Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status. // If STARTED, we need to stop it before update var isStopRequired bool - if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu") && d.Get("started").(bool) { + if d.HasChanges("numa_affinity", "cpu_pin", "hp_backed", "chipset", "preferred_cpu", "hot_resize") && d.Get("started").(bool) { isStopRequired = true } if isStopRequired { @@ -1597,9 +1718,10 @@ func utilityComputeUpdateImage(ctx context.Context, d *schema.ResourceData, m in if oldImage.(int) != newImage.(int) { req := compute.RedeployRequest{ - ComputeID: computeId, - ImageID: uint64(newImage.(int)), - DataDisks: "KEEP", + ComputeID: computeId, + ImageID: uint64(newImage.(int)), + DataDisks: "KEEP", + StoragePolicyID: uint64(d.Get("storage_policy_id").(int)), } if diskSize, ok := d.GetOk("boot_disk_size"); ok { @@ -1612,6 +1734,10 @@ func utilityComputeUpdateImage(ctx context.Context, d *schema.ResourceData, m in req.ForceStop = forceStop.(bool) } + if osVersion, ok := d.GetOk("os_version"); ok { + req.OSVersion = osVersion.(string) + } + _, err := c.CloudBroker().Compute().Redeploy(ctx, req) if err != nil { return err @@ -1772,6 +1898,18 @@ func isRenameDisk(els []interface{}, el interface{}) bool { return false } +func isChangeStoragePolicy(els []interface{}, el interface{}) bool { + for _, elOld := range els { + elOldConv := elOld.(map[string]interface{}) + elConv := el.(map[string]interface{}) + if elOldConv["disk_id"].(int) == elConv["disk_id"].(int) && + elOldConv["storage_policy_id"].(int) != elConv["storage_policy_id"].(int) { + return true + } + } + return false +} + func isContainsDisk(els []interface{}, el interface{}) bool { for _, elOld := range els { elOldConv := elOld.(map[string]interface{}) @@ -1839,3 +1977,25 @@ func getComputeDiskIDs(disksList compute.ListDisks, disksBlocks, extraDisks []in return res } + +func enabledNetwork(rawNetworkConfig cty.Value, netID uint64, netType string) bool { + for _, netConfigVal := range rawNetworkConfig.AsValueSlice() { + if netConfigVal.IsNull() { + continue + } + + netConfig := netConfigVal.AsValueMap() + + tempID, _ := netConfig["net_id"].AsBigFloat().Int64() + configNetID := uint64(tempID) + + configNetType := netConfig["net_type"].AsString() + + if configNetID == netID && configNetType == netType { + enabledVal := netConfig["enabled"] + return !enabledVal.IsNull() + } + } + + return false +} diff --git a/internal/service/cloudbroker/kvmvm/utility_compute_audits.go b/internal/service/cloudbroker/kvmvm/utility_compute_audits.go index 96962286..b2ccfdfa 100644 --- a/internal/service/cloudbroker/kvmvm/utility_compute_audits.go +++ b/internal/service/cloudbroker/kvmvm/utility_compute_audits.go @@ -45,10 +45,36 @@ func utilityComputeAuditsCheckPresence(ctx context.Context, d *schema.ResourceDa req := compute.AuditsRequest{ ComputeID: uint64(d.Get("compute_id").(int)), } - + if timestampAt, ok := d.GetOk("timestamp_at"); ok { + req.TimestampAT = uint64(timestampAt.(int)) + } + if timestampTo, ok := d.GetOk("timestamp_to"); ok { + req.TimestampTO = uint64(timestampTo.(int)) + } + if user, ok := d.GetOk("user"); ok { + req.User = user.(string) + } + if call, ok := d.GetOk("call"); ok { + req.Call = call.(string) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + if size, ok := d.GetOk("size"); ok { + req.Size = uint64(size.(int)) + } + if minStatusCode, ok := d.GetOk("min_status_code"); ok { + req.MinStatusCode = uint64(minStatusCode.(int)) + } + if maxStatusCode, ok := d.GetOk("max_status_code"); ok { + req.MaxStatusCode = uint64(maxStatusCode.(int)) + } computeAudits, err := c.CloudBroker().Compute().Audits(ctx, req) if err != nil { - return nil, err + return compute.ListDetailedAudits{}, err } - return computeAudits, nil + return *computeAudits, nil } diff --git a/internal/service/cloudbroker/kvmvm/utility_compute_list.go b/internal/service/cloudbroker/kvmvm/utility_compute_list.go index ac0af590..53dd6fc8 100644 --- a/internal/service/cloudbroker/kvmvm/utility_compute_list.go +++ b/internal/service/cloudbroker/kvmvm/utility_compute_list.go @@ -75,9 +75,6 @@ func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.Resource if stackName, ok := d.GetOk("stack_name"); ok { req.StackName = stackName.(string) } - if imageID, ok := d.GetOk("image_id"); ok { - req.ImageID = imageID.(uint64) - } if cdImageID, ok := d.GetOk("cd_image_id"); ok { req.CDImageID = cdImageID.(uint64) } @@ -99,6 +96,9 @@ func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.Resource if size, ok := d.GetOk("size"); ok { req.Size = uint64(size.(int)) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } listComputes, err := c.CloudBroker().Compute().List(ctx, req) if err != nil { diff --git a/internal/service/cloudbroker/lb/schema.go b/internal/service/cloudbroker/lb/schema.go index dc3db8b1..d021d6aa 100644 --- a/internal/service/cloudbroker/lb/schema.go +++ b/internal/service/cloudbroker/lb/schema.go @@ -889,6 +889,11 @@ func dsLBListSchemaMake() map[string]*schema.Schema { Optional: true, Default: 0, }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, diff --git a/internal/service/cloudbroker/lb/utility_lb_list.go b/internal/service/cloudbroker/lb/utility_lb_list.go index cada30eb..75a3b91f 100644 --- a/internal/service/cloudbroker/lb/utility_lb_list.go +++ b/internal/service/cloudbroker/lb/utility_lb_list.go @@ -94,6 +94,10 @@ func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m i req.Size = uint64(size.(int)) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } + log.Debugf("utilityLBListCheckPresence: load lb list") lbList, err := c.CloudBroker().LB().List(ctx, req) if err != nil { diff --git a/internal/service/cloudbroker/node/flattens.go b/internal/service/cloudbroker/node/flattens.go index 0b1003e5..892f3bdd 100644 --- a/internal/service/cloudbroker/node/flattens.go +++ b/internal/service/cloudbroker/node/flattens.go @@ -86,7 +86,8 @@ func flattenConsumption(info node.ConsumptionInfo) []map[string]interface{} { } tempFree := map[string]interface{}{ - "ram": info.Free.RAM, + "ram": info.Free.RAM, + "vcpu": info.Free.VCPU, } tempRes["free"] = []map[string]interface{}{ tempFree, diff --git a/internal/service/cloudbroker/node/schema.go b/internal/service/cloudbroker/node/schema.go index 8de1a6b5..9429fd08 100644 --- a/internal/service/cloudbroker/node/schema.go +++ b/internal/service/cloudbroker/node/schema.go @@ -43,6 +43,10 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "vcpu": { + Type: schema.TypeInt, + Computed: true, + }, "ram": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/cloudbroker/rg/flattens.go b/internal/service/cloudbroker/rg/flattens.go index 5b1360aa..4162248c 100644 --- a/internal/service/cloudbroker/rg/flattens.go +++ b/internal/service/cloudbroker/rg/flattens.go @@ -41,6 +41,7 @@ func flattenResgroup(d *schema.ResourceData, rgData *rg.RecordRG) { d.Set("vins", rgData.VINS) d.Set("computes", rgData.VMs) d.Set("sdn_access_group_id", rgData.SDNAccessGroupID) + d.Set("storage_policy_ids", rgData.StoragePolicyIDs) } func flattenRgAcl(rgACLs rg.ListACL) []map[string]interface{} { @@ -64,13 +65,14 @@ func flattenRgAcl(rgACLs rg.ListACL) []map[string]interface{} { func flattenRgResourceLimits(rl rg.ResourceLimits) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "cu_c": rl.CUC, - "cu_d": rl.CuD, - "cu_dm": rl.CUDM, - "cu_i": rl.CUI, - "cu_m": rl.CUM, - "cu_np": rl.CUNP, - "gpu_units": rl.GPUUnits, + "cu_c": rl.CUC, + "cu_d": rl.CuD, + "cu_dm": rl.CUDM, + "cu_i": rl.CUI, + "cu_m": rl.CUM, + "cu_np": rl.CUNP, + "gpu_units": rl.GPUUnits, + "storage_policy": flattenRgStoragePolicy(rl.StoragePolicies), } res = append(res, temp) @@ -413,6 +415,7 @@ func flattenRgList(rgl *rg.ListRG) []map[string]interface{} { "vins": rg.VINS, "vms": rg.VMs, "sdn_access_group_id": rg.SDNAccessGroupID, + "storage_policy_ids": rg.StoragePolicyIDs, } res = append(res, temp) } @@ -475,6 +478,7 @@ func flattenResourceRG(d *schema.ResourceData, rgData *rg.RecordRG) { d.Set("gid", rgData.GID) d.Set("rg_name", rgData.Name) d.Set("resource_limits", flattenRgResourceLimits(rgData.ResourceLimits)) + d.Set("storage_policy", flattenRgStoragePolicy(rgData.ResourceLimits.StoragePolicies)) d.Set("description", rgData.Description) d.Set("uniq_pools", rgData.UniqPools) d.Set("cpu_allocation_parameter", rgData.CPUAllocationParameter) @@ -498,4 +502,19 @@ func flattenResourceRG(d *schema.ResourceData, rgData *rg.RecordRG) { d.Set("vins", rgData.VINS) d.Set("vms", rgData.VMs) d.Set("sdn_access_group_id", rgData.SDNAccessGroupID) + d.Set("storage_policy_ids", rgData.StoragePolicyIDs) +} + +func flattenRgStoragePolicy(spList []rg.StoragePolicy) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(spList)) + for _, sp := range spList { + temp := map[string]interface{}{ + "id": sp.ID, + "limit": sp.Limit, + } + + res = append(res, temp) + } + + return res } diff --git a/internal/service/cloudbroker/rg/resource_rg.go b/internal/service/cloudbroker/rg/resource_rg.go index d771a8a7..ed8ff14e 100644 --- a/internal/service/cloudbroker/rg/resource_rg.go +++ b/internal/service/cloudbroker/rg/resource_rg.go @@ -141,6 +141,27 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter req.SDNAccessGroupID = sdnAccessGroupID.(string) } + if storagePolicies, ok := d.GetOk("storage_policy"); ok { + var id uint64 + var limit int + + if storagePolicies.(*schema.Set).Len() > 0 { + spList := storagePolicies.(*schema.Set).List() + for _, spInterface := range spList { + sps := spInterface.(map[string]interface{}) + id = uint64(sps["id"].(int)) + limit = sps["limit"].(int) + + spModel := rg.StoragePolicy{ + ID: id, + Limit: limit, + } + + req.StoragePolicies = append(req.StoragePolicies, spModel) + } + } + } + rgID, err := c.CloudBroker().RG().Create(ctx, req) if err != nil { d.SetId("") @@ -367,50 +388,52 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter } if d.HasChange("resource_limits") { - resLimits := d.Get("resource_limits").([]interface{})[0] - resLimitsConv := resLimits.(map[string]interface{}) - if resLimitsConv["cu_m"] != nil { - maxMemCap := int64(resLimitsConv["cu_m"].(float64)) - if maxMemCap == 0 { - req.MaxMemoryCapacity = -1 - } else { - req.MaxMemoryCapacity = maxMemCap + if _, ok := d.GetOk("resource_limits"); ok { + resLimits := d.Get("resource_limits").([]interface{})[0] + resLimitsConv := resLimits.(map[string]interface{}) + if resLimitsConv["cu_m"] != nil { + maxMemCap := int64(resLimitsConv["cu_m"].(float64)) + if maxMemCap == 0 { + req.MaxMemoryCapacity = -1 + } else { + req.MaxMemoryCapacity = maxMemCap + } } - } - if resLimitsConv["cu_dm"] != nil { - maxDiskCap := int64(resLimitsConv["cu_dm"].(float64)) - if maxDiskCap == 0 { - req.MaxVDiskCapacity = -1 - } else { - req.MaxVDiskCapacity = maxDiskCap + if resLimitsConv["cu_dm"] != nil { + maxDiskCap := int64(resLimitsConv["cu_dm"].(float64)) + if maxDiskCap == 0 { + req.MaxVDiskCapacity = -1 + } else { + req.MaxVDiskCapacity = maxDiskCap + } } - } - if resLimitsConv["cu_c"] != nil { - maxCPUCap := int64(resLimitsConv["cu_c"].(float64)) - if maxCPUCap == 0 { - req.MaxCPUCapacity = -1 - } else { - req.MaxCPUCapacity = maxCPUCap + if resLimitsConv["cu_c"] != nil { + maxCPUCap := int64(resLimitsConv["cu_c"].(float64)) + if maxCPUCap == 0 { + req.MaxCPUCapacity = -1 + } else { + req.MaxCPUCapacity = maxCPUCap + } } - } - if resLimitsConv["cu_i"] != nil { - maxNumPublicIP := int64(resLimitsConv["cu_i"].(float64)) - if maxNumPublicIP == 0 { - req.MaxNumPublicIP = -1 - } else { - req.MaxNumPublicIP = maxNumPublicIP + if resLimitsConv["cu_i"] != nil { + maxNumPublicIP := int64(resLimitsConv["cu_i"].(float64)) + if maxNumPublicIP == 0 { + req.MaxNumPublicIP = -1 + } else { + req.MaxNumPublicIP = maxNumPublicIP + } } - } - if resLimitsConv["cu_np"] != nil { - maxNP := int64(resLimitsConv["cu_np"].(float64)) - if maxNP == 0 { - req.MaxNetworkPeerTransfer = -1 - } else { - req.MaxNetworkPeerTransfer = maxNP + if resLimitsConv["cu_np"] != nil { + maxNP := int64(resLimitsConv["cu_np"].(float64)) + if maxNP == 0 { + req.MaxNetworkPeerTransfer = -1 + } else { + req.MaxNetworkPeerTransfer = maxNP + } } - } - doGeneralUpdate = true + doGeneralUpdate = true + } } if d.HasChange("description") { @@ -418,6 +441,31 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter doGeneralUpdate = true } + if d.HasChange("storage_policy") { + needUpdate, updateEl, err := utilityRGUpdateStPolicy(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + if needUpdate { + // spList := storagePolicies.(*schema.Set).List() + var id uint64 + var limit int + for _, spInterface := range updateEl { + // sps := spInterface.(map[string]interface{}) + id = uint64(spInterface["id"].(int)) + limit = spInterface["limit"].(int) + + spModel := rg.StoragePolicy{ + ID: id, + Limit: limit, + } + + req.StoragePolicies = append(req.StoragePolicies, spModel) + } + doGeneralUpdate = needUpdate + } + } + if d.HasChange("uniq_pools") { uniqPools := d.Get("uniq_pools").([]interface{}) if len(uniqPools) == 0 { @@ -721,6 +769,10 @@ func ResourceResgroup() *schema.Resource { if diff.HasChange("def_net") { diff.SetNewComputed("def_net_id") } + if diff.HasChange("storage_policy") { + diff.SetNewComputed("storage_policy_ids") + diff.SetNewComputed("resource_limits") + } if diff.HasChanges() { diff.SetNewComputed("updated_by") diff.SetNewComputed("updated_time") diff --git a/internal/service/cloudbroker/rg/schema.go b/internal/service/cloudbroker/rg/schema.go index 8d496b44..73d2d674 100644 --- a/internal/service/cloudbroker/rg/schema.go +++ b/internal/service/cloudbroker/rg/schema.go @@ -152,6 +152,22 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -203,6 +219,13 @@ func dataSourceRgSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, } } @@ -1654,6 +1677,23 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Required: true, + }, + "limit": { + Type: schema.TypeInt, + Optional: true, + }, + }, + }, + }, }, }, }, @@ -1701,6 +1741,13 @@ func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, }, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, }, }, }, @@ -1924,6 +1971,23 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Required: true, + }, + "limit": { + Type: schema.TypeInt, + Optional: true, + }, + }, + }, + }, }, }, }, @@ -1975,6 +2039,13 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, }, }, }, @@ -2244,6 +2315,22 @@ func resourceRgSchemaMake() map[string]*schema.Schema { Type: schema.TypeFloat, Computed: true, }, + "storage_policy": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "limit": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -2392,6 +2479,24 @@ func resourceRgSchemaMake() map[string]*schema.Schema { Computed: true, Description: "ID of the SDN access group", }, + "storage_policy": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Required: true, + }, + "limit": { + Type: schema.TypeInt, + Optional: true, + Default: -1, + }, + }, + }, + }, "acl": { Type: schema.TypeList, @@ -2510,6 +2615,14 @@ func resourceRgSchemaMake() map[string]*schema.Schema { }, Description: "List of VM ids in this resource group.", }, + + "storage_policy_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, } return res diff --git a/internal/service/cloudbroker/rg/utility_rg.go b/internal/service/cloudbroker/rg/utility_rg.go index 499927b2..af8f71cf 100644 --- a/internal/service/cloudbroker/rg/utility_rg.go +++ b/internal/service/cloudbroker/rg/utility_rg.go @@ -36,6 +36,7 @@ import ( "strconv" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg" "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" ) @@ -58,3 +59,92 @@ func utilityResgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m return rgData, nil } + +func utilityRGUpdateStPolicy(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, []map[string]interface{}, error) { + c := m.(*controller.ControllerCfg) + + rgId, _ := strconv.ParseUint(d.Id(), 10, 64) + + addSP, delSP, updateSP := utilityGetStoragePolicyUpdate(ctx, d, m) + needUpdate := len(updateSP) > 0 + + if len(addSP) > 0 { + for _, spMap := range addSP { + req := rg.AddStoragePolicyRequest{ + RGID: rgId, + StoragePolicyID: uint64(spMap["id"].(int)), + Limit: spMap["limit"].(int), + } + log.Debugf("utilityRGUpdateStPolicy: starting to add storage policy ID:%d for rg %d", req.StoragePolicyID, req.RGID) + _, err := c.CloudBroker().RG().AddStoragePolicy(ctx, req) + if err != nil { + return needUpdate, updateSP, err + } + } + } + + if len(delSP) > 0 { + for _, spMap := range delSP { + req := rg.DelStoragePolicyRequest{ + RGID: rgId, + StoragePolicyID: uint64(spMap["id"].(int)), + } + log.Debugf("utilityRGUpdateStPolicy: starting to delete storage policy ID:%d from rg %d", req.StoragePolicyID, req.RGID) + _, err := c.CloudBroker().RG().DelStoragePolicy(ctx, req) + if err != nil { + return needUpdate, updateSP, err + } + } + } + + return needUpdate, updateSP, nil +} + +func utilityGetStoragePolicyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) (added, deleted, updated []map[string]interface{}) { + added = make([]map[string]interface{}, 0) + deleted = make([]map[string]interface{}, 0) + updated = make([]map[string]interface{}, 0) + oldSet, newSet := d.GetChange("storage_policy") + oldList := oldSet.(*schema.Set).List() + newList := newSet.(*schema.Set).List() + + for _, oldSP := range oldList { + oldMap := oldSP.(map[string]interface{}) + found := false + for _, newSP := range newList { + newMap := newSP.(map[string]interface{}) + if oldMap["id"] == newMap["id"] { + found = true + if oldMap["limit"] != newMap["limit"] { + updated = append(added, newMap) + } + break + } + if found { + break + } + } + if found { + continue + } + deleted = append(deleted, oldMap) + } + + for _, newSP := range newList { + newMap := newSP.(map[string]interface{}) + found := false + for _, oldSP := range oldList { + oldMap := oldSP.(map[string]interface{}) + if oldMap["id"] == newMap["id"] { + found = true + break + } + } + if found { + continue + } + added = append(added, newMap) + } + + return +} diff --git a/internal/service/cloudbroker/secgroup/data_source_security_group.go b/internal/service/cloudbroker/secgroup/data_source_security_group.go new file mode 100644 index 00000000..d5ba7ebd --- /dev/null +++ b/internal/service/cloudbroker/secgroup/data_source_security_group.go @@ -0,0 +1,38 @@ +package secgroup + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + securityGroup, err := utilitySecurityGroupCheckPresence(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + flattenSecurityGroup(d, securityGroup) + + return nil +} + +func DataSourceSecurityGroup() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceSecurityGroupRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceSecurityGroupSchemaMake(), + } +} diff --git a/internal/service/cloudbroker/secgroup/data_source_security_group_list.go b/internal/service/cloudbroker/secgroup/data_source_security_group_list.go new file mode 100644 index 00000000..a2bf3e1a --- /dev/null +++ b/internal/service/cloudbroker/secgroup/data_source_security_group_list.go @@ -0,0 +1,40 @@ +package secgroup + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceSecurityGroupListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + storagePolicyList, err := utilitySecurityGroupListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenSecurityGroupList(storagePolicyList)) + d.Set("entry_count", storagePolicyList.EntryCount) + + return nil +} + +func DataSourceSecurityGroupList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceSecurityGroupListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceSecurityGroupListSchemaMake(), + } +} diff --git a/internal/service/cloudbroker/secgroup/flattens.go b/internal/service/cloudbroker/secgroup/flattens.go new file mode 100644 index 00000000..e32297e0 --- /dev/null +++ b/internal/service/cloudbroker/secgroup/flattens.go @@ -0,0 +1,68 @@ +package secgroup + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/secgroup" +) + +func flattenSecurityGroupResource(d *schema.ResourceData, securityGroup *secgroup.RecordSecurityGroup) { + d.Set("security_group_id", securityGroup.ID) + d.Set("account_id", securityGroup.AccountID) + d.Set("name", securityGroup.Name) + d.Set("description", securityGroup.Description) + d.Set("rules", flattenRules(securityGroup.Rules)) + d.Set("created_at", securityGroup.CreatedAt) + d.Set("created_by", securityGroup.CreatedBy) + d.Set("updated_at", securityGroup.UpdatedAt) + d.Set("updated_by", securityGroup.UpdatedBy) +} + +func flattenSecurityGroupList(securityGroupList *secgroup.ListSecurityGroups) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(securityGroupList.Data)) + for _, v := range securityGroupList.Data { + temp := map[string]interface{}{ + "account_id": v.AccountID, + "name": v.Name, + "description": v.Description, + "rules": flattenRules(v.Rules), + "created_at": v.CreatedAt, + "created_by": v.CreatedBy, + "security_group_id": v.ID, + "updated_at": v.UpdatedAt, + "updated_by": v.UpdatedBy, + } + + res = append(res, temp) + } + + return res +} + +func flattenSecurityGroup(d *schema.ResourceData, securityGroup *secgroup.RecordSecurityGroup) { + d.Set("security_group_id", securityGroup.ID) + d.Set("account_id", securityGroup.AccountID) + d.Set("name", securityGroup.Name) + d.Set("description", securityGroup.Description) + d.Set("rules", flattenRules(securityGroup.Rules)) + d.Set("created_at", securityGroup.CreatedAt) + d.Set("created_by", securityGroup.CreatedBy) + d.Set("updated_at", securityGroup.UpdatedAt) + d.Set("updated_by", securityGroup.UpdatedBy) +} + +func flattenRules(rules secgroup.Rules) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(rules)) + for _, rule := range rules { + temp := map[string]interface{}{ + "id": rule.ID, + "direction": rule.Direction, + "ethertype": rule.Ethertype, + "protocol": rule.Protocol, + "port_range_min": rule.PortRangeMin, + "port_range_max": rule.PortRangeMax, + "remote_ip_prefix": rule.RemoteIPPrefix, + } + res = append(res, temp) + } + return res +} diff --git a/internal/service/cloudbroker/secgroup/resource_security_group.go b/internal/service/cloudbroker/secgroup/resource_security_group.go new file mode 100644 index 00000000..1983336c --- /dev/null +++ b/internal/service/cloudbroker/secgroup/resource_security_group.go @@ -0,0 +1,146 @@ +package secgroup + +import ( + "context" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/secgroup" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc" +) + +func resourceSecurityGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSecurityGroupCreate: called with account ID %d, name %s", uint64(d.Get("account_id").(int)), d.Get("name").(string)) + + c := m.(*controller.ControllerCfg) + warnings := dc.Warnings{} + + accountID := uint64(d.Get("account_id").(int)) + name := d.Get("name").(string) + + req := secgroup.CreateRequest{ + AccountID: accountID, + Name: name, + } + + if description, ok := d.GetOk("description"); ok { + req.Description = description.(string) + } + + securityGroupID, err := c.CloudBroker().SecurityGroup().Create(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId(strconv.FormatUint(securityGroupID, 10)) + d.Set("security_group_id", securityGroupID) + + return append(warnings.Get(), resourceSecurityGroupRead(ctx, d, m)...) +} + +func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSecurityGroupRead: called with with account ID %d", uint64(d.Get("account_id").(int))) + + w := dc.Warnings{} + + securityGroupItem, err := utilitySecurityGroupCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenSecurityGroupResource(d, securityGroupItem) + + return w.Get() +} + +func resourceSecurityGroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + securityGroupID, _ := strconv.ParseUint(d.Id(), 10, 64) + + log.Debugf("resourceSecurityGroupUpdate: called security group with id %d", securityGroupID) + + c := m.(*controller.ControllerCfg) + + _, err := utilitySecurityGroupCheckPresence(ctx, d, m) + if err != nil { + + d.SetId("") + + return diag.FromErr(err) + } + + _, err = strconv.ParseInt(d.Id(), 10, 64) + if err != nil { + + d.SetId("") + + return diag.FromErr(err) + } + + if d.HasChanges("name", "description") { + + if err := utilitySecurityGroupHandleHasChanges(ctx, d, c, securityGroupID); err != nil { + return diag.FromErr(err) + } + } + + if d.HasChange("rules") { + if err := utilitySecurityGroupUpdateRules(ctx, d, c, securityGroupID); err != nil { + return diag.FromErr(err) + } + } + + return resourceSecurityGroupRead(ctx, d, m) +} + +func resourceSecurityGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSecurityGroupDelete: called with id %s", d.Id()) + + securityGroupItem, err := utilitySecurityGroupCheckPresence(ctx, d, m) + if err != nil { + + d.SetId("") + return diag.FromErr(err) + } + + c := m.(*controller.ControllerCfg) + req := secgroup.DeleteRequest{ + SecurityGroupID: securityGroupItem.ID, + } + if _, err := c.CloudBroker().SecurityGroup().Delete(ctx, req); err != nil { + return diag.FromErr(err) + } + + d.SetId("") + + return nil +} + +func ResourceSecurityGroup() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + CreateContext: resourceSecurityGroupCreate, + ReadContext: resourceSecurityGroupRead, + UpdateContext: resourceSecurityGroupUpdate, + DeleteContext: resourceSecurityGroupDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: &constants.Timeout600s, + Read: &constants.Timeout600s, + Update: &constants.Timeout600s, + Delete: &constants.Timeout600s, + Default: &constants.Timeout600s, + }, + + Schema: resourceSecurityGroupSchemaMake(), + } +} diff --git a/internal/service/cloudbroker/secgroup/schema.go b/internal/service/cloudbroker/secgroup/schema.go new file mode 100644 index 00000000..9e1a49fd --- /dev/null +++ b/internal/service/cloudbroker/secgroup/schema.go @@ -0,0 +1,288 @@ +package secgroup + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceSecurityGroupSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeInt, + Required: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + }, + "rules": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "direction": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"inbound", "outbound"}, true), + }, + "ethertype": { + Type: schema.TypeString, + Optional: true, + Default: "IPv4", + ValidateFunc: validation.StringInSlice([]string{"IPv4", "IPv6"}, true), + }, + "protocol": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"icmp", "tcp", "udp"}, true), + }, + "port_range_min": { + Type: schema.TypeInt, + Optional: true, + }, + "port_range_max": { + Type: schema.TypeInt, + Optional: true, + }, + "remote_ip_prefix": { + Type: schema.TypeString, + Optional: true, + }, + "id": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "security_group_id": { + Type: schema.TypeInt, + Computed: true, + }, + "created_at": { + Type: schema.TypeInt, + Computed: true, + }, + "updated_at": { + Type: schema.TypeInt, + Computed: true, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + } + return res +} + +func dataSourceSecurityGroupSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "security_group_id": { + Type: schema.TypeInt, + Required: true, + }, + "account_id": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "rules": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "direction": { + Type: schema.TypeString, + Computed: true, + }, + "ethertype": { + Type: schema.TypeString, + Computed: true, + }, + "protocol": { + Type: schema.TypeString, + Computed: true, + }, + "port_range_min": { + Type: schema.TypeInt, + Computed: true, + }, + "port_range_max": { + Type: schema.TypeInt, + Computed: true, + }, + "remote_ip_prefix": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "created_at": { + Type: schema.TypeInt, + Computed: true, + }, + "updated_at": { + Type: schema.TypeInt, + Computed: true, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + } + return res +} + +func dataSourceSecurityGroupListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "page": { + Type: schema.TypeInt, + Optional: true, + }, + "size": { + Type: schema.TypeInt, + Optional: true, + }, + "by_id": { + Type: schema.TypeInt, + Optional: true, + }, + "account_id": { + Type: schema.TypeInt, + Optional: true, + }, + "name": { + Type: schema.TypeString, + Optional: true, + }, + "desc": { + Type: schema.TypeString, + Optional: true, + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + }, + "created_min": { + Type: schema.TypeInt, + Optional: true, + }, + "created_max": { + Type: schema.TypeInt, + Optional: true, + }, + "updated_min": { + Type: schema.TypeInt, + Optional: true, + }, + "updated_max": { + Type: schema.TypeInt, + Optional: true, + }, + "items": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "security_group_id": { + Type: schema.TypeInt, + Computed: true, + }, + "account_id": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "rules": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeInt, + Computed: true, + }, + "direction": { + Type: schema.TypeString, + Computed: true, + }, + "ethertype": { + Type: schema.TypeString, + Computed: true, + }, + "protocol": { + Type: schema.TypeString, + Computed: true, + }, + "port_range_min": { + Type: schema.TypeInt, + Computed: true, + }, + "port_range_max": { + Type: schema.TypeInt, + Computed: true, + }, + "remote_ip_prefix": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "created_at": { + Type: schema.TypeInt, + Computed: true, + }, + "updated_at": { + Type: schema.TypeInt, + Computed: true, + }, + "created_by": { + Type: schema.TypeString, + Computed: true, + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "entry_count": { + Type: schema.TypeInt, + Computed: true, + }, + } + return res +} diff --git a/internal/service/cloudbroker/secgroup/utility_security_group.go b/internal/service/cloudbroker/secgroup/utility_security_group.go new file mode 100644 index 00000000..2a1a5c6f --- /dev/null +++ b/internal/service/cloudbroker/secgroup/utility_security_group.go @@ -0,0 +1,95 @@ +package secgroup + +import ( + "context" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/secgroup" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilitySecurityGroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*secgroup.RecordSecurityGroup, error) { + c := m.(*controller.ControllerCfg) + req := secgroup.GetRequest{} + if d.Id() != "" { + securityGroupID, _ := strconv.ParseUint(d.Id(), 10, 64) + req.SecurityGroupID = securityGroupID + } else { + req.SecurityGroupID = uint64(d.Get("security_group_id").(int)) + } + + log.Debugf("utilitySecurityGroupCheckPresence: load security group") + securityGroup, err := c.CloudBroker().SecurityGroup().Get(ctx, req) + if err != nil { + return nil, err + } + + return securityGroup, nil +} + +func utilitySecurityGroupHandleHasChanges(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, securityGroupID uint64) error { + req := secgroup.UpdateRequest{ + SecurityGroupID: securityGroupID, + } + + if d.HasChange("name") { + name := d.Get("name").(string) + req.Name = name + } + + if d.HasChange("description") { + description := d.Get("description").(string) + req.Description = description + } + + if _, err := c.CloudBroker().SecurityGroup().Update(ctx, req); err != nil { + return err + } + + return nil +} + +func utilitySecurityGroupUpdateRules(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, securityGroupID uint64) error { + oldSet, newSet := d.GetChange("rules") + deletedRules := (oldSet.(*schema.Set).Difference(newSet.(*schema.Set))).List() + for _, deletedInterface := range deletedRules { + deletedItem := deletedInterface.(map[string]interface{}) + ruleID := uint64(deletedItem["id"].(int)) + req := secgroup.DeleteRuleRequest{ + SecurityGroupID: securityGroupID, + RuleID: ruleID, + } + if _, err := c.CloudBroker().SecurityGroup().DeleteRule(ctx, req); err != nil { + return err + } + + } + + addedRules := (newSet.(*schema.Set).Difference(oldSet.(*schema.Set))).List() + for _, addedInterface := range addedRules { + addedItem := addedInterface.(map[string]interface{}) + direction := addedItem["direction"].(string) + ethertype := addedItem["ethertype"].(string) + protocol := addedItem["protocol"].(string) + portRangeMin := uint64(addedItem["port_range_min"].(int)) + portRangeMax := uint64(addedItem["port_range_max"].(int)) + remoteIPPrefix := addedItem["remote_ip_prefix"].(string) + req := secgroup.CreateRuleRequest{ + SecurityGroupID: securityGroupID, + Direction: direction, + Ethertype: ethertype, + Protocol: protocol, + PortRangeMin: portRangeMin, + PortRangeMax: portRangeMax, + RemoteIPPrefix: remoteIPPrefix, + } + + if _, err := c.CloudBroker().SecurityGroup().CreateRule(ctx, req); err != nil { + return err + } + } + + return nil +} diff --git a/internal/service/cloudbroker/secgroup/utility_security_group_list.go b/internal/service/cloudbroker/secgroup/utility_security_group_list.go new file mode 100644 index 00000000..7853c53e --- /dev/null +++ b/internal/service/cloudbroker/secgroup/utility_security_group_list.go @@ -0,0 +1,60 @@ +package secgroup + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/secgroup" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilitySecurityGroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*secgroup.ListSecurityGroups, error) { + c := m.(*controller.ControllerCfg) + + req := secgroup.ListRequest{} + + if size, ok := d.GetOk("size"); ok { + req.Size = uint64(size.(int)) + } + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + if byID, ok := d.GetOk("by_id"); ok { + req.ByID = uint64(byID.(int)) + } + if accountID, ok := d.GetOk("account_id"); ok { + req.AccountID = uint64(accountID.(int)) + } + if name, ok := d.GetOk("name"); ok { + req.Name = name.(string) + } + if desc, ok := d.GetOk("desc"); ok { + req.Description = desc.(string) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if createdMin, ok := d.GetOk("created_min"); ok { + req.CreatedMin = uint64(createdMin.(int)) + } + if createdMax, ok := d.GetOk("created_max"); ok { + req.CreatedMax = uint64(createdMax.(int)) + } + if updatedMin, ok := d.GetOk("updated_min"); ok { + req.UpdatedMin = uint64(updatedMin.(int)) + } + if updatedMax, ok := d.GetOk("updated_max"); ok { + req.UpdatedMax = uint64(updatedMax.(int)) + } + + log.Debugf("utilitySecurityGroupListCheckPresence: load storage policy list") + + securityGroupList, err := c.CloudBroker().SecurityGroup().List(ctx, req) + if err != nil { + return nil, err + } + + return securityGroupList, nil + +} diff --git a/internal/service/cloudbroker/stpolicy/data_source_storage_policy.go b/internal/service/cloudbroker/stpolicy/data_source_storage_policy.go new file mode 100644 index 00000000..90ba6b94 --- /dev/null +++ b/internal/service/cloudbroker/stpolicy/data_source_storage_policy.go @@ -0,0 +1,37 @@ +package stpolicy + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceStoragePolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + storagePolicy, err := utilityStoragePolicyCheckPresence(ctx, d, m) + if err != nil { + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + flattenStoragePolicyData(d, storagePolicy) + return nil +} + +func DataSourceStoragePolicy() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceStoragePolicyRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceStoragePolicySchemaMake(), + } +} diff --git a/internal/service/cloudbroker/stpolicy/data_source_storage_policy_list.go b/internal/service/cloudbroker/stpolicy/data_source_storage_policy_list.go new file mode 100644 index 00000000..73565f97 --- /dev/null +++ b/internal/service/cloudbroker/stpolicy/data_source_storage_policy_list.go @@ -0,0 +1,40 @@ +package stpolicy + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceStoragePolicyListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + storagePolicyList, err := utilityStoragePolicyListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenStoragePolicyList(storagePolicyList)) + d.Set("entry_count", storagePolicyList.EntryCount) + + return nil +} + +func DataSourceStoragePolicyList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceStoragePolicyListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceStoragePolicyListSchemaMake(), + } +} diff --git a/internal/service/cloudbroker/stpolicy/flattens.go b/internal/service/cloudbroker/stpolicy/flattens.go new file mode 100644 index 00000000..6fb02e4c --- /dev/null +++ b/internal/service/cloudbroker/stpolicy/flattens.go @@ -0,0 +1,74 @@ +package stpolicy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stpolicy" +) + +func flattenStoragePolicyData(d *schema.ResourceData, storagePolicy *stpolicy.InfoStoragePolicy) { + d.Set("storage_policy_id", storagePolicy.ID) + d.Set("description", storagePolicy.Description) + d.Set("guid", storagePolicy.GUID) + d.Set("limit_iops", storagePolicy.LimitIOPS) + d.Set("name", storagePolicy.Name) + d.Set("status", storagePolicy.Status) + d.Set("access_seps_pools", flattenAccessSEPPools(storagePolicy.AccessSEPPools)) + d.Set("usage", flattenUsage(storagePolicy.Usage)) +} + +func flattenAccessSEPPools(accessSEPPools stpolicy.ListAccessSEPPools) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(accessSEPPools)) + for _, asp := range accessSEPPools { + temp := map[string]interface{}{ + "sep_id": asp.SEPID, + //TODO + //"name": asp.Name, + "pool_names": asp.PoolNames, + } + + res = append(res, temp) + } + + return res +} + +func flattenUsage(usage stpolicy.Usage) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + + temp := map[string]interface{}{ + "accounts": usage.Accounts, + "resgroups": usage.Resgroups, + } + + res = append(res, temp) + return res +} + +func flattenStoragePolicyList(storagePolicyList *stpolicy.ListStoragePolicies) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(storagePolicyList.Data)) + for _, v := range storagePolicyList.Data { + temp := map[string]interface{}{ + "storage_policy_id": v.ID, + "description": v.Description, + "guid": v.GUID, + "limit_iops": v.LimitIOPS, + "name": v.Name, + "status": v.Status, + "access_seps_pools": flattenAccessSEPPools(v.AccessSEPPools), + "usage": flattenUsage(v.Usage), + } + res = append(res, temp) + } + return res +} + +func flattenStoragePolicyResource(d *schema.ResourceData, storagePolicy *stpolicy.InfoStoragePolicy) { + d.Set("storage_policy_id", storagePolicy.ID) + d.Set("description", storagePolicy.Description) + d.Set("guid", storagePolicy.GUID) + d.Set("limit_iops", storagePolicy.LimitIOPS) + d.Set("name", storagePolicy.Name) + d.Set("status", storagePolicy.Status) + d.Set("access_seps_pools", flattenAccessSEPPools(storagePolicy.AccessSEPPools)) + d.Set("usage", flattenUsage(storagePolicy.Usage)) +} diff --git a/internal/service/cloudbroker/stpolicy/resource_storage_policy.go b/internal/service/cloudbroker/stpolicy/resource_storage_policy.go new file mode 100644 index 00000000..2957fef1 --- /dev/null +++ b/internal/service/cloudbroker/stpolicy/resource_storage_policy.go @@ -0,0 +1,182 @@ +package stpolicy + +import ( + "context" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stpolicy" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc" +) + +func resourceStoragePolicyCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceTrunkCreate: called with name %s", d.Get("name").(string)) + + c := m.(*controller.ControllerCfg) + warnings := dc.Warnings{} + + name := d.Get("name").(string) + aspRaw := d.Get("access_seps_pools") + aspFromMan := aspRaw.(*schema.Set).List() + aspArray := make([]stpolicy.AccessSEPsPool, 0, len(aspFromMan)) + aspMap := make(map[uint64][]string) + for _, aspfm := range aspFromMan { + temp := aspfm.(map[string]interface{}) + sepID := uint64(temp["sep_id"].(int)) + _, ok := aspMap[sepID] + poolName := temp["pool_name"].(string) + if !ok { + aspMap[sepID] = []string{} + } + aspMap[sepID] = append(aspMap[sepID], poolName) + } + + for key, value := range aspMap { + asp := stpolicy.AccessSEPsPool{} + asp.SEPID = key + asp.PoolNames = value + aspArray = append(aspArray, asp) + } + + req := stpolicy.CreateRequest{ + Name: name, + AccessSEPsPools: aspArray, + } + + if description, ok := d.GetOk("description"); ok { + req.Description = description.(string) + } + + if limitIOPS, ok := d.GetOk("limit_iops"); ok { + req.LimitIOPS = uint64(limitIOPS.(int)) + } + + storagePolicyID, err := c.CloudBroker().StPolicy().Create(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId(strconv.FormatUint(storagePolicyID, 10)) + d.Set("storage_policy_id", storagePolicyID) + + if enabled, ok := d.GetOk("enabled"); ok { + isToEnable := enabled.(bool) + if err := handleStoragePolicyEnabling(ctx, d, c, storagePolicyID, isToEnable); err != nil { + warnings.Add(err) + } + } + + return append(warnings.Get(), resourceStoragePolicyRead(ctx, d, m)...) +} + +func resourceStoragePolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceStoragePolicyRead: called with name %s", d.Get("name").(string)) + + w := dc.Warnings{} + storagePolicyItem, err := utilityStoragePolicyCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenStoragePolicyResource(d, storagePolicyItem) + + return w.Get() +} + +func resourceStoragePolicyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + storagePolicyID, _ := strconv.ParseUint(d.Id(), 10, 64) + + log.Debugf("resourceStoragePolicyUpdate: called storage policy with id %d", storagePolicyID) + + c := m.(*controller.ControllerCfg) + + _, err := utilityStoragePolicyCheckPresence(ctx, d, m) + if err != nil { + + d.SetId("") + + return diag.FromErr(err) + } + + _, err = strconv.ParseInt(d.Id(), 10, 64) + if err != nil { + + d.SetId("") + + return diag.FromErr(err) + } + + if d.HasChanges("name", "limit_iops", "description") { + if err := utilityStoragePolicyHandleHasChanges(ctx, d, c, storagePolicyID); err != nil { + return diag.FromErr(err) + } + } + + if d.HasChange("enabled") { + enabled := d.Get("enabled") + isToEnable := enabled.(bool) + if err := handleStoragePolicyEnabling(ctx, d, c, storagePolicyID, isToEnable); err != nil { + return diag.FromErr(err) + } + } + + if d.HasChange("access_seps_pools") { + if err := utilityStoragePolicyUpdateAccessSEPsPools(ctx, d, c, storagePolicyID); err != nil { + return diag.FromErr(err) + } + } + return resourceStoragePolicyRead(ctx, d, m) +} + +func resourceStoragePolicyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceStoragePolicyDelete: called with id %s", d.Id()) + + storagePolicyItem, err := utilityStoragePolicyCheckPresence(ctx, d, m) + if err != nil { + + d.SetId("") + return diag.FromErr(err) + } + + c := m.(*controller.ControllerCfg) + req := stpolicy.DeleteRequest{ + StoragePolicyID: storagePolicyItem.ID, + } + if _, err := c.CloudBroker().StPolicy().Delete(ctx, req); err != nil { + return diag.FromErr(err) + } + + d.SetId("") + + return nil +} + +func ResourceStoragePolicy() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + CreateContext: resourceStoragePolicyCreate, + ReadContext: resourceStoragePolicyRead, + UpdateContext: resourceStoragePolicyUpdate, + DeleteContext: resourceStoragePolicyDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: &constants.Timeout600s, + Read: &constants.Timeout600s, + Update: &constants.Timeout600s, + Delete: &constants.Timeout600s, + Default: &constants.Timeout600s, + }, + + Schema: resourceStoragePolicySchemaMake(), + } +} diff --git a/internal/service/cloudbroker/stpolicy/schema.go b/internal/service/cloudbroker/stpolicy/schema.go new file mode 100644 index 00000000..08e69b24 --- /dev/null +++ b/internal/service/cloudbroker/stpolicy/schema.go @@ -0,0 +1,281 @@ +package stpolicy + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func resourceStoragePolicySchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "storage_policy_id": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "access_seps_pools": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "pool_name": { + Type: schema.TypeString, + Required: true, + }, + "sep_id": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + "description": { + Type: schema.TypeString, + Optional: true, + }, + "limit_iops": { + Type: schema.TypeInt, + Optional: true, + }, + "enabled": { + Type: schema.TypeBool, + Default: true, + Optional: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "usage": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accounts": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "resgroups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + }, + }, + }, + } + + return res +} + +func dataSourceStoragePolicySchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "limit_iops": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "access_seps_pools": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "pool_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "usage": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accounts": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "resgroups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + }, + }, + }, + } + + return res +} + +func dataSourceStoragePolicyListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeInt, + Optional: true, + }, + "page": { + Type: schema.TypeInt, + Optional: true, + }, + "size": { + Type: schema.TypeInt, + Optional: true, + }, + "by_id": { + Type: schema.TypeInt, + Optional: true, + }, + "name": { + Type: schema.TypeString, + Optional: true, + }, + "status": { + Type: schema.TypeString, + Optional: true, + }, + "desc": { + Type: schema.TypeString, + Optional: true, + }, + "limit_iops": { + Type: schema.TypeInt, + Optional: true, + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + }, + "resgroup_id": { + Type: schema.TypeInt, + Optional: true, + }, + "sep_id": { + Type: schema.TypeInt, + Optional: true, + }, + "pool_name": { + Type: schema.TypeString, + Optional: true, + }, + + "items": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "storage_policy_id": { + Type: schema.TypeInt, + Required: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + }, + "limit_iops": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "access_seps_pools": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "pool_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "sep_id": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "usage": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accounts": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "resgroups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + }, + }, + }, + }, + }, + }, + "entry_count": { + Type: schema.TypeInt, + Computed: true, + }, + } + return res +} diff --git a/internal/service/cloudbroker/stpolicy/utility_storage_policy.go b/internal/service/cloudbroker/stpolicy/utility_storage_policy.go new file mode 100644 index 00000000..77147ec0 --- /dev/null +++ b/internal/service/cloudbroker/stpolicy/utility_storage_policy.go @@ -0,0 +1,115 @@ +package stpolicy + +import ( + "context" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stpolicy" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityStoragePolicyCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*stpolicy.InfoStoragePolicy, error) { + c := m.(*controller.ControllerCfg) + req := stpolicy.GetRequest{} + + if d.Id() != "" { + storagePolicyID, _ := strconv.ParseUint(d.Id(), 10, 64) + req.StoragePolicyID = storagePolicyID + } else { + req.StoragePolicyID = uint64(d.Get("storage_policy_id").(int)) + } + + storagePolicyData, err := c.CloudBroker().StPolicy().Get(ctx, req) + if err != nil { + return nil, err + } + + return storagePolicyData, nil +} + +func handleStoragePolicyEnabling(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, storagePolicyID uint64, enable bool) error { + if enable { + req := stpolicy.EnableRequest{ + StoragePolicyID: storagePolicyID, + } + + _, err := c.CloudBroker().StPolicy().Enable(ctx, req) + if err != nil { + return err + } + } else { + req := stpolicy.DisableRequest{ + StoragePolicyID: storagePolicyID, + } + + _, err := c.CloudBroker().StPolicy().Disable(ctx, req) + if err != nil { + return err + } + } + + return nil +} + +func utilityStoragePolicyHandleHasChanges(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, storagePolicyID uint64) error { + req := stpolicy.UpdateRequest{ + StoragePolicyID: storagePolicyID, + } + + if d.HasChange("name") { + name := d.Get("name").(string) + req.Name = name + } + + if d.HasChange("limit_iops") { + limitIOPS := uint64(d.Get("limit_iops").(int)) + req.LimitIOPS = limitIOPS + } + + if d.HasChange("description") { + description := d.Get("description").(string) + req.Description = description + } + + if _, err := c.CloudBroker().StPolicy().Update(ctx, req); err != nil { + return err + } + + return nil +} + +func utilityStoragePolicyUpdateAccessSEPsPools(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, storagePolicyID uint64) error { + oldSet, newSet := d.GetChange("access_seps_pools") + deletedASP := (oldSet.(*schema.Set).Difference(newSet.(*schema.Set))).List() + for _, deletedInterface := range deletedASP { + deletedItem := deletedInterface.(map[string]interface{}) + SEPID := uint64(deletedItem["sep_id"].(int)) + poolName := deletedItem["pool_name"].(string) + req := stpolicy.DeletePoolRequest{ + StoragePolicyID: storagePolicyID, + SEPID: SEPID, + PoolName: poolName, + } + if _, err := c.CloudBroker().StPolicy().DeletePool(ctx, req); err != nil { + return err + } + } + + addedASP := (newSet.(*schema.Set).Difference(oldSet.(*schema.Set))).List() + for _, addedInterface := range addedASP { + addedItem := addedInterface.(map[string]interface{}) + SEPID := uint64(addedItem["sep_id"].(int)) + poolName := addedItem["pool_name"].(string) + req := stpolicy.AddPoolRequest{ + StoragePolicyID: storagePolicyID, + SEPID: SEPID, + PoolName: poolName, + } + if _, err := c.CloudBroker().StPolicy().AddPool(ctx, req); err != nil { + return err + } + } + + return nil +} diff --git a/internal/service/cloudbroker/stpolicy/utility_storage_policy_list.go b/internal/service/cloudbroker/stpolicy/utility_storage_policy_list.go new file mode 100644 index 00000000..e890eab2 --- /dev/null +++ b/internal/service/cloudbroker/stpolicy/utility_storage_policy_list.go @@ -0,0 +1,70 @@ +package stpolicy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stpolicy" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityStoragePolicyListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*stpolicy.ListStoragePolicies, error) { + c := m.(*controller.ControllerCfg) + req := stpolicy.ListRequest{} + + if accountID, ok := d.GetOk("account_id"); ok { + req.AccountID = uint64(accountID.(int)) + } + if size, ok := d.GetOk("size"); ok { + req.Size = uint64(size.(int)) + } + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + + if byID, ok := d.GetOk("by_id"); ok { + req.ByID = uint64(byID.(int)) + } + + if name, ok := d.GetOk("name"); ok { + req.Name = name.(string) + } + + if status, ok := d.GetOk("status"); ok { + req.Status = status.(string) + } + + if desc, ok := d.GetOk("desc"); ok { + req.Desc = desc.(string) + } + + if limitIOPS, ok := d.GetOk("limit_iops"); ok { + req.LimitIOPS = uint64(limitIOPS.(int)) + } + + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + + if resgroupID, ok := d.GetOk("resgroup_id"); ok { + req.ResgroupID = uint64(resgroupID.(int)) + } + + if SEPID, ok := d.GetOk("sep_id"); ok { + req.SepID = uint64(SEPID.(int)) + } + + if poolName, ok := d.GetOk("pool_name"); ok { + req.PoolName = poolName.(string) + } + + log.Debugf("utilityStoragePolicyListCheckPresence: load storage policy list") + + storagePolicyList, err := c.CloudBroker().StPolicy().List(ctx, req) + if err != nil { + return nil, err + } + + return storagePolicyList, nil +} diff --git a/internal/service/cloudbroker/trunk/utility_trunk_list.go b/internal/service/cloudbroker/trunk/utility_trunk_list.go index 9b359aca..ddcdace8 100644 --- a/internal/service/cloudbroker/trunk/utility_trunk_list.go +++ b/internal/service/cloudbroker/trunk/utility_trunk_list.go @@ -28,6 +28,9 @@ func utilityTrunkListCheckPresence(ctx context.Context, d *schema.ResourceData, if trunkTags, ok := d.GetOk("trunk_tags"); ok { req.TrunkTags = trunkTags.(string) } + if status, ok := d.GetOk("status"); ok { + req.Status = status.(string) + } if sortBy, ok := d.GetOk("sort_by"); ok { req.SortBy = sortBy.(string) } diff --git a/internal/service/cloudbroker/vins/flattens.go b/internal/service/cloudbroker/vins/flattens.go index 10d83baa..cca6e405 100644 --- a/internal/service/cloudbroker/vins/flattens.go +++ b/internal/service/cloudbroker/vins/flattens.go @@ -113,6 +113,7 @@ func flattenVinsData(d *schema.ResourceData, vinsRecord *vins.RecordVINS) { d.Set("vxlan_id", vinsRecord.VXLANID) d.Set("computes", flattenComputes(vinsRecord.Computes)) d.Set("zone_id", vinsRecord.ZoneID) + d.Set("enable_secgroups", vinsRecord.EnableSecGroups) } @@ -134,26 +135,28 @@ func flattenLibvirtSettings(libvirtSettings vins.LibvirtSettings) []map[string]i func flattenVinsVNFDev(vd vins.VNFDev) []map[string]interface{} { res := make([]map[string]interface{}, 0) temp := map[string]interface{}{ - "ckey": vd.CKey, - "meta": flattens.FlattenMeta(vd.Meta), - "account_id": vd.AccountID, - "capabilities": vd.Capabilities, - "config": flattenVinsConfig(vd.Config), - "config_saved": vd.ConfigSaved, - "custom_precfg": vd.CustomPreConfig, - "description": vd.Description, - "gid": vd.GID, - "guid": vd.GUID, - "id": vd.ID, - "interfaces": flattenVinsListInterfaces(vd.Interfaces), - "lock_status": vd.LockStatus, - "milestones": vd.Milestones, - "name": vd.Name, - "status": vd.Status, - "tech_status": vd.TechStatus, - "type": vd.Type, - "vnc_password": vd.VNCPassword, - "vins": vd.VINS, + "ckey": vd.CKey, + "meta": flattens.FlattenMeta(vd.Meta), + "account_id": vd.AccountID, + "capabilities": vd.Capabilities, + "config": flattenVinsConfig(vd.Config), + "config_saved": vd.ConfigSaved, + "custom_precfg": vd.CustomPreConfig, + "description": vd.Description, + "gid": vd.GID, + "guid": vd.GUID, + "id": vd.ID, + "interfaces": flattenVinsListInterfaces(vd.Interfaces), + "live_migration_job_id": vd.LiveMigrationJobID, + "lock_status": vd.LockStatus, + "milestones": vd.Milestones, + "name": vd.Name, + "status": vd.Status, + "tech_status": vd.TechStatus, + "type": vd.Type, + "vnc_password": vd.VNCPassword, + "vins": vd.VINS, + "zone_id": vd.ZoneID, } res = append(res, temp) return res @@ -203,6 +206,7 @@ func flattenVinsRecordDHCP(rv vins.RecordDHCP) []map[string]interface{} { "status": rv.Status, "tech_status": rv.TechStatus, "type": rv.Type, + "zone_id": rv.ZoneID, } res = append(res, temp) return res @@ -225,9 +229,11 @@ func flattenVinsRecordGW(rg vins.RecordGW) []map[string]interface{} { "owner_id": rg.OwnerID, "owner_type": rg.OwnerType, "pure_virtual": rg.PureVirtual, + "routes": flattenVinsRoutes(rg.Routes), "status": rg.Status, "tech_status": rg.TechStatus, "type": rg.Type, + "zone_id": rg.ZoneID, } res = append(res, temp) return res @@ -250,9 +256,11 @@ func flattenVinsRecordNAT(rn vins.RecordNAT) []map[string]interface{} { "owner_id": rn.OwnerID, "owner_type": rn.OwnerType, "pure_virtual": rn.PureVirtual, + "routes": flattenVinsRoutes(rn.Routes), "status": rn.Status, "tech_status": rn.TechStatus, "type": rn.Type, + "zone_id": rn.ZoneID, } res = append(res, temp) return res @@ -425,6 +433,7 @@ func flattenVinsListInterfaces(i vins.ListInterfaces) []map[string]interface{} { "conn_type": v.ConnType, "def_gw": v.DefGW, "enabled": v.Enabled, + "enable_secgroups": v.EnableSecGroups, "flipgroup_id": v.FLIPGroupID, "guid": v.GUID, "ip_address": v.IPAddress, @@ -439,6 +448,7 @@ func flattenVinsListInterfaces(i vins.ListInterfaces) []map[string]interface{} { "pci_slot": v.PCISlot, "bus_number": v.BusNumber, "qos": flattenVinsQOS(v.QOS), + "security_groups": v.SecGroups, "sdn_interface_id": v.SDNInterfaceID, "target": v.Target, "type": v.Type, @@ -463,6 +473,7 @@ func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} { "deleted_by": v.DeletedBy, "deleted_time": v.DeletedTime, "description": v.Description, + "enable_secgroups": v.EnableSecGroups, "external_ip": v.ExternalIP, "extnet_id": v.ExtnetId, "free_ips": v.FreeIPs, diff --git a/internal/service/cloudbroker/vins/resource_vins.go b/internal/service/cloudbroker/vins/resource_vins.go index 3b06d175..2920d97a 100644 --- a/internal/service/cloudbroker/vins/resource_vins.go +++ b/internal/service/cloudbroker/vins/resource_vins.go @@ -115,6 +115,12 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface } } + if d.Get("enable_secgroups").(bool) { + if err := resourceVinsEnableSecgroups(ctx, d, m, vinsID); err != nil { + warnings.Add(err) + } + } + return append(warnings.Get(), resourceVinsRead(ctx, d, m)...) } @@ -257,6 +263,13 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface } } + if d.HasChanges("name", "desc", "enable_secgroups") { + vinsID := uint64(d.Get("vins_id").(int)) + if err := utilityUpdateVINS(ctx, d, m, vinsID); err != nil { + return diag.FromErr(err) + } + } + if d.HasChange("enable") { if err := resourceVinsChangeEnabled(ctx, d, m); err != nil { warnings.Add(err) @@ -424,6 +437,21 @@ func resourceVinsIpReserve(ctx context.Context, d *schema.ResourceData, m interf return errs } +func resourceVinsEnableSecgroups(ctx context.Context, d *schema.ResourceData, m interface{}, vinsID uint64) error { + c := m.(*controller.ControllerCfg) + + req := vins.UpdateRequest{ + VINSID: vinsID, + EnableSecGroups: true, + } + + _, err := c.CloudBroker().VINS().Update(ctx, req) + if err != nil { + return err + } + return nil +} + func resourceVinsNatRuleAdd(ctx context.Context, d *schema.ResourceData, m interface{}, vinsId uint64) []error { var errs []error c := m.(*controller.ControllerCfg) diff --git a/internal/service/cloudbroker/vins/schema.go b/internal/service/cloudbroker/vins/schema.go index 16537bd4..005644a7 100644 --- a/internal/service/cloudbroker/vins/schema.go +++ b/internal/service/cloudbroker/vins/schema.go @@ -166,6 +166,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "enabled", }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "flipgroup_id": { Type: schema.TypeInt, Computed: true, @@ -294,6 +298,13 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "security_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "target": { Type: schema.TypeString, Computed: true, @@ -315,6 +326,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema { }, }, }, + "live_migration_job_id": { + Type: schema.TypeInt, + Computed: true, + }, "lock_status": { Type: schema.TypeString, Computed: true, @@ -357,6 +372,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -756,6 +775,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "type", }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -911,6 +934,42 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "pure virtual", }, + "routes": { + Type: schema.TypeList, + Computed: true, + Description: "routes", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compute_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "route_id": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "destination": { + Type: schema.TypeString, + Computed: true, + }, + "netmask": { + Type: schema.TypeString, + Computed: true, + }, + "gateway": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, "status": { Type: schema.TypeString, Computed: true, @@ -926,6 +985,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "type", }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -1095,6 +1158,42 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "pure virtual", }, + "routes": { + Type: schema.TypeList, + Computed: true, + Description: "routes", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compute_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "route_id": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "destination": { + Type: schema.TypeString, + Computed: true, + }, + "netmask": { + Type: schema.TypeString, + Computed: true, + }, + "gateway": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, "status": { Type: schema.TypeString, Computed: true, @@ -1110,6 +1209,10 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "type", }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -1188,6 +1291,11 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema { Optional: true, Description: "Page size", }, + "zone_id": { + Type: schema.TypeInt, + Optional: true, + Description: "Zone ID", + }, "items": { Type: schema.TypeList, Computed: true, @@ -1249,6 +1357,10 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "external_ip": { Type: schema.TypeString, Computed: true, @@ -1386,7 +1498,7 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema { }, "entry_count": { Type: schema.TypeInt, - Optional: true, + Computed: true, Description: "entry count", }, } @@ -1898,6 +2010,12 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "zone id", }, + "enable_secgroups": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "enable security groups", + }, "gid": { Type: schema.TypeInt, Optional: true, @@ -2276,6 +2394,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "enabled", }, + "enable_secgroups": { + Type: schema.TypeBool, + Computed: true, + }, "flipgroup_id": { Type: schema.TypeInt, Computed: true, @@ -2372,9 +2494,8 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Description: "pci slot", }, "bus_number": { - Type: schema.TypeInt, - Computed: true, - Description: "bus number", + Type: schema.TypeInt, + Computed: true, }, "qos": { Type: schema.TypeList, @@ -2401,6 +2522,17 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { }, }, }, + "sdn_interface_id": { + Type: schema.TypeString, + Computed: true, + }, + "security_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, "target": { Type: schema.TypeString, Computed: true, @@ -2422,6 +2554,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { }, }, }, + "live_migration_job_id": { + Type: schema.TypeInt, + Computed: true, + }, "lock_status": { Type: schema.TypeString, Computed: true, @@ -2464,6 +2600,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -2751,6 +2891,47 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "prune virtual", }, + "routes": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compute_ids": { + Type: schema.TypeList, + Computed: true, + Description: "compute ids", + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "route_id": { + Type: schema.TypeInt, + Computed: true, + Description: "route id", + }, + "guid": { + Type: schema.TypeString, + Computed: true, + Description: "guid", + }, + "destination": { + Type: schema.TypeString, + Computed: true, + Description: "destination", + }, + "netmask": { + Type: schema.TypeString, + Computed: true, + Description: "net mask", + }, + "gateway": { + Type: schema.TypeString, + Computed: true, + Description: "gateway", + }, + }, + }, + }, "status": { Type: schema.TypeString, Computed: true, @@ -2766,6 +2947,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "type", }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -2921,6 +3106,42 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "pure virtual", }, + "routes": { + Type: schema.TypeList, + Computed: true, + Description: "routes", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compute_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "route_id": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "destination": { + Type: schema.TypeString, + Computed: true, + }, + "netmask": { + Type: schema.TypeString, + Computed: true, + }, + "gateway": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, "status": { Type: schema.TypeString, Computed: true, @@ -2936,6 +3157,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "type", }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -3105,6 +3330,42 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "pure virtual", }, + "routes": { + Type: schema.TypeList, + Computed: true, + Description: "routes", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "compute_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "route_id": { + Type: schema.TypeInt, + Computed: true, + }, + "guid": { + Type: schema.TypeString, + Computed: true, + }, + "destination": { + Type: schema.TypeString, + Computed: true, + }, + "netmask": { + Type: schema.TypeString, + Computed: true, + }, + "gateway": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, "status": { Type: schema.TypeString, Computed: true, @@ -3120,6 +3381,10 @@ func resourceVinsSchemaMake() map[string]*schema.Schema { Computed: true, Description: "type", }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, diff --git a/internal/service/cloudbroker/vins/utility_vins.go b/internal/service/cloudbroker/vins/utility_vins.go index 7fbf4718..63304fee 100644 --- a/internal/service/cloudbroker/vins/utility_vins.go +++ b/internal/service/cloudbroker/vins/utility_vins.go @@ -63,3 +63,27 @@ func utilityVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m int return vins, nil } + +func utilityUpdateVINS(ctx context.Context, d *schema.ResourceData, m interface{}, vinsID uint64) error { + c := m.(*controller.ControllerCfg) + + req := vins.UpdateRequest{ + VINSID: vinsID, + } + + if d.HasChange("name") { + req.Name = d.Get("name").(string) + } + if d.HasChange("desc") { + req.Desc = d.Get("desc").(string) + } + if d.HasChange("enable_secgroups") { + req.EnableSecGroups = d.Get("enable_secgroups").(bool) + } + + _, err := c.CloudBroker().VINS().Update(ctx, req) + if err != nil { + return err + } + return nil +} diff --git a/internal/service/cloudbroker/vins/utility_vins_list.go b/internal/service/cloudbroker/vins/utility_vins_list.go index dfeb964f..0e4c0a63 100644 --- a/internal/service/cloudbroker/vins/utility_vins_list.go +++ b/internal/service/cloudbroker/vins/utility_vins_list.go @@ -78,6 +78,9 @@ func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m if includeDeleted, ok := d.GetOk("include_deleted"); ok { req.IncludeDeleted = includeDeleted.(bool) } + if zoneID, ok := d.GetOk("zone_id"); ok { + req.ZoneID = uint64(zoneID.(int)) + } log.Debugf("utilityVinsListCheckPresence") vinsList, err := c.CloudBroker().VINS().List(ctx, req) diff --git a/internal/service/cloudbroker/zone/data_source_zone.go b/internal/service/cloudbroker/zone/data_source_zone.go index 80126f4b..788a21fe 100644 --- a/internal/service/cloudbroker/zone/data_source_zone.go +++ b/internal/service/cloudbroker/zone/data_source_zone.go @@ -97,6 +97,55 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, }, }, + "account_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "compute_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "extnet_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "vins_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "lb_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "bservice_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "k8s_ids": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, } } diff --git a/internal/service/cloudbroker/zone/flattens.go b/internal/service/cloudbroker/zone/flattens.go index 8627fae1..7f933424 100644 --- a/internal/service/cloudbroker/zone/flattens.go +++ b/internal/service/cloudbroker/zone/flattens.go @@ -52,6 +52,13 @@ func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error { d.Set("created_time", item.CreatedTime) d.Set("updated_time", item.UpdatedTime) d.Set("node_ids", item.NodeIDs) + d.Set("account_ids", item.AccountIDs) + d.Set("compute_ids", item.ComputeIDs) + d.Set("extnet_ids", item.ExtnetIDs) + d.Set("vins_ids", item.VinsIDs) + d.Set("lb_ids", item.LBIDs) + d.Set("bservice_ids", item.BserviceIDs) + d.Set("k8s_ids", item.K8SIDs) log.Debugf("flattenZone: decoded RecordZone name %q / ID %d, complete", item.Name, item.ID) diff --git a/internal/service/cloudbroker/zone/resource_zone.go b/internal/service/cloudbroker/zone/resource_zone.go index a41f9504..688dd0a4 100644 --- a/internal/service/cloudbroker/zone/resource_zone.go +++ b/internal/service/cloudbroker/zone/resource_zone.go @@ -113,7 +113,7 @@ func resourceZoneUpdate(ctx context.Context, d *schema.ResourceData, m interface log.Debugf("resourceZoneUpdate: called Zone with id %d", zoneID) - if d.HasChanges("name,", "description", "node_ids") { + if d.HasChanges("name", "description", "node_ids") { if err := utilityZoneUpdate(ctx, d, m, zoneID); err != nil { return diag.FromErr(err) } diff --git a/internal/service/cloudbroker/zone/utility_zone.go b/internal/service/cloudbroker/zone/utility_zone.go index a69895bb..73055cab 100644 --- a/internal/service/cloudbroker/zone/utility_zone.go +++ b/internal/service/cloudbroker/zone/utility_zone.go @@ -65,7 +65,7 @@ func utilityZoneCheckPresence(ctx context.Context, d *schema.ResourceData, m int func utilityZoneUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, zoneID uint64) error { c := m.(*controller.ControllerCfg) - if d.HasChanges("name,", "description") { + if d.HasChanges("name", "description") { req := zone.UpdateRequest{ ID: zoneID, } diff --git a/internal/service/sdn/access_group/data_decort_sdn_access_group.go b/internal/service/sdn/access_group/data_decort_sdn_access_group.go new file mode 100644 index 00000000..a8353e11 --- /dev/null +++ b/internal/service/sdn/access_group/data_decort_sdn_access_group.go @@ -0,0 +1,87 @@ +package accessgroup + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceAccessGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + accessGroup, err := utilityAccessGroupCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenAccessGroupDataSource(d, accessGroup) + d.SetId(accessGroup.ID) + return nil +} + +func dataSourceAccessGroupSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Required: true, + Description: "The unique access group ID", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name", + }, + "comment": { + Type: schema.TypeString, + Computed: true, + Description: "Comment description", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation timestamp", + }, + "net_object_access_group": { + Type: schema.TypeList, + Computed: true, + Description: "Net object access group configuration", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Access group ID", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier", + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version identifier", + }, + }, + }, + }, + } + + return res +} + +func DataSourceAccessGroup() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceAccessGroupRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceAccessGroupSchemaMake(), + } +} diff --git a/internal/service/sdn/access_group/data_decort_sdn_access_group_list.go b/internal/service/sdn/access_group/data_decort_sdn_access_group_list.go new file mode 100644 index 00000000..c6886256 --- /dev/null +++ b/internal/service/sdn/access_group/data_decort_sdn_access_group_list.go @@ -0,0 +1,40 @@ +package accessgroup + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceAccessGroupListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + accessGroupList, err := utilityAccessGroupListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenAccessGroupList(accessGroupList)) + + return nil +} + +func DataSourceAccessGroupList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceAccessGroupListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceAccessGroupListSchemaMake(), + } +} + diff --git a/internal/service/sdn/access_group/data_decort_sdn_access_group_user_list.go b/internal/service/sdn/access_group/data_decort_sdn_access_group_user_list.go new file mode 100644 index 00000000..a406d033 --- /dev/null +++ b/internal/service/sdn/access_group/data_decort_sdn_access_group_user_list.go @@ -0,0 +1,39 @@ +package accessgroup + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceAccessGroupUserListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + userList, err := utilityAccessGroupUserListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenAccessGroupUserList(userList)) + + return nil +} + +func DataSourceAccessGroupUserList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceAccessGroupUserListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceAccessGroupUserListSchemaMake(), + } +} diff --git a/internal/service/sdn/access_group/flattens.go b/internal/service/sdn/access_group/flattens.go new file mode 100644 index 00000000..c262456d --- /dev/null +++ b/internal/service/sdn/access_group/flattens.go @@ -0,0 +1,140 @@ +package accessgroup + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/acsgroups" +) + +func flattenAccessGroupDataSource(d *schema.ResourceData, accessGroupRecord *acsgroups.AccessGroup) { + d.Set("display_name", accessGroupRecord.DisplayName) + d.Set("comment", accessGroupRecord.Comment) + d.Set("created_at", accessGroupRecord.CreatedAt) + d.Set("net_object_access_group", flattenNetObjectAccessGroup(accessGroupRecord.NetObjectAccessGroup)) +} + +func flattenAccessGroupResource(d *schema.ResourceData, accessGroupRecord *acsgroups.AccessGroup, userList *acsgroups.UsersList) { + d.Set("display_name", accessGroupRecord.DisplayName) + d.Set("comment", accessGroupRecord.Comment) + d.Set("created_at", accessGroupRecord.CreatedAt) + d.Set("net_object_access_group", flattenNetObjectAccessGroup(accessGroupRecord.NetObjectAccessGroup)) + + defaultSecurityPolicy := accessGroupRecord.DefaultSecurityPolicy + if defaultSecurityPolicy.ID != "" { + flattenedDefaultSecPolicy := map[string]interface{}{ + "display_name": defaultSecurityPolicy.DisplayName, + "id": defaultSecurityPolicy.ID, + "description": defaultSecurityPolicy.Description, + "version_id": int(defaultSecurityPolicy.VersionID), + "access_group_id": defaultSecurityPolicy.AccessGroupID, + "default_open_session_drop": defaultSecurityPolicy.DefaultOpenSessionDrop, + } + + if defaultSecPolicy, ok := d.GetOk("default_security_policy"); ok { + defaultSecPolicyList := defaultSecPolicy.([]interface{}) + if len(defaultSecPolicyList) > 0 { + defaultSecPolicyMap := defaultSecPolicyList[0].(map[string]interface{}) + + if defaultAclDrop, ok := defaultSecPolicyMap["default_acl_drop"].(string); ok && defaultAclDrop != "" { + flattenedDefaultSecPolicy["default_acl_drop"] = defaultAclDrop + } else if defaultSecurityPolicy.DefaultAclDrop != "" { + flattenedDefaultSecPolicy["default_acl_drop"] = defaultSecurityPolicy.DefaultAclDrop + } + + if defaultOpenSessionDrop, ok := defaultSecPolicyMap["default_open_session_drop"].(bool); ok { + flattenedDefaultSecPolicy["default_open_session_drop"] = defaultOpenSessionDrop + } + } else { + if defaultSecurityPolicy.DefaultAclDrop != "" { + flattenedDefaultSecPolicy["default_acl_drop"] = defaultSecurityPolicy.DefaultAclDrop + } + } + } else { + if defaultSecurityPolicy.DefaultAclDrop != "" { + flattenedDefaultSecPolicy["default_acl_drop"] = defaultSecurityPolicy.DefaultAclDrop + } + } + + d.Set("default_security_policy", []map[string]interface{}{flattenedDefaultSecPolicy}) + } + + if userList != nil { + d.Set("users", flattenAccessGroupUsers(userList)) + } +} + +func flattenNetObjectAccessGroup(noag acsgroups.NetObjectAccessGroup) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "access_group_id": noag.AccessGroupID, + "id": noag.ID, + "version_id": noag.VersionID, + } + res = append(res, temp) + return res +} + +func flattenDefaultSecurityPolicy(dsp acsgroups.DefaultSecurityPolicy) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "display_name": dsp.DisplayName, + "id": dsp.ID, + "description": dsp.Description, + "version_id": dsp.VersionID, + "access_group_id": dsp.AccessGroupID, + "default_acl_drop": dsp.DefaultAclDrop, + "default_open_session_drop": dsp.DefaultOpenSessionDrop, + } + res = append(res, temp) + return res +} + +func flattenAccessGroupList(agList *acsgroups.AccessGroupList) []map[string]interface{} { + if agList == nil { + return []map[string]interface{}{} + } + res := make([]map[string]interface{}, 0, len(agList.AccessGroups)) + for _, v := range agList.AccessGroups { + temp := map[string]interface{}{ + "id": v.ID, + "display_name": v.DisplayName, + "comment": v.Comment, + "created_at": v.CreatedAt, + "net_object_access_group": flattenNetObjectAccessGroup(v.NetObjectAccessGroup), + "default_security_policy": flattenDefaultSecurityPolicy(v.DefaultSecurityPolicy), + } + res = append(res, temp) + } + return res +} + +func flattenAccessGroupUserList(userList *acsgroups.UsersList) []map[string]interface{} { + if userList == nil { + return []map[string]interface{}{} + } + res := make([]map[string]interface{}, 0, len(userList.Users)) + for _, v := range userList.Users { + temp := map[string]interface{}{ + "id": v.ID, + "display_name": v.Name, + "role_id": v.RoleID, + "login": v.Login, + } + res = append(res, temp) + } + return res +} + +func flattenAccessGroupUsers(userList *acsgroups.UsersList) []map[string]interface{} { + if userList == nil { + return []map[string]interface{}{} + } + res := make([]map[string]interface{}, 0, len(userList.Users)) + for _, v := range userList.Users { + temp := map[string]interface{}{ + "user_id": v.ID, + "access_group_role_id": v.RoleID, + } + res = append(res, temp) + } + return res +} diff --git a/internal/service/sdn/access_group/resource_decort_sdn_access_group.go b/internal/service/sdn/access_group/resource_decort_sdn_access_group.go new file mode 100644 index 00000000..8cce08e7 --- /dev/null +++ b/internal/service/sdn/access_group/resource_decort_sdn_access_group.go @@ -0,0 +1,276 @@ +package accessgroup + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/acsgroups" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/defsecpolicies" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func resourceAccessGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceAccessGroupCreate: called access group with name %s", + d.Get("display_name").(string)) + c := m.(*controller.ControllerCfg) + + req := acsgroups.CreateRequest{ + DisplayName: d.Get("display_name").(string), + Comment: d.Get("comment").(string), + } + + accessGroup, err := c.SDN().AccessGroups().Create(ctx, req) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + d.SetId(accessGroup.ID) + + if users, ok := d.GetOk("users"); ok { + usersList := users.([]interface{}) + for _, userRaw := range usersList { + userMap := userRaw.(map[string]interface{}) + userReq := acsgroups.UserAddRequest{ + GroupID: accessGroup.ID, + UserID: userMap["user_id"].(string), + AccessGroupRoleID: userMap["access_group_role_id"].(string), + } + _, err := c.SDN().AccessGroups().UserAdd(ctx, userReq) + if err != nil { + log.Warnf("resourceAccessGroupRead: failed to add users for access group %s: %v", d.Id(), err) + + } + } + } + + if defaultSecPolicy, ok := d.GetOk("default_security_policy"); ok { + defaultSecPolicyList := defaultSecPolicy.([]interface{}) + if len(defaultSecPolicyList) > 0 { + defaultSecPolicyMap := defaultSecPolicyList[0].(map[string]interface{}) + + getReq := acsgroups.GetGroupRequest{ + GroupID: accessGroup.ID, + } + fullAccessGroup, err := c.SDN().AccessGroups().Get(ctx, getReq) + if err != nil { + return diag.FromErr(err) + } + + if fullAccessGroup.DefaultSecurityPolicy.ID == "" { + return diag.Errorf("default security policy not found for access group %s", accessGroup.ID) + } + + updateReq := defsecpolicies.UpdateRequest{ + AccessGroupID: accessGroup.ID, + VersionID: uint64(fullAccessGroup.DefaultSecurityPolicy.VersionID), + } + + if defaultAclDrop, ok := defaultSecPolicyMap["default_acl_drop"].(string); ok && defaultAclDrop != "" { + updateReq.DefaultACLDrop = defaultAclDrop + } + + if defaultOpenSessionDrop, ok := defaultSecPolicyMap["default_open_session_drop"].(bool); ok { + updateReq.DefaultOpenSessionDrop = defaultOpenSessionDrop + } + + _, err = c.SDN().DefaultSecurityPolicies().Update(ctx, updateReq) + if err != nil { + return diag.FromErr(err) + } + } + } + + return resourceAccessGroupRead(ctx, d, m) +} + +func resourceAccessGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceAccessGroupRead: called access group with id %s", d.Id()) + + accessGroup, err := utilityAccessGroupCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + userList, err := utilityAccessGroupUsersGet(ctx, accessGroup.ID, m) + if err != nil { + log.Warnf("resourceAccessGroupRead: failed to get users for access group %s: %v", d.Id(), err) + userList = nil + } + + flattenAccessGroupResource(d, accessGroup, userList) + d.SetId(accessGroup.ID) + + return nil +} + +func resourceAccessGroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceAccessGroupUpdate: called access group with id %s", d.Id()) + c := m.(*controller.ControllerCfg) + + req := acsgroups.UpdateRequest{ + AccessGroupID: d.Id(), + } + + needUpdate := false + + if d.HasChange("display_name") { + req.DisplayName = d.Get("display_name").(string) + needUpdate = true + } + + if d.HasChange("comment") { + req.Comment = d.Get("comment").(string) + needUpdate = true + } + + var err error + if needUpdate { + _, err = c.SDN().AccessGroups().Update(ctx, req) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + } + + if d.HasChange("users") { + oldUsers, newUsers := d.GetChange("users") + oldUsersList := oldUsers.([]interface{}) + newUsersList := newUsers.([]interface{}) + + oldUsersMap := make(map[string]string) + for _, userRaw := range oldUsersList { + userMap := userRaw.(map[string]interface{}) + userID := userMap["user_id"].(string) + oldUsersMap[userID] = userMap["access_group_role_id"].(string) + } + + newUsersMap := make(map[string]string) + for _, userRaw := range newUsersList { + userMap := userRaw.(map[string]interface{}) + userID := userMap["user_id"].(string) + newUsersMap[userID] = userMap["access_group_role_id"].(string) + } + + for userID := range oldUsersMap { + if _, exists := newUsersMap[userID]; !exists { + userDeleteReq := acsgroups.UserDeleteRequest{ + GroupID: d.Id(), + UserID: userID, + } + _, err := c.SDN().AccessGroups().UserDelete(ctx, userDeleteReq) + if err != nil { + return diag.FromErr(err) + } + } + } + + for userID, roleID := range newUsersMap { + if oldRoleID, exists := oldUsersMap[userID]; !exists || oldRoleID != roleID { + if !exists { + userAddReq := acsgroups.UserAddRequest{ + GroupID: d.Id(), + UserID: userID, + AccessGroupRoleID: roleID, + } + _, err := c.SDN().AccessGroups().UserAdd(ctx, userAddReq) + if err != nil { + return diag.FromErr(err) + } + } else if oldRoleID != roleID { + userUpdateRoleReq := acsgroups.UserUpdateRoleRequest{ + GroupID: d.Id(), + UserID: userID, + AccessGroupRoleID: roleID, + } + _, err := c.SDN().AccessGroups().UserUpdateRole(ctx, userUpdateRoleReq) + if err != nil { + return diag.FromErr(err) + } + } + } + } + } + + if d.HasChange("default_security_policy") { + defaultSecPolicy, ok := d.GetOk("default_security_policy") + if ok { + defaultSecPolicyList := defaultSecPolicy.([]interface{}) + if len(defaultSecPolicyList) > 0 { + defaultSecPolicyMap := defaultSecPolicyList[0].(map[string]interface{}) + + versionID, ok := defaultSecPolicyMap["version_id"].(int) + if !ok || versionID == 0 { + return diag.Errorf("version_id not found in default_security_policy for access group %s", d.Id()) + } + + updateReq := defsecpolicies.UpdateRequest{ + AccessGroupID: d.Id(), + VersionID: uint64(versionID), + } + + if defaultAclDrop, ok := defaultSecPolicyMap["default_acl_drop"].(string); ok && defaultAclDrop != "" { + updateReq.DefaultACLDrop = defaultAclDrop + } + + if defaultOpenSessionDrop, ok := defaultSecPolicyMap["default_open_session_drop"].(bool); ok { + updateReq.DefaultOpenSessionDrop = defaultOpenSessionDrop + } + + _, err = c.SDN().DefaultSecurityPolicies().Update(ctx, updateReq) + if err != nil { + return diag.FromErr(err) + } + } + } + } + + return resourceAccessGroupRead(ctx, d, m) +} + +func resourceAccessGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceAccessGroupDelete: called access group with id %s", d.Id()) + c := m.(*controller.ControllerCfg) + + req := acsgroups.DeleteRequest{ + GroupID: d.Id(), + } + + _, err := c.SDN().AccessGroups().Delete(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId("") + + return nil +} + +func ResourceAccessGroup() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + CreateContext: resourceAccessGroupCreate, + ReadContext: resourceAccessGroupRead, + UpdateContext: resourceAccessGroupUpdate, + DeleteContext: resourceAccessGroupDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: &constants.Timeout600s, + Read: &constants.Timeout300s, + Update: &constants.Timeout600s, + Delete: &constants.Timeout300s, + Default: &constants.Timeout300s, + }, + + Schema: resourceAccessGroupSchemaMake(), + } +} diff --git a/internal/service/sdn/access_group/schema.go b/internal/service/sdn/access_group/schema.go new file mode 100644 index 00000000..964cf18d --- /dev/null +++ b/internal/service/sdn/access_group/schema.go @@ -0,0 +1,389 @@ +package accessgroup + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func dataSourceAccessGroupListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "page": { + Type: schema.TypeInt, + Optional: true, + Description: "Page number", + }, + "per_page": { + Type: schema.TypeInt, + Optional: true, + Description: "Items per page", + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"display_name", "created_at", "updated_at", "deleted_at", "owner_login"}, false), + Description: "sort by one of supported fields", + }, + "sort_order": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"asc", "desc"}, false), + Description: "sort order", + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Description: "filter by enabled/disabled group", + }, + "deleted": { + Type: schema.TypeBool, + Optional: true, + Description: "filter by deleted/not deleted group", + }, + "display_name": { + Type: schema.TypeString, + Optional: true, + Description: "filter by display name", + }, + "created_from": { + Type: schema.TypeString, + Optional: true, + Description: "filter by the lower limit of the creation date", + }, + "created_to": { + Type: schema.TypeString, + Optional: true, + Description: "filter by the upper limit of the creation date", + }, + "items": { + Type: schema.TypeList, + Computed: true, + Description: "List of access groups", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The unique identifier", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name", + }, + "comment": { + Type: schema.TypeString, + Computed: true, + Description: "Comment description", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation timestamp", + }, + "net_object_access_group": { + Type: schema.TypeList, + Computed: true, + Description: "Net object access group configuration", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Access group ID", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier", + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version identifier", + }, + }, + }, + }, + "default_security_policy": { + Type: schema.TypeList, + Computed: true, + Description: "Default security policy configuration", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Policy display name", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Policy unique identifier", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Policy description", + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Policy version identifier", + }, + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Policy access group ID", + }, + "default_acl_drop": { + Type: schema.TypeString, + Computed: true, + Description: "Default ACL drop action", + }, + "default_open_session_drop": { + Type: schema.TypeBool, + Computed: true, + Description: "Default open session drop flag", + }, + }, + }, + }, + }, + }, + }, + } + + return res +} + +func dataSourceAccessGroupUserListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Required: true, + Description: "filter by access group id", + }, + "global_role": { + Type: schema.TypeString, + Optional: true, + Description: "filter by global role", + }, + "access_group_role": { + Type: schema.TypeString, + Optional: true, + Description: "filter by access group role", + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Description: "filter by inclusion", + }, + "deleted": { + Type: schema.TypeBool, + Optional: true, + Description: "delete filter", + }, + "display_name": { + Type: schema.TypeString, + Optional: true, + Description: "filter by display name", + }, + "login": { + Type: schema.TypeString, + Optional: true, + Description: "filter by user login", + }, + "created_by": { + Type: schema.TypeString, + Optional: true, + Description: "who created the user", + }, + "deleted_by": { + Type: schema.TypeString, + Optional: true, + Description: "who deleted the user", + }, + "disabled_by": { + Type: schema.TypeString, + Optional: true, + Description: "who disabled the user", + }, + "page": { + Type: schema.TypeInt, + Optional: true, + Description: "result page number", + }, + "per_page": { + Type: schema.TypeInt, + Optional: true, + Description: "number of results per page", + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"display_name", "email", "phone", "created_at", "updated_at", "deleted_at"}, false), + Description: "sort by one of supported fields", + }, + "sort_order": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"asc", "desc"}, false), + Description: "sorting order", + }, + "created_from": { + Type: schema.TypeString, + Optional: true, + Description: "filter by the lower limit of the creation date", + }, + "created_to": { + Type: schema.TypeString, + Optional: true, + Description: "filter by the upper limit of the creation date", + }, + "items": { + Type: schema.TypeList, + Computed: true, + Description: "List of users", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The unique identifier", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name", + }, + "role_id": { + Type: schema.TypeString, + Computed: true, + Description: "Role identifier", + }, + "login": { + Type: schema.TypeString, + Computed: true, + Description: "Login", + }, + }, + }, + }, + } + + return res +} + +func resourceAccessGroupSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Required: true, + Description: "group name", + }, + "comment": { + Type: schema.TypeString, + Required: true, + Description: "description (comment) of the group", + }, + "users": { + Type: schema.TypeList, + Optional: true, + Description: "managing users who are part of a group", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_role_id": { + Type: schema.TypeString, + Required: true, + Description: "id of the assigned role", + }, + "user_id": { + Type: schema.TypeString, + Required: true, + Description: "user ID", + }, + }, + }, + }, + "default_security_policy": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Description: "Default security policy configuration", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "default_acl_drop": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Default ACL drop action", + }, + "default_open_session_drop": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Default open session drop flag", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Policy display name", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Policy unique identifier", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Policy description", + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Policy version identifier", + }, + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Policy access group ID", + }, + }, + }, + }, + // Computed fields + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation timestamp", + }, + "net_object_access_group": { + Type: schema.TypeList, + Computed: true, + Description: "Net object access group configuration", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Access group ID", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier", + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version identifier", + }, + }, + }, + }, + } + + return res +} diff --git a/internal/service/sdn/access_group/utility_access_group.go b/internal/service/sdn/access_group/utility_access_group.go new file mode 100644 index 00000000..d8d97677 --- /dev/null +++ b/internal/service/sdn/access_group/utility_access_group.go @@ -0,0 +1,43 @@ +package accessgroup + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/acsgroups" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityAccessGroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*acsgroups.AccessGroup, error) { + c := m.(*controller.ControllerCfg) + + req := acsgroups.GetGroupRequest{} + + if d.Id() != "" { + req.GroupID = d.Id() + } else { + req.GroupID = d.Get("access_group_id").(string) + } + + accessGroup, err := c.SDN().AccessGroups().Get(ctx, req) + if err != nil { + return nil, err + } + + return accessGroup, nil +} + +func utilityAccessGroupUsersGet(ctx context.Context, groupID string, m interface{}) (*acsgroups.UsersList, error) { + c := m.(*controller.ControllerCfg) + + req := acsgroups.UsersListRequest{ + AccessGroupID: groupID, + } + + userList, err := c.SDN().AccessGroups().UsersList(ctx, req) + if err != nil { + return nil, err + } + + return userList, nil +} diff --git a/internal/service/sdn/access_group/utility_access_group_list.go b/internal/service/sdn/access_group/utility_access_group_list.go new file mode 100644 index 00000000..9f84b701 --- /dev/null +++ b/internal/service/sdn/access_group/utility_access_group_list.go @@ -0,0 +1,52 @@ +package accessgroup + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/acsgroups" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityAccessGroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*acsgroups.AccessGroupList, error) { + c := m.(*controller.ControllerCfg) + req := acsgroups.ListGroupsRequest{} + + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + if perPage, ok := d.GetOk("per_page"); ok { + req.PerPage = uint64(perPage.(int)) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if sortOrder, ok := d.GetOk("sort_order"); ok { + req.SortOrder = sortOrder.(string) + } + if enabled, ok := d.GetOk("enabled"); ok { + req.Enabled = enabled.(bool) + } + if deleted, ok := d.GetOk("deleted"); ok { + req.Deleted = deleted.(bool) + } + if displayName, ok := d.GetOk("display_name"); ok { + req.DisplayName = displayName.(string) + } + if createdFrom, ok := d.GetOk("created_from"); ok { + req.CreatedFrom = createdFrom.(string) + } + if createdTo, ok := d.GetOk("created_to"); ok { + req.CreatedTo = createdTo.(string) + } + + log.Debugf("utilityAccessGroupListCheckPresence") + accessGroupList, err := c.SDN().AccessGroups().List(ctx, req) + if err != nil { + return nil, err + } + + return accessGroupList, nil +} + diff --git a/internal/service/sdn/access_group/utility_access_group_user_list.go b/internal/service/sdn/access_group/utility_access_group_user_list.go new file mode 100644 index 00000000..83567cf7 --- /dev/null +++ b/internal/service/sdn/access_group/utility_access_group_user_list.go @@ -0,0 +1,74 @@ +package accessgroup + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/acsgroups" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityAccessGroupUserListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*acsgroups.UsersList, error) { + c := m.(*controller.ControllerCfg) + req := acsgroups.UsersListRequest{} + + req.AccessGroupID = d.Get("access_group_id").(string) + + if globalRole, ok := d.GetOk("global_role"); ok { + req.GlobalRole = globalRole.(string) + } + if accessGroupRole, ok := d.GetOk("access_group_role"); ok { + req.AccessGroupRole = accessGroupRole.(string) + } + if enabled, ok := d.GetOk("enabled"); ok { + req.Enabled = enabled.(bool) + } + if deleted, ok := d.GetOk("deleted"); ok { + req.Deleted = deleted.(bool) + } + if displayName, ok := d.GetOk("display_name"); ok { + req.DisplayName = displayName.(string) + } + if login, ok := d.GetOk("login"); ok { + req.Login = login.(string) + } + if createdBy, ok := d.GetOk("created_by"); ok { + req.CreatedBy = createdBy.(string) + } + if updatedBy, ok := d.GetOk("updated_by"); ok { + req.UpdatedBy = updatedBy.(string) + } + if deletedBy, ok := d.GetOk("deleted_by"); ok { + req.DeletedBy = deletedBy.(string) + } + if disabledBy, ok := d.GetOk("disabled_by"); ok { + req.DisabledBy = disabledBy.(string) + } + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + if perPage, ok := d.GetOk("per_page"); ok { + req.PerPage = uint64(perPage.(int)) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if sortOrder, ok := d.GetOk("sort_order"); ok { + req.SortOrder = sortOrder.(string) + } + if createdFrom, ok := d.GetOk("created_from"); ok { + req.CreatedFrom = createdFrom.(string) + } + if createdTo, ok := d.GetOk("created_to"); ok { + req.CreatedTo = createdTo.(string) + } + + log.Debugf("utilityAccessGroupUserListCheckPresence") + userList, err := c.SDN().AccessGroups().UsersList(ctx, req) + if err != nil { + return nil, err + } + + return userList, nil +} diff --git a/internal/service/sdn/default_security_policy/data_decort_sdn_default_security_policy_list.go b/internal/service/sdn/default_security_policy/data_decort_sdn_default_security_policy_list.go new file mode 100644 index 00000000..44758639 --- /dev/null +++ b/internal/service/sdn/default_security_policy/data_decort_sdn_default_security_policy_list.go @@ -0,0 +1,40 @@ +package defaultsecuritypolicy + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceDefaultSecurityPolicyListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + defaultSecurityPolicyList, err := utilityDefaultSecurityPolicyListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenDefaultSecurityPolicyList(defaultSecurityPolicyList)) + + return nil +} + +func DataSourceDefaultSecurityPolicyList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceDefaultSecurityPolicyListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceDefaultSecurityPolicyListSchemaMake(), + } +} + diff --git a/internal/service/sdn/default_security_policy/flattens.go b/internal/service/sdn/default_security_policy/flattens.go new file mode 100644 index 00000000..d13f91da --- /dev/null +++ b/internal/service/sdn/default_security_policy/flattens.go @@ -0,0 +1,130 @@ +package defaultsecuritypolicy + +import ( + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/defsecpolicies" +) + +func flattenDefaultSecurityPolicyList(policyList *defsecpolicies.SecurityPoliciesList) []map[string]interface{} { + if policyList == nil { + return []map[string]interface{}{} + } + res := make([]map[string]interface{}, 0, len(policyList.Policies)) + for _, v := range policyList.Policies { + temp := map[string]interface{}{ + "access_group_id": v.AccessGroupID, + "created_at": v.CreatedAt, + "default_acl_drop": v.DefaultACLDrop, + "default_open_session_drop": v.DefaultOpenSessionDrop, + "description": v.Description, + "display_name": v.DisplayName, + "id": v.ID, + "security_rules": flattenSecurityRules(v.SecurityRules), + "locked_at": v.LockedAt, + "status": flattenStatus(v.Status), + "version_id": int(v.VersionID), + } + res = append(res, temp) + } + return res +} + +func flattenSecurityRules(rules []defsecpolicies.SecurityRule) []map[string]interface{} { + if rules == nil { + return []map[string]interface{}{} + } + res := make([]map[string]interface{}, 0, len(rules)) + for _, v := range rules { + temp := map[string]interface{}{ + "access_group_id": v.AccessGroupID, + "action": v.Action, + "description": v.Description, + "destination_net_object": flattenNetObject(v.DestinationNetObject), + "direction": v.Direction, + "display_name": v.DisplayName, + "enabled": v.Enabled, + "filter": flattenFilter(v.Filter), + "id": v.ID, + "log_enabled": v.LogEnabled, + "log_name": v.LogName, + "log_severity": v.LogSeverity, + "priority": v.Priority, + "security_policy_id": v.SecurityPolicyID, + "source_net_object": flattenNetObject(v.SourceNetObject), + "statistics_enabled": v.StatisticsEnabled, + "version_id": int(v.VersionID), + } + res = append(res, temp) + } + return res +} + +func flattenNetObject(netObj defsecpolicies.NetObject) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "display_name": netObj.DisplayName, + "net_address_pool_id": netObj.NetAddressPoolID, + "net_object_group_id": netObj.NetObjectGroupID, + } + res = append(res, temp) + return res +} + +func flattenFilter(filter defsecpolicies.Filter) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "filters": flattenFilterParams(filter.Filters), + "name": filter.Name, + } + res = append(res, temp) + return res +} + +func flattenFilterParams(params defsecpolicies.FilterParams) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "all": params.All, + "arp": params.ARP, + "dhcp": params.DHCP, + "expression": params.Expression, + "icmp": params.ICMP, + "ip": params.IP, + "ip_v4": params.IPv4, + "ip_v6": params.IPv6, + "keep_opened_sessions": params.KeepOpenedSessions, + "nd": params.ND, + "tcp": params.TCP, + "tcp_dst_ports": params.TCPDstPorts, + "udp": params.UDP, + "udp_dst_ports": params.UDPDstPorts, + } + res = append(res, temp) + return res +} + +func flattenStatus(status defsecpolicies.Status) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "common": status.Common, + "hypervisors": flattenHypervisorStatuses(status.Hypervisors), + } + res = append(res, temp) + return res +} + +func flattenHypervisorStatuses(hypervisors []defsecpolicies.HypervisorStatus) []map[string]interface{} { + if hypervisors == nil { + return []map[string]interface{}{} + } + res := make([]map[string]interface{}, 0, len(hypervisors)) + for _, v := range hypervisors { + temp := map[string]interface{}{ + "status": v.Status, + "name": v.Name, + "display_name": v.DisplayName, + "hypervisor_status": v.HypervisorStatus, + "synced_at": v.SyncedAt, + } + res = append(res, temp) + } + return res +} diff --git a/internal/service/sdn/default_security_policy/schema.go b/internal/service/sdn/default_security_policy/schema.go new file mode 100644 index 00000000..daabaf8a --- /dev/null +++ b/internal/service/sdn/default_security_policy/schema.go @@ -0,0 +1,369 @@ +package defaultsecuritypolicy + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func dataSourceDefaultSecurityPolicyListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Optional: true, + Description: "id of the access group", + }, + "page": { + Type: schema.TypeInt, + Optional: true, + Description: "result page number", + }, + "per_page": { + Type: schema.TypeInt, + Optional: true, + Description: "number of results per page", + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"created_at", "updated_at"}, false), + Description: "sort by one of the supported fields", + }, + "sort_order": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"asc", "desc"}, false), + Description: "sorting order", + }, + "items": { + Type: schema.TypeList, + Computed: true, + Description: "List of default security policies", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Access group ID", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation timestamp", + }, + "default_acl_drop": { + Type: schema.TypeString, + Computed: true, + Description: "Default ACL drop action", + }, + "default_open_session_drop": { + Type: schema.TypeBool, + Computed: true, + Description: "Default open session drop flag", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Description", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name", + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier", + }, + "security_rules": { + Type: schema.TypeList, + Computed: true, + Description: "Security rules", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Access group ID", + }, + "action": { + Type: schema.TypeString, + Computed: true, + Description: "Action", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Description", + }, + "destination_net_object": { + Type: schema.TypeList, + Computed: true, + Description: "Destination network object", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name", + }, + "net_address_pool_id": { + Type: schema.TypeString, + Computed: true, + Description: "Network address pool ID", + }, + "net_object_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Network object group ID", + }, + }, + }, + }, + "direction": { + Type: schema.TypeString, + Computed: true, + Description: "Direction", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "Enabled flag", + }, + "filter": { + Type: schema.TypeList, + Computed: true, + Description: "Filter configuration", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "filters": { + Type: schema.TypeList, + Computed: true, + Description: "Filter parameters", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "all": { + Type: schema.TypeBool, + Computed: true, + Description: "All protocols flag", + }, + "arp": { + Type: schema.TypeBool, + Computed: true, + Description: "ARP protocol flag", + }, + "dhcp": { + Type: schema.TypeBool, + Computed: true, + Description: "DHCP protocol flag", + }, + "expression": { + Type: schema.TypeString, + Computed: true, + Description: "Filter expression", + }, + "icmp": { + Type: schema.TypeBool, + Computed: true, + Description: "ICMP protocol flag", + }, + "ip": { + Type: schema.TypeBool, + Computed: true, + Description: "IP protocol flag", + }, + "ip_v4": { + Type: schema.TypeBool, + Computed: true, + Description: "IPv4 protocol flag", + }, + "ip_v6": { + Type: schema.TypeBool, + Computed: true, + Description: "IPv6 protocol flag", + }, + "keep_opened_sessions": { + Type: schema.TypeBool, + Computed: true, + Description: "Keep opened sessions flag", + }, + "nd": { + Type: schema.TypeBool, + Computed: true, + Description: "ND protocol flag", + }, + "tcp": { + Type: schema.TypeBool, + Computed: true, + Description: "TCP protocol flag", + }, + "tcp_dst_ports": { + Type: schema.TypeList, + Computed: true, + Description: "TCP destination ports", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "udp": { + Type: schema.TypeBool, + Computed: true, + Description: "UDP protocol flag", + }, + "udp_dst_ports": { + Type: schema.TypeList, + Computed: true, + Description: "UDP destination ports", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Filter name", + }, + }, + }, + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier", + }, + "log_enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "Log enabled flag", + }, + "log_name": { + Type: schema.TypeString, + Computed: true, + Description: "Log name", + }, + "log_severity": { + Type: schema.TypeString, + Computed: true, + Description: "Log severity", + }, + "priority": { + Type: schema.TypeInt, + Computed: true, + Description: "Priority", + }, + "security_policy_id": { + Type: schema.TypeString, + Computed: true, + Description: "Security policy ID", + }, + "source_net_object": { + Type: schema.TypeList, + Computed: true, + Description: "Source network object", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name", + }, + "net_address_pool_id": { + Type: schema.TypeString, + Computed: true, + Description: "Network address pool ID", + }, + "net_object_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "Network object group ID", + }, + }, + }, + }, + "statistics_enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "Statistics enabled flag", + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID", + }, + }, + }, + }, + "locked_at": { + Type: schema.TypeString, + Computed: true, + Description: "Locked timestamp", + }, + "status": { + Type: schema.TypeList, + Computed: true, + Description: "Status information", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "common": { + Type: schema.TypeString, + Computed: true, + Description: "Common status", + }, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Description: "Hypervisor statuses", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + Description: "Status", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Name", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name", + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + Description: "Hypervisor status", + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + Description: "Last sync timestamp", + }, + }, + }, + }, + }, + }, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID", + }, + }, + }, + }, + } + + return res +} + diff --git a/internal/service/sdn/default_security_policy/utility_default_security_policy_list.go b/internal/service/sdn/default_security_policy/utility_default_security_policy_list.go new file mode 100644 index 00000000..5cf41070 --- /dev/null +++ b/internal/service/sdn/default_security_policy/utility_default_security_policy_list.go @@ -0,0 +1,40 @@ +package defaultsecuritypolicy + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/defsecpolicies" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityDefaultSecurityPolicyListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*defsecpolicies.SecurityPoliciesList, error) { + c := m.(*controller.ControllerCfg) + req := defsecpolicies.ListRequest{} + + if accessGroupID, ok := d.GetOk("access_group_id"); ok { + req.AccessGroupID = accessGroupID.(string) + } + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + if perPage, ok := d.GetOk("per_page"); ok { + req.PerPage = uint64(perPage.(int)) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if sortOrder, ok := d.GetOk("sort_order"); ok { + req.SortOrder = sortOrder.(string) + } + + log.Debugf("utilityDefaultSecurityPolicyListCheckPresence") + defaultSecurityPolicyList, err := c.SDN().DefaultSecurityPolicies().List(ctx, req) + if err != nil { + return nil, err + } + + return defaultSecurityPolicyList, nil +} + diff --git a/internal/service/sdn/logicalports/data_source_logical_port.go b/internal/service/sdn/logicalports/data_source_logical_port.go new file mode 100644 index 00000000..c22d52ce --- /dev/null +++ b/internal/service/sdn/logicalports/data_source_logical_port.go @@ -0,0 +1,36 @@ +package logicalports + +import ( + "context" + + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func dataSourceLogicalPortRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + logicalPort, err := utilityLogicalPortCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenLogicalPort(d, logicalPort) + d.SetId(logicalPort.ID) + return nil +} + +func DataSourceLogicalPort() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceLogicalPortRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + Schema: dataSourceLogicalPortSchemaMake(), + } +} diff --git a/internal/service/sdn/logicalports/data_source_logical_port_by_unique_id.go b/internal/service/sdn/logicalports/data_source_logical_port_by_unique_id.go new file mode 100644 index 00000000..700fec07 --- /dev/null +++ b/internal/service/sdn/logicalports/data_source_logical_port_by_unique_id.go @@ -0,0 +1,35 @@ +package logicalports + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceLogicalPortByUniqueIDRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + logicalPort, err := utilityLogicalPortByUniqueIDCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenLogicalPort(d, logicalPort) + d.SetId(logicalPort.ID) + return nil +} + +func DataSourceLogicalPortByUniqueID() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceLogicalPortByUniqueIDRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + Schema: dataSourceLogicalPortByUniqueIDSchemaMake(), + } +} diff --git a/internal/service/sdn/logicalports/data_source_logical_port_list.go b/internal/service/sdn/logicalports/data_source_logical_port_list.go new file mode 100644 index 00000000..4a570699 --- /dev/null +++ b/internal/service/sdn/logicalports/data_source_logical_port_list.go @@ -0,0 +1,39 @@ +package logicalports + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceLogicalPortListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + logicalPortList, err := utilityLogicalPortListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenLogicalPortList(logicalPortList)) + + return nil +} + +func DataSourceLogicalPortList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceLogicalPortListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceLogicalPortListSchemaMake(), + } +} diff --git a/internal/service/sdn/logicalports/flattens.go b/internal/service/sdn/logicalports/flattens.go new file mode 100644 index 00000000..2bf2a8eb --- /dev/null +++ b/internal/service/sdn/logicalports/flattens.go @@ -0,0 +1,114 @@ +package logicalports + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports" +) + +func flattenLogicalPortResource(d *schema.ResourceData, logicalPort *logicalports.LogicalPort) { + d.Set("id", logicalPort.ID) + d.Set("access_group_id", logicalPort.AccessGroupID) + d.Set("access_group_name", logicalPort.AccessGroupName) + d.Set("adapter_mac", logicalPort.AdapterMAC) + d.Set("address_detection", logicalPort.AddressDetection) + d.Set("description", logicalPort.Description) + d.Set("display_name", logicalPort.DisplayName) + d.Set("enabled", logicalPort.Enabled) + d.Set("hypervisor", logicalPort.Hypervisor) + d.Set("hypervisor_display_name", logicalPort.HypervisorDisplayName) + d.Set("live_migration_target_hv", logicalPort.LiveMigrationTargetHV) + d.Set("status", flattenStatus(logicalPort.Status)) + d.Set("unique_identifier", logicalPort.UniqueIdentifier) + d.Set("version_id", logicalPort.VersionID) + d.Set("bindings", flattenBindings(logicalPort.Bindings)) + d.Set("created_at", logicalPort.CreatedAt) +} + +func flattenLogicalPortList(lpl *logicalports.LogicalPortsList) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(lpl.Ports)) + for _, v := range lpl.Ports { + temp := map[string]interface{}{ + "id": v.ID, + "access_group_id": v.AccessGroupID, + "access_group_name": v.AccessGroupName, + "adapter_mac": v.AdapterMAC, + "address_detection": v.AddressDetection, + "description": v.Description, + "display_name": v.DisplayName, + "enabled": v.Enabled, + "hypervisor": v.Hypervisor, + "hypervisor_display_name": v.HypervisorDisplayName, + "live_migration_target_hv": v.LiveMigrationTargetHV, + "status": flattenStatus(v.Status), + "unique_identifier": v.UniqueIdentifier, + "version_id": v.VersionID, + "bindings": flattenBindings(v.Bindings), + "created_at": v.CreatedAt, + "updated_at": v.UpdatedAt, + } + res = append(res, temp) + } + return res +} + +func flattenLogicalPort(d *schema.ResourceData, logicalPort *logicalports.LogicalPort) { + d.Set("id", logicalPort.ID) + d.Set("access_group_id", logicalPort.AccessGroupID) + d.Set("access_group_name", logicalPort.AccessGroupName) + d.Set("adapter_mac", logicalPort.AdapterMAC) + d.Set("address_detection", logicalPort.AddressDetection) + d.Set("description", logicalPort.Description) + d.Set("display_name", logicalPort.DisplayName) + d.Set("enabled", logicalPort.Enabled) + d.Set("hypervisor", logicalPort.Hypervisor) + d.Set("hypervisor_display_name", logicalPort.HypervisorDisplayName) + d.Set("live_migration_target_hv", logicalPort.LiveMigrationTargetHV) + d.Set("status", flattenStatus(logicalPort.Status)) + d.Set("unique_identifier", logicalPort.UniqueIdentifier) + d.Set("version_id", logicalPort.VersionID) + d.Set("bindings", flattenBindings(logicalPort.Bindings)) + d.Set("created_at", logicalPort.CreatedAt) + d.Set("updated_at", logicalPort.UpdatedAt) +} + +func flattenBindings(bindings logicalports.Bindings) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "id": bindings.ID, + "segment_id": bindings.SegmentID, + "segment_display_name": bindings.SegmentDisplayName, + "port_security": bindings.PortSecurity, + "address_detection": bindings.AddressDetection, + "is_excluded_from_firewall": bindings.IsExcludedFromFirewall, + "version_id": bindings.VersionID, + "created_at": bindings.CreatedAt, + "updated_at": bindings.UpdatedAt, + } + res = append(res, temp) + return res +} + +func flattenStatus(status logicalports.Status) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "common": status.Common, + "hypervisors": flattenHypervisors(status.Hypervisors), + } + res = append(res, temp) + return res +} + +func flattenHypervisors(hv []logicalports.HypervisorStatus) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(hv)) + for _, v := range hv { + temp := map[string]interface{}{ + "status": v.Status, + "name": v.Name, + "display_name": v.DisplayName, + "hypervisor_status": v.HypervisorStatus, + "synced_at": v.SyncedAt, + } + res = append(res, temp) + } + return res +} diff --git a/internal/service/sdn/logicalports/resource_logical_port.go b/internal/service/sdn/logicalports/resource_logical_port.go new file mode 100644 index 00000000..69949b63 --- /dev/null +++ b/internal/service/sdn/logicalports/resource_logical_port.go @@ -0,0 +1,226 @@ +package logicalports + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func resourceLogicalPortCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceLogicalPortCreate: called logical port with name %s", + d.Get("display_name").(string)) + c := m.(*controller.ControllerCfg) + + req := logicalports.CreateRequest{ + AccessGroupID: d.Get("access_group_id").(string), + Description: d.Get("description").(string), + DisplayName: d.Get("display_name").(string), + Enabled: d.Get("enabled").(bool), + IsExcludedFromFirewall: d.Get("is_excluded_from_firewall").(bool), + Hypervisor: d.Get("hypervisor").(string), + PortSecurity: d.Get("port_security").(bool), + SegmentID: d.Get("segment_id").(string), + } + + if adapterMAC, ok := d.GetOk("adapter_mac"); ok { + req.AdapterMAC = adapterMAC.(string) + } + if uniqueID, ok := d.GetOk("unique_identifier"); ok { + req.UniqueIdentifier = uniqueID.(string) + } + if logicalPortAddresses, ok := d.GetOk("logical_port_addresses"); ok { + logicalPortAddressesList := logicalPortAddresses.([]interface{}) + logicalPortsAddressesArr := make([]logicalports.LogicalPortAddress, 0) + for _, logicalPortAddressRaw := range logicalPortAddressesList { + logicalPortAddressMap := logicalPortAddressRaw.(map[string]interface{}) + logicalPortAddress := logicalports.LogicalPortAddress{ + IP: logicalPortAddressMap["ip"].(string), + IPType: logicalPortAddressMap["ip_type"].(string), + IsPrimary: logicalPortAddressMap["is_primary"].(bool), + } + if isDiscovered, ok := logicalPortAddressMap["is_discovered"]; ok { + logicalPortAddress.IsDiscovered = isDiscovered.(bool) + } + if mac, ok := logicalPortAddressMap["mac_address"]; ok { + logicalPortAddress.MAC = mac.(string) + } + logicalPortsAddressesArr = append(logicalPortsAddressesArr, logicalPortAddress) + } + req.LogicalPortAddresses = logicalPortsAddressesArr + } + + logicalPort, err := c.SDN().LogicalPorts().Create(ctx, req) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + d.SetId(logicalPort.ID) + + return resourceLogicalPortRead(ctx, d, m) +} + +func resourceLogicalPortRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceLogicalPortRead: called logical port with id %s", d.Id()) + + logicalPort, err := utilityLogicalPortCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenLogicalPortResource(d, logicalPort) + d.SetId(logicalPort.ID) + + return nil +} + +func resourceLogicalPortUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceLogicalPortUpdate: called logical port with id %s", d.Id()) + c := m.(*controller.ControllerCfg) + + req := logicalports.UpdateRequest{ + LogicalPortID: d.Id(), + VersionID: uint64(d.Get("version_id").(int)), + AdapterMAC: d.Get("adapter_mac").(string), + Description: d.Get("description").(string), + DisplayName: d.Get("display_name").(string), + Enabled: d.Get("enabled").(bool), + Hypervisor: d.Get("hypervisor").(string), + PortSecurity: d.Get("port_security").(bool), + IsExcludedFromFirewall: d.Get("is_excluded_from_firewall").(bool), + SegmentID: d.Get("segment_id").(string), + } + + if d.HasChange("logical_port_addresses") { + oldAddresses, newAddresses := d.GetChange("logical_port_addresses") + oldAddressesList := oldAddresses.([]interface{}) + newAddressesList := newAddresses.([]interface{}) + oldAddressesMap := make(map[string]logicalports.LogicalPortAddress) + for _, oldAddressRaw := range oldAddressesList { + logicalPortAddressMap := oldAddressRaw.(map[string]interface{}) + logicalPortAddress := logicalports.LogicalPortAddress{ + IP: logicalPortAddressMap["ip"].(string), + IPType: logicalPortAddressMap["ip_type"].(string), + IsPrimary: logicalPortAddressMap["is_primary"].(bool), + } + if isDiscovered, ok := logicalPortAddressMap["is_discovered"]; ok { + logicalPortAddress.IsDiscovered = isDiscovered.(bool) + } + if mac, ok := logicalPortAddressMap["mac_address"]; ok { + logicalPortAddress.MAC = mac.(string) + } + oldAddressesMap[logicalPortAddress.IP] = logicalPortAddress + } + newAddressesMap := make(map[string]logicalports.LogicalPortAddress) + for _, newAddressRaw := range newAddressesList { + logicalPortAddressMap := newAddressRaw.(map[string]interface{}) + logicalPortAddress := logicalports.LogicalPortAddress{ + IP: logicalPortAddressMap["ip"].(string), + IPType: logicalPortAddressMap["ip_type"].(string), + IsPrimary: logicalPortAddressMap["is_primary"].(bool), + } + if isDiscovered, ok := logicalPortAddressMap["is_discovered"]; ok { + logicalPortAddress.IsDiscovered = isDiscovered.(bool) + } + if mac, ok := logicalPortAddressMap["mac_address"]; ok { + logicalPortAddress.MAC = mac.(string) + } + newAddressesMap[logicalPortAddress.IP] = logicalPortAddress + } + + for addressIP, _ := range oldAddressesMap { + removeAddresses := make([]string, 0) + if _, exists := newAddressesMap[addressIP]; !exists { + removeAddresses = append(removeAddresses, addressIP) + } + req.RemoveAddresses = removeAddresses + } + + for addressIP, address := range newAddressesMap { + if oldAddressIP, exists := oldAddressesMap[addressIP]; !exists || address != oldAddressIP { + if !exists { + logicalPortAddress := logicalports.AddAddress{ + IP: address.IP, + IPType: address.IPType, + IsPrimary: address.IsPrimary, + IsDiscovered: address.IsDiscovered, + MAC: address.MAC, + } + req.AddAddresses = append(req.AddAddresses, logicalPortAddress) + } else if address != oldAddressIP { + logicalPortAddress := logicalports.UpdateAddress{ + IP: address.IP, + IPType: address.IPType, + IsPrimary: address.IsPrimary, + IsDiscovered: address.IsDiscovered, + MAC: address.MAC, + } + req.UpdateAddresses = append(req.UpdateAddresses, logicalPortAddress) + } + } + } + + } + + _, err := c.SDN().LogicalPorts().Update(ctx, req) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + return resourceLogicalPortRead(ctx, d, m) +} + +func resourceLogicalPortDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceLogicalPortDelete: called logical port with id %s", d.Id()) + c := m.(*controller.ControllerCfg) + + req := logicalports.DeleteRequest{ + ID: d.Id(), + Version: uint64(d.Get("version_id").(int)), + } + + if force, ok := d.GetOk("force"); ok { + req.Force = force.(bool) + } + + _, err := c.SDN().LogicalPorts().Delete(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId("") + + return nil +} + +func ResourceLogicalPort() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + CreateContext: resourceLogicalPortCreate, + ReadContext: resourceLogicalPortRead, + UpdateContext: resourceLogicalPortUpdate, + DeleteContext: resourceLogicalPortDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: &constants.Timeout600s, + Read: &constants.Timeout300s, + Update: &constants.Timeout600s, + Delete: &constants.Timeout300s, + Default: &constants.Timeout300s, + }, + + Schema: resourceLogicalPortSchemaMake(), + } +} diff --git a/internal/service/sdn/logicalports/schema.go b/internal/service/sdn/logicalports/schema.go new file mode 100644 index 00000000..8cc7709d --- /dev/null +++ b/internal/service/sdn/logicalports/schema.go @@ -0,0 +1,858 @@ +package logicalports + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceLogicalPortSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Required: true, + Description: "Access Group ID", + }, + "description": { + Type: schema.TypeString, + Required: true, + Description: "Description", + }, + "display_name": { + Type: schema.TypeString, + Required: true, + Description: "Display Name", + }, + "enabled": { + Type: schema.TypeBool, + Required: true, + Description: "Whether the logical port should be enabled", + }, + "is_excluded_from_firewall": { + Type: schema.TypeBool, + Required: true, + }, + "hypervisor": { + Type: schema.TypeString, + Required: true, + Description: "Hypervisor", + }, + "port_security": { + Type: schema.TypeBool, + Required: true, + Description: "Whether the port security is enabled", + }, + "segment_id": { + Type: schema.TypeString, + Required: true, + Description: "Segment ID", + }, + "adapter_mac": { + Type: schema.TypeString, + Optional: true, + Description: "Adapter MAC address", + }, + "unique_identifier": { + Type: schema.TypeString, + Optional: true, + Description: "Unique identifier of the logical port", + }, + "force": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "logical_port_addresses": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ip": { + Type: schema.TypeString, + Required: true, + Description: "IP address of the logical port", + }, + "ip_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"IPv4", "IPv6"}, false), + }, + "is_primary": { + Type: schema.TypeBool, + Required: true, + }, + "is_discovered": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "mac": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + "id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the logical port", + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the access group", + }, + "address_detection": { + Type: schema.TypeBool, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "external_network_id": { + Type: schema.TypeString, + Computed: true, + }, + "hypervisor_display_name": { + Type: schema.TypeString, + Computed: true, + }, + "live_migration_target_hv": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "common": { + Type: schema.TypeString, + Computed: true, + Description: "Common status", + }, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + Description: "Status of the hypervisor", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the hypervisor", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the hypervisor", + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + Description: "Status of the hypervisor", + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + Description: "Sync time of the hypervisor", + }, + }, + }, + }, + }, + }, + }, + "bindings": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the binding", + }, + "segment_id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the segment", + }, + "segment_display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the segment", + }, + "port_security": { + Type: schema.TypeBool, + Computed: true, + Description: "If the port is secured", + }, + "address_detection": { + Type: schema.TypeBool, + Computed: true, + Description: "If the adapter address detection is enabled", + }, + "is_excluded_from_firewall": { + Type: schema.TypeBool, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID of the binding", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation time of the binding", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "Update time of the binding", + }, + }, + }, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID of the logical port", + }, + } + return res +} + +func dataSourceLogicalPortListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Optional: true, + Description: "Access Group ID", + }, + "segment_id": { + Type: schema.TypeString, + Optional: true, + Description: "Segment ID", + }, + "segment_display_name": { + Type: schema.TypeString, + Optional: true, + Description: "Segment display name", + }, + "external_network_id": { + Type: schema.TypeString, + Optional: true, + Description: "External Network ID", + }, + "unique_identifier": { + Type: schema.TypeString, + Optional: true, + Description: "Unique identifier", + }, + "display_name": { + Type: schema.TypeString, + Optional: true, + Description: "Display name", + }, + "adapter_mac": { + Type: schema.TypeString, + Optional: true, + Description: "Adapter mac", + }, + "hypervisor": { + Type: schema.TypeString, + Optional: true, + Description: "Hypervisor", + }, + "hypervisor_display_name": { + Type: schema.TypeString, + Optional: true, + Description: "Hypervisor display name", + }, + "live_migration_target_hv": { + Type: schema.TypeString, + Optional: true, + Description: "Live migration target HV", + }, + "port_security": { + Type: schema.TypeBool, + Optional: true, + }, + "address_detection": { + Type: schema.TypeBool, + Optional: true, + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + }, + "created_from": { + Type: schema.TypeString, + Optional: true, + }, + "created_to": { + Type: schema.TypeString, + Optional: true, + }, + "page": { + Type: schema.TypeInt, + Optional: true, + }, + "per_page": { + Type: schema.TypeInt, + Optional: true, + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"display_name", "created_at", "updated_at", + "deleted_at", "segment_id", "hypervisor", + "port_security", "segment_display_name", "primary_address", + "hypervisor_display_name"}, false), + }, + "sort_order": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"asc", "dec"}, false), + }, + "items": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the logical port to use", + }, + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the access group", + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the access group", + }, + "adapter_mac": { + Type: schema.TypeString, + Computed: true, + Description: "MAC address of the adapter", + }, + "address_detection": { + Type: schema.TypeBool, + Computed: true, + Description: "If the adapter address detection is enabled", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Description of the logical port", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the logical port", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "If the logical port is enabled", + }, + "hypervisor": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the hypervisor", + }, + "hypervisor_display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the hypervisor", + }, + "live_migration_target_hv": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "common": { + Type: schema.TypeString, + Computed: true, + Description: "Common status", + }, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + Description: "Status of the hypervisor", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the hypervisor", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the hypervisor", + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + Description: "Status of the hypervisor", + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + Description: "Sync time of the hypervisor", + }, + }, + }, + }, + }, + }, + }, + "unique_identifier": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the logical port", + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID of the logical port", + }, + "bindings": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the binding", + }, + "segment_id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the segment", + }, + "segment_display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the segment", + }, + "port_security": { + Type: schema.TypeBool, + Computed: true, + Description: "If the port is secured", + }, + "address_detection": { + Type: schema.TypeBool, + Computed: true, + Description: "If the adapter address detection is enabled", + }, + "is_excluded_from_firewall": { + Type: schema.TypeBool, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID of the binding", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation time of the binding", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "Update time of the binding", + }, + }, + }, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation time of the logical port", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "Update time the logical port", + }, + }, + }, + }, + } + return res +} + +func dataSourceLogicalPortByUniqueIDSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "unique_identifier": { + Type: schema.TypeString, + Required: true, + Description: "Unique ID of the logical port to use", + }, + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the access group", + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the access group", + }, + "adapter_mac": { + Type: schema.TypeString, + Computed: true, + Description: "MAC address of the adapter", + }, + "address_detection": { + Type: schema.TypeBool, + Computed: true, + Description: "If the adapter address detection is enabled", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Description of the logical port", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the logical port", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "If the logical port is enabled", + }, + "hypervisor": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the hypervisor", + }, + "hypervisor_display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the hypervisor", + }, + "live_migration_target_hv": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "common": { + Type: schema.TypeString, + Computed: true, + Description: "Common status", + }, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + Description: "Status of the hypervisor", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the hypervisor", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the hypervisor", + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + Description: "Status of the hypervisor", + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + Description: "Sync time of the hypervisor", + }, + }, + }, + }, + }, + }, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID of the logical port", + }, + "bindings": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the binding", + }, + "segment_id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the segment", + }, + "segment_display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the segment", + }, + "port_security": { + Type: schema.TypeBool, + Computed: true, + Description: "If the port is secured", + }, + "address_detection": { + Type: schema.TypeBool, + Computed: true, + Description: "If the adapter address detection is enabled", + }, + "is_excluded_from_firewall": { + Type: schema.TypeBool, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID of the binding", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation time of the binding", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "Update time of the binding", + }, + }, + }, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation time of the logical port", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "Update time the logical port", + }, + } + return res +} + +func dataSourceLogicalPortSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "logical_port_id": { + Type: schema.TypeString, + Required: true, + Description: "ID of the logical port to use", + }, + "access_group_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the access group", + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the access group", + }, + "adapter_mac": { + Type: schema.TypeString, + Computed: true, + Description: "MAC address of the adapter", + }, + "address_detection": { + Type: schema.TypeBool, + Computed: true, + Description: "If the adapter address detection is enabled", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Description of the logical port", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the logical port", + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "If the logical port is enabled", + }, + "hypervisor": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the hypervisor", + }, + "hypervisor_display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the hypervisor", + }, + "live_migration_target_hv": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "common": { + Type: schema.TypeString, + Computed: true, + Description: "Common status", + }, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + Description: "Status of the hypervisor", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the hypervisor", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the hypervisor", + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + Description: "Status of the hypervisor", + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + Description: "Sync time of the hypervisor", + }, + }, + }, + }, + }, + }, + }, + "unique_identifier": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the logical port", + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID of the logical port", + }, + "bindings": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the binding", + }, + "segment_id": { + Type: schema.TypeString, + Computed: true, + Description: "Unique identifier of the segment", + }, + "segment_display_name": { + Type: schema.TypeString, + Computed: true, + Description: "Display name of the segment", + }, + "port_security": { + Type: schema.TypeBool, + Computed: true, + Description: "If the port is secured", + }, + "address_detection": { + Type: schema.TypeBool, + Computed: true, + Description: "If the adapter address detection is enabled", + }, + "is_excluded_from_firewall": { + Type: schema.TypeBool, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Version ID of the binding", + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation time of the binding", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "Update time of the binding", + }, + }, + }, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + Description: "Creation time of the logical port", + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + Description: "Update time the logical port", + }, + } + return res +} diff --git a/internal/service/sdn/logicalports/utility_logical_port.go b/internal/service/sdn/logicalports/utility_logical_port.go new file mode 100644 index 00000000..94025a44 --- /dev/null +++ b/internal/service/sdn/logicalports/utility_logical_port.go @@ -0,0 +1,30 @@ +package logicalports + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityLogicalPortCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*logicalports.LogicalPort, error) { + c := m.(*controller.ControllerCfg) + + req := logicalports.GetRequest{ + ID: d.Id(), + } + + if d.Id() != "" { + req.ID = d.Id() + } else { + req.ID = d.Get("logical_port_id").(string) + } + + logicalPort, err := c.SDN().LogicalPorts().Get(ctx, req) + if err != nil { + return nil, err + } + + return logicalPort, nil +} diff --git a/internal/service/sdn/logicalports/utility_logical_port_by_unique_id.go b/internal/service/sdn/logicalports/utility_logical_port_by_unique_id.go new file mode 100644 index 00000000..8a76385e --- /dev/null +++ b/internal/service/sdn/logicalports/utility_logical_port_by_unique_id.go @@ -0,0 +1,30 @@ +package logicalports + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityLogicalPortByUniqueIDCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*logicalports.LogicalPort, error) { + c := m.(*controller.ControllerCfg) + + req := logicalports.GetByUniqueIdentifierRequest{ + ID: d.Id(), + } + + if d.Id() != "" { + req.ID = d.Id() + } else { + req.ID = d.Get("unique_identifier").(string) + } + + logicalPort, err := c.SDN().LogicalPorts().GetByUniqueIdentifier(ctx, req) + if err != nil { + return nil, err + } + + return logicalPort, nil +} diff --git a/internal/service/sdn/logicalports/utility_logical_port_list.go b/internal/service/sdn/logicalports/utility_logical_port_list.go new file mode 100644 index 00000000..4fa39724 --- /dev/null +++ b/internal/service/sdn/logicalports/utility_logical_port_list.go @@ -0,0 +1,79 @@ +package logicalports + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilityLogicalPortListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*logicalports.LogicalPortsList, error) { + c := m.(*controller.ControllerCfg) + req := logicalports.ListRequest{} + + if accessGroupID, ok := d.GetOk("access_group_id"); ok { + req.AccessGroupID = accessGroupID.(string) + } + if segmentID, ok := d.GetOk("segment_id"); ok { + req.SegmentID = segmentID.(string) + } + if segmentDisplayName, ok := d.GetOk("segment_display_name"); ok { + req.SegmentDisplayName = segmentDisplayName.(string) + } + if externalNetworkID, ok := d.GetOk("external_network_id"); ok { + req.ExternalNetworkID = externalNetworkID.(string) + } + if uniqueID, ok := d.GetOk("unique_identifier"); ok { + req.UniqueIdentifier = uniqueID.(string) + } + if displayName, ok := d.GetOk("display_name"); ok { + req.DisplayName = displayName.(string) + } + if adapterMAC, ok := d.GetOk("adapter_mac"); ok { + req.AdapterMAC = adapterMAC.(string) + } + if hypervisor, ok := d.GetOk("hypervisor"); ok { + req.Hypervisor = hypervisor.(string) + } + if hypervisorDisplayName, ok := d.GetOk("hypervisor_display_name"); ok { + req.HypervisorDisplayName = hypervisorDisplayName.(string) + } + if liveMigrationTargetHV, ok := d.GetOk("live_migration_target_hv"); ok { + req.LiveMigrationTargetHv = liveMigrationTargetHV.(string) + } + if portSecurity, ok := d.GetOk("port_security"); ok { + req.PortSecurity = portSecurity.(bool) + } + if addressDetection, ok := d.GetOk("address_detection"); ok { + req.AddressDetection = addressDetection.(bool) + } + if enabled, ok := d.GetOk("enabled"); ok { + req.Enabled = enabled.(bool) + } + if createdFrom, ok := d.GetOk("created_from"); ok { + req.CreatedFrom = createdFrom.(string) + } + if createdTo, ok := d.GetOk("created_to"); ok { + req.CreatedTo = createdTo.(string) + } + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + if perPage, ok := d.GetOk("per_page"); ok { + req.PerPage = uint64(perPage.(int)) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if sortOrder, ok := d.GetOk("sort_order"); ok { + req.SortOrder = sortOrder.(string) + } + + logicalPortList, err := c.SDN().LogicalPorts().List(ctx, req) + if err != nil { + return nil, err + } + + return logicalPortList, nil +} diff --git a/internal/service/sdn/segments/decort_sdn_get_status.go b/internal/service/sdn/segments/decort_sdn_get_status.go new file mode 100644 index 00000000..4c62333d --- /dev/null +++ b/internal/service/sdn/segments/decort_sdn_get_status.go @@ -0,0 +1,70 @@ +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud +Orchestration Technology) with Terraform by Hashicorp. + +Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki +*/ + +package segments + +import ( + "context" + + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func dataSourceSegmentGetStatusRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + status, err := utilitySegmentGetStatusCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + if d.Id() == "" { + d.SetId(d.Get("segment_id").(string)) + } + + d.Set("status", status) + return nil +} + +func DataSourceSegmentGetStatus() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceSegmentGetStatusRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + Schema: dataSourceSegmentGetStatusSchemaMake(), + } +} diff --git a/internal/service/sdn/segments/decort_sdn_segment.go b/internal/service/sdn/segments/decort_sdn_segment.go new file mode 100644 index 00000000..fedb5ad1 --- /dev/null +++ b/internal/service/sdn/segments/decort_sdn_segment.go @@ -0,0 +1,67 @@ +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud +Orchestration Technology) with Terraform by Hashicorp. + +Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki +*/ + +package segments + +import ( + "context" + + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func dataSourceSegmentRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + segment, err := utilitySegmentCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenSegment(d, segment) + d.SetId(segment.ID) + return nil +} + +func DataSourceSegment() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceSegmentRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + Schema: dataSourceSegmentSchemaMake(), + } +} diff --git a/internal/service/sdn/segments/decort_sdn_segment_list.go b/internal/service/sdn/segments/decort_sdn_segment_list.go new file mode 100644 index 00000000..432e0bea --- /dev/null +++ b/internal/service/sdn/segments/decort_sdn_segment_list.go @@ -0,0 +1,70 @@ +/* +Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud +Orchestration Technology) with Terraform by Hashicorp. + +Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki +*/ + +package segments + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" +) + +func dataSourceSegmentListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + segmentList, err := utilitySegmentListCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + d.Set("items", flattenSegmentList(segmentList)) + + return nil +} + +func DataSourceSegmentList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceSegmentListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceSegmentListSchemaMake(), + } +} diff --git a/internal/service/sdn/segments/flattens.go b/internal/service/sdn/segments/flattens.go new file mode 100644 index 00000000..d1181193 --- /dev/null +++ b/internal/service/sdn/segments/flattens.go @@ -0,0 +1,117 @@ +package segments + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/segments" +) + +func flattenSegment(d *schema.ResourceData, segmentRecord *segments.SegmentResponse) { + d.Set("access_group_id", segmentRecord.AccessGroupID) + d.Set("access_group_name", segmentRecord.AccessGroupName) + d.Set("created_at", segmentRecord.CreatedAt.String()) + d.Set("description", segmentRecord.Description) + d.Set("dhcp_v4", flattenDHCPv4(segmentRecord.DHCPv4)) + d.Set("dhcp_v6", flattenDHCPv6(segmentRecord.DHCPv6)) + d.Set("display_name", segmentRecord.DisplayName) + d.Set("enabled", segmentRecord.Enabled) + d.Set("logical_ports_info", flattenEntity(segmentRecord.LogicalPortsInfo)) + d.Set("routers_info", flattenEntity(segmentRecord.RoutersInfo)) + d.Set("status", flattenStatus(segmentRecord.Status)) + d.Set("subnet_v4", segmentRecord.SubnetV4) + d.Set("subnet_v6", segmentRecord.SubnetV6) + d.Set("updated_at", segmentRecord.UpdatedAt.String()) + d.Set("version_id", segmentRecord.VersionID) +} + +func flattenStatus(s segments.Status) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "common": s.Common, + "hypervisors": flattenHypervisors(s.Hypervisors), + } + res = append(res, temp) + return res +} + +func flattenHypervisors(hv []segments.HypervisorStatus) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(hv)) + for _, v := range hv { + temp := map[string]interface{}{ + "status": v.Status, + "name": v.Name, + "display_name": v.DisplayName, + "hypervisor_status": v.HypervisorStatus, + "synced_at": v.SyncedAt.String(), + } + res = append(res, temp) + } + return res +} + +func flattenEntity(ei []segments.EntityInfo) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(ei)) + for _, v := range ei { + temp := map[string]interface{}{ + "display_name": v.DisplayName, + "id": v.ID, + } + res = append(res, temp) + } + return res +} + +func flattenDHCPv4(dchp segments.DHCPv4Config) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "dns": dchp.DNS, + "excluded_address_ranges": dchp.ExcludedAddressRanges, + "gateway": dchp.Gateway, + "id": dchp.ID, + "lease_time": dchp.LeaseTime, + "server_ip": dchp.ServerIP, + "server_mac": dchp.ServerMAC, + "enabled": dchp.Enabled, + } + res = append(res, temp) + return res +} + +func flattenDHCPv6(dchp segments.DHCPv6Config) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + temp := map[string]interface{}{ + "dns": dchp.DNS, + "address_prefix": dchp.AddressPrefix, + "id": dchp.ID, + "lease_time": dchp.LeaseTime, + "server_mac": dchp.ServerMAC, + "enabled": dchp.Enabled, + } + res = append(res, temp) + return res +} + +func flattenSegmentList(sl *segments.ListSegment) []map[string]interface{} { + res := make([]map[string]interface{}, 0, len(*sl)) + for _, v := range *sl { + temp := map[string]interface{}{ + "access_group_id": v.AccessGroupID, + "access_group_name": v.AccessGroupName, + "created_at": v.CreatedAt.String(), + "description": v.Description, + "dhcp_v4": flattenDHCPv4(v.DHCPv4), + "dhcp_v6": flattenDHCPv6(v.DHCPv6), + "display_name": v.DisplayName, + "enabled": v.Enabled, + "logical_ports_info": flattenEntity(v.LogicalPortsInfo), + "routers_info": flattenEntity(v.RoutersInfo), + "status": flattenStatus(v.Status), + "id": v.ID, + "subnet_v4": v.SubnetV4, + "subnet_v6": v.SubnetV6, + "updated_at": v.UpdatedAt.String(), + "version_id": v.VersionID, + } + res = append(res, temp) + } + return res +} diff --git a/internal/service/sdn/segments/resource_sdn_segment.go b/internal/service/sdn/segments/resource_sdn_segment.go new file mode 100644 index 00000000..53327f11 --- /dev/null +++ b/internal/service/sdn/segments/resource_sdn_segment.go @@ -0,0 +1,357 @@ +/* +Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. +Authors: +Petr Krutov, +Stanislav Solovev, + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud +Orchestration Technology) with Terraform by Hashicorp. + +Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki +*/ + +package segments + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/segments" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func resourceSegmentCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSegmentCreate: called segment with name %s", + d.Get("display_name").(string)) + c := m.(*controller.ControllerCfg) + + subnetV4, v4ok := d.GetOk("subnet_v4") + subnetV6, v6ok := d.GetOk("subnet_v6") + + if !v4ok && !v6ok { + return diag.Errorf("resourceSegmentCreate: either subnet_v4 or subnet_v6 must be specified") + } + + req := segments.CreateRequest{ + AccessGroupID: d.Get("access_group_id").(string), + Description: d.Get("description").(string), + DisplayName: d.Get("display_name").(string), + Enabled: d.Get("enabled").(bool), + } + + if v4ok { + req.SubnetV4 = subnetV4.(string) + } + + if v6ok { + req.SubnetV6 = subnetV6.(string) + } + + if dhcpV4, ok := d.GetOk("dhcp_v4"); ok { + dhcpV4 := dhcpV4.([]interface{})[0] + dhcpV4Map := dhcpV4.(map[string]interface{}) + dhcpReq := segments.DHCPv4ConfigRequest{ + Gateway: dhcpV4Map["gateway"].(string), + ServerIP: dhcpV4Map["server_ip"].(string), + Enabled: dhcpV4Map["enabled"].(bool), + } + serverMAC, sMAC := dhcpV4Map["server_mac"] + if sMAC { + dhcpReq.ServerMAC = serverMAC.(string) + } + + leaseTime, lTime := dhcpV4Map["lease_time"] + if lTime { + dhcpReq.LeaseTime = uint64(leaseTime.(int)) + } + + dns, dnsOk := dhcpV4Map["dns"] + if dnsOk { + dnsArr := make([]string, 0) + for _, v := range dns.([]interface{}) { + dnsArr = append(dnsArr, v.(string)) + } + dhcpReq.DNS = dnsArr + } + + adrRanges, earOK := dhcpV4Map["excluded_address_ranges"] + if earOK { + earArr := make([]string, 0) + for _, v := range adrRanges.([]interface{}) { + earArr = append(earArr, v.(string)) + } + dhcpReq.ExcludedAddressRanges = earArr + } + req.DHCPv4 = &dhcpReq + } + + if dhcpV6, ok := d.GetOk("dhcp_v6"); ok { + dhcpV6 := dhcpV6.([]interface{})[0] + dhcpV6Map := dhcpV6.(map[string]interface{}) + dhcpReq := segments.DHCPv6ConfigRequest{ + AddressPrefix: dhcpV6Map["address_prefix"].(string), + Enabled: dhcpV6Map["enabled"].(bool), + } + serverMAC, sMAC := dhcpV6Map["server_mac"] + if sMAC { + dhcpReq.ServerMAC = serverMAC.(string) + } + + leaseTime, lTime := dhcpV6Map["lease_time"] + if lTime { + dhcpReq.LeaseTime = uint64(leaseTime.(int)) + } + + dns, dnsOk := dhcpV6Map["dns"] + if dnsOk { + dnsArr := make([]string, 0) + for _, v := range dns.([]interface{}) { + dnsArr = append(dnsArr, v.(string)) + } + dhcpReq.DNS = dnsArr + } + req.DHCPv6 = &dhcpReq + } + + segmentData, err := c.SDN().Segments().Create(ctx, req) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + d.SetId(segmentData.ID) + d.Set("segment_id", segmentData.ID) + + return append(resourceSegmentRead(ctx, d, m)) +} + +func resourceSegmentRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSegmentRead: called segment with name %s", + d.Get("display_name").(string)) + + segmentData, err := utilitySegmentCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + flattenSegment(d, segmentData) + + return nil +} + +func resourceSegmentUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSegmentUpdate: called segment with name %s", + d.Get("display_name").(string)) + + c := m.(*controller.ControllerCfg) + + segmentData, err := utilitySegmentCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + subnetV4, v4ok := d.GetOk("subnet_v4") + subnetV6, v6ok := d.GetOk("subnet_v6") + + if !v4ok && !v6ok { + return diag.Errorf("resourceSegmentCreate: either subnet_v4 or subnet_v6 must be specified") + } + + needUpdate := false + + req := segments.UpdateRequest{ + SegmentID: segmentData.ID, + VersionID: segmentData.VersionID, + AccessGroupID: d.Get("access_group_id").(string), + Description: d.Get("description").(string), + DisplayName: d.Get("display_name").(string), + Enabled: d.Get("enabled").(bool), + } + + if d.HasChanges("access_group_id", "description", "display_name", "enabled") { + needUpdate = true + } + + if v4ok { + req.SubnetV4 = subnetV4.(string) + } + + if v6ok { + req.SubnetV6 = subnetV6.(string) + } + + if d.HasChange("dhcp_v4") { + if dhcpV4, ok := d.GetOk("dhcp_v4"); ok { + dhcpV4 := dhcpV4.([]interface{})[0] + dhcpV4Map := dhcpV4.(map[string]interface{}) + dhcpReq := segments.DHCPv4ConfigRequest{ + Gateway: dhcpV4Map["gateway"].(string), + ServerIP: dhcpV4Map["server_ip"].(string), + Enabled: dhcpV4Map["enabled"].(bool), + } + serverMAC, sMAC := dhcpV4Map["server_mac"] + if sMAC { + dhcpReq.ServerMAC = serverMAC.(string) + } + + leaseTime, lTime := dhcpV4Map["lease_time"] + if lTime { + dhcpReq.LeaseTime = uint64(leaseTime.(int)) + } + + dns, dnsOk := dhcpV4Map["dns"] + if dnsOk { + dnsArr := make([]string, 0) + for _, v := range dns.([]interface{}) { + dnsArr = append(dnsArr, v.(string)) + } + dhcpReq.DNS = dnsArr + } + + adrRanges, earOK := dhcpV4Map["excluded_address_ranges"] + if earOK { + earArr := make([]string, 0) + for _, v := range adrRanges.([]interface{}) { + earArr = append(earArr, v.(string)) + } + dhcpReq.ExcludedAddressRanges = earArr + } + req.DHCPv4 = &dhcpReq + } + + needUpdate = true + } + + if d.HasChange("dhcp_v6") { + if dhcpV6, ok := d.GetOk("dhcp_v6"); ok { + dhcpV6 := dhcpV6.([]interface{})[0] + dhcpV6Map := dhcpV6.(map[string]interface{}) + dhcpReq := segments.DHCPv6ConfigRequest{ + AddressPrefix: dhcpV6Map["address_prefix"].(string), + Enabled: dhcpV6Map["enabled"].(bool), + } + serverMAC, sMAC := dhcpV6Map["server_mac"] + if sMAC { + dhcpReq.ServerMAC = serverMAC.(string) + } + + leaseTime, lTime := dhcpV6Map["lease_time"] + if lTime { + dhcpReq.LeaseTime = uint64(leaseTime.(int)) + } + + dns, dnsOk := dhcpV6Map["dns"] + if dnsOk { + dnsArr := make([]string, 0) + for _, v := range dns.([]interface{}) { + dnsArr = append(dnsArr, v.(string)) + } + dhcpReq.DNS = dnsArr + } + req.DHCPv6 = &dhcpReq + } + needUpdate = true + } + + if needUpdate { + segmentData, err = c.SDN().Segments().Update(ctx, req) + } + + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + d.SetId(segmentData.ID) + d.Set("segment_id", segmentData.ID) + + return append(resourceSegmentRead(ctx, d, m)) +} + +func resourceSegmentDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Debugf("resourceSegmentUpdate: called segment with name %s", + d.Get("display_name").(string)) + + segmentData, err := utilitySegmentCheckPresence(ctx, d, m) + if err != nil { + d.SetId("") + return diag.FromErr(err) + } + + req := segments.DeleteRequest{ + SegmentID: segmentData.ID, + VersionID: segmentData.VersionID, + } + + if force, ok := d.GetOk("force"); ok { + req.Force = force.(bool) + } + + c := m.(*controller.ControllerCfg) + err = c.SDN().Segments().Delete(ctx, req) + if err != nil { + return diag.FromErr(err) + } + + d.SetId("") + + return nil +} + +func ResourceSegment() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + CreateContext: resourceSegmentCreate, + ReadContext: resourceSegmentRead, + UpdateContext: resourceSegmentUpdate, + DeleteContext: resourceSegmentDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + CustomizeDiff: func(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error { + changedKeys := diff.GetChangedKeysPrefix("") + if len(changedKeys) > 0 { + diff.SetNewComputed("updated_at") + diff.SetNewComputed("version_id") + } + return nil + }, + + Timeouts: &schema.ResourceTimeout{ + Create: &constants.Timeout600s, + Read: &constants.Timeout300s, + Update: &constants.Timeout600s, + Delete: &constants.Timeout900s, + Default: &constants.Timeout300s, + }, + + Schema: resourceSegmentSchemaMake(), + } +} diff --git a/internal/service/sdn/segments/schema.go b/internal/service/sdn/segments/schema.go new file mode 100644 index 00000000..c2794c9c --- /dev/null +++ b/internal/service/sdn/segments/schema.go @@ -0,0 +1,731 @@ +package segments + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func dataSourceSegmentSchemaMake() map[string]*schema.Schema { + sch := map[string]*schema.Schema{ + "segment_id": { + Type: schema.TypeString, + Required: true, + }, + "access_group_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "dhcp_v4": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "dns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "excluded_address_ranges": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "gateway": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + "lease_time": { + Type: schema.TypeInt, + Computed: true, + }, + "server_ip": { + Type: schema.TypeString, + Computed: true, + }, + "server_mac": { + Type: schema.TypeString, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + }, + }, + }, + "dhcp_v6": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "address_prefix": { + Type: schema.TypeString, + Computed: true, + }, + "dns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + "lease_time": { + Type: schema.TypeInt, + Computed: true, + }, + "server_mac": { + Type: schema.TypeString, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + }, + }, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + "logical_ports_info": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "routers_info": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "status": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "common": { + Type: schema.TypeString, + Computed: true, + }, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "subnet_v4": { + Type: schema.TypeString, + Computed: true, + }, + "subnet_v6": { + Type: schema.TypeString, + Computed: true, + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + }, + } + return sch +} + +func dataSourceSegmentListSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "page": { + Type: schema.TypeInt, + Optional: true, + Description: "Page number", + }, + "per_page": { + Type: schema.TypeInt, + Optional: true, + Description: "Items per page", + }, + "sort_by": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"display_name", "subnet", "created_at", "updated_at"}, false), + Description: "sort by one of supported fields", + }, + "sort_order": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"asc", "dec"}, false), + Description: "sort order", + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Description: "find by enabled status", + }, + "is_synced": { + Type: schema.TypeBool, + Optional: true, + Description: "does core currently believe that its data is synchronized with the data in the OVN?", + }, + "display_name": { + Type: schema.TypeString, + Optional: true, + Description: "find by display name", + }, + "subnet": { + Type: schema.TypeString, + Optional: true, + Description: "IPv4 or IPv6 subnet for the current segment", + }, + "access_group_id": { + Type: schema.TypeString, + Optional: true, + Description: "find by access group id", + }, + "created_from": { + Type: schema.TypeString, + Optional: true, + Description: "find by created date", + }, + "created_to": { + Type: schema.TypeString, + Optional: true, + Description: "find by created date", + }, + "updated_from": { + Type: schema.TypeString, + Optional: true, + Description: "find by updated date", + }, + "updated_to": { + Type: schema.TypeString, + Optional: true, + Description: "find by updated date", + }, + "items": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + }, + "access_group_id": { + Type: schema.TypeString, + Computed: true, + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "dhcp_v4": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "dns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "excluded_address_ranges": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "gateway": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + "lease_time": { + Type: schema.TypeInt, + Computed: true, + }, + "server_ip": { + Type: schema.TypeString, + Computed: true, + }, + "server_mac": { + Type: schema.TypeString, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + }, + }, + }, + "dhcp_v6": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "address_prefix": { + Type: schema.TypeString, + Computed: true, + }, + "dns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + "lease_time": { + Type: schema.TypeInt, + Computed: true, + }, + "server_mac": { + Type: schema.TypeString, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + }, + }, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + "logical_ports_info": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "routers_info": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "status": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "common": { + Type: schema.TypeString, + Computed: true, + }, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "subnet_v4": { + Type: schema.TypeString, + Computed: true, + }, + "subnet_v6": { + Type: schema.TypeString, + Computed: true, + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "entry_count": { + Type: schema.TypeInt, + Computed: true, + Description: "entry count", + }, + } + return res +} + +func dataSourceSegmentGetStatusSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "segment_id": { + Type: schema.TypeString, + Required: true, + }, + "version_id": { + Type: schema.TypeInt, + Optional: true, + }, + "detailed": { + Type: schema.TypeBool, + Optional: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + } + return res +} + +func resourceSegmentSchemaMake() map[string]*schema.Schema { + res := map[string]*schema.Schema{ + "access_group_id": { + Type: schema.TypeString, + Required: true, + }, + "description": { + Type: schema.TypeString, + Required: true, + }, + "display_name": { + Type: schema.TypeString, + Required: true, + }, + "enabled": { + Type: schema.TypeBool, + Required: true, + }, + "force": { + Type: schema.TypeBool, + Optional: true, + }, + "subnet_v4": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "subnet_v6": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "dhcp_v4": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "dns": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "excluded_address_ranges": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "gateway": { + Type: schema.TypeString, + Required: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + "lease_time": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "server_ip": { + Type: schema.TypeString, + Required: true, + }, + "server_mac": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Required: true, + }, + }, + }, + }, + "dhcp_v6": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "address_prefix": { + Type: schema.TypeString, + Required: true, + }, + "dns": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + "lease_time": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, + "server_mac": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Required: true, + }, + }, + }, + }, + "access_group_name": { + Type: schema.TypeString, + Computed: true, + }, + "created_at": { + Type: schema.TypeString, + Computed: true, + }, + "logical_ports_info": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "routers_info": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "status": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "common": { + Type: schema.TypeString, + Computed: true, + }, + "hypervisors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + }, + "hypervisor_status": { + Type: schema.TypeString, + Computed: true, + }, + "synced_at": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "updated_at": { + Type: schema.TypeString, + Computed: true, + }, + "version_id": { + Type: schema.TypeInt, + Computed: true, + }, + } + return res +} diff --git a/internal/service/sdn/segments/utility_segment.go b/internal/service/sdn/segments/utility_segment.go new file mode 100644 index 00000000..8d5d526a --- /dev/null +++ b/internal/service/sdn/segments/utility_segment.go @@ -0,0 +1,28 @@ +package segments + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/segments" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilitySegmentCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*segments.SegmentResponse, error) { + c := m.(*controller.ControllerCfg) + + req := segments.GetRequest{} + + if d.Id() != "" { + req.SegmentID = d.Id() + } else { + req.SegmentID = d.Get("segment_id").(string) + } + + segment, err := c.SDN().Segments().Get(ctx, req) + if err != nil { + return nil, err + } + + return segment, nil +} diff --git a/internal/service/sdn/segments/utility_segment_get_status.go b/internal/service/sdn/segments/utility_segment_get_status.go new file mode 100644 index 00000000..85b5f334 --- /dev/null +++ b/internal/service/sdn/segments/utility_segment_get_status.go @@ -0,0 +1,36 @@ +package segments + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/segments" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilitySegmentGetStatusCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) { + c := m.(*controller.ControllerCfg) + + req := segments.GetStatusRequest{} + + if d.Id() != "" { + req.SegmentID = d.Id() + } else { + req.SegmentID = d.Get("segment_id").(string) + } + + if version, ok := d.GetOk("version"); ok { + req.VersionID = uint64(version.(int)) + } + + if detailed, ok := d.GetOk("detailed"); ok { + req.Detailed = detailed.(bool) + } + + segment, err := c.SDN().Segments().GetStatus(ctx, req) + if err != nil { + return "", err + } + + return segment, nil +} diff --git a/internal/service/sdn/segments/utility_segment_list.go b/internal/service/sdn/segments/utility_segment_list.go new file mode 100644 index 00000000..b034b9d4 --- /dev/null +++ b/internal/service/sdn/segments/utility_segment_list.go @@ -0,0 +1,63 @@ +package segments + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + log "github.com/sirupsen/logrus" + "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/segments" + "repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller" +) + +func utilitySegmentListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*segments.ListSegment, error) { + c := m.(*controller.ControllerCfg) + req := segments.ListRequest{} + + if page, ok := d.GetOk("page"); ok { + req.Page = uint64(page.(int)) + } + if perPage, ok := d.GetOk("per_page"); ok { + req.PerPage = uint64(perPage.(int)) + } + if sortBy, ok := d.GetOk("sort_by"); ok { + req.SortBy = sortBy.(string) + } + if sortOrder, ok := d.GetOk("sort_order"); ok { + req.SortOrder = sortOrder.(string) + } + if enabled, ok := d.GetOk("enabled"); ok { + req.Enabled = enabled.(bool) + } + if isSynced, ok := d.GetOk("is_synced"); ok { + req.Enabled = isSynced.(bool) + } + if displayName, ok := d.GetOk("display_name"); ok { + req.DisplayName = displayName.(string) + } + if subnet, ok := d.GetOk("subnet"); ok { + req.Subnet = subnet.(string) + } + if accessGroupID, ok := d.GetOk("access_group_id"); ok { + req.AccessGroupID = accessGroupID.(string) + } + if createdFrom, ok := d.GetOk("created_from"); ok { + req.CreatedFrom = createdFrom.(string) + } + if createdTo, ok := d.GetOk("created_to"); ok { + req.CreatedTo = createdTo.(string) + } + if updatedFrom, ok := d.GetOk("updated_from"); ok { + req.UpdatedTo = updatedFrom.(string) + } + if updatedTo, ok := d.GetOk("updated_to"); ok { + req.UpdatedTo = updatedTo.(string) + } + + log.Debugf("utilitySegmentListCheckPresence") + segmentList, err := c.SDN().Segments().List(ctx, req) + if err != nil { + return nil, err + } + + return &segmentList, nil +} diff --git a/samples/README.md b/samples/README.md index 23d0bc66..bbfca80b 100644 --- a/samples/README.md +++ b/samples/README.md @@ -87,10 +87,14 @@ - rg_resource_consumption_get - rg_resource_consumption_list - rg_usage + - security_group + - security_group_list - sep_and_pools_available_list - snapshot_list - stack - stack_list + - storage_policy + - storage_policy_list - trunk - trunk_list - vfpool @@ -128,6 +132,7 @@ - lb_frontend_bind - pfw - resgroup + - security_group - snapshot - vins - vins_static_route @@ -227,6 +232,8 @@ - cb_rg_resource_consumption_get - cb_rg_resource_consumption_list - cb_rg_usage + - cb_security_group + - cb_security_group_list - cb_sep - cb_sep_and_pools_available_list - cb_sep_config @@ -236,6 +243,8 @@ - cb_sep_pool - cb_stack - cb_stack_list + - cb_storage_policy + - cb_storage_policy_list - cb_trunk - cb_trunk_list - cb_user @@ -277,9 +286,11 @@ - cb_lb_frontend_bind - cb_pcidevice - cb_rg + - cb_security_group - cb_sep - cb_sep_config - cb_sep_template + - cb_storage_policy - cb_trunk - cb_user - cb_vfpool @@ -287,6 +298,22 @@ - cb_vins_static_route - cb_virtual_image - cb_zone +- sdn + - data: + - sdn_access_group + - sdn_access_group_list + - sdn_access_group_user_list + - sdn_default_security_policy_list + - sdn_segment + - sdn_segment_get_status + - sdn_segment_list + - sdn_logical_port + - sdn_logical_port_get_by_unique_identifier + - sdn_logical_port_list + - resources: + - sdn_access_group + - sdn_segment + - sdn_logical_port ## Как пользоваться примерами diff --git a/samples/cloudapi/account/data_account_audits_list/main.tf b/samples/cloudapi/account/data_account_audits_list/main.tf index b698a0e2..1ea2d735 100644 --- a/samples/cloudapi/account/data_account_audits_list/main.tf +++ b/samples/cloudapi/account/data_account_audits_list/main.tf @@ -1,3 +1,8 @@ +/*Deprecated + +Данный datasource является **deprecated** и будет удалён в следующих версиях. Вместо него неоходимо использовать datasource **decort_audit_list**. +*/ + /* Пример использования Получение информации об использовании аккаунта diff --git a/samples/cloudapi/account/data_account_list/main.tf b/samples/cloudapi/account/data_account_list/main.tf index ea6d65b1..f349f2ab 100644 --- a/samples/cloudapi/account/data_account_list/main.tf +++ b/samples/cloudapi/account/data_account_list/main.tf @@ -64,6 +64,12 @@ data "decort_account_list" "al" { #тип - целое число #если не задан - выводятся все доступные данные #size = 3 + + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 } output "test" { diff --git a/samples/cloudapi/account/resource_account/main.tf b/samples/cloudapi/account/resource_account/main.tf index 6a69b11a..c8a60ad2 100644 --- a/samples/cloudapi/account/resource_account/main.tf +++ b/samples/cloudapi/account/resource_account/main.tf @@ -140,15 +140,11 @@ resource "decort_account" "a" { #по умолчанию - false #permanently = true - #зона по умольчанию для аккаунта + #зона по умолчанию для аккаунта #опциональный параметр - #тип - целое число + #тип - целое число + #используется при обновлении #default_zone_id = 1111 - - #управление зонами аккаунта - #опциональный параметр - #тип - массив целых чисел - #zone_ids = [1,2,3] } output "test" { diff --git a/samples/cloudapi/audit/data_audit_list/main.tf b/samples/cloudapi/audit/data_audit_list/main.tf new file mode 100644 index 00000000..eee0ec6d --- /dev/null +++ b/samples/cloudapi/audit/data_audit_list/main.tf @@ -0,0 +1,136 @@ +/* +Пример использования +Получение списка аудитов +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_audit_list" "al" { + #фильтр по аудитам с временной меткой после указанного значения + #опциональный параметр + #тип - целое число + #timestamp_at = 123456 + + #фильтр по аудитам с временной меткой до указанного значения + #опциональный параметр + #тип - целое число + #timestamp_to = 123456 + + #фильтр по пользователю (Mongo RegExp поддерживаются) + #опциональный параметр + #тип - строка + #user = "username" + + #фильтр по api endpoint (Mongo RegExp поддерживаются) + #опциональный параметр + #тип - строка + #call = "/restmachine/cloudbroker/audit/list" + + #фильтр по минимальному HTTP статус-коду + #опциональный параметр + #тип - целое число + #min_status_code = 200 + + #фильтр по максимальному HTTP статус-коду + #опциональный параметр + #тип - целое число + #max_status_code = 500 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #формат - "+поле" по возрастанию / "-поле" по убыванию + #тип - строка + #sort_by = "+name" + + #номер страницы для отображения + #опциональный параметр + #тип - целое число + #page = 2 + + #идентификатор запроса + #опциональный параметр + #тип - строка + #request_id = "35" + + #размер страницы + #опциональный параметр + #тип - целое число + #size = 3 + + #id ресурсной группы + #опциональный параметр + #тип - целое число + #resgroup_id = 3 + + #id компьюта + #опциональный параметр + #тип - целое число + #compute_id = 3 + + #id аккаунта + #опциональный параметр + #тип - целое число + #account_id = 3 + + #id vins + #опциональный параметр + #тип - целое число + #vins_id = 3 + + #id базовой службы + #опциональный параметр + #тип - целое число + #service_id = 3 + + #id k8s-кластера + #опциональный параметр + #тип - целое число + #k8s_id = 3 + + #id flipgroup + #опциональный параметр + #тип - целое число + #flipgroup_id = 3 + + #id балансировщика нагрузки + #опциональный параметр + #тип - целое число + #lb_id = 3 + + #id sep + #опциональный параметр + #тип - целое число + #sep_id = 3 + + #исключить ли строки + #опциональный параметр + #тип - булев + #default – false + #exclude_audit_lines = false + +} + +output "test" { + value = data.decort_audit_list.al +} diff --git a/samples/cloudapi/bservice/data_bservice_list/main.tf b/samples/cloudapi/bservice/data_bservice_list/main.tf index 6a0574a0..f1c6f5dc 100644 --- a/samples/cloudapi/bservice/data_bservice_list/main.tf +++ b/samples/cloudapi/bservice/data_bservice_list/main.tf @@ -86,6 +86,12 @@ data "decort_bservice_list" "bsl" { #тип - целое число #если не задан - выводятся все доступные данные #size = 3 + + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 } output "test" { diff --git a/samples/cloudapi/bservice/resource_bservice_group/main.tf b/samples/cloudapi/bservice/resource_bservice_group/main.tf index fa13e2ef..bc6a966c 100644 --- a/samples/cloudapi/bservice/resource_bservice_group/main.tf +++ b/samples/cloudapi/bservice/resource_bservice_group/main.tf @@ -78,11 +78,11 @@ resource "decort_bservice_group" "bsg" { #используется при создании image_id = 2222 - #драйвер + #id политики хранения #обязательный параметр - #тип - строка + #тип - целое число #используется при создании - driver = "KVM_X86" + storage_policy_id = 111 #id Storage endpoint provider #опциональный параметр @@ -171,13 +171,20 @@ resource "decort_bservice_group" "bsg" { #режим увеличения числа выч. мощностей #опциональный параметр + #возможные значения - "RELATIVE" и "ABSOLUTE" #тип - строка #используется в связке с comp_count при редактировании группы - #возможные варианты - RELATIVE и ABSOLUTE #используется при обновлении #по умолчанию - "RELATIVE" #mode = "RELATIVE" + #драйвер + #опциональный параметр + #возможные значения - "KVM_X86" + #тип - строка + #используется при создании + #по умолчанию - "KVM_X86" + #driver = "KVM_X86" } output "test" { diff --git a/samples/cloudapi/disk/data_disk_list/main.tf b/samples/cloudapi/disk/data_disk_list/main.tf index 4c9a128a..6045fdbf 100644 --- a/samples/cloudapi/disk/data_disk_list/main.tf +++ b/samples/cloudapi/disk/data_disk_list/main.tf @@ -93,6 +93,11 @@ data "decort_disk_list" "dl" { #опциональный параметр #тип - целое число #size = 1 + + #id политики хранения + #опциональный параметр + #тип - целое число + #storage_policy_id = 1 } output "test" { diff --git a/samples/cloudapi/disk/data_disk_list_unattached/main.tf b/samples/cloudapi/disk/data_disk_list_unattached/main.tf index 901b2a09..b56048c3 100644 --- a/samples/cloudapi/disk/data_disk_list_unattached/main.tf +++ b/samples/cloudapi/disk/data_disk_list_unattached/main.tf @@ -87,6 +87,11 @@ data "decort_disk_list_unattached" "dlu" { #тип - целое число #если не задан - выводятся все доступные данные #size = 3 + + #id политики хранения + #опциональный параметр + #тип - целое число + #storage_policy_id = 1 } output "test" { diff --git a/samples/cloudapi/disk/resource_disk/main.tf b/samples/cloudapi/disk/resource_disk/main.tf index 00d3ef49..184abb78 100644 --- a/samples/cloudapi/disk/resource_disk/main.tf +++ b/samples/cloudapi/disk/resource_disk/main.tf @@ -45,6 +45,12 @@ resource "decort_disk" "acl" { #используется при создании и обновлении size_max = 20 + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании и обновлении + storage_policy_id = 1 + #флаг для отключения диска от ВМ при удалении #опциональный параметр #тип - булев diff --git a/samples/cloudapi/extnet/data_extnet_list/main.tf b/samples/cloudapi/extnet/data_extnet_list/main.tf index 9ea584a1..06747e00 100644 --- a/samples/cloudapi/extnet/data_extnet_list/main.tf +++ b/samples/cloudapi/extnet/data_extnet_list/main.tf @@ -82,6 +82,12 @@ data "decort_extnet_list" "el" { #опциональный параметр #тип - строка #ovs_bridge = "key" + + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 } output "test" { diff --git a/samples/cloudapi/image/data_image_list/main.tf b/samples/cloudapi/image/data_image_list/main.tf index 5ba93e8d..42e36c99 100644 --- a/samples/cloudapi/image/data_image_list/main.tf +++ b/samples/cloudapi/image/data_image_list/main.tf @@ -110,6 +110,11 @@ data "decort_image_list" "il" { #опциональный параметр #тип - булев #enabled = true + + #фильтр по id политики хранения + #опциональный параметр + #тип - целое число + #storage_policy_id = 6 } output "test" { diff --git a/samples/cloudapi/image/resource_image/main.tf b/samples/cloudapi/image/resource_image/main.tf index c38294a3..e8c04ff7 100644 --- a/samples/cloudapi/image/resource_image/main.tf +++ b/samples/cloudapi/image/resource_image/main.tf @@ -35,13 +35,6 @@ resource "decort_image" "img" { #используется при создании и обновлении name = "image_name" - #драйверы компьютов, подходящие для данного образа - #обязательный параметр - #тип - массив строк - #возможные значения: "KVM_X86" - #используется при создании - drivers = ["KVM_X86"] - #тип образа (linux, windows и др.) #обязательный параметр #тип - строка @@ -66,6 +59,12 @@ resource "decort_image" "img" { #используется при создании account_id = 138 + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 111 + #поддержка hot resize #опциональный параметр #тип - булев diff --git a/samples/cloudapi/image/resource_image_virtual/main.tf b/samples/cloudapi/image/resource_image_virtual/main.tf index 5df18d4f..789b6c0f 100644 --- a/samples/cloudapi/image/resource_image_virtual/main.tf +++ b/samples/cloudapi/image/resource_image_virtual/main.tf @@ -43,6 +43,13 @@ resource "decort_image_virtual" "iv" { #используется при создании и обновлении link_to = 123 + #id аккаунта + #опциональный параметр + #значение по умолчанию - 0 + #тип - целое число + #используется при создании + #account_id = 123 + } output "sr" { diff --git a/samples/cloudapi/k8s/data_k8s_list/main.tf b/samples/cloudapi/k8s/data_k8s_list/main.tf index 70f805be..18ecd344 100644 --- a/samples/cloudapi/k8s/data_k8s_list/main.tf +++ b/samples/cloudapi/k8s/data_k8s_list/main.tf @@ -90,6 +90,12 @@ data "decort_k8s_list" "k8s_list" { #тип - целое число #если не задан - выводятся все доступные данные #size = 1 + + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 } output "output_k8s_list" { diff --git a/samples/cloudapi/k8s/resource_k8s/main.tf b/samples/cloudapi/k8s/resource_k8s/main.tf index a46464b3..37b33bcf 100644 --- a/samples/cloudapi/k8s/resource_k8s/main.tf +++ b/samples/cloudapi/k8s/resource_k8s/main.tf @@ -60,6 +60,12 @@ resource "decort_k8s" "cluster" { #используется при создании wg_name = "workers" + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 111 + #список labels для дефолтной worker группы #опциональный параметр #тип - массив строк diff --git a/samples/cloudapi/k8s/resource_k8s_cp/main.tf b/samples/cloudapi/k8s/resource_k8s_cp/main.tf index 21334581..1e7af125 100644 --- a/samples/cloudapi/k8s/resource_k8s_cp/main.tf +++ b/samples/cloudapi/k8s/resource_k8s_cp/main.tf @@ -56,6 +56,12 @@ resource "decort_k8s_cp" "cp" { #используется при создании rg_id = 1387 + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 111 + #кол-во ядер мастер-узла #опциональный параметр #тип - целое число diff --git a/samples/cloudapi/k8s/resource_k8s_wg/main.tf b/samples/cloudapi/k8s/resource_k8s_wg/main.tf index 62770b3a..544e3606 100644 --- a/samples/cloudapi/k8s/resource_k8s_wg/main.tf +++ b/samples/cloudapi/k8s/resource_k8s_wg/main.tf @@ -42,6 +42,12 @@ resource "decort_k8s_wg" "wg" { #используется при создании name = "workers-2" + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 111 + #количество worker node #опциональный параметр #тип - целое число diff --git a/samples/cloudapi/kvmvm/data_kvmvm_audits/main.tf b/samples/cloudapi/kvmvm/data_kvmvm_audits/main.tf index b8a627c8..1256a26b 100644 --- a/samples/cloudapi/kvmvm/data_kvmvm_audits/main.tf +++ b/samples/cloudapi/kvmvm/data_kvmvm_audits/main.tf @@ -1,3 +1,8 @@ +/*Deprecated + +Данный datasource является **deprecated** и будет удалён в следующих версиях. Вместо него неоходимо использовать datasource **decort_audit_list**. +*/ + /* Пример использования Получение данных об аудитах compute (виртуальной машине) @@ -31,8 +36,57 @@ data "decort_kvmvm_audits" "kvmvm_audits" { #обязательный параметр #тип - целое число compute_id = 10154 + + #найти все аудиты после определенного момента времени + #опциональный параметр + #тип - целое число + #timestamp_to = 11 + + #найти все аудиты до определенного момента времени + #опциональный параметр + #тип - целое число + #timestamp_at = 11 + + #фильтр по юзеру + #опциональный параметр + #тип - строка + #user = "user" + + #фильтр по эндпоинту апи + #опциональный параметр + #тип - строка + #call = "call" + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #формат - "+поле" по возрастанию / "-поле" по убыванию + #sort_by = "+name" + + #номер страницы для отображения + #опциональный параметр + #тип - целое число + #значение по умолчанию - 1 + #page = 1 + + #размер страницы + #опциональный параметр + #тип - целое число + #значение по умолчанию - 100 + #size = 100 + + #найти по минимальному коду статуса HTTP + #опциональный параметр + #тип - целое число + #min_status_code = 1 + + #найти по максимальному коду статуса HTTP + #опциональный параметр + #тип - целое число + #max_status_code = 140 + } output "output" { value = data.decort_kvmvm_audits.kvmvm_audits -} + } diff --git a/samples/cloudapi/kvmvm/data_kvmvm_list/main.tf b/samples/cloudapi/kvmvm/data_kvmvm_list/main.tf index ed091581..585f2030 100644 --- a/samples/cloudapi/kvmvm/data_kvmvm_list/main.tf +++ b/samples/cloudapi/kvmvm/data_kvmvm_list/main.tf @@ -101,6 +101,12 @@ data "decort_kvmvm_list" "compute_list" { #тип - целое число #если не задан - выводятся все доступные данные #size = 1 + + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 } diff --git a/samples/cloudapi/kvmvm/resource_kvmvm/main.tf b/samples/cloudapi/kvmvm/resource_kvmvm/main.tf index b48210ef..398198a4 100644 --- a/samples/cloudapi/kvmvm/resource_kvmvm/main.tf +++ b/samples/cloudapi/kvmvm/resource_kvmvm/main.tf @@ -43,13 +43,6 @@ resource "decort_kvmvm" "comp" { #используется при создании rg_id = 1111 - #тип драйвера для compute - #обязательный параметр - #тип - строка - #возможные значения: "KVM_X86" - #используется при создании - driver = "KVM_X86" - #число cpu #обязательный параметр #тип - целое число @@ -62,6 +55,12 @@ resource "decort_kvmvm" "comp" { #используется при создании и обновлении ram = 2048 + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 1 + #тип эмулируемой системы #опциональный параметр #тип - строка @@ -151,6 +150,11 @@ resource "decort_kvmvm" "comp" { #тип - строка #disk_name = "disk_name" + #id политики хранения + #обязательный для диска параметр + #тип - целое число + #storage_policy_id = 1 + #размер диска #обязательный для диска параметр #тип - целое число @@ -328,8 +332,44 @@ resource "decort_kvmvm" "comp" { #id sdn сети #используется только с сетями типа "SDN" #опциональный параметр - #тип - строка число + #тип - строка #sdn_interface_id = "f2d87a70-ea35-468d-8aef-bb1ecbe2e476" + + #включение сетевого интерфейса + #используется с сетями типа "VINS", "EXTNET", "DPDK", "SDN", "TRUNK" + #по умолчанию - true + #опциональный параметр + #тип - булев + #enabled = true + #} + + #группы безопасности + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #security groups { + #тип сети + #обязательный параметр + #тип - строка + #возможные значения - "VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK" (при выборе типа DPDK, необходимо указать hp_backed = true) + #net_type = "VINS" + + #id сети + #обязательный параметр + #при использовании SDN необходимо указать любое значение отличное от 0 + #тип - целое число + #net_id = 1234 + + #список id групп безопасности + #обязательный параметр + #тип - массив целых чисел + #security_groups = [12, 34] + + #флаг, указывающий, включены ли группы безопасности + #опциональный параметр + #тип - булев + #по умолчанию: false + #enable_secgroups = false #} #добавление и удаление тэгов @@ -539,6 +579,11 @@ resource "decort_kvmvm" "comp" { #используется при создании и обновлении #zone_id = 1111 + #версия ОС, установленная на ВМ + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #os_version = "name" } output "test" { diff --git a/samples/cloudapi/lb/data_lb_list/main.tf b/samples/cloudapi/lb/data_lb_list/main.tf index 0785edd8..1e31b320 100644 --- a/samples/cloudapi/lb/data_lb_list/main.tf +++ b/samples/cloudapi/lb/data_lb_list/main.tf @@ -92,6 +92,12 @@ data "decort_lb_list" "lbl" { #тип - целое число #если не задан - выводятся все доступные данные #size = 1 + + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 } output "test" { diff --git a/samples/cloudapi/rg/data_rg_audits/main.tf b/samples/cloudapi/rg/data_rg_audits/main.tf index 48140d3c..ed9916b6 100644 --- a/samples/cloudapi/rg/data_rg_audits/main.tf +++ b/samples/cloudapi/rg/data_rg_audits/main.tf @@ -1,3 +1,8 @@ +/*Deprecated + +Данный datasource является **deprecated** и будет удалён в следующих версиях. Вместо него неоходимо использовать datasource **decort_audit_list**. +*/ + /* Пример использования Получение информации о списке аудитов ресурсной группы diff --git a/samples/cloudapi/rg/resource_rg/main.tf b/samples/cloudapi/rg/resource_rg/main.tf index f804accc..0974d0db 100644 --- a/samples/cloudapi/rg/resource_rg/main.tf +++ b/samples/cloudapi/rg/resource_rg/main.tf @@ -198,6 +198,22 @@ resource "decort_resgroup" "rg" { #тип - строка #используется при создании #sdn_access_group_id = "64e039f4-3705-4feb-84ff-a59fbdb1ebfe" + + #добавление/удаление политик хранения + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #storage_policy { + #id политики хранения + #обязательный параметр + #тип - целое число + #id = 8 + #лимит ресурсов хранения в ГБ + #опциональный параметр + #тип - целое число + #значение по умолчанию - -1 + #limit = 111 + #} } diff --git a/samples/cloudapi/secgroup/data_security_group/main.tf b/samples/cloudapi/secgroup/data_security_group/main.tf new file mode 100644 index 00000000..b9ceb039 --- /dev/null +++ b/samples/cloudapi/secgroup/data_security_group/main.tf @@ -0,0 +1,38 @@ +/* +Пример использования +Получение информации о security group по её id +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_security_group" "sc" { + #идентификатор группы безопасности + #обязательный параметр + #тип - целое число + security_group_id = 1111 +} + +output "test" { + value = data.decort_security_group.sc +} \ No newline at end of file diff --git a/samples/cloudapi/secgroup/data_security_group_list/main.tf b/samples/cloudapi/secgroup/data_security_group_list/main.tf new file mode 100644 index 00000000..ba8e4963 --- /dev/null +++ b/samples/cloudapi/secgroup/data_security_group_list/main.tf @@ -0,0 +1,89 @@ +/* +Пример использования +Получение списка security group +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_security_group_list" "lsc" { + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #размер страницы результата + #опциональный параметр + #тип - целое число + #size = 1 + + #фильтр по id + #опциональный параметр + #тип - целое число + #by_id = 1111 + + #фильтр по id аккаунта + #опциональный параметр + #тип - целое число + #account_id = 1111 + + #фильтр по имени + #опциональный параметр + #тип - строка + #name = "security_group_name" + + #фильтр по описанию + #опциональный параметр + #тип - строка + #desc = "desc" + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #формат - "+поле" по возрастанию / "-поле" по убыванию + #sort_by = "+name" + + #фильтр по созданию до временной метки + #опциональный параметр + #тип - целое число + #created_min = 1111 + + #фильтр по созданию после временной метки + #опциональный параметр + #тип - целое число + #created_max = 1111 + + #фильтр по обновлению после временной метки + #опциональный параметр + #тип - целое число + #updated_min = 1111 + + #фильтр по обновлению до временной метки + #опциональный параметр + #тип - целое число + #updated_max = 1111 +} + +output "test" { + value = data.decort_security_group_list.lsc +} diff --git a/samples/cloudapi/secgroup/resource_security_group/main.tf b/samples/cloudapi/secgroup/resource_security_group/main.tf new file mode 100644 index 00000000..43e94ee5 --- /dev/null +++ b/samples/cloudapi/secgroup/resource_security_group/main.tf @@ -0,0 +1,96 @@ +/* +Пример использования +Ресурса группы безопасности: +1. Создание ресурса +2. Изменение ресурса +3. Удаление ресурса +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером + +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +resource "decort_security_group" "name" { + #id аккаунта, которому принадлежит группа безопасности + #обязательный параметр + #тип - целое число + #используется при создании + account_id = 111 + + #название группы безопасности + #обязательный параметр + #тип - строка + #используется при создании и обновлении + name = "NAME" + + #описание + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #description = "desc" + + #правила + #опциональный параметр + #тип - блок + #используется при обновлении + #rules { + #направление движения + #обязательный параметр + #тип - строка + #возможные значения - inbound, outbound + #direction = "inbound" + + #версия протокола IP + #опциональный параметр + #тип - строка + #возможные значения - IPv4, IPv6 + #значение по умолчанию - IPv4 + #ethertype = "IPv4" + + #сетевой протокол + #опциональный параметр + #тип - строка + #возможные значения - icmp, tcp, udp + #protocol = "icmp" + + #номер начального порта (для TCP/UDP) + #опциональный параметр + #тип - целое число + #port_range_min = 11 + + #номер конечного порта (для TCP/UDP) + #опциональный параметр + #тип - целое число + #port_range_max = 15 + + #удаленный IP префикс в нотации CIDR + #опциональный параметр + #тип - строка + #remote_ip_prefix = "192.168.1.0/24" + + #} +} + +output "test" { + value = decort_security_group.name +} \ No newline at end of file diff --git a/samples/cloudapi/stpolicy/data_storage_policy/main.tf b/samples/cloudapi/stpolicy/data_storage_policy/main.tf new file mode 100644 index 00000000..2fe60b01 --- /dev/null +++ b/samples/cloudapi/stpolicy/data_storage_policy/main.tf @@ -0,0 +1,38 @@ +/* +Пример использования +Получение информации о storage policy по её id +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_storage_policy" "sp" { + #идентификатор политики хранения + #обязательный параметр + #тип - целое число + storage_policy_id = 11111 +} + +output "test" { + value = data.decort_storage_policy.sp +} \ No newline at end of file diff --git a/samples/cloudapi/stpolicy/data_storage_policy_list/main.tf b/samples/cloudapi/stpolicy/data_storage_policy_list/main.tf new file mode 100644 index 00000000..d986dca9 --- /dev/null +++ b/samples/cloudapi/stpolicy/data_storage_policy_list/main.tf @@ -0,0 +1,94 @@ +/* +Пример использования +Получение списка storage policy +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_storage_policy_list" "lsp" { + #фильтр по id аккаунта + #опциональный параметр + #тип - целое число + #account_id = 1111 + + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #размер страницы результата + #опциональный параметр + #тип - целое число + #size = 1 + + #фильтр по id + #опциональный параметр + #тип - целое число + #by_id = 1111 + + #фильтр по имени + #опциональный параметр + #тип - строка + #name = "storage_policy_name" + + #фильтр по статусу + #опциональный параметр + #тип - строка + #status = "status" + + #фильтр по описанию + #опциональный параметр + #тип - строка + #desc = "desc" + + #фильтр по лимиту iops + #опциональный параметр + #тип - целое число + #limit_iops = 1111 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #формат - "+поле" по возрастанию / "-поле" по убыванию + #sort_by = "+name" + + #фильтр по id ресурсной группы + #опциональный параметр + #тип - целое число + #resgroup_id = 1111 + + #фильтр по id сеп + #опциональный параметр + #тип - целое число + #sep_id = 1111 + + #фильтр по имени пула + #опциональный параметр + #тип - строка + #pool_name = "name" +} + +output "test" { + value = data.decort_storage_policy_list.lsp +} \ No newline at end of file diff --git a/samples/cloudapi/trunk/data_trunk_list/main.tf b/samples/cloudapi/trunk/data_trunk_list/main.tf index a26ed75e..f2ab32fd 100644 --- a/samples/cloudapi/trunk/data_trunk_list/main.tf +++ b/samples/cloudapi/trunk/data_trunk_list/main.tf @@ -43,6 +43,11 @@ data "decort_trunk_list" "name" { #тип - строка #trunk_tags = "4095" + #сортировка по статусу + #опциональный параметр + #тип - строка + #status = "DISABLED" + #сортировка по одному из поддерживаемых полей #опциональный параметр #формат - "+поле" по возрастанию / "-поле" по убыванию diff --git a/samples/cloudapi/vins/data_vins_audits/main.tf b/samples/cloudapi/vins/data_vins_audits/main.tf index bd3c997a..e459c5c7 100644 --- a/samples/cloudapi/vins/data_vins_audits/main.tf +++ b/samples/cloudapi/vins/data_vins_audits/main.tf @@ -1,3 +1,8 @@ +/*Deprecated + +Данный datasource является **deprecated** и будет удалён в следующих версиях. Вместо него неоходимо использовать datasource **decort_audit_list**. +*/ + /* Пример использования Получение списка записей аудита для внутренней сети vins. diff --git a/samples/cloudapi/vins/data_vins_list/main.tf b/samples/cloudapi/vins/data_vins_list/main.tf index ebd0ce7d..712b809a 100644 --- a/samples/cloudapi/vins/data_vins_list/main.tf +++ b/samples/cloudapi/vins/data_vins_list/main.tf @@ -86,6 +86,12 @@ data "decort_vins_list" "vl" { #если не задан - выводятся все доступные данные #size = 1 + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 + } output "test" { diff --git a/samples/cloudbroker/account/data_account_audits_list/main.tf b/samples/cloudbroker/account/data_account_audits_list/main.tf index 83e69ecf..88c7ba83 100644 --- a/samples/cloudbroker/account/data_account_audits_list/main.tf +++ b/samples/cloudbroker/account/data_account_audits_list/main.tf @@ -1,3 +1,8 @@ +/*Deprecated + +Данный datasource является **deprecated** и будет удалён в следующих версиях. Вместо него неоходимо использовать datasource **decort_cb_audit_list**. +*/ + /* Пример использования Получение информации об использовании аккаунта diff --git a/samples/cloudbroker/account/data_account_list/main.tf b/samples/cloudbroker/account/data_account_list/main.tf index 324ba0c5..9f3532ac 100644 --- a/samples/cloudbroker/account/data_account_list/main.tf +++ b/samples/cloudbroker/account/data_account_list/main.tf @@ -65,6 +65,12 @@ data "decort_cb_account_list" "al" { #тип - целое число #size = 3 + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 + } output "test" { diff --git a/samples/cloudbroker/account/resource_account/main.tf b/samples/cloudbroker/account/resource_account/main.tf index 855a61b8..b99da82a 100644 --- a/samples/cloudbroker/account/resource_account/main.tf +++ b/samples/cloudbroker/account/resource_account/main.tf @@ -117,6 +117,23 @@ resource "decort_cb_account" "acc" { #gpu_units = 2 #} + #добавление/удаление политик хранения + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #storage_policy { + #id политики хранения + #обязательный параметр + #тип - целое число + #storage_policy_id = 111 + + #лимит ресурсов хранения в ГБ + #опциональный параметр + #тип - целое число + #значение "-1", если не ограничено + #limit = 111 + #} + #добавление/редактирование/удаление пользователей, к которым привязан аккаунт #опциональный параметр #тип - блок, кол-во таких блоков не ограничено diff --git a/samples/cloudbroker/audit/data_audit_list/main.tf b/samples/cloudbroker/audit/data_audit_list/main.tf index 9277a4e8..2cddd1d4 100644 --- a/samples/cloudbroker/audit/data_audit_list/main.tf +++ b/samples/cloudbroker/audit/data_audit_list/main.tf @@ -78,6 +78,62 @@ data "decort_cb_audit_list" "al" { #тип - целое число #size = 3 + #id ресурсной группы + #опциональный параметр + #тип - целое число + #resgroup_id = 3 + + #id компьюта + #опциональный параметр + #тип - целое число + #compute_id = 3 + + #id аккаунта + #опциональный параметр + #тип - целое число + #account_id = 3 + + #id vins + #опциональный параметр + #тип - целое число + #vins_id = 3 + + #id базовой службы + #опциональный параметр + #тип - целое число + #service_id = 3 + + #id k8s-кластера + #опциональный параметр + #тип - целое число + #k8s_id = 3 + + #id flipgroup + #опциональный параметр + #тип - целое число + #flipgroup_id = 3 + + #id балансировщика нагрузки + #опциональный параметр + #тип - целое число + #lb_id = 3 + + #id sep + #опциональный параметр + #тип - целое число + #sep_id = 3 + + #id узла + #опциональный параметр + #тип - целое число + #node_id = 3 + + #исключить ли строки + #опциональный параметр + #тип - булев + #default – false + #exclude_audit_lines = false + } output "test" { diff --git a/samples/cloudbroker/disk/data_disk_list/main.tf b/samples/cloudbroker/disk/data_disk_list/main.tf index b47372dd..e70b3ec9 100644 --- a/samples/cloudbroker/disk/data_disk_list/main.tf +++ b/samples/cloudbroker/disk/data_disk_list/main.tf @@ -94,6 +94,11 @@ data "decort_cb_disk_list" "dl" { #тип - целое число #size = 1 + #id политики хранения + #опциональный параметр + #тип - целое число + #storage_policy_id = 1 + } output "test" { diff --git a/samples/cloudbroker/disk/data_disk_list_unattached/main.tf b/samples/cloudbroker/disk/data_disk_list_unattached/main.tf index d8cf80fd..4c0d15dc 100644 --- a/samples/cloudbroker/disk/data_disk_list_unattached/main.tf +++ b/samples/cloudbroker/disk/data_disk_list_unattached/main.tf @@ -86,6 +86,10 @@ data "decort_cb_disk_list_unattached" "dlu" { #тип - целое число #size = 3 + #id политики хранения + #опциональный параметр + #тип - целое число + #storage_policy_id = 1 } output "test" { diff --git a/samples/cloudbroker/disk/resource_disk/main.tf b/samples/cloudbroker/disk/resource_disk/main.tf index b671c22f..59171bc9 100644 --- a/samples/cloudbroker/disk/resource_disk/main.tf +++ b/samples/cloudbroker/disk/resource_disk/main.tf @@ -49,19 +49,18 @@ resource "decort_cb_disk" "my_disk01" { #используется при создании и обновлении size_max = 20 + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании и обновлении + storage_policy_id = 1 + #описание диска #опциональный параметр #тип - строка #используется при создании и обновлении #desc = "description" - #max IOPS disk can perform - #опциональный параметр - #тип - целое число - #по умолчанию - 2000 - #используется при создании - #iops = 1 - #sep id #опциональный параметр #тип - целое число diff --git a/samples/cloudbroker/dpdknet/resource_dpdknet/main.tf b/samples/cloudbroker/dpdknet/resource_dpdknet/main.tf index d04c9450..1440cd39 100644 --- a/samples/cloudbroker/dpdknet/resource_dpdknet/main.tf +++ b/samples/cloudbroker/dpdknet/resource_dpdknet/main.tf @@ -79,6 +79,13 @@ resource "decort_cb_dpdknet" "dpdk" { #тип - булев #используется при создании и обновлении #enabled = true + + #флаг, указывающий, включены ли группы безопасности для этой сети + #опциональный параметр + #тип - булев + #используется при создании и обновлении + #значение по умолчанию - false + #enable_secgroups = false } output "test" { diff --git a/samples/cloudbroker/extnet/data_extnet_list/main.tf b/samples/cloudbroker/extnet/data_extnet_list/main.tf index a48392d9..fe28532a 100644 --- a/samples/cloudbroker/extnet/data_extnet_list/main.tf +++ b/samples/cloudbroker/extnet/data_extnet_list/main.tf @@ -78,6 +78,12 @@ data "decort_cb_extnet_list" "ex_list" { #тип - целое число #size = 1 + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 + } output "ex_out" { diff --git a/samples/cloudbroker/extnet/resource_extnet/main.tf b/samples/cloudbroker/extnet/resource_extnet/main.tf index b621c869..caf7b7ca 100644 --- a/samples/cloudbroker/extnet/resource_extnet/main.tf +++ b/samples/cloudbroker/extnet/resource_extnet/main.tf @@ -245,6 +245,13 @@ resource "decort_cb_extnet" "new_extnet" { #тип - целое число #используется при создании и обновлении #mtu = 1500 + + #флаг, указывающий, включены ли группы безопасности для этой сети + #опциональный параметр + #тип - булев + #используется при создании и обновлении + #значение по умолчанию - false + #enable_secgroups = false } output "extnet" { diff --git a/samples/cloudbroker/image/data_image_list/main.tf b/samples/cloudbroker/image/data_image_list/main.tf index e7ac636f..4112178d 100644 --- a/samples/cloudbroker/image/data_image_list/main.tf +++ b/samples/cloudbroker/image/data_image_list/main.tf @@ -110,6 +110,11 @@ data "decort_cb_image_list" "il" { #тип - булев #enabled = true + #фильтр по id политики хранения + #опциональный параметр + #тип - целое число + #storage_policy_id = 6 + } output "test" { diff --git a/samples/cloudbroker/image/data_image_list_stacks/main.tf b/samples/cloudbroker/image/data_image_list_stacks/main.tf index 914d667c..1d2c0443 100644 --- a/samples/cloudbroker/image/data_image_list_stacks/main.tf +++ b/samples/cloudbroker/image/data_image_list_stacks/main.tf @@ -1,3 +1,7 @@ +/* +Данный datasource является **deprecated** и будет удалён в следующих версиях. +*/ + /* Пример использования Получение списка stack по id образа diff --git a/samples/cloudbroker/image/resource_image/main.tf b/samples/cloudbroker/image/resource_image/main.tf index 73b3d1a0..331d9cd7 100644 --- a/samples/cloudbroker/image/resource_image/main.tf +++ b/samples/cloudbroker/image/resource_image/main.tf @@ -57,12 +57,11 @@ resource "decort_cb_image" "my_image" { #используется при создании image_type = "linux" - #драйвера + #id политики хранения #обязательный параметр - #тип - массив строк - #возможные варианты - ["KVM_X86"] + #тип - целое число #используется при создании - drivers = ["KVM_X86"] + storage_policy_id = 111 #поддержка hot resize #опциональный параметр @@ -135,13 +134,6 @@ resource "decort_cb_image" "my_image" { #используется при обновлении #computeci_id = 1 - #доступные стаки - #опциональный параметр - #тип - массив целых чисел - #для удаления всех доступных стаков, необходимо передать пустой массив - #используется при обновлении - #enabled_stacks = [9] - #наименование сетевого интерфейса для вашего компьютера с Linux #eth - встроенный, ens - pci слот #опциональный параметр diff --git a/samples/cloudbroker/image/resource_image_cdrom/main.tf b/samples/cloudbroker/image/resource_image_cdrom/main.tf index 85ff075e..d1a46e45 100644 --- a/samples/cloudbroker/image/resource_image_cdrom/main.tf +++ b/samples/cloudbroker/image/resource_image_cdrom/main.tf @@ -43,12 +43,11 @@ resource "decort_cb_cdrom_image" "my_image" { #используется при создании url = "https://colba.decs.online/index.php/s/G3H7AREngzeKGw2/download" - #драйвера - #опциональный параметр - #тип - массив строк - #возможные варианты - ["KVM_X86", "SVA_KVM_X86"], ["KVM_X86"], ["SVA_KVM_X86"] + #id политики хранения + #обязательный параметр + #тип - целое число #используется при создании - #drivers = ["KVM_X86", "SVA_KVM_X86"] + storage_policy_id = 111 #поддержка hot resize #опциональный параметр @@ -108,13 +107,6 @@ resource "decort_cb_cdrom_image" "my_image" { #используется при обновлении #computeci_id = 1 - #доступные стаки - #опциональный параметр - #тип - массив целых чисел - #для удаления всех доступных стаков, необходимо передать пустой массив - #используется при обновлении - #enabled_stacks = [9] - #является ли образ загрузочным #опциональный параметр #тип - булев diff --git a/samples/cloudbroker/image/resource_image_from_blank_compute/main.tf b/samples/cloudbroker/image/resource_image_from_blank_compute/main.tf index d4066088..7f900d99 100644 --- a/samples/cloudbroker/image/resource_image_from_blank_compute/main.tf +++ b/samples/cloudbroker/image/resource_image_from_blank_compute/main.tf @@ -119,13 +119,6 @@ resource "decort_cb_image_from_blank_compute" "my_image" { #используется при обновлении #computeci_id = 1 - #доступные стаки - #опциональный параметр - #тип - массив целых чисел - #для удаления всех доступных стаков, необходимо передать пустой массив - #используется при обновлении - #enabled_stacks = [9] - #наименование сетевого интерфейса для вашего компьютера с Linux #eth - встроенный, ens - pci слот #опциональный параметр diff --git a/samples/cloudbroker/image/resource_image_from_platform_disk/main.tf b/samples/cloudbroker/image/resource_image_from_platform_disk/main.tf index 4dc3e591..f0901b74 100644 --- a/samples/cloudbroker/image/resource_image_from_platform_disk/main.tf +++ b/samples/cloudbroker/image/resource_image_from_platform_disk/main.tf @@ -56,11 +56,6 @@ resource "decort_cb_image_from_platform_disk" "my_image" { #используется при создании image_type = "linux" - #драйверы компьютов, подходящие для данного образа - #обязательный параметр - #тип - массив строк - #используется при создании - drivers = ["KVM_X86"] #имя пользователя для образа #опциональный параметр @@ -124,13 +119,6 @@ resource "decort_cb_image_from_platform_disk" "my_image" { #используется при обновлении #computeci_id = 1 - #доступные стаки - #опциональный параметр - #тип - массив целых чисел - #для удаления всех доступных стаков, необходимо передать пустой массив - #используется при обновлении - #enabled_stacks = [9] - #наименование сетевого интерфейса для вашего компьютера с Linux #eth - встроенный, ens - pci слот #опциональный параметр diff --git a/samples/cloudbroker/image/resource_virtual_image/main.tf b/samples/cloudbroker/image/resource_virtual_image/main.tf index c31d8ea7..f4aefa26 100644 --- a/samples/cloudbroker/image/resource_virtual_image/main.tf +++ b/samples/cloudbroker/image/resource_virtual_image/main.tf @@ -46,7 +46,7 @@ resource "decort_cb_virtual_image" "my_image" { #id аккаунта владельца образа #опциональный параметр #тип данных - целое число - #используется при обновлении + #используется при создании и обновлении #account_id = 57252 #является ли образ загрузочным @@ -92,13 +92,6 @@ resource "decort_cb_virtual_image" "my_image" { #тип - целое число #используется при обновлении #computeci_id = 1 - - #доступные стаки - #опциональный параметр - #для удаления всех доступных стаков, необходимо передать пустой массив - #тип - массив целых чисел - #используется при обновлении - #enabled_stacks = [9] } diff --git a/samples/cloudbroker/k8s/data_k8ci_list/main.tf b/samples/cloudbroker/k8s/data_k8ci_list/main.tf index b2d936c1..353345f7 100644 --- a/samples/cloudbroker/k8s/data_k8ci_list/main.tf +++ b/samples/cloudbroker/k8s/data_k8ci_list/main.tf @@ -42,16 +42,6 @@ data "decort_cb_k8ci_list" "k8cil" { #тип - строка #status = "status" - #фильтр по worker driver - #опциональный параметр - #тип - строка - #worker_driver = "KVM_X86" - - #фильтр по master driver - #опциональный параметр - #тип - строка - #master_driver = "KVM_X86" - #фильтр по network plugin #опциональный параметр #тип - строка diff --git a/samples/cloudbroker/k8s/data_k8ci_list_deleted/main.tf b/samples/cloudbroker/k8s/data_k8ci_list_deleted/main.tf index f6dd1843..ab58eb29 100644 --- a/samples/cloudbroker/k8s/data_k8ci_list_deleted/main.tf +++ b/samples/cloudbroker/k8s/data_k8ci_list_deleted/main.tf @@ -37,16 +37,6 @@ data "decort_cb_k8ci_list_deleted" "k8cild" { #тип - строка #name = "name" - #фильтр по worker driver - #опциональный параметр - #тип - строка - #worker_driver = "KVM_X86" - - #фильтр по master driver - #опциональный параметр - #тип - строка - #master_driver = "KVM_X86" - #фильтр по network plugin #опциональный параметр #тип - строка diff --git a/samples/cloudbroker/k8s/data_k8s_list/main.tf b/samples/cloudbroker/k8s/data_k8s_list/main.tf index c5014f67..94721670 100644 --- a/samples/cloudbroker/k8s/data_k8s_list/main.tf +++ b/samples/cloudbroker/k8s/data_k8s_list/main.tf @@ -90,6 +90,12 @@ data "decort_cb_k8s_list" "k8s_list" { #тип - целое число #если не задан - выводятся все доступные данные #size = 1 + + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 } output "output_k8s_list" { diff --git a/samples/cloudbroker/k8s/resource_k8ci/main.tf b/samples/cloudbroker/k8s/resource_k8ci/main.tf index 74dfc42f..ed3f2c3c 100644 --- a/samples/cloudbroker/k8s/resource_k8ci/main.tf +++ b/samples/cloudbroker/k8s/resource_k8ci/main.tf @@ -43,18 +43,6 @@ resource "decort_cb_k8ci" "k8ci" { #используется при создании version = "1.1.1" - #тип master driver - #обязательный параметр - #тип - строка - #используется при создании - master_driver = "KVM_X86" - - #тип worker driver - #обязательный параметр - #тип - строка - #используется при создании - worker_driver = "KVM_X86" - #максимальное число master компьютов #обязательный параметр #тип - целое число diff --git a/samples/cloudbroker/k8s/resource_k8s_cp/main.tf b/samples/cloudbroker/k8s/resource_k8s_cp/main.tf index 36e55dda..fa58b6bc 100644 --- a/samples/cloudbroker/k8s/resource_k8s_cp/main.tf +++ b/samples/cloudbroker/k8s/resource_k8s_cp/main.tf @@ -57,6 +57,12 @@ resource "decort_cb_k8s_cp" "cp" { #используется при создании rg_id = 1387 + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 111 + #кол-во ядер мастер-узла #опциональный параметр #тип - целое число diff --git a/samples/cloudbroker/k8s/resource_k8s_wg/main.tf b/samples/cloudbroker/k8s/resource_k8s_wg/main.tf index c4c1ad12..e32c6213 100644 --- a/samples/cloudbroker/k8s/resource_k8s_wg/main.tf +++ b/samples/cloudbroker/k8s/resource_k8s_wg/main.tf @@ -40,6 +40,12 @@ resource "decort_cb_k8s_wg" "wg" { #используется при создании name = "workers-2" + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 111 + #количество worker node для создания #опциональный параметр #тип - целое число diff --git a/samples/cloudbroker/kvmvm/data_kvmvm_audits/main.tf b/samples/cloudbroker/kvmvm/data_kvmvm_audits/main.tf index 1084ae25..04e01861 100644 --- a/samples/cloudbroker/kvmvm/data_kvmvm_audits/main.tf +++ b/samples/cloudbroker/kvmvm/data_kvmvm_audits/main.tf @@ -1,3 +1,8 @@ +/*Deprecated + +Данный datasource является **deprecated** и будет удалён в следующих версиях. Вместо него неоходимо использовать datasource **decort_cb_audit_list**. +*/ + /* Пример использования Получение данных об аудитах compute (виртулаьной машине) @@ -31,6 +36,54 @@ data "decort_cb_kvmvm_audits" "kvmvm_audits" { #обязательный параметр #тип - целое число compute_id = 10154 + + #найти все аудиты после определенного момента времени + #опциональный параметр + #тип - целое число + #timestamp_to = 11 + + #найти все аудиты до определенного момента времени + #опциональный параметр + #тип - целое число + #timestamp_at = 11 + + #фильтр по юзеру + #опциональный параметр + #тип - строка + #user = "user" + + #фильтр по эндпоинту апи + #опциональный параметр + #тип - строка + #call = "call" + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #формат - "+поле" по возрастанию / "-поле" по убыванию + #sort_by = "+name" + + #номер страницы для отображения + #опциональный параметр + #тип - целое число + #значение по умолчанию - 1 + #page = 1 + + #размер страницы + #опциональный параметр + #тип - целое число + #значение по умолчанию - 100 + #size = 100 + + #найти по минимальному коду статуса HTTP + #опциональный параметр + #тип - целое число + #min_status_code = 1 + + #найти по максимальному коду статуса HTTP + #опциональный параметр + #тип - целое число + #max_status_code = 140 } diff --git a/samples/cloudbroker/kvmvm/data_kvmvm_list/main.tf b/samples/cloudbroker/kvmvm/data_kvmvm_list/main.tf index 39939acc..ec392940 100644 --- a/samples/cloudbroker/kvmvm/data_kvmvm_list/main.tf +++ b/samples/cloudbroker/kvmvm/data_kvmvm_list/main.tf @@ -76,11 +76,6 @@ data "decort_cb_kvmvm_list" "compute_list" { #тип - целое число #stack_id = 123 - #фильтр по image id - #опциональный параметр - #тип - целое число - #image_id = 123 - #фильтр по cd image id #опциональный параметр #тип - целое число @@ -121,6 +116,12 @@ data "decort_cb_kvmvm_list" "compute_list" { #тип - целое число #size = 1 + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 + } output "output" { diff --git a/samples/cloudbroker/kvmvm/resource_kvmvm/main.tf b/samples/cloudbroker/kvmvm/resource_kvmvm/main.tf index ebdd2be4..dd6c13fa 100644 --- a/samples/cloudbroker/kvmvm/resource_kvmvm/main.tf +++ b/samples/cloudbroker/kvmvm/resource_kvmvm/main.tf @@ -43,13 +43,6 @@ resource "decort_cb_kvmvm" "comp" { #используется при создании rg_id = 1111 - #тип драйвера для compute - #обязательный параметр - #тип - строка - #возможные значения: "KVM_X86" - #используется при создании - driver = "KVM_X86" - #число cpu #обязательный параметр #тип - целое число @@ -62,6 +55,12 @@ resource "decort_cb_kvmvm" "comp" { #используется при создании и обновлении ram = 2048 + #id политики хранения + #обязательный параметр + #тип - целое число + #используется при создании + storage_policy_id = 1 + #тип эмулируемой системы #опциональный параметр #тип - строка @@ -162,6 +161,11 @@ resource "decort_cb_kvmvm" "comp" { #тип - целое число #size = 5 + #id политики хранения + #обязательный для диска параметр + #тип - целое число + #storage_policy_id = 1 + #тип диска #опциональный параметр #тип - строка @@ -342,8 +346,44 @@ resource "decort_cb_kvmvm" "comp" { #id sdn сети #используется только с сетями типа "SDN" #опциональный параметр - #тип - строка число + #тип - строка #sdn_interface_id = "f2d87a70-ea35-468d-8aef-bb1ecbe2e476" + + #включение сетевого интерфейса + #используется с сетями типа "VINS", "EXTNET", "DPDK", "SDN", "TRUNK" + #по умолчанию - true + #опциональный параметр + #тип - булев + #enabled = true + #} + + #группы безопасности + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #security groups { + #тип сети + #обязательный параметр + #тип - строка + #возможные значения - "VINS", "EXTNET", "VFNIC", "DPDK", "SDN", "TRUNK" (при выборе типа DPDK, необходимо указать hp_backed = true) + #net_type = "VINS" + + #id сети + #обязательный параметр + #при использовании SDN необходимо указать любое значение отличное от 0 + #тип - целое число + #net_id = 1234 + + #список id групп безопасности + #обязательный параметр + #тип - массив целых чисел + #security_groups = [12, 34] + + #флаг, указывающий, включены ли группы безопасности + #опциональный параметр + #тип - булев + #по умолчанию: false + #enable_secgroups = false #} #добавление и удаление тэгов @@ -616,6 +656,12 @@ resource "decort_cb_kvmvm" "comp" { #тип - целое число #используется при создании и обновлении #zone_id = 1111 + + #версия ОС, установленная на ВМ + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #os_version = "name" } output "test" { diff --git a/samples/cloudbroker/lb/data_lb_list/main.tf b/samples/cloudbroker/lb/data_lb_list/main.tf index fa071de5..e2d3242b 100644 --- a/samples/cloudbroker/lb/data_lb_list/main.tf +++ b/samples/cloudbroker/lb/data_lb_list/main.tf @@ -91,6 +91,12 @@ data "decort_cb_lb_list" "lbl" { #тип - целое число #если не задан - выводятся все доступные данные #size = 1 + + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 } output "test" { diff --git a/samples/cloudbroker/rg/data_rg_audits/main.tf b/samples/cloudbroker/rg/data_rg_audits/main.tf index cbcffe3e..09a863c3 100644 --- a/samples/cloudbroker/rg/data_rg_audits/main.tf +++ b/samples/cloudbroker/rg/data_rg_audits/main.tf @@ -1,3 +1,8 @@ +/*Deprecated + +Данный datasource является **deprecated** и будет удалён в следующих версиях. Вместо него неоходимо использовать datasource **decort_cb_audit_list**. +*/ + /* Пример использования Получение информации о списке аудитов ресурсной группы diff --git a/samples/cloudbroker/rg/resource_rg/main.tf b/samples/cloudbroker/rg/resource_rg/main.tf index ef41dfb0..77a20144 100644 --- a/samples/cloudbroker/rg/resource_rg/main.tf +++ b/samples/cloudbroker/rg/resource_rg/main.tf @@ -210,6 +210,22 @@ resource "decort_cb_rg" "rg" { #тип - строка #используется при создании #sdn_access_group_id = "64e039f4-3705-4feb-84ff-a59fbdb1ebfe" + + #добавление/удаление политик хранения + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #storage_policy { + #id политики хранения + #обязательный параметр + #тип - целое число + #id = 8 + #лимит ресурсов хранения в ГБ + #опциональный параметр + #тип - целое число + #значение по умолчанию - -1 + #limit = 111 + #} } output "output" { diff --git a/samples/cloudbroker/secgroup/data_security_group/main.tf b/samples/cloudbroker/secgroup/data_security_group/main.tf new file mode 100644 index 00000000..8797f4cb --- /dev/null +++ b/samples/cloudbroker/secgroup/data_security_group/main.tf @@ -0,0 +1,38 @@ +/* +Пример использования +Получение списка security group +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_cb_security_group" "sc" { + #идентификатор группы безопасности + #обязательный параметр + #тип - целое число + security_group_id = 1111 +} + +output "test" { + value = data.decort_cb_security_group.sc +} \ No newline at end of file diff --git a/samples/cloudbroker/secgroup/data_security_group_list/main.tf b/samples/cloudbroker/secgroup/data_security_group_list/main.tf new file mode 100644 index 00000000..937808d7 --- /dev/null +++ b/samples/cloudbroker/secgroup/data_security_group_list/main.tf @@ -0,0 +1,89 @@ +/* +Пример использования +Получение списка security group +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_cb_security_group_list" "lsc" { + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #размер страницы результата + #опциональный параметр + #тип - целое число + #size = 1 + + #фильтр по id + #опциональный параметр + #тип - целое число + #by_id = 1111 + + #фильтр по имени + #опциональный параметр + #тип - строка + #name = "storage_policy_name" + + #фильтр по описанию + #опциональный параметр + #тип - строка + #desc = "desc" + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #формат - "+поле" по возрастанию / "-поле" по убыванию + #sort_by = "+name" + + #фильтр по id аккаунта + #опциональный параметр + #тип - целое число + #account_id = 1111 + + #фильтр по созданию до временной метки + #опциональный параметр + #тип - целое число + #created_min = 1111 + + #фильтр по созданию после временной метки + #опциональный параметр + #тип - целое число + #created_max = 1111 + + #фильтр по обновлению после временной метки + #опциональный параметр + #тип - целое число + #updated_min = 1111 + + #фильтр по обновлению до временной метки + #опциональный параметр + #тип - целое число + #updated_max = 1111 +} + +output "test" { + value = data.decort_cb_security_group_list.lsc +} diff --git a/samples/cloudbroker/secgroup/resource_security_group/main.tf b/samples/cloudbroker/secgroup/resource_security_group/main.tf new file mode 100644 index 00000000..d9aaaac6 --- /dev/null +++ b/samples/cloudbroker/secgroup/resource_security_group/main.tf @@ -0,0 +1,96 @@ +/* +Пример использования +Ресурса группы безопасности: +1. Создание ресурса +2. Изменение ресурса +3. Удаление ресурса +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером + +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +resource "decort_cb_security_group" "name" { + #id аккаунта, которому принадлежит группа безопасности + #обязательный параметр + #тип - целое число + #используется при создании + account_id = 111 + + #название группы безопасности + #обязательный параметр + #тип - строка + #используется при создании и обновлении + name = "NAME" + + #описание + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #description = "desc" + + #правила + #опциональный параметр + #тип - блок + #используется при обновлении + #rules { + #направление движения + #обязательный параметр + #тип - строка + #возможные значения - inbound, outbound + #direction = "inbound" + + #версия протокола IP + #опциональный параметр + #тип - строка + #возможные значения - IPv4, IPv6 + #значение по умолчанию - IPv4 + #ethertype = "IPv4" + + #сетевой протокол + #опциональный параметр + #тип - строка + #возможные значения - icmp, tcp, udp + #protocol = "icmp" + + #номер начального порта (для TCP/UDP) + #опциональный параметр + #тип - целое число + #port_range_min = 11 + + #номер конечного порта (для TCP/UDP) + #опциональный параметр + #тип - целое число + #port_range_max = 15 + + #удаленный IP префикс в нотации CIDR + #опциональный параметр + #тип - строка + #remote_ip_prefix = "192.168.1.0/24" + + #} +} + +output "test" { + value = decort_cb_security_group.name +} \ No newline at end of file diff --git a/samples/cloudbroker/sep/resource_sep/main.tf b/samples/cloudbroker/sep/resource_sep/main.tf index 6be60137..ca8342a3 100644 --- a/samples/cloudbroker/sep/resource_sep/main.tf +++ b/samples/cloudbroker/sep/resource_sep/main.tf @@ -63,12 +63,14 @@ resource "decort_cb_sep" "s" { #desc = "rrrrr" #предоставление/отключение доступа указанных аккаунтов к sep + #deprecated, поле скоро будет удалено #опциональный параметр #тип - массив целых чисел #используется при создании #account_ids = [12, 245] #предоставление/отключение доступа к пулу на sep + #deprecated, поле скоро будет удалено #опциональный параметр #тип - блок доступа к пулу #используется при создании diff --git a/samples/cloudbroker/stpolicy/data_storage_policy/main.tf b/samples/cloudbroker/stpolicy/data_storage_policy/main.tf new file mode 100644 index 00000000..df7442bf --- /dev/null +++ b/samples/cloudbroker/stpolicy/data_storage_policy/main.tf @@ -0,0 +1,38 @@ +/* +Пример использования +Получение информации о storage policy по её id +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_cb_storage_policy" "sp" { + #идентификатор политики хранения + #обязательный параметр + #тип - целое число + storage_policy_id = 1111 +} + +output "test" { + value = data.decort_cb_storage_policy.sp +} \ No newline at end of file diff --git a/samples/cloudbroker/stpolicy/data_storage_policy_list/main.tf b/samples/cloudbroker/stpolicy/data_storage_policy_list/main.tf new file mode 100644 index 00000000..1c0ed906 --- /dev/null +++ b/samples/cloudbroker/stpolicy/data_storage_policy_list/main.tf @@ -0,0 +1,95 @@ +/* +Пример использования +Получение списка storage policy +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_cb_storage_policy_list" "lsp" { + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #размер страницы результата + #опциональный параметр + #тип - целое число + #size = 1 + + #фильтр по id + #опциональный параметр + #тип - целое число + #by_id = 1111 + + #фильтр по имени + #опциональный параметр + #тип - строка + #name = "storage_policy_name" + + #фильтр по статусу + #опциональный параметр + #тип - строка + #status = "status" + + #фильтр по описанию + #опциональный параметр + #тип - строка + #desc = "desc" + + #фильтр по лимиту iops + #опциональный параметр + #тип - целое число + #limit_iops = 1111 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #формат - "+поле" по возрастанию / "-поле" по убыванию + #sort_by = "+name" + + #фильтр по id аккаунта + #опциональный параметр + #тип - целое число + #account_id = 1111 + + #фильтр по id ресурсной группы + #опциональный параметр + #тип - целое число + #resgroup_id = 1111 + + #фильтр по id сеп + #опциональный параметр + #тип - целое число + #sep_id = 1111 + + #фильтр по имени пула + #опциональный параметр + #тип - строка + #pool_name = "name" + +} + +output "test" { + value = data.decort_cb_storage_policy_list.lsp +} \ No newline at end of file diff --git a/samples/cloudbroker/stpolicy/resource_storage_policy/main.tf b/samples/cloudbroker/stpolicy/resource_storage_policy/main.tf new file mode 100644 index 00000000..654f9182 --- /dev/null +++ b/samples/cloudbroker/stpolicy/resource_storage_policy/main.tf @@ -0,0 +1,79 @@ +/* +Пример использования +Ресурса политики хранения: +1. Создание ресурса +2. Изменение ресурса +3. Удаление ресурса +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером + +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +resource "decort_cb_storage_policy" "name" { + #название политики хранения + #обязательный параметр + #тип - строка + #используется при создании и обновлении + name = "policy_name" + + #список доступов + #обязательный параметр + #тип - блок + #используется при создании и обновлении + access_seps_pools { + #id сепа + #обязательный параметр + #тип - целое число + sep_id = 11 + + #имя пула + #обязательный параметр + #тип - строка + pool_name = "name" + } + + #описание + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #description = "desc" + + #максимальный лимит iops для дисков, использующих данную политику хранения + #опциональный параметр + #тип - целое число + #значение по умолчанию - 2000 + #используется при создании и обновлении + #limit_iops = 2000 + + #сделать доступной или отключить + #опциональный параметр + #тип - булев + #значение по умолчанию - true + #используется при обновлении + #enabled = true +} + +output "test" { + value = decort_cb_storage_policy.name +} \ No newline at end of file diff --git a/samples/cloudbroker/trunk/data_trunk_list/main.tf b/samples/cloudbroker/trunk/data_trunk_list/main.tf index b98d98e1..37d127ff 100644 --- a/samples/cloudbroker/trunk/data_trunk_list/main.tf +++ b/samples/cloudbroker/trunk/data_trunk_list/main.tf @@ -33,6 +33,11 @@ data "decort_cb_trunk_list" "name" { #тип - строка #trunk_tags = "4095" + #сортировка по статусу + #опциональный параметр + #тип - строка + #status = "DISABLED" + #сортировка по одному из поддерживаемых полей #опциональный параметр #формат - "+поле" по возрастанию / "-поле" по убыванию diff --git a/samples/cloudbroker/vins/data_vins_audits/main.tf b/samples/cloudbroker/vins/data_vins_audits/main.tf index 11adc3bb..643816ec 100644 --- a/samples/cloudbroker/vins/data_vins_audits/main.tf +++ b/samples/cloudbroker/vins/data_vins_audits/main.tf @@ -1,3 +1,8 @@ +/*Deprecated + +Данный datasource является **deprecated** и будет удалён в следующих версиях. Вместо него неоходимо использовать datasource **decort_cb_audit_list**. +*/ + /* Пример использования Получение списка vins audits diff --git a/samples/cloudbroker/vins/data_vins_list/main.tf b/samples/cloudbroker/vins/data_vins_list/main.tf index 6786891c..7500d7cd 100644 --- a/samples/cloudbroker/vins/data_vins_list/main.tf +++ b/samples/cloudbroker/vins/data_vins_list/main.tf @@ -85,6 +85,12 @@ data "decort_cb_vins_list" "vl" { #тип - целое число #если не задан - выводятся все доступные данные #size = 1 + + #id зоны + #опциональный параметр + #тип - целое число + #значение по умолчанию - 0 + #zone_id = 11 } output "test" { diff --git a/samples/cloudbroker/vins/resource_vins/main.tf b/samples/cloudbroker/vins/resource_vins/main.tf index 14284f23..5240334f 100644 --- a/samples/cloudbroker/vins/resource_vins/main.tf +++ b/samples/cloudbroker/vins/resource_vins/main.tf @@ -248,6 +248,13 @@ resource "decort_cb_vins" "vins" { #используется при создании и обновлении #zone_id = 1111 + #флаг, указывающий, включены ли группы безопасности для этой сети + #опциональный параметр + #тип - булев + #используется при создании и обновлении + #значение по умолчанию - false + #enable_secgroups = false + } output "test" { diff --git a/samples/cloudbroker/zone/resource_zone/main.tf b/samples/cloudbroker/zone/resource_zone/main.tf index 5fb78b6b..b68b115e 100644 --- a/samples/cloudbroker/zone/resource_zone/main.tf +++ b/samples/cloudbroker/zone/resource_zone/main.tf @@ -52,7 +52,7 @@ resource "decort_cb_zone" "zone" { } output "test" { - value = decort_cb_zone.comp + value = decort_cb_zone.zone } diff --git a/samples/sdn/access_group/data_decort_sdn_access_group/main.tf b/samples/sdn/access_group/data_decort_sdn_access_group/main.tf new file mode 100644 index 00000000..622ee9ca --- /dev/null +++ b/samples/sdn/access_group/data_decort_sdn_access_group/main.tf @@ -0,0 +1,38 @@ +/* +Пример использования +Получение информации о access group по ее id +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_access_group" "name" { + #идентификатор группы доступа + #обязательный параметр + #тип - строка + access_group_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" +} + +output "test" { + value = data.decort_sdn_access_group.name +} + diff --git a/samples/sdn/access_group/data_decort_sdn_access_group_list/main.tf b/samples/sdn/access_group/data_decort_sdn_access_group_list/main.tf new file mode 100644 index 00000000..bc837d48 --- /dev/null +++ b/samples/sdn/access_group/data_decort_sdn_access_group_list/main.tf @@ -0,0 +1,82 @@ +/* +Пример использования +Получение информации о списке групп доступа +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_access_group_list" "name" { + #фильтр по включенной\выключенной группе + #опциональный параметр + #тип - булев + #enabled = false + + #фильтр по удаленной/не удаленной группе + #опциональный параметр + #тип - булев + #deleted = true + + #фильтр по отображаемому имени + #опциональный параметр + #тип - строка + #display_name = "name" + + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #количество результатов на странице + #опциональный параметр + #тип - целое число + #per_page = 2 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #возможные значения - display_name, created_at, updated_at, deleted_at, owner_login + #sort_by = "created_at" + + #порядок сортировки + #опциональный параметр + #тип - строка + #возможные значения - asc, desc + #sort_order = "asc" + + #фильтр по нижней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_from = "2023-01-01T00:00:00Z" + + #фильтр по верхней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_to = "2023-01-01T00:00:00Z" +} + +output "test" { + value = data.decort_sdn_access_group_list.name +} + diff --git a/samples/sdn/access_group/data_decort_sdn_access_group_user_list/main.tf b/samples/sdn/access_group/data_decort_sdn_access_group_user_list/main.tf new file mode 100644 index 00000000..d23d69e0 --- /dev/null +++ b/samples/sdn/access_group/data_decort_sdn_access_group_user_list/main.tf @@ -0,0 +1,122 @@ +/* +Пример использования +Получение информации о списке пользователей группы доступа +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_access_group_user_list" "name" { + #фильтр по идентификатору группы доступа + #обязательный параметр + #тип - строка + access_group_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #фильтр по глобальной роли + #опциональный параметр + #тип - строка + #global_role = "global_role" + + #фильтр по роли группы доступа + #опциональный параметр + #тип - строка + #access_group_role = "access_group_role" + + #фильтр по включению + #опциональный параметр + #тип - булев + #enabled = false + + #фильтр по удалению + #опциональный параметр + #тип - булев + #deleted = true + + #фильтр по отображаемому имени + #опциональный параметр + #тип - строка + #display_name = "name" + + #фильтр по логину пользователя + #опциональный параметр + #тип - строка + #login = "login" + + #кто создал пользователя + #опциональный параметр + #тип - строка + #created_by = "name" + + #кто обновил пользователя + #опциональный параметр + #тип - строка + #updated_by = "name" + + #кто удалил пользователя + #опциональный параметр + #тип - строка + #deleted_by = "name" + + #кто отключил пользователя + #опциональный параметр + #тип - строка + #disabled_by = "name" + + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #количество результатов на странице + #опциональный параметр + #тип - целое число + #per_page = 2 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #возможные значения - display_name, email, phone, created_at, updated_at, deleted_at + #sort_by = "created_at" + + #порядок сортировки + #опциональный параметр + #тип - строка + #возможные значения - asc, desc + #sort_order = "asc" + + #фильтр по нижней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_from = "2023-01-01T00:00:00Z" + + #фильтр по верхней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_to = "2023-01-01T00:00:00Z" +} + +output "test" { + value = data.decort_sdn_access_group_user_list.name +} + diff --git a/samples/sdn/access_group/resource_decort_sdn_access_group/main.tf b/samples/sdn/access_group/resource_decort_sdn_access_group/main.tf new file mode 100644 index 00000000..fcdc440a --- /dev/null +++ b/samples/sdn/access_group/resource_decort_sdn_access_group/main.tf @@ -0,0 +1,81 @@ +/* +Пример использования +Ресурс позволяет: +1. Создавать группу доступа +2. Изменять группу доступа +3. Удалять группу доступа +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + + +resource "decort_sdn_access_group" "name" { + #название группы + #обязательный параметр + #тип - строка + #используется при создании и обновлении + display_name = "name" + + #описание (комментарий) к группе + #обязательный параметр + #тип - строка + #используется при создании и обновлении + comment = "comment" + + #управление пользователями, входящими в группу + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #users { + #id назначаемой роли + #обязательный параметр + #тип - строка + #access_group_role_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #id пользователя + #обязательный параметр + #тип - строка + #user_id = "jkf-jfi-456fn5-kks" + #} + + #определение политик безопасности по умолчанию + #опциональный параметр + #может быть один или ни одного + #тип - блок + #используется при создании и обновлении ресурса + #default_security_policy { + #начальные права доступа + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #default_acl_drop = "default_acl_drop" + + #флаг сброса открытых сессий + #опциональный параметр + #тип - булев + #используется при создании и обновлении + #default_open_session_drop = true + #} +} + diff --git a/samples/sdn/default_security_policy/data_decort_sdn_default_security_policy_list/main.tf b/samples/sdn/default_security_policy/data_decort_sdn_default_security_policy_list/main.tf new file mode 100644 index 00000000..b5477938 --- /dev/null +++ b/samples/sdn/default_security_policy/data_decort_sdn_default_security_policy_list/main.tf @@ -0,0 +1,61 @@ +/* +Пример использования +Получение списка политик безопасности по умолчанию +*/ + +#Раскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_default_security_policy_list" "policy_list" { + #id группы доступа + #опциональный параметр + #тип - строка + #access_group_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #количество результатов на странице + #опциональный параметр + #тип - целое число + #per_page = 2 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #возможные значения - created_at, updated_at + #sort_by = "created_at" + + #порядок сортировки + #опциональный параметр + #тип - строка + #возможные значения - asc, desc + #sort_order = "asc" +} + +output "test" { + value = data.decort_sdn_default_security_policy_list.policy_list +} + diff --git a/samples/sdn/logicalports/data_logical_port/main.tf b/samples/sdn/logicalports/data_logical_port/main.tf new file mode 100644 index 00000000..8ae137f6 --- /dev/null +++ b/samples/sdn/logicalports/data_logical_port/main.tf @@ -0,0 +1,38 @@ +/* +Пример использования +Получение информации о логическом порте по его id +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + + +data "decort_sdn_logical_port" "test" { + #идентификатор логического порта + #обязательный параметр + #тип - строка + logical_port_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" +} + +output "test" { + value = data.decort_sdn_logical_port.test +} \ No newline at end of file diff --git a/samples/sdn/logicalports/data_logical_port_by_unique_id/main.tf b/samples/sdn/logicalports/data_logical_port_by_unique_id/main.tf new file mode 100644 index 00000000..fd539844 --- /dev/null +++ b/samples/sdn/logicalports/data_logical_port_by_unique_id/main.tf @@ -0,0 +1,38 @@ +/* +Пример использования +Получение информации о логическом порте по его уникальному идентификатору +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + + +data "decort_sdn_logical_port_get_by_unique_identifier" "test" { + #уникальный идентификатор логического порта + #обязательный параметр + #тип - строка + unique_identifier = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" +} + +output "test" { + value = data.decort_sdn_logical_port_get_by_unique_identifier.test +} \ No newline at end of file diff --git a/samples/sdn/logicalports/data_logical_port_list/main.tf b/samples/sdn/logicalports/data_logical_port_list/main.tf new file mode 100644 index 00000000..273e8032 --- /dev/null +++ b/samples/sdn/logicalports/data_logical_port_list/main.tf @@ -0,0 +1,131 @@ +/* +Пример использования +Получение информации о списке логических портов +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + + +data "decort_sdn_logical_port_list" "test" { + #фильтр по id группы доступа + #опциональный параметр + #тип - строка + #access_group_id = "b2c3d4e5-f6g7-8901-h2i3-j4k5l6m7n8o9" + + #фильтр по id сегмента + #опциональный параметр + #тип - строка + #segment_id = "b2c3d4e5-f6g7-8901-h2i3-j4k5l6m7n8o9" + + #фильтр по отображаемому имени сегмента + #опциональный параметр + #тип - строка + #segment_display_name = "name" + + #фильтр по id внешней сети + #опциональный параметр + #тип - строка + #external_network_id = "b2c3d4e5-f6g7-8901-h2i3-j4k5l6m7n8o9" + + #фильтр по уникальному идентификатору + #опциональный параметр + #тип - строка + #unique_identifier = "ca9d66f0-63b3-4709-98c7-5bc99247c4d3" + + #фильтр по отображаемому имени логического порта + #опциональный параметр + #тип - строка + #display_name = "name" + + #фильтр по MAC адресу адаптера + #опциональный параметр + #тип - строка + #adapter_mac = "12:1f:00:2f:00:14" + + #фильтр по гипервизору + #опциональный параметр + #тип - строка + #hypervisor = "hypervisor" + + #фильтр по отображаемому имени гипервизора + #опциональный параметр + #тип - строка + #hypervisor_display_name = "name" + + #фильтр по live migration target hv + #опциональный параметр + #тип - строка + #live_migration_target_hv = "" + + #фильтр по защите порта + #опциональный параметр + #тип - булев + #port_security = true + + #фильтр по обнаружению адреса + #опциональный параметр + #тип - булев + #address_detection = true + + #фильтр по включенному\выключенному порту + #опциональный параметр + #тип - булев + #enabled = false + + #фильтр по нижней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_from = "2023-01-01T00:00:00Z" + + #фильтр по верхней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_to = "2023-01-01T00:00:00Z" + + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #количество результатов на странице + #опциональный параметр + #тип - целое число + #per_page = 2 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #возможные значения - display_name, created_at, updated_at, deleted_at, segment_id, hypervisor, port_security, segment_display_name, primary_address, hypervisor_display_name + #sort_by = "created_at" + + #порядок сортировки + #опциональный параметр + #тип - строка + #возможные значения - asc, desc + #sort_order = "asc" +} +output "test" { + value = data.decort_sdn_logical_port_list.test +} \ No newline at end of file diff --git a/samples/sdn/logicalports/resource_logical_port/main.tf b/samples/sdn/logicalports/resource_logical_port/main.tf new file mode 100644 index 00000000..f19b1cfb --- /dev/null +++ b/samples/sdn/logicalports/resource_logical_port/main.tf @@ -0,0 +1,140 @@ +/* +Пример использования + +Функция позволяет: +- Создать логический порт +- Изменять логический порт +- Удалить логический порт +- Включить/отключить логический порт +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +resource "decort_sdn_logical_port" "test" { + #id группы доступа + #обязательный параметр + #тип - строка + #используется при создании + access_group_id = "b2c3d4e5-f6g7-8901-h2i3-j4k5l6m7n8o9" + + #описание логического порта + #обязательный параметр + #тип - строка + #используется при создании и обновлении + description = "description" + + #отображаемое имя логического порта + #обязательный параметр + #тип - строка + #используется при создании и обновлении + display_name = "name" + + #включенение порта + #обязательный параметр + #тип - булев + #используется при создании и обновлении + enabled = true + + #исключение порта из правил фаервола + #обязательный параметр + #тип - булев + #используется при создании и обновлении + is_excluded_from_firewall = true + + #связанный гипервизор + #обязательный параметр + #тип - строка + #используется при создании и обновлении + hypervisor = "hypervisor" + + #статус безопасности порта + #обязательный параметр + #тип - булев + #используется при создании и обновлении + port_security = true + + #id сегмента сети + #обязательный параметр + #тип - строка + #используется при создании и обновлении + segment_id = "a866059a-1900-4f7f-89c1-0f98880f5f4c" + + #MAC адрес адаптера + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #adapter_mac = "^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$ default: null" + + #уникальный идентификатор порта + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #используется при создании + #unique_identifier = "b2c3d4e5-f6g7-8901-h2i3-j4k5l6m7n8o9" + + #управление списком адресов логических портов + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #logical_port_addresses { + #ip + #обязательный параметр + #тип - строка + #ip = "192.168.0.1" + + #тип ip + #обязательный параметр + #тип - строка + #возможные значения - IPv4, IPv6 + #ip_type = IPv4" + + #обнаружен/не обнаружен + #опциональный параметр + #тип - булев + #значение по умолчанию - false + #is_discovered = false + + #является ли основным + #обязательный параметр + #тип - булев + #значение по умолчанию - true + #is_primary = true + + #MAC адрес + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #mac = "^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$" + #} + + #флаг принудительного удаления + #опциональный параметр + #тип - булев + #значение по умолчанию - null + #используется при обновлении + #force = true +} + +output "test" { + value = decort_sdn_logical_port.test +} diff --git a/samples/sdn/segments/data_segment/main.tf b/samples/sdn/segments/data_segment/main.tf new file mode 100644 index 00000000..53439c5d --- /dev/null +++ b/samples/sdn/segments/data_segment/main.tf @@ -0,0 +1,43 @@ +/* +Пример использования +Получение информации о segment по ее id +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_segment" "name" { + #идентификатор сегмента + #обязательный параметр + #тип - строка + segment_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #идентификатор группы доступа + #опциональный параметр + #тип - строка + #access_group_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" +} + +output "test" { + value = data.decort_sdn_segment.name +} + diff --git a/samples/sdn/segments/data_segment_get_status/main.tf b/samples/sdn/segments/data_segment_get_status/main.tf new file mode 100644 index 00000000..60f87607 --- /dev/null +++ b/samples/sdn/segments/data_segment_get_status/main.tf @@ -0,0 +1,48 @@ +/* +Пример использования +Получение информации о статусе segment по ее id +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_segment_get_status" "name" { + #идентификатор сегмента + #обязательный параметр + #тип - строка + segment_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #идентификатор версии + #опциональный параметр + #тип - целое число + #version_id = 378849 + + #подробный статус + #опциональный параметр + #тип - булев + #detailed = true +} + +output "test" { + value = data.decort_sdn_segment_get_status.name +} + diff --git a/samples/sdn/segments/data_segment_list/main.tf b/samples/sdn/segments/data_segment_list/main.tf new file mode 100644 index 00000000..abae4949 --- /dev/null +++ b/samples/sdn/segments/data_segment_list/main.tf @@ -0,0 +1,104 @@ +/* +Пример использования +Получение списка segments +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_sdn_segment_list" "name" { + #номер страницы результата + #опциональный параметр + #тип - целое число + #page = 1 + + #количество результатов на странице + #опциональный параметр + #тип - целое число + #per_page = 2 + + #сортировка по одному из поддерживаемых полей + #опциональный параметр + #тип - строка + #возможные значения - display_name, subnet, created_at, updated_at + #sort_by = "created_at" + + #порядок сортировки + #опциональный параметр + #тип - строка + #возможные значения - asc, desc + #sort_order = "asc" + + #фильтр по включенному/выключенному сегменту + #опциональный параметр + #тип - булев + #enabled = false + + #считает ли Core в настоящее время, что его данные синхронизированы с данными в OVN? + #опциональный параметр + #тип - булев + #is_synced = true + + #фильтр по отображаемому имени + #опциональный параметр + #тип - строка + #display_name = "name" + + #фильтр по подсети IPv4 или IPv6 + #опциональный параметр + #тип - строка + #subnet = "192.168.1.0/24" + + #фильтр по id группы доступа + #опциональный параметр + #тип - строка + #access_group_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #фильтр по нижней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_from = "2023-01-01T00:00:00Z" + + #фильтр по верхней границе даты создания + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #created_to = "2023-01-01T00:00:00Z" + + #фильтр по нижней границе даты обновления + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #updated_from = "2023-01-01T00:00:00Z" + + #фильтр по верхней границе даты обновления + #опциональный параметр + #тип - строка + #значение по умолчанию - null + #updated_to = "2023-01-01T00:00:00Z" +} + +output "test" { + value = data.decort_sdn_segment_list.name +} + diff --git a/samples/sdn/segments/resource_segment/main.tf b/samples/sdn/segments/resource_segment/main.tf new file mode 100644 index 00000000..f58fbdd9 --- /dev/null +++ b/samples/sdn/segments/resource_segment/main.tf @@ -0,0 +1,154 @@ +/* +Пример использования +Ресурс позволяет: +1. Создавать сегмент +2. Изменять сегмент +3. Удалять сегмент +*/ + +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером +/* +terraform { + required_providers { + decort = { + source = "basis/decort/decort" + version = "" + } + } +} +*/ + +provider "decort" { + authenticator = "decs3o" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +resource "decort_sdn_segment" "name" { + #id группы доступа + #обязательный параметр + #тип - строка + #используется при создании и обновлении + access_group_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" + + #описание сегмента + #обязательный параметр + #тип - строка + #используется при создании и обновлении + description = "description" + + #отображаемое имя сегмента + #обязательный параметр + #тип - строка + #используется при создании и обновлении + display_name = "name" + + #включение/отключение сегмента + #обязательный параметр + #тип - булев + #используется при создании и обновлении + enabled = true + + #подсеть IPv4 для текущего сегмента + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #subnet_v4 = "192.168.1.0/24" + + #подсеть IPv6 для текущего сегмента + #опциональный параметр + #тип - строка + #используется при создании и обновлении + #subnet_v6 = "aef0::/64" + + #настройка DHCPv4 + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #dhcp_v4 { + #DNS + #опциональный параметр + #тип - массив строк + #dns = ["198.51.100.42","8.8.8.8"] + + #исключенные диапазоны адресов + #опциональный параметр + #тип - массив строк + #excluded_address_ranges = ["198.51.100.42","8.8.8.8"] + + #шлюз + #обязательный параметр + #тип - строка + #gateway = "192.168.0.1" + + #время аренды + #опциональный параметр + #тип - целое число + #lease_time = 86400 + + #ip сервера + #обязательный параметр + #тип - строка + #server_ip = "192.168.1.100" + + #MAC адрес сервера + #опциональный параметр + #тип - строка + #server_mac = "^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$" + + #включение/отключение + #обязательный параметр + #тип - булев + #enabled = true + #} + + #настройка DHCPv6 + #опциональный параметр + #тип - блок + #используется при создании и обновлении + #dhcp_v6 { + #префикс IPv6 + #обязательный параметр + #тип - строка + #address_prefix = "2001:db8::/64" + + #DNS + #опциональный параметр + #тип - массив строк + #dns = ["198.51.100.42","8.8.8.8"] + + #время аренды + #опциональный параметр + #тип - целое число + #lease_time = 86400 + + #MAC адрес сервера + #опциональный параметр + #тип - строка + #server_mac = "^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$" + + #включение/отключение + #обязательный параметр + #тип - булев + #enabled = true + #} + + #флаг принудительного удаления + #опциональный параметр + #тип - булев + #значение по умолчанию - null + #используется при обновлении + #force = true +} + +output "test" { + value = decort_sdn_segment.name +} + + +