From 48cada2cf3044ab95519933946c481e2fc6dfe05 Mon Sep 17 00:00:00 2001 From: stSolo Date: Thu, 7 Jul 2022 18:46:39 +0300 Subject: [PATCH] Add locations --- README.md | 3 +- README_EN.md | 3 +- internal/provider/data_sources_map.go | 10 +- internal/provider/provider.go | 16 +- .../cloudapi/account/data_source_account.go | 6 - .../account/data_source_account_rg_list.go | 5 - .../cloudapi/account/resource_account.go | 5 - .../cloudapi/extnet/data_source_extnet.go | 2 - .../cloudapi/kvmvm/data_source_compute.go | 3 +- .../cloudapi/kvmvm/network_subresource.go | 4 +- .../cloudapi/kvmvm/resource_compute.go | 4 +- internal/service/cloudapi/locations/api.go | 23 +++ .../locations/data_source_locations_list.go | 155 ++++++++++++++++++ .../locations/data_source_locations_url.go | 81 +++++++++ internal/service/cloudapi/locations/models.go | 33 ++++ .../locations/utility_location_url.go | 61 +++++++ .../locations/utility_locations_list.go | 70 ++++++++ .../service/cloudapi/rg/data_source_rg.go | 1 - .../cloudapi/rg/data_source_rg_list.go | 1 - .../sep/data_source_sep_consumption.go | 1 - internal/statefuncs/statefuncs.go | 30 ++++ samples/README.md | 2 + samples/{ => cloudapi}/data_account/main.tf | 0 .../data_account_audits_list/main.tf | 0 .../data_account_computes_list/main.tf | 0 .../data_account_consumed_units/main.tf | 0 .../main.tf | 0 .../data_account_deleted_list/main.tf | 0 .../data_account_disks_list/main.tf | 0 .../data_account_flipgroups_list/main.tf | 0 .../{ => cloudapi}/data_account_list/main.tf | 0 .../data_account_reserved_units/main.tf | 0 .../data_account_rg_list/main.tf | 0 .../data_account_templates_list/main.tf | 0 .../data_account_vins_list/main.tf | 0 samples/{ => cloudapi}/data_bservice/main.tf | 0 .../data_bservice_deleted_list/main.tf | 0 .../data_bservice_group/main.tf | 0 .../{ => cloudapi}/data_bservice_list/main.tf | 0 .../data_bservice_snapshot_list/main.tf | 0 samples/{ => cloudapi}/data_disk_list/main.tf | 0 samples/{ => cloudapi}/data_extnet/main.tf | 0 .../data_extnet_computes_list/main.tf | 0 .../data_extnet_default/main.tf | 0 .../{ => cloudapi}/data_extnet_list/main.tf | 0 samples/cloudapi/data_location_url/main.tf | 0 samples/cloudapi/data_locations_list/main.tf | 45 +++++ samples/{ => cloudapi}/data_rg_list/main.tf | 0 .../{ => cloudapi}/data_snapshot_list/main.tf | 0 samples/{ => cloudapi}/data_vgpu/main.tf | 0 samples/{ => cloudapi}/data_vins_list/main.tf | 0 .../{ => cloudapi}/resource_account/main.tf | 0 .../{ => cloudapi}/resource_bservice/main.tf | 0 .../resource_bservice_group/main.tf | 0 samples/{ => cloudapi}/resource_k8s/main.tf | 0 .../{ => cloudapi}/resource_k8s_wg/main.tf | 0 .../{ => cloudapi}/resource_snapshot/main.tf | 0 samples/{ => cloudbroker}/data_grid/main.tf | 0 .../{ => cloudbroker}/data_grid_list/main.tf | 0 samples/{ => cloudbroker}/data_image/main.tf | 0 .../{ => cloudbroker}/data_image_list/main.tf | 0 .../data_image_list_stacks/main.tf | 0 .../{ => cloudbroker}/data_pcidevice/main.tf | 0 .../data_pcidevice_list/main.tf | 0 samples/{ => cloudbroker}/data_sep/main.tf | 0 .../{ => cloudbroker}/data_sep_config/main.tf | 0 .../data_sep_consumption/main.tf | 0 .../data_sep_disk_list/main.tf | 0 .../{ => cloudbroker}/data_sep_list/main.tf | 0 .../{ => cloudbroker}/data_sep_pool/main.tf | 0 .../resource_delete_images/main.tf | 0 .../{ => cloudbroker}/resource_image/main.tf | 0 .../resource_image_cdrom/main.tf | 0 .../resource_pcidevice/main.tf | 0 .../{ => cloudbroker}/resource_sep/main.tf | 0 .../resource_sep_config/main.tf | 0 .../resource_virtual_image/main.tf | 0 77 files changed, 520 insertions(+), 44 deletions(-) create mode 100644 internal/service/cloudapi/locations/api.go create mode 100644 internal/service/cloudapi/locations/data_source_locations_list.go create mode 100644 internal/service/cloudapi/locations/data_source_locations_url.go create mode 100644 internal/service/cloudapi/locations/models.go create mode 100644 internal/service/cloudapi/locations/utility_location_url.go create mode 100644 internal/service/cloudapi/locations/utility_locations_list.go create mode 100644 internal/statefuncs/statefuncs.go rename samples/{ => cloudapi}/data_account/main.tf (100%) rename samples/{ => cloudapi}/data_account_audits_list/main.tf (100%) rename samples/{ => cloudapi}/data_account_computes_list/main.tf (100%) rename samples/{ => cloudapi}/data_account_consumed_units/main.tf (100%) rename samples/{ => cloudapi}/data_account_consumed_units_by_type/main.tf (100%) rename samples/{ => cloudapi}/data_account_deleted_list/main.tf (100%) rename samples/{ => cloudapi}/data_account_disks_list/main.tf (100%) rename samples/{ => cloudapi}/data_account_flipgroups_list/main.tf (100%) rename samples/{ => cloudapi}/data_account_list/main.tf (100%) rename samples/{ => cloudapi}/data_account_reserved_units/main.tf (100%) rename samples/{ => cloudapi}/data_account_rg_list/main.tf (100%) rename samples/{ => cloudapi}/data_account_templates_list/main.tf (100%) rename samples/{ => cloudapi}/data_account_vins_list/main.tf (100%) rename samples/{ => cloudapi}/data_bservice/main.tf (100%) rename samples/{ => cloudapi}/data_bservice_deleted_list/main.tf (100%) rename samples/{ => cloudapi}/data_bservice_group/main.tf (100%) rename samples/{ => cloudapi}/data_bservice_list/main.tf (100%) rename samples/{ => cloudapi}/data_bservice_snapshot_list/main.tf (100%) rename samples/{ => cloudapi}/data_disk_list/main.tf (100%) rename samples/{ => cloudapi}/data_extnet/main.tf (100%) rename samples/{ => cloudapi}/data_extnet_computes_list/main.tf (100%) rename samples/{ => cloudapi}/data_extnet_default/main.tf (100%) rename samples/{ => cloudapi}/data_extnet_list/main.tf (100%) create mode 100644 samples/cloudapi/data_location_url/main.tf create mode 100644 samples/cloudapi/data_locations_list/main.tf rename samples/{ => cloudapi}/data_rg_list/main.tf (100%) rename samples/{ => cloudapi}/data_snapshot_list/main.tf (100%) rename samples/{ => cloudapi}/data_vgpu/main.tf (100%) rename samples/{ => cloudapi}/data_vins_list/main.tf (100%) rename samples/{ => cloudapi}/resource_account/main.tf (100%) rename samples/{ => cloudapi}/resource_bservice/main.tf (100%) rename samples/{ => cloudapi}/resource_bservice_group/main.tf (100%) rename samples/{ => cloudapi}/resource_k8s/main.tf (100%) rename samples/{ => cloudapi}/resource_k8s_wg/main.tf (100%) rename samples/{ => cloudapi}/resource_snapshot/main.tf (100%) rename samples/{ => cloudbroker}/data_grid/main.tf (100%) rename samples/{ => cloudbroker}/data_grid_list/main.tf (100%) rename samples/{ => cloudbroker}/data_image/main.tf (100%) rename samples/{ => cloudbroker}/data_image_list/main.tf (100%) rename samples/{ => cloudbroker}/data_image_list_stacks/main.tf (100%) rename samples/{ => cloudbroker}/data_pcidevice/main.tf (100%) rename samples/{ => cloudbroker}/data_pcidevice_list/main.tf (100%) rename samples/{ => cloudbroker}/data_sep/main.tf (100%) rename samples/{ => cloudbroker}/data_sep_config/main.tf (100%) rename samples/{ => cloudbroker}/data_sep_consumption/main.tf (100%) rename samples/{ => cloudbroker}/data_sep_disk_list/main.tf (100%) rename samples/{ => cloudbroker}/data_sep_list/main.tf (100%) rename samples/{ => cloudbroker}/data_sep_pool/main.tf (100%) rename samples/{ => cloudbroker}/resource_delete_images/main.tf (100%) rename samples/{ => cloudbroker}/resource_image/main.tf (100%) rename samples/{ => cloudbroker}/resource_image_cdrom/main.tf (100%) rename samples/{ => cloudbroker}/resource_pcidevice/main.tf (100%) rename samples/{ => cloudbroker}/resource_sep/main.tf (100%) rename samples/{ => cloudbroker}/resource_sep_config/main.tf (100%) rename samples/{ => cloudbroker}/resource_virtual_image/main.tf (100%) diff --git a/README.md b/README.md index 36687f1..566daaa 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,8 @@ Terraform provider для платформы Digital Energy Cloud Orchestration - Работа с sep, - Работа с vgpu, - Работа с bservice, -- Работа с extnets. +- Работа с extnets, +- Работа с locations. Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki diff --git a/README_EN.md b/README_EN.md index 396d151..d942b38 100644 --- a/README_EN.md +++ b/README_EN.md @@ -19,7 +19,8 @@ NOTE: provider rc-1.25 is designed for DECORT API 3.7.x. For older API versions - Work with sep, - Work with vgpu, - Work with bservice, -- Work with extnets. +- Work with extnets, +- Work with locations. This provider supports Import operations on pre-existing resources. diff --git a/internal/provider/data_sources_map.go b/internal/provider/data_sources_map.go index 70d715a..5897525 100644 --- a/internal/provider/data_sources_map.go +++ b/internal/provider/data_sources_map.go @@ -25,6 +25,8 @@ import ( "github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/bservice" "github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/disks" "github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/extnet" + "github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm" + "github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/locations" "github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/rg" "github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/snapshot" "github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/vgpu" @@ -37,9 +39,9 @@ import ( func NewDataSourcesMap() map[string]*schema.Resource { return map[string]*schema.Resource{ - "decort_account": account.DataSourceAccount(), - "decort_resgroup": rg.DataSourceResgroup(), - // "decort_kvmvm": dataSourceCompute(), + "decort_account": account.DataSourceAccount(), + "decort_resgroup": rg.DataSourceResgroup(), + "decort_kvmvm": kvmvm.DataSourceCompute(), "decort_image": image.DataSourceImage(), "decort_disk": disks.DataSourceDisk(), "decort_vins": vins.DataSourceVins(), @@ -81,6 +83,8 @@ func NewDataSourcesMap() map[string]*schema.Resource { "decort_extnet": extnet.DataSourceExtnet(), "decort_extnet_default": extnet.DataSourceExtnetDefault(), "decort_vins_list": vins.DataSourceVinsList(), + "decort_locations_list": locations.DataSourceLocationsList(), + "decort_location_url": locations.DataSourceLocationUrl(), // "decort_pfw": dataSourcePfw(), } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index c6c76f1..39fe2c3 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -21,7 +21,6 @@ package provider import ( "fmt" - "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -29,6 +28,7 @@ import ( "github.com/rudecs/terraform-provider-decort/internal/controller" "github.com/rudecs/terraform-provider-decort/internal/location" + "github.com/rudecs/terraform-provider-decort/internal/statefuncs" ) func Provider() *schema.Provider { @@ -37,7 +37,7 @@ func Provider() *schema.Provider { "authenticator": { Type: schema.TypeString, Required: true, - StateFunc: StateFuncToLower, + StateFunc: statefuncs.StateFuncToLower, ValidateFunc: validation.StringInSlice([]string{"oauth2", "legacy", "jwt"}, true), // ignore case while validating Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'oauth2', 'legacy' or 'jwt'.", }, @@ -45,7 +45,7 @@ func Provider() *schema.Provider { "oauth2_url": { Type: schema.TypeString, Optional: true, - StateFunc: StateFuncToLower, + StateFunc: statefuncs.StateFuncToLower, DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil), Description: "OAuth2 application URL in 'oauth2' authentication mode.", }, @@ -54,7 +54,7 @@ func Provider() *schema.Provider { Type: schema.TypeString, Required: true, ForceNew: true, - StateFunc: StateFuncToLower, + StateFunc: statefuncs.StateFuncToLower, Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.", }, @@ -109,14 +109,6 @@ func Provider() *schema.Provider { } } -func StateFuncToLower(argval interface{}) string { - return strings.ToLower(argval.(string)) -} - -func StateFuncToUpper(argval interface{}) string { - return strings.ToUpper(argval.(string)) -} - func providerConfigure(d *schema.ResourceData) (interface{}, error) { decsController, err := controller.ControllerConfigure(d) if err != nil { diff --git a/internal/service/cloudapi/account/data_source_account.go b/internal/service/cloudapi/account/data_source_account.go index f3b2c6e..233ac18 100644 --- a/internal/service/cloudapi/account/data_source_account.go +++ b/internal/service/cloudapi/account/data_source_account.go @@ -168,13 +168,11 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { "resources": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "current": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cpu": { @@ -207,7 +205,6 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { "reserved": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cpu": { @@ -330,7 +327,6 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { "resource_limits": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cu_c": { @@ -390,7 +386,6 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { "computes": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "started": { @@ -407,7 +402,6 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema { "machines": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "halted": { diff --git a/internal/service/cloudapi/account/data_source_account_rg_list.go b/internal/service/cloudapi/account/data_source_account_rg_list.go index c9b94d4..42fa18e 100644 --- a/internal/service/cloudapi/account/data_source_account_rg_list.go +++ b/internal/service/cloudapi/account/data_source_account_rg_list.go @@ -113,7 +113,6 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema { Schema: map[string]*schema.Schema{ "computes": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -131,13 +130,11 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema { "resources": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "consumed": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cpu": { @@ -171,7 +168,6 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema { "limits": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cpu": { @@ -204,7 +200,6 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema { "reserved": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cpu": { diff --git a/internal/service/cloudapi/account/resource_account.go b/internal/service/cloudapi/account/resource_account.go index 5aa57f7..3ad2939 100644 --- a/internal/service/cloudapi/account/resource_account.go +++ b/internal/service/cloudapi/account/resource_account.go @@ -559,13 +559,11 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { "resources": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "current": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cpu": { @@ -598,7 +596,6 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { "reserved": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cpu": { @@ -740,7 +737,6 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { "computes": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "started": { @@ -757,7 +753,6 @@ func resourceAccountSchemaMake() map[string]*schema.Schema { "machines": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "halted": { diff --git a/internal/service/cloudapi/extnet/data_source_extnet.go b/internal/service/cloudapi/extnet/data_source_extnet.go index 9744b3c..02de7cf 100644 --- a/internal/service/cloudapi/extnet/data_source_extnet.go +++ b/internal/service/cloudapi/extnet/data_source_extnet.go @@ -156,7 +156,6 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema { }, "default_qos": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -302,7 +301,6 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema { }, "vnfs": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/internal/service/cloudapi/kvmvm/data_source_compute.go b/internal/service/cloudapi/kvmvm/data_source_compute.go index 7738409..2ad51d1 100644 --- a/internal/service/cloudapi/kvmvm/data_source_compute.go +++ b/internal/service/cloudapi/kvmvm/data_source_compute.go @@ -207,7 +207,7 @@ func dataSourceComputeRead(ctx context.Context, d *schema.ResourceData, m interf return diag.FromErr(flattenCompute(d, compFacts)) } -func dataSourceCompute() *schema.Resource { +func DataSourceCompute() *schema.Resource { return &schema.Resource{ SchemaVersion: 1, @@ -302,7 +302,6 @@ func dataSourceCompute() *schema.Resource { "extra_disks": { Type: schema.TypeSet, Computed: true, - MaxItems: constants.MaxExtraDisksPerCompute, Elem: &schema.Schema{ Type: schema.TypeInt, }, diff --git a/internal/service/cloudapi/kvmvm/network_subresource.go b/internal/service/cloudapi/kvmvm/network_subresource.go index 4a0663f..9bc94b4 100644 --- a/internal/service/cloudapi/kvmvm/network_subresource.go +++ b/internal/service/cloudapi/kvmvm/network_subresource.go @@ -35,7 +35,7 @@ import ( "bytes" "hash/fnv" - "github.com/rudecs/terraform-provider-decort/internal/provider" + "github.com/rudecs/terraform-provider-decort/internal/statefuncs" log "github.com/sirupsen/logrus" "sort" @@ -125,7 +125,7 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema { "net_type": { Type: schema.TypeString, Required: true, - StateFunc: provider.StateFuncToUpper, + StateFunc: statefuncs.StateFuncToUpper, ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, false), // observe case while validating Description: "Type of the network for this connection, either EXTNET or VINS.", }, diff --git a/internal/service/cloudapi/kvmvm/resource_compute.go b/internal/service/cloudapi/kvmvm/resource_compute.go index 75dde35..941c16d 100644 --- a/internal/service/cloudapi/kvmvm/resource_compute.go +++ b/internal/service/cloudapi/kvmvm/resource_compute.go @@ -40,7 +40,7 @@ import ( "github.com/rudecs/terraform-provider-decort/internal/constants" "github.com/rudecs/terraform-provider-decort/internal/controller" - "github.com/rudecs/terraform-provider-decort/internal/provider" + "github.com/rudecs/terraform-provider-decort/internal/statefuncs" log "github.com/sirupsen/logrus" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -394,7 +394,7 @@ func ResourceCompute() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - StateFunc: provider.StateFuncToUpper, + StateFunc: statefuncs.StateFuncToUpper, ValidateFunc: validation.StringInSlice([]string{"KVM_X86", "KVM_PPC"}, false), // observe case while validating Description: "Hardware architecture of this compute instance.", }, diff --git a/internal/service/cloudapi/locations/api.go b/internal/service/cloudapi/locations/api.go new file mode 100644 index 0000000..7d26c35 --- /dev/null +++ b/internal/service/cloudapi/locations/api.go @@ -0,0 +1,23 @@ +package locations + +/* +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. +*/ + +const locationsListAPI = "/restmachine/cloudapi/locations/list" +const locationURLAPI = "/restmachine/cloudapi/locations/getUrl" diff --git a/internal/service/cloudapi/locations/data_source_locations_list.go b/internal/service/cloudapi/locations/data_source_locations_list.go new file mode 100644 index 0000000..3129015 --- /dev/null +++ b/internal/service/cloudapi/locations/data_source_locations_list.go @@ -0,0 +1,155 @@ +/* +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://github.com/rudecs/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://github.com/rudecs/terraform-provider-decort/wiki +*/ + +package locations + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/rudecs/terraform-provider-decort/internal/constants" + "github.com/rudecs/terraform-provider-decort/internal/flattens" +) + +func flattenLocationsList(ll LocationsList) []map[string]interface{} { + res := make([]map[string]interface{}, 0) + for _, l := range ll { + temp := map[string]interface{}{ + "ckey": l.CKey, + "meta": flattens.FlattenMeta(l.Meta), + "flag": l.Flag, + "gid": l.GridID, + "guid": l.Guid, + "id": l.Id, + "location_code": l.LocationCode, + "name": l.Name, + } + res = append(res, temp) + } + return res + +} + +func dataSourceLocationsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + locations, err := utilityLocationsListCheckPresence(ctx, d, m) + if err != nil { + + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + + d.Set("items", flattenLocationsList(locations)) + + return nil +} + +func dataSourceLocationsListSchemaMake() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "page": { + Type: schema.TypeInt, + Optional: true, + Description: "page number", + }, + "size": { + Type: schema.TypeInt, + Optional: true, + Description: "page size", + }, + "items": { + Type: schema.TypeList, + Computed: true, + Description: "Locations list", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ckey": { + Type: schema.TypeString, + Computed: true, + }, + "meta": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "flag": { + Type: schema.TypeString, + Computed: true, + }, + "gid": { + Type: schema.TypeInt, + Computed: true, + Description: "Grid id", + }, + "guid": { + Type: schema.TypeInt, + Computed: true, + Description: "location id", + }, + "id": { + Type: schema.TypeInt, + Computed: true, + Description: "location id", + }, + "location_code": { + Type: schema.TypeString, + Computed: true, + Description: "Location code", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Location name", + }, + }, + }, + }, + } +} + +func DataSourceLocationsList() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceLocationsListRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceLocationsListSchemaMake(), + } +} diff --git a/internal/service/cloudapi/locations/data_source_locations_url.go b/internal/service/cloudapi/locations/data_source_locations_url.go new file mode 100644 index 0000000..b06d55b --- /dev/null +++ b/internal/service/cloudapi/locations/data_source_locations_url.go @@ -0,0 +1,81 @@ +/* +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://github.com/rudecs/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://github.com/rudecs/terraform-provider-decort/wiki +*/ + +package locations + +import ( + "context" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/rudecs/terraform-provider-decort/internal/constants" +) + +func dataSourceLocationUrlRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + url, err := utilityLocationUrlCheckPresence(ctx, d, m) + if err != nil { + + return diag.FromErr(err) + } + + id := uuid.New() + d.SetId(id.String()) + + d.Set("url", url) + + return nil +} + +func dataSourceLocationUrlSchemaMake() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "url": { + Type: schema.TypeString, + Computed: true, + Description: "Location url", + }, + } +} + +func DataSourceLocationUrl() *schema.Resource { + return &schema.Resource{ + SchemaVersion: 1, + + ReadContext: dataSourceLocationUrlRead, + + Timeouts: &schema.ResourceTimeout{ + Read: &constants.Timeout30s, + Default: &constants.Timeout60s, + }, + + Schema: dataSourceLocationUrlSchemaMake(), + } +} diff --git a/internal/service/cloudapi/locations/models.go b/internal/service/cloudapi/locations/models.go new file mode 100644 index 0000000..a65104f --- /dev/null +++ b/internal/service/cloudapi/locations/models.go @@ -0,0 +1,33 @@ +/* +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. +*/ + +package locations + +type Location struct { + GridID int `json:"gid"` + Id int `json:"id"` + Guid int `json:"guid"` + LocationCode string `json:"locationCode"` + Name string `json:"name"` + Flag string `json:"flag"` + Meta []interface{} `json:"_meta"` + CKey string `json:"_ckey"` +} + +type LocationsList []Location diff --git a/internal/service/cloudapi/locations/utility_location_url.go b/internal/service/cloudapi/locations/utility_location_url.go new file mode 100644 index 0000000..9ebc215 --- /dev/null +++ b/internal/service/cloudapi/locations/utility_location_url.go @@ -0,0 +1,61 @@ +/* +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://github.com/rudecs/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://github.com/rudecs/terraform-provider-decort/wiki +*/ + +package locations + +import ( + "context" + "encoding/json" + "net/url" + + "github.com/rudecs/terraform-provider-decort/internal/controller" + log "github.com/sirupsen/logrus" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func utilityLocationUrlCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) { + c := m.(*controller.ControllerCfg) + + log.Debugf("utilityLocationUrlCheckPresence: load locations list") + locationUrl, err := c.DecortAPICall(ctx, "POST", locationURLAPI, &url.Values{}) + if err != nil { + return "", err + } + + location := new(string) + err = json.Unmarshal([]byte(locationUrl), location) + if err != nil { + return "", nil + } + + return *location, nil +} diff --git a/internal/service/cloudapi/locations/utility_locations_list.go b/internal/service/cloudapi/locations/utility_locations_list.go new file mode 100644 index 0000000..3454980 --- /dev/null +++ b/internal/service/cloudapi/locations/utility_locations_list.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://github.com/rudecs/terraform-provider-decort + +Please see README.md to learn where to place source code so that it +builds seamlessly. + +Documentation: https://github.com/rudecs/terraform-provider-decort/wiki +*/ + +package locations + +import ( + "context" + "encoding/json" + "net/url" + "strconv" + + "github.com/rudecs/terraform-provider-decort/internal/controller" + log "github.com/sirupsen/logrus" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func utilityLocationsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (LocationsList, error) { + locationsList := LocationsList{} + c := m.(*controller.ControllerCfg) + urlValues := &url.Values{} + + if page, ok := d.GetOk("page"); ok { + urlValues.Add("page", strconv.Itoa(page.(int))) + } + if size, ok := d.GetOk("size"); ok { + urlValues.Add("size", strconv.Itoa(size.(int))) + } + + log.Debugf("utilityLocationsListCheckPresence: load locations list") + locationsListRaw, err := c.DecortAPICall(ctx, "POST", locationsListAPI, urlValues) + if err != nil { + return nil, err + } + + err = json.Unmarshal([]byte(locationsListRaw), &locationsList) + if err != nil { + return nil, err + } + + return locationsList, nil +} diff --git a/internal/service/cloudapi/rg/data_source_rg.go b/internal/service/cloudapi/rg/data_source_rg.go index 09d42ec..3afdb69 100644 --- a/internal/service/cloudapi/rg/data_source_rg.go +++ b/internal/service/cloudapi/rg/data_source_rg.go @@ -147,7 +147,6 @@ func DataSourceResgroup() *schema.Resource { "quota": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: quotaRgSubresourceSchemaMake(), // this is a dictionary }, diff --git a/internal/service/cloudapi/rg/data_source_rg_list.go b/internal/service/cloudapi/rg/data_source_rg_list.go index b33c5ea..dfbb888 100644 --- a/internal/service/cloudapi/rg/data_source_rg_list.go +++ b/internal/service/cloudapi/rg/data_source_rg_list.go @@ -242,7 +242,6 @@ func dataSourceRgListSchemaMake() map[string]*schema.Schema { "resource_limits": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cu_c": { diff --git a/internal/service/cloudbroker/sep/data_source_sep_consumption.go b/internal/service/cloudbroker/sep/data_source_sep_consumption.go index 1b3406b..73e6d4e 100644 --- a/internal/service/cloudbroker/sep/data_source_sep_consumption.go +++ b/internal/service/cloudbroker/sep/data_source_sep_consumption.go @@ -141,7 +141,6 @@ func dataSourceSepConsumptionSchemaMake() map[string]*schema.Schema { "total": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "capacity_limit": { diff --git a/internal/statefuncs/statefuncs.go b/internal/statefuncs/statefuncs.go new file mode 100644 index 0000000..44c17af --- /dev/null +++ b/internal/statefuncs/statefuncs.go @@ -0,0 +1,30 @@ +/* +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. +*/ + +package statefuncs + +import "strings" + +func StateFuncToLower(argval interface{}) string { + return strings.ToLower(argval.(string)) +} + +func StateFuncToUpper(argval interface{}) string { + return strings.ToUpper(argval.(string)) +} diff --git a/samples/README.md b/samples/README.md index 1797fa0..d77ed3e 100644 --- a/samples/README.md +++ b/samples/README.md @@ -42,6 +42,8 @@ - extnet - extnet_computes_list - vins_list + - locations_list + - location_url - resources: - image - virtual_image diff --git a/samples/data_account/main.tf b/samples/cloudapi/data_account/main.tf similarity index 100% rename from samples/data_account/main.tf rename to samples/cloudapi/data_account/main.tf diff --git a/samples/data_account_audits_list/main.tf b/samples/cloudapi/data_account_audits_list/main.tf similarity index 100% rename from samples/data_account_audits_list/main.tf rename to samples/cloudapi/data_account_audits_list/main.tf diff --git a/samples/data_account_computes_list/main.tf b/samples/cloudapi/data_account_computes_list/main.tf similarity index 100% rename from samples/data_account_computes_list/main.tf rename to samples/cloudapi/data_account_computes_list/main.tf diff --git a/samples/data_account_consumed_units/main.tf b/samples/cloudapi/data_account_consumed_units/main.tf similarity index 100% rename from samples/data_account_consumed_units/main.tf rename to samples/cloudapi/data_account_consumed_units/main.tf diff --git a/samples/data_account_consumed_units_by_type/main.tf b/samples/cloudapi/data_account_consumed_units_by_type/main.tf similarity index 100% rename from samples/data_account_consumed_units_by_type/main.tf rename to samples/cloudapi/data_account_consumed_units_by_type/main.tf diff --git a/samples/data_account_deleted_list/main.tf b/samples/cloudapi/data_account_deleted_list/main.tf similarity index 100% rename from samples/data_account_deleted_list/main.tf rename to samples/cloudapi/data_account_deleted_list/main.tf diff --git a/samples/data_account_disks_list/main.tf b/samples/cloudapi/data_account_disks_list/main.tf similarity index 100% rename from samples/data_account_disks_list/main.tf rename to samples/cloudapi/data_account_disks_list/main.tf diff --git a/samples/data_account_flipgroups_list/main.tf b/samples/cloudapi/data_account_flipgroups_list/main.tf similarity index 100% rename from samples/data_account_flipgroups_list/main.tf rename to samples/cloudapi/data_account_flipgroups_list/main.tf diff --git a/samples/data_account_list/main.tf b/samples/cloudapi/data_account_list/main.tf similarity index 100% rename from samples/data_account_list/main.tf rename to samples/cloudapi/data_account_list/main.tf diff --git a/samples/data_account_reserved_units/main.tf b/samples/cloudapi/data_account_reserved_units/main.tf similarity index 100% rename from samples/data_account_reserved_units/main.tf rename to samples/cloudapi/data_account_reserved_units/main.tf diff --git a/samples/data_account_rg_list/main.tf b/samples/cloudapi/data_account_rg_list/main.tf similarity index 100% rename from samples/data_account_rg_list/main.tf rename to samples/cloudapi/data_account_rg_list/main.tf diff --git a/samples/data_account_templates_list/main.tf b/samples/cloudapi/data_account_templates_list/main.tf similarity index 100% rename from samples/data_account_templates_list/main.tf rename to samples/cloudapi/data_account_templates_list/main.tf diff --git a/samples/data_account_vins_list/main.tf b/samples/cloudapi/data_account_vins_list/main.tf similarity index 100% rename from samples/data_account_vins_list/main.tf rename to samples/cloudapi/data_account_vins_list/main.tf diff --git a/samples/data_bservice/main.tf b/samples/cloudapi/data_bservice/main.tf similarity index 100% rename from samples/data_bservice/main.tf rename to samples/cloudapi/data_bservice/main.tf diff --git a/samples/data_bservice_deleted_list/main.tf b/samples/cloudapi/data_bservice_deleted_list/main.tf similarity index 100% rename from samples/data_bservice_deleted_list/main.tf rename to samples/cloudapi/data_bservice_deleted_list/main.tf diff --git a/samples/data_bservice_group/main.tf b/samples/cloudapi/data_bservice_group/main.tf similarity index 100% rename from samples/data_bservice_group/main.tf rename to samples/cloudapi/data_bservice_group/main.tf diff --git a/samples/data_bservice_list/main.tf b/samples/cloudapi/data_bservice_list/main.tf similarity index 100% rename from samples/data_bservice_list/main.tf rename to samples/cloudapi/data_bservice_list/main.tf diff --git a/samples/data_bservice_snapshot_list/main.tf b/samples/cloudapi/data_bservice_snapshot_list/main.tf similarity index 100% rename from samples/data_bservice_snapshot_list/main.tf rename to samples/cloudapi/data_bservice_snapshot_list/main.tf diff --git a/samples/data_disk_list/main.tf b/samples/cloudapi/data_disk_list/main.tf similarity index 100% rename from samples/data_disk_list/main.tf rename to samples/cloudapi/data_disk_list/main.tf diff --git a/samples/data_extnet/main.tf b/samples/cloudapi/data_extnet/main.tf similarity index 100% rename from samples/data_extnet/main.tf rename to samples/cloudapi/data_extnet/main.tf diff --git a/samples/data_extnet_computes_list/main.tf b/samples/cloudapi/data_extnet_computes_list/main.tf similarity index 100% rename from samples/data_extnet_computes_list/main.tf rename to samples/cloudapi/data_extnet_computes_list/main.tf diff --git a/samples/data_extnet_default/main.tf b/samples/cloudapi/data_extnet_default/main.tf similarity index 100% rename from samples/data_extnet_default/main.tf rename to samples/cloudapi/data_extnet_default/main.tf diff --git a/samples/data_extnet_list/main.tf b/samples/cloudapi/data_extnet_list/main.tf similarity index 100% rename from samples/data_extnet_list/main.tf rename to samples/cloudapi/data_extnet_list/main.tf diff --git a/samples/cloudapi/data_location_url/main.tf b/samples/cloudapi/data_location_url/main.tf new file mode 100644 index 0000000..e69de29 diff --git a/samples/cloudapi/data_locations_list/main.tf b/samples/cloudapi/data_locations_list/main.tf new file mode 100644 index 0000000..45c1fca --- /dev/null +++ b/samples/cloudapi/data_locations_list/main.tf @@ -0,0 +1,45 @@ +/* +Пример использования +Получение информации о доступных локациях +Ресурс позволяет: +Используется для получения информации о grid_id для создания ресурсов +*/ +#Расскомментируйте этот код, +#и внесите необходимые правки в версию и путь, +#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером + +/* +terraform { + required_providers { + decort = { + version = "1.1" + source = "digitalenergy.online/decort/decort" + } + } +} +*/ + +provider "decort" { + authenticator = "oauth2" + #controller_url = + controller_url = "https://ds1.digitalenergy.online" + #oauth2_url = + oauth2_url = "https://sso.digitalenergy.online" + allow_unverified_ssl = true +} + +data "decort_locations_list" "ll" { + #кол-во страниц для вывода + #опицональный параметр + #тип - число + #page = 1 + + #размер страницы + #опицональный параметр + #тип - число + #size = 1 +} + +output "test" { + value = data.decort_locations_list.ll +} diff --git a/samples/data_rg_list/main.tf b/samples/cloudapi/data_rg_list/main.tf similarity index 100% rename from samples/data_rg_list/main.tf rename to samples/cloudapi/data_rg_list/main.tf diff --git a/samples/data_snapshot_list/main.tf b/samples/cloudapi/data_snapshot_list/main.tf similarity index 100% rename from samples/data_snapshot_list/main.tf rename to samples/cloudapi/data_snapshot_list/main.tf diff --git a/samples/data_vgpu/main.tf b/samples/cloudapi/data_vgpu/main.tf similarity index 100% rename from samples/data_vgpu/main.tf rename to samples/cloudapi/data_vgpu/main.tf diff --git a/samples/data_vins_list/main.tf b/samples/cloudapi/data_vins_list/main.tf similarity index 100% rename from samples/data_vins_list/main.tf rename to samples/cloudapi/data_vins_list/main.tf diff --git a/samples/resource_account/main.tf b/samples/cloudapi/resource_account/main.tf similarity index 100% rename from samples/resource_account/main.tf rename to samples/cloudapi/resource_account/main.tf diff --git a/samples/resource_bservice/main.tf b/samples/cloudapi/resource_bservice/main.tf similarity index 100% rename from samples/resource_bservice/main.tf rename to samples/cloudapi/resource_bservice/main.tf diff --git a/samples/resource_bservice_group/main.tf b/samples/cloudapi/resource_bservice_group/main.tf similarity index 100% rename from samples/resource_bservice_group/main.tf rename to samples/cloudapi/resource_bservice_group/main.tf diff --git a/samples/resource_k8s/main.tf b/samples/cloudapi/resource_k8s/main.tf similarity index 100% rename from samples/resource_k8s/main.tf rename to samples/cloudapi/resource_k8s/main.tf diff --git a/samples/resource_k8s_wg/main.tf b/samples/cloudapi/resource_k8s_wg/main.tf similarity index 100% rename from samples/resource_k8s_wg/main.tf rename to samples/cloudapi/resource_k8s_wg/main.tf diff --git a/samples/resource_snapshot/main.tf b/samples/cloudapi/resource_snapshot/main.tf similarity index 100% rename from samples/resource_snapshot/main.tf rename to samples/cloudapi/resource_snapshot/main.tf diff --git a/samples/data_grid/main.tf b/samples/cloudbroker/data_grid/main.tf similarity index 100% rename from samples/data_grid/main.tf rename to samples/cloudbroker/data_grid/main.tf diff --git a/samples/data_grid_list/main.tf b/samples/cloudbroker/data_grid_list/main.tf similarity index 100% rename from samples/data_grid_list/main.tf rename to samples/cloudbroker/data_grid_list/main.tf diff --git a/samples/data_image/main.tf b/samples/cloudbroker/data_image/main.tf similarity index 100% rename from samples/data_image/main.tf rename to samples/cloudbroker/data_image/main.tf diff --git a/samples/data_image_list/main.tf b/samples/cloudbroker/data_image_list/main.tf similarity index 100% rename from samples/data_image_list/main.tf rename to samples/cloudbroker/data_image_list/main.tf diff --git a/samples/data_image_list_stacks/main.tf b/samples/cloudbroker/data_image_list_stacks/main.tf similarity index 100% rename from samples/data_image_list_stacks/main.tf rename to samples/cloudbroker/data_image_list_stacks/main.tf diff --git a/samples/data_pcidevice/main.tf b/samples/cloudbroker/data_pcidevice/main.tf similarity index 100% rename from samples/data_pcidevice/main.tf rename to samples/cloudbroker/data_pcidevice/main.tf diff --git a/samples/data_pcidevice_list/main.tf b/samples/cloudbroker/data_pcidevice_list/main.tf similarity index 100% rename from samples/data_pcidevice_list/main.tf rename to samples/cloudbroker/data_pcidevice_list/main.tf diff --git a/samples/data_sep/main.tf b/samples/cloudbroker/data_sep/main.tf similarity index 100% rename from samples/data_sep/main.tf rename to samples/cloudbroker/data_sep/main.tf diff --git a/samples/data_sep_config/main.tf b/samples/cloudbroker/data_sep_config/main.tf similarity index 100% rename from samples/data_sep_config/main.tf rename to samples/cloudbroker/data_sep_config/main.tf diff --git a/samples/data_sep_consumption/main.tf b/samples/cloudbroker/data_sep_consumption/main.tf similarity index 100% rename from samples/data_sep_consumption/main.tf rename to samples/cloudbroker/data_sep_consumption/main.tf diff --git a/samples/data_sep_disk_list/main.tf b/samples/cloudbroker/data_sep_disk_list/main.tf similarity index 100% rename from samples/data_sep_disk_list/main.tf rename to samples/cloudbroker/data_sep_disk_list/main.tf diff --git a/samples/data_sep_list/main.tf b/samples/cloudbroker/data_sep_list/main.tf similarity index 100% rename from samples/data_sep_list/main.tf rename to samples/cloudbroker/data_sep_list/main.tf diff --git a/samples/data_sep_pool/main.tf b/samples/cloudbroker/data_sep_pool/main.tf similarity index 100% rename from samples/data_sep_pool/main.tf rename to samples/cloudbroker/data_sep_pool/main.tf diff --git a/samples/resource_delete_images/main.tf b/samples/cloudbroker/resource_delete_images/main.tf similarity index 100% rename from samples/resource_delete_images/main.tf rename to samples/cloudbroker/resource_delete_images/main.tf diff --git a/samples/resource_image/main.tf b/samples/cloudbroker/resource_image/main.tf similarity index 100% rename from samples/resource_image/main.tf rename to samples/cloudbroker/resource_image/main.tf diff --git a/samples/resource_image_cdrom/main.tf b/samples/cloudbroker/resource_image_cdrom/main.tf similarity index 100% rename from samples/resource_image_cdrom/main.tf rename to samples/cloudbroker/resource_image_cdrom/main.tf diff --git a/samples/resource_pcidevice/main.tf b/samples/cloudbroker/resource_pcidevice/main.tf similarity index 100% rename from samples/resource_pcidevice/main.tf rename to samples/cloudbroker/resource_pcidevice/main.tf diff --git a/samples/resource_sep/main.tf b/samples/cloudbroker/resource_sep/main.tf similarity index 100% rename from samples/resource_sep/main.tf rename to samples/cloudbroker/resource_sep/main.tf diff --git a/samples/resource_sep_config/main.tf b/samples/cloudbroker/resource_sep_config/main.tf similarity index 100% rename from samples/resource_sep_config/main.tf rename to samples/cloudbroker/resource_sep_config/main.tf diff --git a/samples/resource_virtual_image/main.tf b/samples/cloudbroker/resource_virtual_image/main.tf similarity index 100% rename from samples/resource_virtual_image/main.tf rename to samples/cloudbroker/resource_virtual_image/main.tf