Add resource, data, samples

2.2
stSolo 3 years ago
parent 9af980964a
commit 2f2fa2a544

@ -15,7 +15,8 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
- Работа с VINS, - Работа с VINS,
- Работа с pfw, - Работа с pfw,
- Работа с accounts, - Работа с accounts,
- Работа с snapshots. - Работа с snapshots,
- Работа с sep.
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki

@ -14,7 +14,8 @@ NOTE: provider rc-1.25 is designed for DECORT API 3.7.x. For older API versions
- Work with VINS, - Work with VINS,
- Work with pfw, - Work with pfw,
- Work with accounts, - Work with accounts,
- Work with snapshots. - Work with snapshots,
- Work with sep.
This provider supports Import operations on pre-existing resources. This provider supports Import operations on pre-existing resources.

@ -0,0 +1,145 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepRead(d *schema.ResourceData, m interface{}) error {
desSep, err := utilitySepCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("ckey", desSep.Ckey)
d.Set("meta", flattenMeta(desSep.Meta))
d.Set("consumed_by", desSep.ConsumedBy)
d.Set("desc", desSep.Desc)
d.Set("gid", desSep.Gid)
d.Set("guid", desSep.Guid)
d.Set("sep_id", desSep.Id)
d.Set("milestones", desSep.Milestones)
d.Set("name", desSep.Name)
d.Set("obj_status", desSep.ObjStatus)
d.Set("provided_by", desSep.ProvidedBy)
d.Set("tech_status", desSep.TechStatus)
d.Set("type", desSep.Type)
data, _ := json.Marshal(desSep.Config)
d.Set("config", string(data))
return nil
}
func dataSourceSepCSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Required: true,
Description: "sep type des id",
},
"ckey": {
Type: schema.TypeString,
Computed: true,
},
"meta": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"consumed_by": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"obj_status": {
Type: schema.TypeString,
Computed: true,
},
"provided_by": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"config": {
Type: schema.TypeString,
Computed: true,
},
}
}
func dataSourceSep() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepCSchemaMake(),
}
}

@ -26,42 +26,52 @@ package decort
import ( import (
"encoding/json" "encoding/json"
"errors"
"net/url"
"strconv"
"strings"
log "github.com/sirupsen/logrus"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
) )
func utilitySepTatlinCheckPresence(d *schema.ResourceData, m interface{}) (*SepTatlin, error) { func dataSourceSepConfigRead(d *schema.ResourceData, m interface{}) error {
controller := m.(*ControllerCfg) sepConfig, err := utilitySepConfigCheckPresence(d, m)
urlValues := &url.Values{} if err != nil {
return err
}
sepTatlin := &SepTatlin{} id := uuid.New()
d.SetId(id.String())
if d.Get("sep_id").(int) == 0 { data, _ := json.Marshal(sepConfig)
urlValues.Add("sep_id", d.Id()) d.Set("config", string(data))
} else {
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
}
log.Debugf("utilitySepTatlinCheckPresence: load sep") return nil
sepTatlinRaw, err := controller.decortAPICall("POST", sepGetAPI, urlValues) }
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(sepTatlinRaw), sepTatlin) func dataSourceSepConfigSchemaMake() map[string]*schema.Schema {
if err != nil { return map[string]*schema.Schema{
return nil, err "sep_id": {
Type: schema.TypeInt,
Required: true,
Description: "storage endpoint provider ID",
},
"config": {
Type: schema.TypeString,
Computed: true,
Description: "sep config json string",
},
} }
}
if strings.ToLower(sepTatlin.Type) != "tatlin" { func dataSourceSepConfig() *schema.Resource {
return nil, errors.New("Invalid sep type") return &schema.Resource{
} SchemaVersion: 1,
return sepTatlin, nil Read: dataSourceSepConfigRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepConfigSchemaMake(),
}
} }

@ -25,8 +25,6 @@ Visit https://github.com/rudecs/terraform-provider-decort for full source code p
package decort package decort
import ( import (
"strconv"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
) )
@ -41,10 +39,7 @@ func dataSourceSepConsumptionRead(d *schema.ResourceData, m interface{}) error {
d.Set("type", sepCons.Type) d.Set("type", sepCons.Type)
d.Set("total", flattenSepConsumption(sepCons.Total)) d.Set("total", flattenSepConsumption(sepCons.Total))
err = d.Set("by_pool", flattenSepConsumptionPools(sepCons.ByPool)) d.Set("by_pool", flattenSepConsumptionPools(sepCons.ByPool))
if err != nil {
return err
}
return nil return nil
} }
@ -66,16 +61,19 @@ func flattenSepConsumptionPools(mp map[string]SepConsumptionInd) []map[string]in
return sh return sh
} }
func flattenSepConsumption(sc SepConsumptionTotal) map[string]interface{} { func flattenSepConsumption(sc SepConsumptionTotal) []map[string]interface{} {
return map[string]interface{}{ sh := make([]map[string]interface{}, 0)
"capacity_limit": strconv.Itoa(sc.CapacityLimit), temp := map[string]interface{}{
"disk_count": strconv.Itoa(sc.DiskCount), "capacity_limit": sc.CapacityLimit,
"disk_usage": strconv.Itoa(sc.DiskUsage), "disk_count": sc.DiskCount,
"snapshot_count": strconv.Itoa(sc.SnapshotCount), "disk_usage": sc.DiskUsage,
"snapshot_usage": strconv.Itoa(sc.SnapshotUsage), "snapshot_count": sc.SnapshotCount,
"usage": strconv.Itoa(sc.Usage), "snapshot_usage": sc.SnapshotUsage,
"usage_limit": strconv.Itoa(sc.UsageLimit), "usage": sc.Usage,
"usage_limit": sc.UsageLimit,
} }
sh = append(sh, temp)
return sh
} }
func dataSourceSepConsumptionSchemaMake() map[string]*schema.Schema { func dataSourceSepConsumptionSchemaMake() map[string]*schema.Schema {
@ -83,7 +81,7 @@ func dataSourceSepConsumptionSchemaMake() map[string]*schema.Schema {
"sep_id": { "sep_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
Description: "sep type des id", Description: "sep id",
}, },
"by_pool": { "by_pool": {
Type: schema.TypeList, Type: schema.TypeList,
@ -91,75 +89,92 @@ func dataSourceSepConsumptionSchemaMake() map[string]*schema.Schema {
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": { "name": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Description: "pool name",
}, },
"disk_count": { "disk_count": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "number of disks",
}, },
"disk_usage": { "disk_usage": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "disk usage",
}, },
"snapshot_count": { "snapshot_count": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "number of snapshots",
}, },
"snapshot_usage": { "snapshot_usage": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "snapshot usage",
}, },
"usage": { "usage": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "usage",
}, },
"usage_limit": { "usage_limit": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "usage limit",
}, },
}, },
}, },
Description: "consumption divided by pool",
}, },
"total": { "total": {
Type: schema.TypeMap, Type: schema.TypeList,
Computed: true, Computed: true,
MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"capacity_limit": { "capacity_limit": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"disk_count": { "disk_count": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "number of disks",
}, },
"disk_usage": { "disk_usage": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "disk usage",
}, },
"snapshot_count": { "snapshot_count": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "number of snapshots",
}, },
"snapshot_usage": { "snapshot_usage": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "snapshot usage",
}, },
"usage": { "usage": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "usage",
}, },
"usage_limit": { "usage_limit": {
Type: schema.TypeString, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "usage limit",
}, },
}, },
}, },
Description: "total consumption",
}, },
"type": { "type": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Description: "sep type",
}, },
} }
} }

@ -1,380 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepDesRead(d *schema.ResourceData, m interface{}) error {
desSep, err := utilitySepDesCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("ckey", desSep.Ckey)
d.Set("meta", flattenMeta(desSep.Meta))
d.Set("consumed_by", desSep.ConsumedBy)
d.Set("desc", desSep.Desc)
d.Set("gid", desSep.Gid)
d.Set("guid", desSep.Guid)
d.Set("sep_id", desSep.Id)
d.Set("milestones", desSep.Milestones)
d.Set("name", desSep.Name)
d.Set("obj_status", desSep.ObjStatus)
d.Set("provided_by", desSep.ProvidedBy)
d.Set("tech_status", desSep.TechStatus)
d.Set("type", desSep.Type)
data, _ := json.Marshal(desSep.Config)
d.Set("config_string", string(data))
err = d.Set("config", flattenSepDesConfig(desSep.Config))
if err != nil {
return err
}
return nil
}
func flattenSepDesConfig(sc DesConfigSep) []interface{} {
return []interface{}{
map[string]interface{}{
"api_ips": sc.ApiIps,
"protocol": sc.Protocol,
"capacity_limit": sc.CapacityLimit,
"decs3o_app_secret": sc.Decs3oAppSecret,
"decs3o_app_id": sc.Decs3oAppId,
"format": sc.Format,
"edgeuser_password": sc.EdgeuserPassword,
"edgeuser_name": sc.EdgeuserName,
"transport": sc.Transport,
"ovs_settings": []interface{}{
map[string]interface{}{
"vpool_data_metadatacache": sc.OVSSettings.VPoolDataMetadataCache,
"vpool_vmstor_metadatacache": sc.OVSSettings.VPoolVMstorMetadataCache,
},
},
"housekeeping_settings": []interface{}{
map[string]interface{}{
"disk_del_queue": []interface{}{
map[string]interface{}{
"purgatory_id": sc.HousekeepingSettings.DiskDelQueue.PurgatoryId,
"chunk_max_size": sc.HousekeepingSettings.DiskDelQueue.ChunkMaxSize,
"disk_count_max": sc.HousekeepingSettings.DiskDelQueue.DiskCountMax,
"enabled": sc.HousekeepingSettings.DiskDelQueue.Enabled,
"normal_time_to_sleep": sc.HousekeepingSettings.DiskDelQueue.NormalTimeToSleep,
"one_minute_la_threshold": sc.HousekeepingSettings.DiskDelQueue.OneMinuteLaThreshold,
"oversize_time_to_sleep": sc.HousekeepingSettings.DiskDelQueue.OversizeTimeToSleep,
"purge_attempts_threshold": sc.HousekeepingSettings.DiskDelQueue.PurgeAttemptsThreshold,
},
},
},
},
"pools": flattenSepDesPools(sc.Pools),
},
}
}
func flattenSepDesPools(pools DesConfigPoolList) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
for _, pool := range pools {
t := map[string]interface{}{
"types": pool.Types,
"reference_id": pool.ReferenceId,
"name": pool.Name,
"pagecache_ratio": pool.PagecacheRatio,
"uris": flattenDesSepPoolUris(pool.URIS),
}
temp = append(temp, t)
}
return temp
}
func flattenDesSepPoolUris(uris URIList) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
for _, uri := range uris {
t := map[string]interface{}{
"ip": uri.IP,
"port": uri.Port,
}
temp = append(temp, t)
}
return temp
}
func dataSourceSepDesSchemaMake(sh map[string]*schema.Schema) map[string]*schema.Schema {
sh["config"] = &schema.Schema{
Type: schema.TypeList,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"api_ips": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"capacity_limit": {
Type: schema.TypeInt,
Computed: true,
},
"protocol": {
Type: schema.TypeString,
Computed: true,
},
"decs3o_app_secret": {
Type: schema.TypeString,
Computed: true,
},
"format": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_password": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_name": {
Type: schema.TypeString,
Computed: true,
},
"decs3o_app_id": {
Type: schema.TypeString,
Computed: true,
},
"transport": {
Type: schema.TypeString,
Computed: true,
},
"ovs_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpool_data_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
"vpool_vmstor_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"pagecache_ratio": {
Type: schema.TypeInt,
Computed: true,
},
"uris": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"housekeeping_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_del_queue": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"chunk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"disk_count_max": {
Type: schema.TypeInt,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"normal_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"one_minute_la_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"oversize_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"purge_attempts_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"purgatory_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
},
},
}
return sh
}
func dataSourceSepSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Required: true,
Description: "sep type des id",
},
"ckey": {
Type: schema.TypeString,
Computed: true,
},
"meta": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"consumed_by": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"obj_status": {
Type: schema.TypeString,
Computed: true,
},
"provided_by": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
"config_string": {
Type: schema.TypeString,
Computed: true,
},
}
}
func dataSourceSepDes() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepDesRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepDesSchemaMake(dataSourceSepSchemaMake()),
}
}

@ -1,238 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepConfigDesRead(d *schema.ResourceData, m interface{}) error {
desConfigSep, err := utilitySepConfigDesCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
data, _ := json.Marshal(&desConfigSep)
d.Set("config_string", string(data))
err = d.Set("config", flattenSepDesConfig(*desConfigSep))
if err != nil {
return err
}
return nil
}
func dataSourceSepConfigDesSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Required: true,
Description: "storage endpoint provider ID",
},
"config_string": {
Type: schema.TypeString,
Computed: true,
},
"config": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"api_ips": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"capacity_limit": {
Type: schema.TypeInt,
Computed: true,
},
"protocol": {
Type: schema.TypeString,
Computed: true,
},
"decs3o_app_secret": {
Type: schema.TypeString,
Computed: true,
},
"format": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_password": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_name": {
Type: schema.TypeString,
Computed: true,
},
"decs3o_app_id": {
Type: schema.TypeString,
Computed: true,
},
"transport": {
Type: schema.TypeString,
Computed: true,
},
"ovs_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpool_data_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
"vpool_vmstor_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"pagecache_ratio": {
Type: schema.TypeInt,
Computed: true,
},
"uris": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"housekeeping_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_del_queue": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"chunk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"disk_count_max": {
Type: schema.TypeInt,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"normal_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"one_minute_la_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"oversize_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"purge_attempts_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"purgatory_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
},
},
},
}
}
func dataSourceSepConfigDes() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepConfigDesRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepConfigDesSchemaMake(),
}
}

@ -1,129 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepDesPoolRead(d *schema.ResourceData, m interface{}) error {
desSepPool, err := utilitySepDesPoolCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("pool", flattenSepDesPool(desSepPool))
return nil
}
func flattenSepDesPool(pool *DesConfigPool) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
t := map[string]interface{}{
"types": pool.Types,
"reference_id": pool.ReferenceId,
"name": pool.Name,
"pagecache_ratio": pool.PagecacheRatio,
"uris": flattenDesSepPoolUris(pool.URIS),
}
temp = append(temp, t)
return temp
}
func dataSourceSepDesPoolSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Required: true,
Description: "storage endpoint provider ID",
},
"pool_name": {
Type: schema.TypeString,
Required: true,
Description: "pool name",
},
"pool": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"pagecache_ratio": {
Type: schema.TypeInt,
Computed: true,
},
"uris": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
}
}
func dataSourceSepDesPool() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepDesPoolRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepDesPoolSchemaMake(),
}
}

@ -1,348 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepDoradoRead(d *schema.ResourceData, m interface{}) error {
doradoSep, err := utilitySepDoradoCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("ckey", doradoSep.Ckey)
d.Set("meta", flattenMeta(doradoSep.Meta))
d.Set("consumed_by", doradoSep.ConsumedBy)
d.Set("desc", doradoSep.Desc)
d.Set("gid", doradoSep.Gid)
d.Set("guid", doradoSep.Guid)
d.Set("sep_id", doradoSep.Id)
d.Set("milestones", doradoSep.Milestones)
d.Set("name", doradoSep.Name)
d.Set("obj_status", doradoSep.ObjStatus)
d.Set("provided_by", doradoSep.ProvidedBy)
d.Set("tech_status", doradoSep.TechStatus)
d.Set("type", doradoSep.Type)
data, _ := json.Marshal(doradoSep.Config)
d.Set("config_string", string(data))
d.Set("config", flattenSepDoradoConfig(doradoSep.Config))
return nil
}
func flattenSepDoradoConfig(dc DoradoConfigSep) []interface{} {
return []interface{}{
map[string]interface{}{
"api_urls": dc.ApiUrls,
"disk_max_size": dc.DiskMaxSize,
"edgeuser_password": dc.EdgeuserPassword,
"edgeuser_name": dc.EdgeuserName,
"format": dc.Format,
"groups": []interface{}{
map[string]interface{}{
"host_group": dc.Groups.HostGroup,
"lung_group": dc.Groups.LungGroup,
"port_group": dc.Groups.PortGroup,
},
},
"ovs_settings": []interface{}{
map[string]interface{}{
"vpool_data_metadatacache": dc.OVSSettings.VPoolDataMetadataCache,
"vpool_vmstor_metadatacache": dc.OVSSettings.VPoolVMstorMetadataCache,
},
},
"host_group_name": dc.HostGroupName,
"housekeeping_settings": []interface{}{
map[string]interface{}{
"disk_del_queue": []interface{}{
map[string]interface{}{
"purgatory_id": dc.HousekeepingSettings.DiskDelQueue.PurgatoryId,
"chunk_max_size": dc.HousekeepingSettings.DiskDelQueue.ChunkMaxSize,
"disk_count_max": dc.HousekeepingSettings.DiskDelQueue.DiskCountMax,
"enabled": dc.HousekeepingSettings.DiskDelQueue.Enabled,
"normal_time_to_sleep": dc.HousekeepingSettings.DiskDelQueue.NormalTimeToSleep,
"one_minute_la_threshold": dc.HousekeepingSettings.DiskDelQueue.OneMinuteLaThreshold,
"oversize_time_to_sleep": dc.HousekeepingSettings.DiskDelQueue.OversizeTimeToSleep,
"purge_attempts_threshold": dc.HousekeepingSettings.DiskDelQueue.PurgeAttemptsThreshold,
},
},
},
},
"mgmt_password": dc.MGMTPassword,
"mgmt_user": dc.MGMTUser,
"model": dc.Model,
"name_prefix": dc.NamePrefix,
"pools": flattenSepDoradoPools(dc.Pools),
"ports": flattenSepDoradoPorts(dc.Ports),
"protocol": dc.Protocol,
},
}
}
func flattenSepDoradoPorts(dp DoradoPortList) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
for _, port := range dp {
t := map[string]interface{}{
"name": port.Name,
"ip": port.IP,
}
temp = append(temp, t)
}
return temp
}
func flattenSepDoradoPools(dp PoolList) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
for _, pool := range dp {
t := map[string]interface{}{
"name": pool.Name,
"types": pool.Types,
"usage_limit": pool.UsageLimit,
}
temp = append(temp, t)
}
return temp
}
func dataSourceSepDoradoSchemaMake(sh map[string]*schema.Schema) map[string]*schema.Schema {
sh["config"] = &schema.Schema{
Type: schema.TypeList,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"api_urls": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"disk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"edgeuser_password": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_name": {
Type: schema.TypeString,
Computed: true,
},
"format": {
Type: schema.TypeString,
Computed: true,
},
"groups": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"host_group": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"lung_group": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"port_group": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
"host_group_name": {
Type: schema.TypeString,
Computed: true,
},
"housekeeping_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_del_queue": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"purge_attempts_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"chunk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"disk_count_max": {
Type: schema.TypeInt,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"normal_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"one_minute_la_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"oversize_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"purgatory_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"mgmt_password": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_user": {
Type: schema.TypeString,
Computed: true,
},
"model": {
Type: schema.TypeString,
Computed: true,
},
"name_prefix": {
Type: schema.TypeString,
Computed: true,
},
"ovs_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpool_data_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
"vpool_vmstor_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"usage_limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"ports": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"protocol": {
Type: schema.TypeString,
Computed: true,
},
},
},
}
return sh
}
func dataSourceSepDorado() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepDoradoRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepDoradoSchemaMake(dataSourceSepSchemaMake()),
}
}

@ -1,268 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepDoradoConfigRead(d *schema.ResourceData, m interface{}) error {
doradoSepConfig, err := utilitySepDoradoConfigCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
data, _ := json.Marshal(doradoSepConfig)
d.Set("config_string", string(data))
d.Set("config", flattenSepDoradoConfig(*doradoSepConfig))
return nil
}
func dataSourceSepDoradoConfigSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Required: true,
Description: "storage endpoint provider ID",
},
"config_string": {
Type: schema.TypeString,
Computed: true,
},
"config": {
Type: schema.TypeList,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"api_urls": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"disk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"edgeuser_password": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_name": {
Type: schema.TypeString,
Computed: true,
},
"format": {
Type: schema.TypeString,
Computed: true,
},
"groups": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"host_group": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"lung_group": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"port_group": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
"host_group_name": {
Type: schema.TypeString,
Computed: true,
},
"housekeeping_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_del_queue": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"purge_attempts_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"chunk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"disk_count_max": {
Type: schema.TypeInt,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"normal_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"one_minute_la_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"oversize_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"purgatory_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"mgmt_password": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_user": {
Type: schema.TypeString,
Computed: true,
},
"model": {
Type: schema.TypeString,
Computed: true,
},
"name_prefix": {
Type: schema.TypeString,
Computed: true,
},
"ovs_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpool_data_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
"vpool_vmstor_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"usage_limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"ports": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"protocol": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
}
}
func dataSourceSepDoradoConfig() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepDoradoConfigRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepDoradoConfigSchemaMake(),
}
}

@ -1,329 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepHitachiRead(d *schema.ResourceData, m interface{}) error {
hitachiSep, err := utilitySepHitachiCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("ckey", hitachiSep.Ckey)
d.Set("meta", flattenMeta(hitachiSep.Meta))
d.Set("consumed_by", hitachiSep.ConsumedBy)
d.Set("desc", hitachiSep.Desc)
d.Set("gid", hitachiSep.Gid)
d.Set("guid", hitachiSep.Guid)
d.Set("sep_id", hitachiSep.Id)
d.Set("milestones", hitachiSep.Milestones)
d.Set("name", hitachiSep.Name)
d.Set("obj_status", hitachiSep.ObjStatus)
d.Set("provided_by", hitachiSep.ProvidedBy)
d.Set("tech_status", hitachiSep.TechStatus)
d.Set("type", hitachiSep.Type)
data, _ := json.Marshal(hitachiSep.Config)
d.Set("config_string", string(data))
d.Set("config", flattenSepHitachiConfig(hitachiSep.Config))
return nil
}
func flattenSepHitachiConfig(hc HitachiConfigSep) []interface{} {
return []interface{}{
map[string]interface{}{
"api_urls": hc.ApiUrls,
"sn": hc.SN,
"disk_max_size": hc.DiskMaxSize,
"format": hc.Format,
"host_group_num_max": hc.HostGroupNumMax,
"host_group_num_min": hc.HostGroupNumMin,
"host_group_number": hc.HostGroupNumber,
"mgmt_password": hc.MGMTPassword,
"mgmt_user": hc.MGMTUser,
"model": hc.Model,
"name_prefix": hc.NamePrefix,
"ports": hc.Ports,
"protocol": hc.Protocol,
"ssl_verify": hc.SSLVerify,
"pools": flattenSepHitachiPools(hc.Pools),
"ovs_settings": []interface{}{
map[string]interface{}{
"vpool_data_metadatacache": hc.OVSSettings.VPoolDataMetadataCache,
"vpool_vmstor_metadatacache": hc.OVSSettings.VPoolVMstorMetadataCache,
},
},
"housekeeping_settings": []interface{}{
map[string]interface{}{
"disk_del_queue": []interface{}{
map[string]interface{}{
"purgatory_id": hc.HousekeepingSettings.DiskDelQueue.PurgatoryId,
"chunk_max_size": hc.HousekeepingSettings.DiskDelQueue.ChunkMaxSize,
"disk_count_max": hc.HousekeepingSettings.DiskDelQueue.DiskCountMax,
"enabled": hc.HousekeepingSettings.DiskDelQueue.Enabled,
"normal_time_to_sleep": hc.HousekeepingSettings.DiskDelQueue.NormalTimeToSleep,
"one_minute_la_threshold": hc.HousekeepingSettings.DiskDelQueue.OneMinuteLaThreshold,
"oversize_time_to_sleep": hc.HousekeepingSettings.DiskDelQueue.OversizeTimeToSleep,
"purge_attempts_threshold": hc.HousekeepingSettings.DiskDelQueue.PurgeAttemptsThreshold,
},
},
},
},
},
}
}
func flattenSepHitachiPools(hp HitachiConfigPoolList) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
for _, pool := range hp {
t := map[string]interface{}{
"clone_technology": pool.CloneTechnology,
"id": pool.Id,
"max_l_dev_id": pool.MaxLdevId,
"min_l_dev_id": pool.MinLdevId,
"name": pool.Name,
"snapshot_pool_id": pool.SnapshotPoolId,
"snapshotable": pool.Snapshotable,
"types": pool.Types,
"usage_limit": pool.UsageLimit,
}
temp = append(temp, t)
}
return temp
}
func dataSourceSepHitachiSchemaMake(sh map[string]*schema.Schema) map[string]*schema.Schema {
sh["config"] = &schema.Schema{
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"api_urls": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"sn": {
Type: schema.TypeInt,
Computed: true,
},
"disk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"format": {
Type: schema.TypeString,
Computed: true,
},
"host_group_num_max": {
Type: schema.TypeInt,
Computed: true,
},
"host_group_num_min": {
Type: schema.TypeInt,
Computed: true,
},
"host_group_number": {
Type: schema.TypeInt,
Computed: true,
},
"housekeeping_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_del_queue": {
Type: schema.TypeList,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"purge_attempts_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"chunk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"disk_count_max": {
Type: schema.TypeInt,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"normal_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"one_minute_la_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"oversize_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"purgatory_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"ovs_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpool_data_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
"vpool_vmstor_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"mgmt_password": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_user": {
Type: schema.TypeString,
Computed: true,
},
"model": {
Type: schema.TypeString,
Computed: true,
},
"name_prefix": {
Type: schema.TypeString,
Computed: true,
},
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"clone_technology": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeInt,
Computed: true,
},
"max_l_dev_id": {
Type: schema.TypeInt,
Computed: true,
},
"min_l_dev_id": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"snapshot_pool_id": {
Type: schema.TypeInt,
Computed: true,
},
"snapshotable": {
Type: schema.TypeBool,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"usage_limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"ports": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"protocol": {
Type: schema.TypeString,
Computed: true,
},
"ssl_verify": {
Type: schema.TypeBool,
Computed: true,
},
},
},
}
return sh
}
func dataSourceSepHitachi() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepHitachiRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepHitachiSchemaMake(dataSourceSepSchemaMake()),
}
}

@ -1,261 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepHitachiConfigRead(d *schema.ResourceData, m interface{}) error {
hitachiSepConfig, err := utilitySepHitachiConfigCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
data, _ := json.Marshal(hitachiSepConfig)
d.Set("config_string", string(data))
d.Set("config", flattenSepHitachiConfig(*hitachiSepConfig))
return nil
}
func dataSourceSepHitachiConfigSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Required: true,
Description: "storage endpoint provider ID",
},
"config_string": {
Type: schema.TypeString,
Computed: true,
},
"config": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"api_urls": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"sn": {
Type: schema.TypeInt,
Computed: true,
},
"disk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"format": {
Type: schema.TypeString,
Computed: true,
},
"host_group_num_max": {
Type: schema.TypeInt,
Computed: true,
},
"host_group_num_min": {
Type: schema.TypeInt,
Computed: true,
},
"host_group_number": {
Type: schema.TypeInt,
Computed: true,
},
"housekeeping_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_del_queue": {
Type: schema.TypeList,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"purge_attempts_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"chunk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"disk_count_max": {
Type: schema.TypeInt,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"normal_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"one_minute_la_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"oversize_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"purgatory_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"ovs_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpool_data_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
"vpool_vmstor_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"mgmt_password": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_user": {
Type: schema.TypeString,
Computed: true,
},
"model": {
Type: schema.TypeString,
Computed: true,
},
"name_prefix": {
Type: schema.TypeString,
Computed: true,
},
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"clone_technology": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeInt,
Computed: true,
},
"max_l_dev_id": {
Type: schema.TypeInt,
Computed: true,
},
"min_l_dev_id": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"snapshot_pool_id": {
Type: schema.TypeInt,
Computed: true,
},
"snapshotable": {
Type: schema.TypeBool,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"usage_limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"ports": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"protocol": {
Type: schema.TypeString,
Computed: true,
},
"ssl_verify": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
}
}
func dataSourceSepHitachiConfig() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepHitachiConfigRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepHitachiConfigSchemaMake(),
}
}

@ -1,127 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepHitachiPoolRead(d *schema.ResourceData, m interface{}) error {
hitachiSepPool, err := utilitySepHitachiPoolCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("pool", flattenSepHitachiPool(hitachiSepPool))
return nil
}
func flattenSepHitachiPool(pool *HitachiConfigPool) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
t := map[string]interface{}{
"clone_technology": pool.CloneTechnology,
"id": pool.Id,
"max_l_dev_id": pool.MaxLdevId,
"min_l_dev_id": pool.MinLdevId,
"name": pool.Name,
"snapshot_pool_id": pool.SnapshotPoolId,
"snapshotable": pool.Snapshotable,
"types": pool.Types,
"usage_limit": pool.UsageLimit,
}
temp = append(temp, t)
return temp
}
func dataSourceSepHitachiPoolSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"pool": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"clone_technology": {
Type: schema.TypeString,
Computed: true,
},
"id": {
Type: schema.TypeInt,
Computed: true,
},
"max_l_dev_id": {
Type: schema.TypeInt,
Computed: true,
},
"min_l_dev_id": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"snapshot_pool_id": {
Type: schema.TypeInt,
Computed: true,
},
"snapshotable": {
Type: schema.TypeBool,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"usage_limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
}
}
func dataSourceSepHitachiPool() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepHitachiPoolRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepHitachiPoolSchemaMake(),
}
}

@ -34,23 +34,22 @@ import (
func flattenSepList(sl SepList) []map[string]interface{} { func flattenSepList(sl SepList) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0)
for _, item := range sl { for _, item := range sl {
d, _ := json.Marshal(item.ConfigString) data, _ := json.Marshal(item.Config)
configString := string(d)
temp := map[string]interface{}{ temp := map[string]interface{}{
"ckey": item.Ckey, "ckey": item.Ckey,
"meta": flattenMeta(item.Meta), "meta": flattenMeta(item.Meta),
"consumed_by": item.ConsumedBy, "consumed_by": item.ConsumedBy,
"desc": item.Desc, "desc": item.Desc,
"gid": item.Gid, "gid": item.Gid,
"guid": item.Guid, "guid": item.Guid,
"sep_id": item.Id, "sep_id": item.Id,
"milestones": item.Milestones, "milestones": item.Milestones,
"name": item.Name, "name": item.Name,
"obj_status": item.ObjStatus, "obj_status": item.ObjStatus,
"provided_by": item.ProvidedBy, "provided_by": item.ProvidedBy,
"tech_status": item.TechStatus, "tech_status": item.TechStatus,
"type": item.Type, "type": item.Type,
"config_string": configString, "config": string(data),
} }
res = append(res, temp) res = append(res, temp)
@ -158,7 +157,7 @@ func dataSourceSepShortSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"config_string": { "config": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },

@ -25,35 +25,27 @@ Visit https://github.com/rudecs/terraform-provider-decort for full source code p
package decort package decort
import ( import (
"encoding/json"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
) )
func dataSourceSepDoradoPoolRead(d *schema.ResourceData, m interface{}) error { func dataSourceSepPoolRead(d *schema.ResourceData, m interface{}) error {
doradoSepPool, err := utilitySepDoradoPoolCheckPresence(d, m) sepPool, err := utilitySepPoolCheckPresence(d, m)
if err != nil { if err != nil {
return err return err
} }
id := uuid.New() id := uuid.New()
d.SetId(id.String()) d.SetId(id.String())
d.Set("pool", flattenSepDoradoPool(doradoSepPool))
return nil
}
func flattenSepDoradoPool(pool *Pool) []map[string]interface{} { data, _ := json.Marshal(sepPool)
temp := make([]map[string]interface{}, 0) d.Set("pool", string(data))
t := map[string]interface{}{
"name": pool.Name,
"types": pool.Types,
"usage_limit": pool.UsageLimit,
}
temp = append(temp, t)
return temp return nil
} }
func dataSourceSepDoradoPoolSchemaMake() map[string]*schema.Schema { func dataSourceSepPoolSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{ return map[string]*schema.Schema{
"sep_id": { "sep_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
@ -66,42 +58,23 @@ func dataSourceSepDoradoPoolSchemaMake() map[string]*schema.Schema {
Description: "pool name", Description: "pool name",
}, },
"pool": { "pool": {
Type: schema.TypeList, Type: schema.TypeString,
Computed: true, Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"usage_limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
}, },
} }
} }
func dataSourceSepDoradoPool() *schema.Resource { func dataSourceSepPool() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceSepDoradoPoolRead, Read: dataSourceSepPoolRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &Timeout30s,
Default: &Timeout60s, Default: &Timeout60s,
}, },
Schema: dataSourceSepDoradoPoolSchemaMake(), Schema: dataSourceSepPoolSchemaMake(),
} }
} }

@ -1,352 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepTatlinRead(d *schema.ResourceData, m interface{}) error {
tatlinSep, err := utilitySepTatlinCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("ckey", tatlinSep.Ckey)
d.Set("meta", flattenMeta(tatlinSep.Meta))
d.Set("consumed_by", tatlinSep.ConsumedBy)
d.Set("desc", tatlinSep.Desc)
d.Set("gid", tatlinSep.Gid)
d.Set("guid", tatlinSep.Guid)
d.Set("sep_id", tatlinSep.Id)
d.Set("milestones", tatlinSep.Milestones)
d.Set("name", tatlinSep.Name)
d.Set("obj_status", tatlinSep.ObjStatus)
d.Set("provided_by", tatlinSep.ProvidedBy)
d.Set("tech_status", tatlinSep.TechStatus)
d.Set("type", tatlinSep.Type)
data, _ := json.Marshal(tatlinSep.Config)
d.Set("config_string", string(data))
d.Set("config", flattenSepTatlinConfig(tatlinSep.Config))
return nil
}
func flattenSepTatlinConfig(tc TatlinConfigSep) []interface{} {
return []interface{}{
map[string]interface{}{
"api_urls": tc.ApiUrls,
"disk_max_size": tc.DiskMaxSize,
"edgeuser_password": tc.EdgeuserPassword,
"edgeuser_name": tc.EdgeuserName,
"format": tc.Format,
"host_group_name": tc.HostGroupName,
"housekeeping_settings": []interface{}{
map[string]interface{}{
"disk_del_queue": []interface{}{
map[string]interface{}{
"purgatory_id": tc.HousekeepingSettings.DiskDelQueue.PurgatoryId,
"chunk_max_size": tc.HousekeepingSettings.DiskDelQueue.ChunkMaxSize,
"disk_count_max": tc.HousekeepingSettings.DiskDelQueue.DiskCountMax,
"enabled": tc.HousekeepingSettings.DiskDelQueue.Enabled,
"normal_time_to_sleep": tc.HousekeepingSettings.DiskDelQueue.NormalTimeToSleep,
"one_minute_la_threshold": tc.HousekeepingSettings.DiskDelQueue.OneMinuteLaThreshold,
"oversize_time_to_sleep": tc.HousekeepingSettings.DiskDelQueue.OversizeTimeToSleep,
"purge_attempts_threshold": tc.HousekeepingSettings.DiskDelQueue.PurgeAttemptsThreshold,
},
},
},
},
"ovs_settings": []interface{}{
map[string]interface{}{
"vpool_data_metadatacache": tc.OVSSettings.VPoolDataMetadataCache,
"vpool_vmstor_metadatacache": tc.OVSSettings.VPoolVMstorMetadataCache,
},
},
"mgmt_password": tc.MGMTPassword,
"mgmt_user": tc.MGMTUser,
"model": tc.Model,
"name_prefix": tc.NamePrefix,
"pools": flattenSepTatlinPools(tc.Pools),
"ports": flattenSepTatlinPorts(tc.Ports),
"protocol": tc.Protocol,
"tech_disk": []interface{}{
map[string]interface{}{
"name": tc.TechDisk.Name,
"size": tc.TechDisk.Size,
"pool": tc.TechDisk.Pool,
"wwid": tc.TechDisk.WWID,
},
},
},
}
}
func flattenSepTatlinPools(tp PoolList) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
for _, pool := range tp {
t := map[string]interface{}{
"name": pool.Name,
"types": pool.Types,
"usage_limit": pool.UsageLimit,
}
temp = append(temp, t)
}
return temp
}
func flattenSepTatlinPorts(tp TatlinPortList) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
for _, port := range tp {
t := map[string]interface{}{
"ips": port.IPS,
"iqn": port.IQN,
"name": port.Name,
}
temp = append(temp, t)
}
return temp
}
func dataSourceSepTatlinSchemaMake(sh map[string]*schema.Schema) map[string]*schema.Schema {
sh["config"] = &schema.Schema{
Type: schema.TypeList,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"api_urls": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"disk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"ovs_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpool_data_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
"vpool_vmstor_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"edgeuser_password": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_name": {
Type: schema.TypeString,
Computed: true,
},
"format": {
Type: schema.TypeString,
Computed: true,
},
"host_group_name": {
Type: schema.TypeString,
Computed: true,
},
"housekeeping_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_del_queue": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"purge_attempts_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"chunk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"disk_count_max": {
Type: schema.TypeInt,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"normal_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"one_minute_la_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"oversize_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"purgatory_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"mgmt_password": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_user": {
Type: schema.TypeString,
Computed: true,
},
"model": {
Type: schema.TypeString,
Computed: true,
},
"name_prefix": {
Type: schema.TypeString,
Computed: true,
},
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"usage_limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"ports": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ips": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"iqn": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"protocol": {
Type: schema.TypeString,
Computed: true,
},
"tech_disk": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"pool": {
Type: schema.TypeString,
Computed: true,
},
"size": {
Type: schema.TypeInt,
Computed: true,
},
"wwid": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
},
}
return sh
}
func dataSourceSepTatlin() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepTatlinRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepTatlinSchemaMake(dataSourceSepSchemaMake()),
}
}

@ -1,270 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepTatlinConfigRead(d *schema.ResourceData, m interface{}) error {
tatlinSepConfig, err := utilitySepTatlinConfigCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
data, _ := json.Marshal(tatlinSepConfig)
d.Set("config_string", string(data))
d.Set("config", flattenSepTatlinConfig(*tatlinSepConfig))
return nil
}
func dataSourceSepTatlinConfigSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Required: true,
Description: "storage endpoint provider ID",
},
"config_string": {
Type: schema.TypeString,
Computed: true,
},
"config": {
Type: schema.TypeList,
MaxItems: 1,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"api_urls": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"disk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"ovs_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpool_data_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
"vpool_vmstor_metadatacache": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"edgeuser_password": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_name": {
Type: schema.TypeString,
Computed: true,
},
"format": {
Type: schema.TypeString,
Computed: true,
},
"host_group_name": {
Type: schema.TypeString,
Computed: true,
},
"housekeeping_settings": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_del_queue": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"purge_attempts_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"chunk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"disk_count_max": {
Type: schema.TypeInt,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"normal_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"one_minute_la_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"oversize_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"purgatory_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"mgmt_password": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_user": {
Type: schema.TypeString,
Computed: true,
},
"model": {
Type: schema.TypeString,
Computed: true,
},
"name_prefix": {
Type: schema.TypeString,
Computed: true,
},
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"usage_limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"ports": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ips": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"iqn": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"protocol": {
Type: schema.TypeString,
Computed: true,
},
"tech_disk": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"pool": {
Type: schema.TypeString,
Computed: true,
},
"size": {
Type: schema.TypeInt,
Computed: true,
},
"wwid": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
},
},
}
}
func dataSourceSepTatlinConfig() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepTatlinConfigRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepTatlinConfigSchemaMake(),
}
}

@ -1,98 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceSepTatlinPoolRead(d *schema.ResourceData, m interface{}) error {
tatlinSepPool, err := utilitySepTatlinPoolCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("pool", flattenSepTatlinPool(tatlinSepPool))
return nil
}
func flattenSepTatlinPool(pool *Pool) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
t := map[string]interface{}{
"name": pool.Name,
"types": pool.Types,
"usage_limit": pool.UsageLimit,
}
temp = append(temp, t)
return temp
}
func dataSourceSepTatlinPoolSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"usage_limit": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
}
}
func dataSourceSepTatlinPool() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSepTatlinPoolRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSepTatlinPoolSchemaMake(),
}
}

@ -866,240 +866,7 @@ const sepListAPI = "/restmachine/cloudbroker/sep/list"
const sepUpdateCapacityLimitAPI = "/restmachine/cloudbroker/sep/updateCapacityLimit" const sepUpdateCapacityLimitAPI = "/restmachine/cloudbroker/sep/updateCapacityLimit"
///Sep Configs ///Sep Models
///////DES config
type DesDiskDelQueue struct {
PurgatoryId int `json:"purgatory_id"`
ChunkMaxSize int `json:"chunk_max_size"`
DiskCountMax int `json:"disk_count_max"`
Enabled bool `json:"enabled"`
NormalTimeToSleep int `json:"normal_time_to_sleep"`
OneMinuteLaThreshold int `json:"one_minute_la_threshold"`
OversizeTimeToSleep int `json:"oversize_time_to_sleep"`
PurgeAttemptsThreshold int `json:"purge_attempts_threshold"`
}
type DesHousekeepingSettings struct {
DiskDelQueue DesDiskDelQueue `json:"disk_del_queue"`
}
type URI struct {
IP string `json:"ip"`
Port int `json:"port"`
}
type URIList []URI
type DesConfigPool struct {
Types []string `json:"types"`
ReferenceId string `json:"referenceId"`
Name string `json:"name"`
PagecacheRatio int `json:"pagecache_ratio"`
URIS []URI `json:"uris"`
}
type DesConfigPoolList []DesConfigPool
type OVSSettings struct {
VPoolDataMetadataCache int `json:"vpool_data_metadatacache"`
VPoolVMstorMetadataCache int `json:"vpool_vmstor_metadatacache"`
}
type DesConfigSep struct {
ApiIps []string `json:"API_IPs"`
Protocol string `json:"protocol"`
Decs3oAppSecret string `json:"decs3o_app_secret"`
Decs3oAppId string `json:"decs3o_app_id"`
Format string `json:"format"`
EdgeuserName string `json:"edgeuser_name"`
EdgeuserPassword string `json:"edgeuser_password"`
HousekeepingSettings DesHousekeepingSettings `json:"housekeeping_settings"`
Pools DesConfigPoolList `json:"pools"`
Transport string `json:"transport"`
CapacityLimit int `json:"capacity_limit"`
OVSSettings OVSSettings `json:"ovs_settings"`
}
///////Hitachi config
type HitachiConfigPool struct {
CloneTechnology string `json:"clone_technology"`
Id int `json:"id"`
MaxLdevId int `json:"maxLdevId"`
MinLdevId int `json:"minLdevId"`
Name string `json:"name"`
SnapshotPoolId int `json:"snapshot_pool_id"`
Snapshotable bool `json:"snapshotable"`
Types []string `json:"types"`
UsageLimit int `json:"usage_limit"`
}
type HitachiConfigPoolList []HitachiConfigPool
type HitachiConfigSep struct {
ApiUrls []string `json:"API_URLs"`
SN int `json:"SN"`
DiskMaxSize int `json:"disk_max_size"`
Format string `json:"format"`
HostGroupNumMax int `json:"hostGroupNumMax"`
HostGroupNumMin int `json:"hostGroupNumMin"`
HostGroupNumber int `json:"hostGroupNumber"`
HousekeepingSettings HousekeepingSettings `json:"housekeeping_settings"`
MGMTPassword string `json:"mgmt_password"`
MGMTUser string `json:"mgmt_user"`
Model string `json:"model"`
NamePrefix string `json:"name_prefix"`
Pools HitachiConfigPoolList `json:"pools"`
Ports []string `json:"ports"`
Protocol string `json:"protocol"`
SSLVerify bool `json:"ssl_verify"`
OVSSettings OVSSettings `json:"ovs_settings"`
}
///////Tatlin Config
type TatlinPort struct {
IPS []string `json:"ips"`
IQN string `json:"iqn"`
Name string `json:"name"`
}
type TatlinPortList []TatlinPort
type Pool struct {
Name string `json:"name"`
Types []string `json:"types"`
UsageLimit int `json:"usage_limit"`
}
type PoolList []Pool
type TatlinTechDisk struct {
Name string `json:"name"`
Size int `json:"size"`
Pool string `json:"pool"`
WWID string `json:"wwid"`
}
type DiskDelQueue struct {
PurgatoryId int `json:"purgatory_id"`
ChunkMaxSize int `json:"chunk_max_size"`
DiskCountMax int `json:"disk_count_max"`
Enabled bool `json:"enabled"`
NormalTimeToSleep int `json:"normal_time_to_sleep"`
OneMinuteLaThreshold int `json:"one_minute_la_threshold"`
OversizeTimeToSleep int `json:"oversize_time_to_sleep"`
PurgeAttemptsThreshold int `json:"purge_attempts_threshold"`
}
type HousekeepingSettings struct {
DiskDelQueue DiskDelQueue `json:"disk_del_queue"`
}
type TatlinConfigSep struct {
ApiUrls []string `json:"API_URLs"`
DiskMaxSize int `json:"disk_max_size"`
Format string `json:"format"`
EdgeuserName string `json:"edgeuser_name"`
EdgeuserPassword string `json:"edgeuser_password"`
MGMTPassword string `json:"mgmt_password"`
MGMTUser string `json:"mgmt_user"`
HostGroupName string `json:"hostGroupName"`
Model string `json:"model"`
NamePrefix string `json:"name_prefix"`
Ports TatlinPortList `json:"ports"`
Pools PoolList `json:"pools"`
Protocol string `json:"protocol"`
TechDisk TatlinTechDisk `json:"techDisk"`
HousekeepingSettings HousekeepingSettings `json:"housekeeping_settings"`
OVSSettings OVSSettings `json:"ovs_settings"`
}
//////Huawei Dorado
type DoradoPort struct {
IP string `json:"ip"`
Name string `json:"name"`
}
type DoradoPortList []DoradoPort
type DoradoGroup struct {
HostGroup []string `json:"hostgroup"`
LungGroup []string `json:"lungroup"`
PortGroup []string `json:"portgroup"`
}
type DoradoConfigSep struct {
ApiUrls []string `json:"API_URLs"`
DiskMaxSize int `json:"disk_max_size"`
Format string `json:"format"`
EdgeuserName string `json:"edgeuser_name"`
EdgeuserPassword string `json:"edgeuser_password"`
MGMTPassword string `json:"mgmt_password"`
MGMTUser string `json:"mgmt_user"`
HostGroupName string `json:"hostGroupName"`
Model string `json:"model"`
NamePrefix string `json:"name_prefix"`
Pools PoolList `json:"pools"`
Protocol string `json:"protocol"`
Ports DoradoPortList `json:"ports"`
Groups DoradoGroup `json:"groups"`
HousekeepingSettings HousekeepingSettings `json:"housekeeping_settings"`
OVSSettings OVSSettings `json:"ovs_settings"`
}
////////////SEP
type SepCommon struct {
Ckey string `json:"_ckey"`
Meta []interface{} `json:"_meta"`
ConsumedBy []int `json:"consumedBy"`
Desc string `json:"desc"`
Gid int `json:"gid"`
Guid int `json:"guid"`
Id int `json:"id"`
Milestones int `json:"milestones"`
Name string `json:"name"`
ObjStatus string `json:"objStatus"`
ProvidedBy []int `json:"providedBy"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
ConfigString interface{} `json:"config"`
}
type SepList []SepCommon
type SepDes struct {
SepCommon
Config DesConfigSep `json:"config"`
}
type SepDesList []SepDes
type SepHitachi struct {
SepCommon
Config HitachiConfigSep `json:"config"`
}
type SepHitachiList []SepHitachi
type SepTatlin struct {
SepCommon
Config TatlinConfigSep `json:"config"`
}
type SepTatlinList []SepTatlin
type SepDorado struct {
SepCommon
Config DoradoConfigSep `json:"config"`
}
type SepDoradoList []SepDorado
//////Consumption
type SepConsumptionInd struct { type SepConsumptionInd struct {
DiskCount int `json:"disk_count"` DiskCount int `json:"disk_count"`
DiskUsage int `json:"disk_usage"` DiskUsage int `json:"disk_usage"`
@ -1121,3 +888,25 @@ type SepConsumption struct {
} }
type SepDiskList []int type SepDiskList []int
type Sep struct {
Ckey string `json:"_ckey"`
Meta []interface{} `json:"_meta"`
ConsumedBy []int `json:"consumedBy"`
Desc string `json:"desc"`
Gid int `json:"gid"`
Guid int `json:"guid"`
Id int `json:"id"`
Milestones int `json:"milestones"`
Name string `json:"name"`
ObjStatus string `json:"objStatus"`
ProvidedBy []int `json:"providedBy"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
Config SepConfig `json:"config"`
}
type SepConfig map[string]interface{}
type SepList []Sep
type SepPool map[string]interface{}

@ -111,36 +111,28 @@ func Provider() *schema.Provider {
"decort_cdrom_image": resourceCDROMImage(), "decort_cdrom_image": resourceCDROMImage(),
"decort_delete_images": resourceDeleteImages(), "decort_delete_images": resourceDeleteImages(),
"decort_snapshot": resourceSnapshot(), "decort_snapshot": resourceSnapshot(),
"decort_sep_des": resourceSepDes(), "decort_sep": resourceSep(),
"decort_sep_config": resourceSepConfig(),
}, },
DataSourcesMap: map[string]*schema.Resource{ DataSourcesMap: map[string]*schema.Resource{
"decort_account": dataSourceAccount(), "decort_account": dataSourceAccount(),
"decort_resgroup": dataSourceResgroup(), "decort_resgroup": dataSourceResgroup(),
"decort_kvmvm": dataSourceCompute(), "decort_kvmvm": dataSourceCompute(),
"decort_image": dataSourceImage(), "decort_image": dataSourceImage(),
"decort_disk": dataSourceDisk(), "decort_disk": dataSourceDisk(),
"decort_vins": dataSourceVins(), "decort_vins": dataSourceVins(),
"decort_grid": dataSourceGrid(), "decort_grid": dataSourceGrid(),
"decort_grid_list": dataSourceGridList(), "decort_grid_list": dataSourceGridList(),
"decort_image_list": dataSourceImageList(), "decort_image_list": dataSourceImageList(),
"decort_image_list_stacks": dataSourceImageListStacks(), "decort_image_list_stacks": dataSourceImageListStacks(),
"decort_snapshot_list": dataSourceSnapshotList(), "decort_snapshot_list": dataSourceSnapshotList(),
"decort_sep_list": dataSourceSepList(), "decort_sep_list": dataSourceSepList(),
"decort_sep_des": dataSourceSepDes(), "decort_sep": dataSourceSep(),
"decort_sep_hitachi": dataSourceSepHitachi(), "decort_sep_consumption": dataSourceSepConsumption(),
"decort_sep_tatlin": dataSourceSepTatlin(), "decort_sep_disk_list": dataSourceSepDiskList(),
"decort_sep_dorado": dataSourceSepDorado(), "decort_sep_config": dataSourceSepConfig(),
"decort_sep_consumption": dataSourceSepConsumption(), "decort_sep_pool": dataSourceSepPool(),
"decort_sep_disk_list": dataSourceSepDiskList(),
"decort_sep_des_pool": dataSourceSepDesPool(),
"decort_sep_dorado_pool": dataSourceSepDoradoPool(),
"decort_sep_hitachi_pool": dataSourceSepHitachiPool(),
"decort_sep_tatlin_pool": dataSourceSepTatlinPool(),
"decort_sep_des_config": dataSourceSepConfigDes(),
"decort_sep_hitahci_config": dataSourceSepHitachiConfig(),
"decort_sep_dorado_config": dataSourceSepDoradoConfig(),
"decort_sep_tatlin_config": dataSourceSepTatlinConfig(),
// "decort_pfw": dataSourcePfw(), // "decort_pfw": dataSourcePfw(),
}, },

@ -36,23 +36,23 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func resourceSepDesCreate(d *schema.ResourceData, m interface{}) error { func resourceSepCreate(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSepDesCreate: called for sep %s type \"des\"", d.Get("name").(string)) log.Debugf("resourceSepCreate: called for sep %s", d.Get("name").(string))
if sepId, ok := d.GetOk("sep_id"); ok { if sepId, ok := d.GetOk("sep_id"); ok {
if exists, err := resourceSepDesExists(d, m); exists { if exists, err := resourceSepExists(d, m); exists {
if err != nil { if err != nil {
return err return err
} }
d.SetId(strconv.Itoa(sepId.(int))) d.SetId(strconv.Itoa(sepId.(int)))
err = resourceSepDesRead(d, m) err = resourceSepRead(d, m)
if err != nil { if err != nil {
return err return err
} }
return nil return nil
} }
return errors.New("provided device id does not exist") return errors.New("provided sep id does not exist")
} }
controller := m.(*ControllerCfg) controller := m.(*ControllerCfg)
@ -60,12 +60,12 @@ func resourceSepDesCreate(d *schema.ResourceData, m interface{}) error {
urlValues.Add("name", d.Get("name").(string)) urlValues.Add("name", d.Get("name").(string))
urlValues.Add("gid", strconv.Itoa(d.Get("gid").(int))) urlValues.Add("gid", strconv.Itoa(d.Get("gid").(int)))
urlValues.Add("sep_type", "des") urlValues.Add("sep_type", d.Get("type").(string))
if desc, ok := d.GetOk("desc"); ok { if desc, ok := d.GetOk("desc"); ok {
urlValues.Add("description", desc.(string)) urlValues.Add("description", desc.(string))
} }
if configString, ok := d.GetOk("config_string"); ok { if configString, ok := d.GetOk("config"); ok {
urlValues.Add("config", configString.(string)) urlValues.Add("config", configString.(string))
} }
if enable, ok := d.GetOk("enable"); ok { if enable, ok := d.GetOk("enable"); ok {
@ -98,16 +98,16 @@ func resourceSepDesCreate(d *schema.ResourceData, m interface{}) error {
temp = "[" + temp + "]" temp = "[" + temp + "]"
urlValues.Add("provider_nids", temp) urlValues.Add("provider_nids", temp)
sepDesId, err := controller.decortAPICall("POST", sepCreateAPI, urlValues) sepId, err := controller.decortAPICall("POST", sepCreateAPI, urlValues)
if err != nil { if err != nil {
return err return err
} }
id := uuid.New() id := uuid.New()
d.SetId(sepDesId) d.SetId(sepId)
d.Set("sep_id", sepDesId) d.Set("sep_id", sepId)
err = resourceSepDesRead(d, m) err = resourceSepRead(d, m)
if err != nil { if err != nil {
return err return err
} }
@ -117,39 +117,38 @@ func resourceSepDesCreate(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceSepDesRead(d *schema.ResourceData, m interface{}) error { func resourceSepRead(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSepDesRead: called for %s id: %d", d.Get("name").(string), d.Get("sep_id").(int)) log.Debugf("resourceSepRead: called for %s id: %d", d.Get("name").(string), d.Get("sep_id").(int))
sepDes, err := utilitySepDesCheckPresence(d, m) sep, err := utilitySepCheckPresence(d, m)
if sepDes == nil { if sep == nil {
d.SetId("") d.SetId("")
return err return err
} }
d.Set("ckey", sepDes.Ckey) d.Set("ckey", sep.Ckey)
d.Set("meta", flattenMeta(sepDes.Meta)) d.Set("meta", flattenMeta(sep.Meta))
d.Set("consumed_by", sepDes.ConsumedBy) d.Set("consumed_by", sep.ConsumedBy)
d.Set("desc", sepDes.Desc) d.Set("desc", sep.Desc)
d.Set("gid", sepDes.Gid) d.Set("gid", sep.Gid)
d.Set("guid", sepDes.Guid) d.Set("guid", sep.Guid)
d.Set("sep_id", sepDes.Id) d.Set("sep_id", sep.Id)
d.Set("milestones", sepDes.Milestones) d.Set("milestones", sep.Milestones)
d.Set("name", sepDes.Name) d.Set("name", sep.Name)
d.Set("obj_status", sepDes.ObjStatus) d.Set("obj_status", sep.ObjStatus)
d.Set("provided_by", sepDes.ProvidedBy) d.Set("provided_by", sep.ProvidedBy)
d.Set("tech_status", sepDes.TechStatus) d.Set("tech_status", sep.TechStatus)
d.Set("type", sepDes.Type) d.Set("type", sep.Type)
data, _ := json.Marshal(sepDes.Config) data, _ := json.Marshal(sep.Config)
d.Set("config_string", string(data)) d.Set("config", string(data))
d.Set("config", flattenSepDesConfig(sepDes.Config))
return nil return nil
} }
func resourceSepDesDelete(d *schema.ResourceData, m interface{}) error { func resourceSepDelete(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSepDesDelete: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int)) log.Debugf("resourceSepDelete: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
sepDes, err := utilitySepDesCheckPresence(d, m) sepDes, err := utilitySepCheckPresence(d, m)
if sepDes == nil { if sepDes == nil {
if err != nil { if err != nil {
return err return err
@ -170,10 +169,10 @@ func resourceSepDesDelete(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceSepDesExists(d *schema.ResourceData, m interface{}) (bool, error) { func resourceSepExists(d *schema.ResourceData, m interface{}) (bool, error) {
log.Debugf("resourceSepDesExists: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int)) log.Debugf("resourceSepExists: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
sepDes, err := utilitySepDesCheckPresence(d, m) sepDes, err := utilitySepCheckPresence(d, m)
if sepDes == nil { if sepDes == nil {
if err != nil { if err != nil {
return false, err return false, err
@ -184,14 +183,14 @@ func resourceSepDesExists(d *schema.ResourceData, m interface{}) (bool, error) {
return true, nil return true, nil
} }
func resourceSepDesEdit(d *schema.ResourceData, m interface{}) error { func resourceSepEdit(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSepDesEdit: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int)) log.Debugf("resourceSepEdit: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
c := m.(*ControllerCfg) c := m.(*ControllerCfg)
urlValues := &url.Values{}
if d.HasChange("decommision") { urlValues := &url.Values{}
decommision := d.Get("decommision").(bool) if d.HasChange("decommission") {
if decommision { decommission := d.Get("decommission").(bool)
if decommission {
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int))) urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
urlValues.Add("clear_physically", strconv.FormatBool(d.Get("clear_physically").(bool))) urlValues.Add("clear_physically", strconv.FormatBool(d.Get("clear_physically").(bool)))
_, err := c.decortAPICall("POST", sepDecommissionAPI, urlValues) _, err := c.decortAPICall("POST", sepDecommissionAPI, urlValues)
@ -200,6 +199,7 @@ func resourceSepDesEdit(d *schema.ResourceData, m interface{}) error {
} }
} }
} }
urlValues = &url.Values{} urlValues = &url.Values{}
if d.HasChange("upd_capacity_limit") { if d.HasChange("upd_capacity_limit") {
updCapacityLimit := d.Get("upd_capacity_limit").(bool) updCapacityLimit := d.Get("upd_capacity_limit").(bool)
@ -213,8 +213,37 @@ func resourceSepDesEdit(d *schema.ResourceData, m interface{}) error {
} }
urlValues = &url.Values{} urlValues = &url.Values{}
if d.HasChange("config") {
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
urlValues.Add("config", d.Get("config").(string))
_, err := c.decortAPICall("POST", sepConfigValidateAPI, urlValues)
if err != nil {
return err
}
_, err = c.decortAPICall("POST", sepConfigInsertAPI, urlValues)
if err != nil {
return err
}
err := resourceSepDesRead(d, m) }
urlValues = &url.Values{}
if d.HasChange("field_edit") {
fieldConfig := d.Get("field_edit").([]interface{})
field := fieldConfig[0].(map[string]interface{})
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
urlValues.Add("field_name", field["field_name"].(string))
urlValues.Add("field_value", field["field_value"].(string))
urlValues.Add("field_type", field["field_type"].(string))
_, err := c.decortAPICall("POST", sepConfigFieldEditAPI, urlValues)
if err != nil {
return err
}
}
urlValues = &url.Values{}
err := resourceSepRead(d, m)
if err != nil { if err != nil {
return err return err
} }
@ -340,7 +369,7 @@ func resourceSepSchemaMake() map[string]*schema.Schema {
Default: false, Default: false,
Description: "Update SEP capacity limit", Description: "Update SEP capacity limit",
}, },
"decommision": { "decommission": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
Default: false, Default: false,
@ -352,7 +381,7 @@ func resourceSepSchemaMake() map[string]*schema.Schema {
Default: true, Default: true,
Description: "clear disks and images physically", Description: "clear disks and images physically",
}, },
"config_string": { "config": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
Computed: true, Computed: true,
@ -421,7 +450,7 @@ func resourceSepSchemaMake() map[string]*schema.Schema {
}, },
"type": { "type": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Required: true,
Description: "type of storage", Description: "type of storage",
}, },
"enable": { "enable": {
@ -430,164 +459,40 @@ func resourceSepSchemaMake() map[string]*schema.Schema {
Default: false, Default: false,
Description: "enable SEP after creation", Description: "enable SEP after creation",
}, },
} "field_edit": {
} Type: schema.TypeList,
MaxItems: 1,
func resourceSepDesSchemaMake(sh map[string]*schema.Schema) map[string]*schema.Schema { Optional: true,
sh["config"] = &schema.Schema{ Computed: true,
Type: schema.TypeList, Elem: &schema.Resource{
MaxItems: 1, Schema: map[string]*schema.Schema{
Computed: true, "field_name": {
Elem: &schema.Resource{ Type: schema.TypeString,
Schema: map[string]*schema.Schema{ Required: true,
"api_ips": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
}, },
}, "field_value": {
"capacity_limit": { Type: schema.TypeString,
Type: schema.TypeInt, Required: true,
Computed: true,
},
"protocol": {
Type: schema.TypeString,
Computed: true,
},
"decs3o_app_secret": {
Type: schema.TypeString,
Computed: true,
},
"format": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_password": {
Type: schema.TypeString,
Computed: true,
},
"edgeuser_name": {
Type: schema.TypeString,
Computed: true,
},
"decs3o_app_id": {
Type: schema.TypeString,
Computed: true,
},
"transport": {
Type: schema.TypeString,
Computed: true,
},
"pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"types": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"reference_id": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"pagecache_ratio": {
Type: schema.TypeInt,
Computed: true,
},
"uris": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
}, },
}, "field_type": {
"housekeeping_settings": { Type: schema.TypeString,
Type: schema.TypeList, Required: true,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disk_del_queue": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"chunk_max_size": {
Type: schema.TypeInt,
Computed: true,
},
"disk_count_max": {
Type: schema.TypeInt,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"normal_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"one_minute_la_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"oversize_time_to_sleep": {
Type: schema.TypeInt,
Computed: true,
},
"purge_attempts_threshold": {
Type: schema.TypeInt,
Computed: true,
},
"purgatory_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
}, },
}, },
}, },
}, },
} }
return sh
} }
func resourceSepDes() *schema.Resource { func resourceSep() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Create: resourceSepDesCreate, Create: resourceSepCreate,
Read: resourceSepDesRead, Read: resourceSepRead,
Update: resourceSepDesEdit, Update: resourceSepEdit,
Delete: resourceSepDesDelete, Delete: resourceSepDelete,
Exists: resourceSepDesExists, Exists: resourceSepExists,
Importer: &schema.ResourceImporter{ Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough, State: schema.ImportStatePassthrough,
@ -601,7 +506,7 @@ func resourceSepDes() *schema.Resource {
Default: &Timeout60s, Default: &Timeout60s,
}, },
Schema: resourceSepDesSchemaMake(resourceSepSchemaMake()), Schema: resourceSepSchemaMake(),
CustomizeDiff: customdiff.All( CustomizeDiff: customdiff.All(
customdiff.IfValueChange("enable", func(old, new, meta interface{}) bool { customdiff.IfValueChange("enable", func(old, new, meta interface{}) bool {

@ -0,0 +1,197 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"errors"
"net/url"
"strconv"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
log "github.com/sirupsen/logrus"
)
func resourceSepConfigCreate(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSepConfigCreate: called for sep id %d", d.Get("sep_id").(int))
if _, ok := d.GetOk("sep_id"); ok {
if exists, err := resourceSepConfigExists(d, m); exists {
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
err = resourceSepConfigRead(d, m)
if err != nil {
return err
}
return nil
}
return errors.New("provided sep id config does not exist")
}
resourceSepConfigRead(d, m)
return nil
}
func resourceSepConfigRead(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSepConfigRead: called for sep id: %d", d.Get("sep_id").(int))
sepConfig, err := utilitySepConfigCheckPresence(d, m)
if sepConfig == nil {
d.SetId("")
return err
}
data, _ := json.Marshal(sepConfig)
d.Set("config", string(data))
return nil
}
func resourceSepConfigDelete(d *schema.ResourceData, m interface{}) error {
d.SetId("")
return nil
}
func resourceSepConfigExists(d *schema.ResourceData, m interface{}) (bool, error) {
log.Debugf("resourceSepConfigExists: called for sep id: %d", d.Get("sep_id").(int))
sepDesConfig, err := utilitySepConfigCheckPresence(d, m)
if sepDesConfig == nil {
if err != nil {
return false, err
}
return false, nil
}
return true, nil
}
func resourceSepConfigEdit(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSepConfigEdit: called for sep id: %d", d.Get("sep_id").(int))
c := m.(*ControllerCfg)
urlValues := &url.Values{}
if d.HasChange("config") {
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
urlValues.Add("config", d.Get("config").(string))
_, err := c.decortAPICall("POST", sepConfigValidateAPI, urlValues)
if err != nil {
return err
}
_, err = c.decortAPICall("POST", sepConfigInsertAPI, urlValues)
if err != nil {
return err
}
}
urlValues = &url.Values{}
if d.HasChange("field_edit") {
fieldConfig := d.Get("field_edit").([]interface{})
field := fieldConfig[0].(map[string]interface{})
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
urlValues.Add("field_name", field["field_name"].(string))
urlValues.Add("field_value", field["field_value"].(string))
urlValues.Add("field_type", field["field_type"].(string))
_, err := c.decortAPICall("POST", sepConfigFieldEditAPI, urlValues)
if err != nil {
return err
}
}
err := resourceSepConfigRead(d, m)
if err != nil {
return err
}
return nil
}
func resourceSepConfigSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"sep_id": {
Type: schema.TypeInt,
Required: true,
},
"config": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"field_edit": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"field_name": {
Type: schema.TypeString,
Required: true,
},
"field_value": {
Type: schema.TypeString,
Required: true,
},
"field_type": {
Type: schema.TypeString,
Required: true,
},
},
},
},
}
}
func resourceSepConfig() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Create: resourceSepConfigCreate,
Read: resourceSepConfigRead,
Update: resourceSepConfigEdit,
Delete: resourceSepConfigDelete,
Exists: resourceSepConfigExists,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Timeouts: &schema.ResourceTimeout{
Create: &Timeout60s,
Read: &Timeout30s,
Update: &Timeout60s,
Delete: &Timeout60s,
Default: &Timeout60s,
},
Schema: resourceSepConfigSchemaMake(),
}
}

@ -26,21 +26,19 @@ package decort
import ( import (
"encoding/json" "encoding/json"
"errors"
"net/url" "net/url"
"strconv" "strconv"
"strings"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
) )
func utilitySepDesCheckPresence(d *schema.ResourceData, m interface{}) (*SepDes, error) { func utilitySepCheckPresence(d *schema.ResourceData, m interface{}) (*Sep, error) {
controller := m.(*ControllerCfg) controller := m.(*ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
sepDes := &SepDes{} sep := &Sep{}
if d.Get("sep_id").(int) == 0 { if d.Get("sep_id").(int) == 0 {
urlValues.Add("sep_id", d.Id()) urlValues.Add("sep_id", d.Id())
@ -48,19 +46,16 @@ func utilitySepDesCheckPresence(d *schema.ResourceData, m interface{}) (*SepDes,
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int))) urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
} }
log.Debugf("utilitySepDesCheckPresence: load sep") log.Debugf("utilitySepCheckPresence: load sep")
sepDesRaw, err := controller.decortAPICall("POST", sepGetAPI, urlValues) sepRaw, err := controller.decortAPICall("POST", sepGetAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = json.Unmarshal([]byte(sepDesRaw), sepDes) err = json.Unmarshal([]byte(sepRaw), sep)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if strings.ToLower(sepDes.Type) != "des" {
return nil, errors.New("Invalid sep type")
}
return sepDes, nil return sep, nil
} }

@ -34,24 +34,24 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
) )
func utilitySepConfigDesCheckPresence(d *schema.ResourceData, m interface{}) (*DesConfigSep, error) { func utilitySepConfigCheckPresence(d *schema.ResourceData, m interface{}) (SepConfig, error) {
controller := m.(*ControllerCfg) controller := m.(*ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
sepConfigDes := &DesConfigSep{} sepConfig := SepConfig{}
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int))) urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
log.Debugf("utilitySepConfigDesCheckPresence: load sep") log.Debugf("utilitySepConfigCheckPresence: load sep config")
sepConfigDesRaw, err := controller.decortAPICall("POST", sepGetConfigAPI, urlValues) sepConfigRaw, err := controller.decortAPICall("POST", sepGetConfigAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = json.Unmarshal([]byte(sepConfigDesRaw), sepConfigDes) err = json.Unmarshal([]byte(sepConfigRaw), &sepConfig)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return sepConfigDes, nil return sepConfig, nil
} }

@ -1,67 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"errors"
"net/url"
"strconv"
"strings"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySepDoradoCheckPresence(d *schema.ResourceData, m interface{}) (*SepDorado, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
sepDorado := &SepDorado{}
if d.Get("sep_id").(int) == 0 {
urlValues.Add("sep_id", d.Id())
} else {
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
}
log.Debugf("utilitySepDoradoCheckPresence: load sep")
sepDoradoRaw, err := controller.decortAPICall("POST", sepGetAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(sepDoradoRaw), sepDorado)
if err != nil {
return nil, err
}
if strings.ToLower(sepDorado.Type) != "dorado" {
return nil, errors.New("Invalid sep type")
}
return sepDorado, nil
}

@ -1,57 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"net/url"
"strconv"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySepDoradoConfigCheckPresence(d *schema.ResourceData, m interface{}) (*DoradoConfigSep, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
sepDoradoConfig := &DoradoConfigSep{}
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
log.Debugf("utilitySepDoradoConfigCheckPresence: load sep")
sepDoradoConfigRaw, err := controller.decortAPICall("POST", sepGetConfigAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(sepDoradoConfigRaw), sepDoradoConfig)
if err != nil {
return nil, err
}
return sepDoradoConfig, nil
}

@ -1,58 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"net/url"
"strconv"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySepDoradoPoolCheckPresence(d *schema.ResourceData, m interface{}) (*Pool, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
sepDoradoPool := &Pool{}
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
urlValues.Add("pool_name", d.Get("pool_name").(string))
log.Debugf("utilitySepDoradoPoolCheckPresence: load sep")
sepDoradoPoolRaw, err := controller.decortAPICall("POST", sepGetPoolAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(sepDoradoPoolRaw), sepDoradoPool)
if err != nil {
return nil, err
}
return sepDoradoPool, nil
}

@ -1,67 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"errors"
"net/url"
"strconv"
"strings"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySepHitachiCheckPresence(d *schema.ResourceData, m interface{}) (*SepHitachi, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
sepHitachi := &SepHitachi{}
if d.Get("sep_id").(int) == 0 {
urlValues.Add("sep_id", d.Id())
} else {
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
}
log.Debugf("utilitySepHitachiCheckPresence: load sep")
sepHitachiRaw, err := controller.decortAPICall("POST", sepGetAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(sepHitachiRaw), sepHitachi)
if err != nil {
return nil, err
}
if strings.ToLower(sepHitachi.Type) != "hitachi" {
return nil, errors.New("Invalid sep type")
}
return sepHitachi, nil
}

@ -1,57 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"net/url"
"strconv"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySepHitachiConfigCheckPresence(d *schema.ResourceData, m interface{}) (*HitachiConfigSep, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
sepHitachiConfig := &HitachiConfigSep{}
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
log.Debugf("utilitySepHitachiConfigCheckPresence: load sep")
sepHitachiConfigRaw, err := controller.decortAPICall("POST", sepGetConfigAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(sepHitachiConfigRaw), sepHitachiConfig)
if err != nil {
return nil, err
}
return sepHitachiConfig, nil
}

@ -1,58 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"net/url"
"strconv"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySepHitachiPoolCheckPresence(d *schema.ResourceData, m interface{}) (*HitachiConfigPool, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
sepHitachiPool := &HitachiConfigPool{}
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
urlValues.Add("pool_name", d.Get("pool_name").(string))
log.Debugf("utilitySepDoradoPoolCheckPresence: load sep")
sepHitachiPoolRaw, err := controller.decortAPICall("POST", sepGetPoolAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(sepHitachiPoolRaw), sepHitachiPool)
if err != nil {
return nil, err
}
return sepHitachiPool, nil
}

@ -34,25 +34,25 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
) )
func utilitySepDesPoolCheckPresence(d *schema.ResourceData, m interface{}) (*DesConfigPool, error) { func utilitySepPoolCheckPresence(d *schema.ResourceData, m interface{}) (SepPool, error) {
controller := m.(*ControllerCfg) controller := m.(*ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
sepDesPool := &DesConfigPool{} sepPool := SepPool{}
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int))) urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
urlValues.Add("pool_name", d.Get("pool_name").(string)) urlValues.Add("pool_name", d.Get("pool_name").(string))
log.Debugf("utilitySepDesPoolCheckPresence: load sep") log.Debugf("utilitySepDesPoolCheckPresence: load sep")
sepDesPoolRaw, err := controller.decortAPICall("POST", sepGetPoolAPI, urlValues) sepPoolRaw, err := controller.decortAPICall("POST", sepGetPoolAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = json.Unmarshal([]byte(sepDesPoolRaw), sepDesPool) err = json.Unmarshal([]byte(sepPoolRaw), &sepPool)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return sepDesPool, nil return sepPool, nil
} }

@ -1,57 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"net/url"
"strconv"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySepTatlinConfigCheckPresence(d *schema.ResourceData, m interface{}) (*TatlinConfigSep, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
sepTatlinConfig := &TatlinConfigSep{}
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
log.Debugf("utilitySepTatlinConfigCheckPresence: load sep")
sepTatlinConfigRaw, err := controller.decortAPICall("POST", sepGetConfigAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(sepTatlinConfigRaw), sepTatlinConfig)
if err != nil {
return nil, err
}
return sepTatlinConfig, nil
}

@ -1,58 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"net/url"
"strconv"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySepTatlinPoolCheckPresence(d *schema.ResourceData, m interface{}) (*Pool, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
sepTatlinPool := &Pool{}
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
urlValues.Add("pool_name", d.Get("pool_name").(string))
log.Debugf("utilitySepDoradoPoolCheckPresence: load sep")
sepTatlinPoolRaw, err := controller.decortAPICall("POST", sepGetPoolAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(sepTatlinPoolRaw), sepTatlinPool)
if err != nil {
return nil, err
}
return sepTatlinPool, nil
}

@ -9,6 +9,12 @@
- image_list - image_list
- image_list_stacks - image_list_stacks
- snapshot_list - snapshot_list
- sep
- sep_list
- sep_disk_list
- sep_config
- sep_pool
- sep_consumption
- resources: - resources:
- image - image
- virtual_image - virtual_image
@ -17,6 +23,8 @@
- k8s - k8s
- k8s_wg - k8s_wg
- snapshot - snapshot
- sep
- sep_config
## Как пользоваться примерами ## Как пользоваться примерами
1. Установить terraform 1. Установить terraform

@ -1,16 +1,11 @@
/* /*
Пример использования Пример использования
Ресурса cdrom image Получение данных sep
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/ */
#Расскомментируйте этот код, #Расскомментируйте код ниже,
#и внесите необходимые правки в версию и путь, #и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером #чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform { terraform {
required_providers { required_providers {
decort = { decort = {
@ -19,23 +14,29 @@ terraform {
} }
} }
} }
*/
provider "decort" { provider "decort" {
authenticator = "oauth2" authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL> #controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online" controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://alfa.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL> #oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online" oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://iyo-alfa.dev.decs.online:8443"
allow_unverified_ssl = true allow_unverified_ssl = true
} }
data "decort_sep_des" "sl" { data "decort_sep" "sd" {
sep_id = 1206 #id sep
#обязательный параметр
#тип - число
sep_id = 1111
} }
output "test" { output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips value = data.decort_sep.sd
value = data.decort_sep_des.sl }
output "config" {
value = jsondecode(data.decort_sep.sd.config)
} }

@ -1,16 +1,11 @@
/* /*
Пример использования Пример использования
Ресурса cdrom image Получение данных конфигурации sep
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/ */
#Расскомментируйте этот код, #Расскомментируйте код ниже,
#и внесите необходимые правки в версию и путь, #и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером #чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform { terraform {
required_providers { required_providers {
decort = { decort = {
@ -19,23 +14,28 @@ terraform {
} }
} }
} }
*/
provider "decort" { provider "decort" {
authenticator = "oauth2" authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL> #controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online" controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://alfa.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL> #oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online" oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://iyo-alfa.dev.decs.online:8443"
allow_unverified_ssl = true allow_unverified_ssl = true
} }
data "decort_sep_des" "sl" { data "decort_sep_config" "sc" {
sep_id = 1206 #id sep
#обязательный параметр
#тип - число
sep_id = 1111
} }
output "test" { output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips value = data.decort_sep_config.sc
value = data.decort_sep_des.sl }
output "config" {
value = jsondecode(data.decort_config.sc.config)
} }

@ -1,16 +1,11 @@
/* /*
Пример использования Пример использования
Ресурса cdrom image Получение общих данных об использовании sep
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/ */
#Расскомментируйте этот код, #Расскомментируйте код ниже,
#и внесите необходимые правки в версию и путь, #и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером #чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform { terraform {
required_providers { required_providers {
decort = { decort = {
@ -19,26 +14,24 @@ terraform {
} }
} }
} }
*/
provider "decort" { provider "decort" {
authenticator = "oauth2" authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL> #controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online" controller_url = "https://ds1.digitalenergy.online"
#controller_url = "https://gamma.dev.decs.online"
controller_url = "https://alfa.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL> #oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online" oauth2_url = "https://sso.digitalenergy.online"
#oauth2_url = "https://sso-gamma.dev.decs.online:8443"
oauth2_url = "https://iyo-alfa.dev.decs.online:8443"
allow_unverified_ssl = true allow_unverified_ssl = true
} }
data "decort_sep_consumption" "sd" { data "decort_sep_consumption" "scons" {
sep_id = 1206 #id sep
#обязательный параметр
#тип - число
sep_id = 1111
} }
output "test" { output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips value = data.decort_sep_consumption.scons
value = data.decort_sep_consumption.sd
} }

@ -1,42 +0,0 @@
/*
Пример использования
Ресурса cdrom image
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://alfa.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://iyo-alfa.dev.decs.online:8443"
allow_unverified_ssl = true
}
data "decort_sep_des_config" "sd" {
sep_id = 1206
}
output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips
value = data.decort_sep_des_config.sd
}

@ -1,43 +0,0 @@
/*
Пример использования
Ресурса cdrom image
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://gamma.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://sso-gamma.dev.decs.online:8443"
allow_unverified_ssl = true
}
data "decort_sep_des_pool" "sd" {
sep_id = 1
pool_name = "data01"
}
output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips
value = data.decort_sep_des_pool.sd
}

@ -1,16 +1,12 @@
/* /*
Пример использования Пример использования
Ресурса cdrom image Получение данных об используемых sep дисках
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/ */
#Расскомментируйте этот код,
#Расскомментируйте код ниже,
#и внесите необходимые правки в версию и путь, #и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером #чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform { terraform {
required_providers { required_providers {
decort = { decort = {
@ -19,26 +15,28 @@ terraform {
} }
} }
} }
*/
provider "decort" { provider "decort" {
authenticator = "oauth2" authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL> #controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online" controller_url = "https://ds1.digitalenergy.online"
#controller_url = "https://gamma.dev.decs.online"
controller_url = "https://alfa.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL> #oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online" oauth2_url = "https://sso.digitalenergy.online"
#oauth2_url = "https://sso-gamma.dev.decs.online:8443"
oauth2_url = "https://iyo-alfa.dev.decs.online:8443"
allow_unverified_ssl = true allow_unverified_ssl = true
} }
data "decort_sep_disk_list" "sd" { data "decort_sep_disk_list" "sdl" {
sep_id = 1206 #id sep
#обязательный параметр
#тип - число
sep_id = 1111
#sep pool name
#необязательный параметр
#тип - строка
#pool_name = "sep_pool"
} }
output "test" { output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips value = data.decort_sep_disk_list.sdl
value = data.decort_sep_disk_list.sd
} }

@ -1,43 +0,0 @@
/*
Пример использования
Ресурса cdrom image
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://gamma.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://sso-gamma.dev.decs.online:8443"
allow_unverified_ssl = true
}
data "decort_sep_dorado_pool" "sd" {
sep_id = 7
pool_name = "SP1"
}
output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips
value = data.decort_sep_dorado_pool.sd
}

@ -1,41 +0,0 @@
/*
Пример использования
Ресурса cdrom image
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://alfa.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://iyo-alfa.dev.decs.online:8443"
allow_unverified_ssl = true
}
data "decort_sep_des" "sl" {
sep_id = 1206
}
output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips
value = data.decort_sep_des.sl
}

@ -1,43 +0,0 @@
/*
Пример использования
Ресурса cdrom image
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://gamma.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://sso-gamma.dev.decs.online:8443"
allow_unverified_ssl = true
}
data "decort_sep_hitachi_pool" "sd" {
sep_id = 7
pool_name = "SP1"
}
output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips
value = data.decort_sep_hitachi_pool.sd
}

@ -1,16 +1,11 @@
/* /*
Пример использования Пример использования
Ресурса cdrom image Получение списка sep
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/ */
#Расскомментируйте этот код, #Расскомментируйте код ниже,
#и внесите необходимые правки в версию и путь, #и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером #чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform { terraform {
required_providers { required_providers {
decort = { decort = {
@ -19,19 +14,25 @@ terraform {
} }
} }
} }
*/
provider "decort" { provider "decort" {
authenticator = "oauth2" authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL> #controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online" controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://alfa.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL> #oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online" oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://iyo-alfa.dev.decs.online:8443"
allow_unverified_ssl = true allow_unverified_ssl = true
} }
data "decort_sep_list" "sl" { data "decort_sep_list" "sl" {
#страница
#необязательный параметр
#тип - число
#page = 3
#размер страницы
#необязательный параметр
#тип - число
#size = 2
} }
output "test" { output "test" {

@ -1,16 +1,12 @@
/* /*
Пример использования Пример использования
Ресурса cdrom image Получение данных sep pool
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/ */
#Расскомментируйте этот код, #Расскомментируйте код ниже,
#и внесите необходимые правки в версию и путь, #и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером #чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform { terraform {
required_providers { required_providers {
decort = { decort = {
@ -19,23 +15,32 @@ terraform {
} }
} }
} }
*/
provider "decort" { provider "decort" {
authenticator = "oauth2" authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL> #controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online" controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://alfa.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL> #oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online" oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://iyo-alfa.dev.decs.online:8443"
allow_unverified_ssl = true allow_unverified_ssl = true
} }
data "decort_sep_des" "sl" { data "decort_sep_pool" "sp" {
sep_id = 1206 #id sep
#обязательный параметр
#тип - число
sep_id = 1111
#sep pool name
#обязательный параметр
#тип - строка
pool_name = "sep_pool"
} }
output "test" { output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips value = data.decort_sep_pool.sp
value = data.decort_sep_des.sl }
output "pool" {
value = jsondecode(data.decort_sep_pool.sp.pool)
} }

@ -1,43 +0,0 @@
/*
Пример использования
Ресурса cdrom image
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://gamma.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://sso-gamma.dev.decs.online:8443"
allow_unverified_ssl = true
}
data "decort_sep_tatlin_pool" "sd" {
sep_id = 7
pool_name = "SP1"
}
output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips
value = data.decort_sep_tatlin_pool.sd
}

@ -0,0 +1,124 @@
/*
Пример использования
Ресурса sep
Ресурс позволяет:
1. Создавать sep.
2. Редактировать sep.
3. Удалять sep.
4. Конфигурировать sep.
*/
#Расскомментируйте код ниже,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
*/
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
controller_url = "https://ds1.digitalenergy.online"
#oauth2_url = <DECORT_SSO_URL>
oauth2_url = "https://sso.digitalenergy.online"
allow_unverified_ssl = true
}
resource "decort_sep" "s" {
#grid id
#обязательный параметр
#тип - число
gid = 212
#sep name
#обязательный параметр
#тип - строка
name = "test sep"
#тип sep
#обязательный параметр
#тип - строка
#возможные значения - des, dorado, tatlin, hitachi
type = "des"
#описание sep
#необязательный параметр, используется при создании ресурса
#тип - строка
desc = "rrrrr"
#конфигурация sep
#необязательный параметр, мб применен при создании или редактировании sep
#представляет собой json-строку
#тип - строка
#config = file("./config.json")
#изменение поля в конфигурации
#необязательный параметр, мб применен на уже созданном sep
#тип - объект
#внимание, во избежание конфликтов не использовать с полем config
/*
field_edit {
#имя поля
#обязательный параметр
#тип - строка
field_name = "edgeuser_password"
#значение поля
#обязательный параметр
#тип - json строка
field_value = "mosk"
#тип значения
#обязательный параметр
#тип - строка, возможные значения: list,dict,int,bool,str
field_type = "str"
}
*/
#доступность sep
#необязательный параметр, мб применен на уже созданном ресурсе
#тип - булево значение
#enable = false
#использование нодами
#необязательный параметр, используется при редактировании ресурса
#тип - массив чисел
#consumed_by = []
#обновление лимита объема
#необязательный параметр, применяется на уж созданнном ресурсе
#тип - булев тип
#upd_capacity_limit = true
#id provided nodes
#необязательный параметр, применяется на уже созданном ресурсе
#тип - массив чисел
#provided_by = [16, 14, 15]
#отключение nodes
#необязательный параметр, применяется на уже созданном ресурсе
#тип - булев тип
#используется в связке с clear_physically
#decommission = true
#физическое очищение nodes
#необязательный параметр, используется при удалении ресурса
#тип - булев тип
#clear_physically = false
}
output "test" {
value = decort_sep.s
}
output "config" {
value = jsondecode(decort_sep.s.config)
}

@ -0,0 +1,73 @@
/*
Пример использования
Ресурс конфигурации sep
Ресурс позволяет:
1. Получить конфигурацию
2. Изменять конфигурацию
3. Изменять отдельные поля конфигурации
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
*/
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
controller_url = "https://ds1.digitalenergy.online"
#oauth2_url = <DECORT_SSO_URL>
oauth2_url = "https://sso.digitalenergy.online"
allow_unverified_ssl = true
}
resource "decort_sep_config" "sc" {
#id sep
#обязательный параметр
#тип - число
sep_id = 1111
#конфигурация
#необязательное поле, используется для изменения конфигурации
#тип - json-строка
#config = file("./config.json")
#редактироваие поля
#неоябазательный параметр, используется при редактировании ресурса
#тип - объект
/*
field_edit {
#имя поля
#обязательный параметр
#тип - строка
field_name = "edgeuser_password"
#значение поля
#обязательный параметр
#тип - строка
field_value = "shshs"
#тип поля
#обязательный параметр
#тип - строка
#возможные значения - int,bool, str, dict, list
field_type = "str"
}
*/
}
output "sep_config" {
value = decort_sep_config.sc
}
output "sep_config_json" {
value = jsondecode(decort_sep_config.sc.config)
}

@ -1,51 +0,0 @@
/*
Пример использования
Ресурса cdrom image
Ресурс позволяет:
1. Создавать образ
2. Редактировать образ
3. Удалять образ
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
#controller_url = "https://ds1.digitalenergy.online"
controller_url = "https://gamma.dev.decs.online"
#oauth2_url = <DECORT_SSO_URL>
#oauth2_url = "https://sso.digitalenergy.online"
oauth2_url = "https://sso-gamma.dev.decs.online:8443"
allow_unverified_ssl = true
}
resource "decort_sep_des" "sd" {
sep_id = 11
gid = 214
name = "test sep"
desc = "rrrrr"
enable = false
consumed_by = []
upd_capacity_limit = true
#provided_by = [16, 14, 15]
#decommision = true
#clear_physically = false
}
output "test" {
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips
value = decort_sep_des.sd
}
Loading…
Cancel
Save