Add all data and des resource
This commit is contained in:
180
decort/data_source_sep_consumption.go
Normal file
180
decort/data_source_sep_consumption.go
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
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 (
|
||||
"strconv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceSepConsumptionRead(d *schema.ResourceData, m interface{}) error {
|
||||
sepCons, err := utilitySepConsumptionCheckPresence(d, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
|
||||
d.Set("type", sepCons.Type)
|
||||
d.Set("total", flattenSepConsumption(sepCons.Total))
|
||||
err = d.Set("by_pool", flattenSepConsumptionPools(sepCons.ByPool))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func flattenSepConsumptionPools(mp map[string]SepConsumptionInd) []map[string]interface{} {
|
||||
sh := make([]map[string]interface{}, 0)
|
||||
for k, v := range mp {
|
||||
temp := map[string]interface{}{
|
||||
"name": k,
|
||||
"disk_count": v.DiskCount,
|
||||
"disk_usage": v.DiskUsage,
|
||||
"snapshot_count": v.SnapshotCount,
|
||||
"snapshot_usage": v.SnapshotUsage,
|
||||
"usage": v.Usage,
|
||||
"usage_limit": v.UsageLimit,
|
||||
}
|
||||
sh = append(sh, temp)
|
||||
}
|
||||
return sh
|
||||
}
|
||||
|
||||
func flattenSepConsumption(sc SepConsumptionTotal) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"capacity_limit": strconv.Itoa(sc.CapacityLimit),
|
||||
"disk_count": strconv.Itoa(sc.DiskCount),
|
||||
"disk_usage": strconv.Itoa(sc.DiskUsage),
|
||||
"snapshot_count": strconv.Itoa(sc.SnapshotCount),
|
||||
"snapshot_usage": strconv.Itoa(sc.SnapshotUsage),
|
||||
"usage": strconv.Itoa(sc.Usage),
|
||||
"usage_limit": strconv.Itoa(sc.UsageLimit),
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceSepConsumptionSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "sep type des id",
|
||||
},
|
||||
"by_pool": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_usage": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"snapshot_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"snapshot_usage": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"usage": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"usage_limit": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"total": {
|
||||
Type: schema.TypeMap,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"capacity_limit": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_count": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_usage": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"snapshot_count": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"snapshot_usage": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"usage": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"usage_limit": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceSepConsumption() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
Read: dataSourceSepConsumptionRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &Timeout30s,
|
||||
Default: &Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepConsumptionSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -25,49 +25,114 @@ Visit https://github.com/rudecs/terraform-provider-decort for full source code p
|
||||
package decort
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
)
|
||||
|
||||
func flattenSepList(sl SepList) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, item := range sl {
|
||||
temp := map[string]interface{}{
|
||||
"ckey": item.Ckey,
|
||||
"meta": flattenMeta(item.Meta),
|
||||
"consumed_by": item.ConsumedBy,
|
||||
"desc": item.Desc,
|
||||
"gid": item.Gid,
|
||||
"guid": item.Guid,
|
||||
"sep_id": item.Id,
|
||||
"milestones": item.Milestones,
|
||||
"name": item.Name,
|
||||
"obj_status": item.ObjStatus,
|
||||
"provided_by": item.ProvidedBy,
|
||||
"tech_status": item.TechStatus,
|
||||
"type": item.Type,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceSepListRead(d *schema.ResourceData, m interface{}) error {
|
||||
sepList, err := utilitySepListCheckPresence(d, m)
|
||||
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("items", flattenSepList(sepList))
|
||||
|
||||
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.TypeMap,
|
||||
Type: schema.TypeList,
|
||||
MaxItems: 1,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
@@ -78,6 +143,10 @@ func dataSourceSepDesSchemaMake(sh map[string]*schema.Schema) map[string]*schema
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"capacity_limit": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"protocol": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -106,6 +175,117 @@ func dataSourceSepDesSchemaMake(sh map[string]*schema.Schema) map[string]*schema
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -113,7 +293,7 @@ func dataSourceSepDesSchemaMake(sh map[string]*schema.Schema) map[string]*schema
|
||||
return sh
|
||||
}
|
||||
|
||||
func dataSourceSepCommonSchemaMake() map[string]*schema.Schema {
|
||||
func dataSourceSepSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -177,6 +357,10 @@ func dataSourceSepCommonSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"config_string": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +375,6 @@ func dataSourceSepDes() *schema.Resource {
|
||||
Default: &Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepDesSchemaMake(),
|
||||
Schema: dataSourceSepDesSchemaMake(dataSourceSepSchemaMake()),
|
||||
}
|
||||
}
|
||||
|
||||
238
decort/data_source_sep_des_config.go
Normal file
238
decort/data_source_sep_des_config.go
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
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(),
|
||||
}
|
||||
}
|
||||
129
decort/data_source_sep_des_pool.go
Normal file
129
decort/data_source_sep_des_pool.go
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
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(),
|
||||
}
|
||||
}
|
||||
82
decort/data_source_sep_disk_list.go
Normal file
82
decort/data_source_sep_disk_list.go
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
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 dataSourceSepDiskListRead(d *schema.ResourceData, m interface{}) error {
|
||||
sepDiskList, err := utilitySepDiskListCheckPresence(d, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", sepDiskList)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceSepDiskListSchemaMake() map[string]*schema.Schema {
|
||||
rets := map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "storage endpoint provider ID",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "pool name",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "sep disk list",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return rets
|
||||
}
|
||||
|
||||
func dataSourceSepDiskList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
Read: dataSourceSepDiskListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &Timeout30s,
|
||||
Default: &Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepDiskListSchemaMake(),
|
||||
}
|
||||
}
|
||||
348
decort/data_source_sep_dorado.go
Normal file
348
decort/data_source_sep_dorado.go
Normal file
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
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()),
|
||||
}
|
||||
}
|
||||
268
decort/data_source_sep_dorado_config.go
Normal file
268
decort/data_source_sep_dorado_config.go
Normal file
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
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(),
|
||||
}
|
||||
}
|
||||
107
decort/data_source_sep_dorado_pool.go
Normal file
107
decort/data_source_sep_dorado_pool.go
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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 dataSourceSepDoradoPoolRead(d *schema.ResourceData, m interface{}) error {
|
||||
doradoSepPool, err := utilitySepDoradoPoolCheckPresence(d, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("pool", flattenSepDoradoPool(doradoSepPool))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func flattenSepDoradoPool(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 dataSourceSepDoradoPoolSchemaMake() 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{
|
||||
"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 {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
Read: dataSourceSepDoradoPoolRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &Timeout30s,
|
||||
Default: &Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepDoradoPoolSchemaMake(),
|
||||
}
|
||||
}
|
||||
329
decort/data_source_sep_hitachi.go
Normal file
329
decort/data_source_sep_hitachi.go
Normal file
@@ -0,0 +1,329 @@
|
||||
/*
|
||||
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()),
|
||||
}
|
||||
}
|
||||
261
decort/data_source_sep_hitachi_config.go
Normal file
261
decort/data_source_sep_hitachi_config.go
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
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(),
|
||||
}
|
||||
}
|
||||
127
decort/data_source_sep_hitachi_pool.go
Normal file
127
decort/data_source_sep_hitachi_pool.go
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
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(),
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ Visit https://github.com/rudecs/terraform-provider-decort for full source code p
|
||||
package decort
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
)
|
||||
@@ -32,20 +34,23 @@ import (
|
||||
func flattenSepList(sl SepList) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, item := range sl {
|
||||
d, _ := json.Marshal(item.ConfigString)
|
||||
configString := string(d)
|
||||
temp := map[string]interface{}{
|
||||
"ckey": item.Ckey,
|
||||
"meta": flattenMeta(item.Meta),
|
||||
"consumed_by": item.ConsumedBy,
|
||||
"desc": item.Desc,
|
||||
"gid": item.Gid,
|
||||
"guid": item.Guid,
|
||||
"sep_id": item.Id,
|
||||
"milestones": item.Milestones,
|
||||
"name": item.Name,
|
||||
"obj_status": item.ObjStatus,
|
||||
"provided_by": item.ProvidedBy,
|
||||
"tech_status": item.TechStatus,
|
||||
"type": item.Type,
|
||||
"ckey": item.Ckey,
|
||||
"meta": flattenMeta(item.Meta),
|
||||
"consumed_by": item.ConsumedBy,
|
||||
"desc": item.Desc,
|
||||
"gid": item.Gid,
|
||||
"guid": item.Guid,
|
||||
"sep_id": item.Id,
|
||||
"milestones": item.Milestones,
|
||||
"name": item.Name,
|
||||
"obj_status": item.ObjStatus,
|
||||
"provided_by": item.ProvidedBy,
|
||||
"tech_status": item.TechStatus,
|
||||
"type": item.Type,
|
||||
"config_string": configString,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
@@ -153,6 +158,10 @@ func dataSourceSepShortSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"config_string": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
352
decort/data_source_sep_tatlin.go
Normal file
352
decort/data_source_sep_tatlin.go
Normal file
@@ -0,0 +1,352 @@
|
||||
/*
|
||||
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()),
|
||||
}
|
||||
}
|
||||
270
decort/data_source_sep_tatlin_config.go
Normal file
270
decort/data_source_sep_tatlin_config.go
Normal file
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
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(),
|
||||
}
|
||||
}
|
||||
98
decort/data_source_sep_tatlin_pool.go
Normal file
98
decort/data_source_sep_tatlin_pool.go
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
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(),
|
||||
}
|
||||
}
|
||||
@@ -854,7 +854,7 @@ const sepDecommissionAPI = "/restmachine/cloudbroker/sep/decommission"
|
||||
const sepEnableAPI = "/restmachine/cloudbroker/sep/enable"
|
||||
const sepDisableAPI = "/restmachine/cloudbroker/sep/disable"
|
||||
|
||||
const sepDislListAPI = "/restmachine/cloudbroker/sep/diskList"
|
||||
const sepDiskListAPI = "/restmachine/cloudbroker/sep/diskList"
|
||||
|
||||
const sepGetAPI = "/restmachine/cloudbroker/sep/get"
|
||||
const sepGetConfigAPI = "/restmachine/cloudbroker/sep/getConfig"
|
||||
@@ -869,7 +869,14 @@ const sepUpdateCapacityLimitAPI = "/restmachine/cloudbroker/sep/updateCapacityLi
|
||||
///Sep Configs
|
||||
///////DES config
|
||||
type DesDiskDelQueue struct {
|
||||
PurgatoryId int `json:"purgatory_id"`
|
||||
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 {
|
||||
@@ -881,6 +888,8 @@ type URI struct {
|
||||
Port int `json:"port"`
|
||||
}
|
||||
|
||||
type URIList []URI
|
||||
|
||||
type DesConfigPool struct {
|
||||
Types []string `json:"types"`
|
||||
ReferenceId string `json:"referenceId"`
|
||||
@@ -889,17 +898,26 @@ type DesConfigPool struct {
|
||||
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"`
|
||||
Desc3oAppSecret string `json:"decs3o_app_secret"`
|
||||
Desc3oAppId string `json:"decs3o_app_id"`
|
||||
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 []DesConfigPool `json:"pools"`
|
||||
Pools DesConfigPoolList `json:"pools"`
|
||||
Transport string `json:"transport"`
|
||||
CapacityLimit int `json:"capacity_limit"`
|
||||
OVSSettings OVSSettings `json:"ovs_settings"`
|
||||
}
|
||||
|
||||
///////Hitachi config
|
||||
@@ -916,23 +934,26 @@ type HitachiConfigPool struct {
|
||||
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 []HitachiConfigPool `json:"pools"`
|
||||
Ports []string `json:"ports"`
|
||||
Protocol string `json:"protocol"`
|
||||
SSLVerify bool `json:"ssl_verify"`
|
||||
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
|
||||
@@ -943,12 +964,16 @@ type TatlinPort struct {
|
||||
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"`
|
||||
@@ -957,7 +982,14 @@ type TatlinTechDisk struct {
|
||||
}
|
||||
|
||||
type DiskDelQueue struct {
|
||||
PurgeAttemptsThreshold int `json:"purge_attempts_threshold"`
|
||||
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 {
|
||||
@@ -975,27 +1007,30 @@ type TatlinConfigSep struct {
|
||||
HostGroupName string `json:"hostGroupName"`
|
||||
Model string `json:"model"`
|
||||
NamePrefix string `json:"name_prefix"`
|
||||
Ports []TatlinPort `json:"ports"`
|
||||
Pools []Pool `json:"pools"`
|
||||
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 HuaweiDoradoPort struct {
|
||||
type DoradoPort struct {
|
||||
IP string `json:"ip"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type HuaweiDoradoGroup struct {
|
||||
type DoradoPortList []DoradoPort
|
||||
|
||||
type DoradoGroup struct {
|
||||
HostGroup []string `json:"hostgroup"`
|
||||
LungGroup []string `json:"lungroup"`
|
||||
PortGroup []string `json:"portgroup"`
|
||||
}
|
||||
|
||||
type HuaweiDoradoConfigSep struct {
|
||||
type DoradoConfigSep struct {
|
||||
ApiUrls []string `json:"API_URLs"`
|
||||
DiskMaxSize int `json:"disk_max_size"`
|
||||
Format string `json:"format"`
|
||||
@@ -1006,49 +1041,83 @@ type HuaweiDoradoConfigSep struct {
|
||||
HostGroupName string `json:"hostGroupName"`
|
||||
Model string `json:"model"`
|
||||
NamePrefix string `json:"name_prefix"`
|
||||
Pools []Pool `json:"pools"`
|
||||
Pools PoolList `json:"pools"`
|
||||
Protocol string `json:"protocol"`
|
||||
Ports []HuaweiDoradoPort `json:"ports"`
|
||||
Groups []HuaweiDoradoGroup `json:"groups"`
|
||||
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"`
|
||||
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 DesSep struct {
|
||||
type SepDes struct {
|
||||
SepCommon
|
||||
Config DesConfigSep `json:"config"`
|
||||
}
|
||||
|
||||
type HitachiSep struct {
|
||||
type SepDesList []SepDes
|
||||
|
||||
type SepHitachi struct {
|
||||
SepCommon
|
||||
Config HitachiConfigSep `json:"config"`
|
||||
}
|
||||
|
||||
type TatlinSep struct {
|
||||
type SepHitachiList []SepHitachi
|
||||
|
||||
type SepTatlin struct {
|
||||
SepCommon
|
||||
Config TatlinConfigSep `json:"config"`
|
||||
}
|
||||
|
||||
type HuaweiDoradoSep struct {
|
||||
type SepTatlinList []SepTatlin
|
||||
|
||||
type SepDorado struct {
|
||||
SepCommon
|
||||
Config HuaweiDoradoConfigSep `json:"config"`
|
||||
Config DoradoConfigSep `json:"config"`
|
||||
}
|
||||
|
||||
type SepDoradoList []SepDorado
|
||||
|
||||
//////Consumption
|
||||
|
||||
type SepConsumptionInd struct {
|
||||
DiskCount int `json:"disk_count"`
|
||||
DiskUsage int `json:"disk_usage"`
|
||||
SnapshotCount int `json:"snapshot_count"`
|
||||
SnapshotUsage int `json:"snapshot_usage"`
|
||||
Usage int `json:"usage"`
|
||||
UsageLimit int `json:"usage_limit"`
|
||||
}
|
||||
|
||||
type SepConsumptionTotal struct {
|
||||
CapacityLimit int `json:"capacity_limit"`
|
||||
SepConsumptionInd
|
||||
}
|
||||
|
||||
type SepConsumption struct {
|
||||
Total SepConsumptionTotal `json:"total"`
|
||||
Type string `json:"type"`
|
||||
ByPool map[string]SepConsumptionInd `json:"byPool"`
|
||||
}
|
||||
|
||||
type SepDiskList []int
|
||||
|
||||
@@ -111,20 +111,36 @@ func Provider() *schema.Provider {
|
||||
"decort_cdrom_image": resourceCDROMImage(),
|
||||
"decort_delete_images": resourceDeleteImages(),
|
||||
"decort_snapshot": resourceSnapshot(),
|
||||
"decort_sep_des": resourceSepDes(),
|
||||
},
|
||||
|
||||
DataSourcesMap: map[string]*schema.Resource{
|
||||
"decort_account": dataSourceAccount(),
|
||||
"decort_resgroup": dataSourceResgroup(),
|
||||
"decort_kvmvm": dataSourceCompute(),
|
||||
"decort_image": dataSourceImage(),
|
||||
"decort_disk": dataSourceDisk(),
|
||||
"decort_vins": dataSourceVins(),
|
||||
"decort_grid": dataSourceGrid(),
|
||||
"decort_grid_list": dataSourceGridList(),
|
||||
"decort_image_list": dataSourceImageList(),
|
||||
"decort_image_list_stacks": dataSourceImageListStacks(),
|
||||
"decort_snapshot_list": dataSourceSnapshotList(),
|
||||
"decort_account": dataSourceAccount(),
|
||||
"decort_resgroup": dataSourceResgroup(),
|
||||
"decort_kvmvm": dataSourceCompute(),
|
||||
"decort_image": dataSourceImage(),
|
||||
"decort_disk": dataSourceDisk(),
|
||||
"decort_vins": dataSourceVins(),
|
||||
"decort_grid": dataSourceGrid(),
|
||||
"decort_grid_list": dataSourceGridList(),
|
||||
"decort_image_list": dataSourceImageList(),
|
||||
"decort_image_list_stacks": dataSourceImageListStacks(),
|
||||
"decort_snapshot_list": dataSourceSnapshotList(),
|
||||
"decort_sep_list": dataSourceSepList(),
|
||||
"decort_sep_des": dataSourceSepDes(),
|
||||
"decort_sep_hitachi": dataSourceSepHitachi(),
|
||||
"decort_sep_tatlin": dataSourceSepTatlin(),
|
||||
"decort_sep_dorado": dataSourceSepDorado(),
|
||||
"decort_sep_consumption": dataSourceSepConsumption(),
|
||||
"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(),
|
||||
},
|
||||
|
||||
|
||||
655
decort/resource_sep_des.go
Normal file
655
decort/resource_sep_des.go
Normal file
@@ -0,0 +1,655 @@
|
||||
/*
|
||||
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/customdiff"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceSepDesCreate(d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepDesCreate: called for sep %s type \"des\"", d.Get("name").(string))
|
||||
|
||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||
if exists, err := resourceSepDesExists(d, m); exists {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.SetId(strconv.Itoa(sepId.(int)))
|
||||
err = resourceSepDesRead(d, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
return errors.New("provided device id does not exist")
|
||||
}
|
||||
|
||||
controller := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
urlValues.Add("name", d.Get("name").(string))
|
||||
urlValues.Add("gid", strconv.Itoa(d.Get("gid").(int)))
|
||||
urlValues.Add("sep_type", "des")
|
||||
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
urlValues.Add("description", desc.(string))
|
||||
}
|
||||
if configString, ok := d.GetOk("config_string"); ok {
|
||||
urlValues.Add("config", configString.(string))
|
||||
}
|
||||
if enable, ok := d.GetOk("enable"); ok {
|
||||
urlValues.Add("enable", strconv.FormatBool(enable.(bool)))
|
||||
}
|
||||
|
||||
tstr := d.Get("consumed_by").([]interface{})
|
||||
temp := ""
|
||||
l := len(tstr)
|
||||
for i, str := range tstr {
|
||||
s := "\"" + str.(string) + "\""
|
||||
if i != (l - 1) {
|
||||
s += ","
|
||||
}
|
||||
temp = temp + s
|
||||
}
|
||||
temp = "[" + temp + "]"
|
||||
urlValues.Add("consumer_nids", temp)
|
||||
|
||||
tstr = d.Get("provided_by").([]interface{})
|
||||
temp = ""
|
||||
l = len(tstr)
|
||||
for i, str := range tstr {
|
||||
s := "\"" + str.(string) + "\""
|
||||
if i != (l - 1) {
|
||||
s += ","
|
||||
}
|
||||
temp = temp + s
|
||||
}
|
||||
temp = "[" + temp + "]"
|
||||
urlValues.Add("provider_nids", temp)
|
||||
|
||||
sepDesId, err := controller.decortAPICall("POST", sepCreateAPI, urlValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(sepDesId)
|
||||
d.Set("sep_id", sepDesId)
|
||||
|
||||
err = resourceSepDesRead(d, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.SetId(id.String())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepDesRead(d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepDesRead: called for %s id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
|
||||
sepDes, err := utilitySepDesCheckPresence(d, m)
|
||||
if sepDes == nil {
|
||||
d.SetId("")
|
||||
return err
|
||||
}
|
||||
|
||||
d.Set("ckey", sepDes.Ckey)
|
||||
d.Set("meta", flattenMeta(sepDes.Meta))
|
||||
d.Set("consumed_by", sepDes.ConsumedBy)
|
||||
d.Set("desc", sepDes.Desc)
|
||||
d.Set("gid", sepDes.Gid)
|
||||
d.Set("guid", sepDes.Guid)
|
||||
d.Set("sep_id", sepDes.Id)
|
||||
d.Set("milestones", sepDes.Milestones)
|
||||
d.Set("name", sepDes.Name)
|
||||
d.Set("obj_status", sepDes.ObjStatus)
|
||||
d.Set("provided_by", sepDes.ProvidedBy)
|
||||
d.Set("tech_status", sepDes.TechStatus)
|
||||
d.Set("type", sepDes.Type)
|
||||
data, _ := json.Marshal(sepDes.Config)
|
||||
d.Set("config_string", string(data))
|
||||
d.Set("config", flattenSepDesConfig(sepDes.Config))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepDesDelete(d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepDesDelete: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
|
||||
sepDes, err := utilitySepDesCheckPresence(d, m)
|
||||
if sepDes == nil {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
controller := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
|
||||
_, err = controller.decortAPICall("POST", sepDeleteAPI, urlValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepDesExists(d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
log.Debugf("resourceSepDesExists: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
|
||||
sepDes, err := utilitySepDesCheckPresence(d, m)
|
||||
if sepDes == nil {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func resourceSepDesEdit(d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepDesEdit: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
if d.HasChange("decommision") {
|
||||
decommision := d.Get("decommision").(bool)
|
||||
if decommision {
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
urlValues.Add("clear_physically", strconv.FormatBool(d.Get("clear_physically").(bool)))
|
||||
_, err := c.decortAPICall("POST", sepDecommissionAPI, urlValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
urlValues = &url.Values{}
|
||||
if d.HasChange("upd_capacity_limit") {
|
||||
updCapacityLimit := d.Get("upd_capacity_limit").(bool)
|
||||
if updCapacityLimit {
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
_, err := c.decortAPICall("POST", sepUpdateCapacityLimitAPI, urlValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
urlValues = &url.Values{}
|
||||
|
||||
err := resourceSepDesRead(d, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepChangeEnabled(d *schema.ResourceDiff, m interface{}) error {
|
||||
var api string
|
||||
|
||||
c := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
if d.Get("enable").(bool) {
|
||||
api = sepEnableAPI
|
||||
} else {
|
||||
api = sepDisableAPI
|
||||
}
|
||||
resp, err := c.decortAPICall("POST", api, urlValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err := strconv.ParseBool(resp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !res {
|
||||
return errors.New("Cannot enable/disable")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepUpdateNodes(d *schema.ResourceDiff, m interface{}) error {
|
||||
log.Debugf("resourceSepUpdateNodes: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
t1, t2 := d.GetChange("consumed_by")
|
||||
d1 := t1.([]interface{})
|
||||
d2 := t2.([]interface{})
|
||||
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
|
||||
consumedIds := make([]interface{}, 0)
|
||||
temp := ""
|
||||
api := ""
|
||||
|
||||
if len(d1) > len(d2) {
|
||||
for _, n := range d2 {
|
||||
if !findElInt(d1, n) {
|
||||
consumedIds = append(consumedIds, n)
|
||||
}
|
||||
}
|
||||
api = sepDelConsumerNodesAPI
|
||||
} else {
|
||||
consumedIds = d.Get("consumed_by").([]interface{})
|
||||
api = sepAddConsumerNodesAPI
|
||||
}
|
||||
|
||||
l := len(consumedIds)
|
||||
for i, consumedId := range consumedIds {
|
||||
s := strconv.Itoa(consumedId.(int))
|
||||
if i != (l - 1) {
|
||||
s += ","
|
||||
}
|
||||
temp = temp + s
|
||||
}
|
||||
temp = "[" + temp + "]"
|
||||
urlValues.Add("consumer_nids", temp)
|
||||
_, err := c.decortAPICall("POST", api, urlValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func findElInt(sl []interface{}, el interface{}) bool {
|
||||
for _, e := range sl {
|
||||
if e.(int) == el.(int) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func resourceSepUpdateProviders(d *schema.ResourceDiff, m interface{}) error {
|
||||
log.Debugf("resourceSepUpdateProviders: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
providerIds := d.Get("provided_by").([]interface{})
|
||||
temp := ""
|
||||
l := len(providerIds)
|
||||
for i, providerId := range providerIds {
|
||||
s := strconv.Itoa(providerId.(int))
|
||||
if i != (l - 1) {
|
||||
s += ","
|
||||
}
|
||||
temp = temp + s
|
||||
}
|
||||
temp = "[" + temp + "]"
|
||||
urlValues.Add("provider_nids", temp)
|
||||
_, err := c.decortAPICall("POST", sepAddProviderNodesAPI, urlValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "sep type des id",
|
||||
},
|
||||
"upd_capacity_limit": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Update SEP capacity limit",
|
||||
},
|
||||
"decommision": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "unlink everything that exists from SEP",
|
||||
},
|
||||
"clear_physically": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
Description: "clear disks and images physically",
|
||||
},
|
||||
"config_string": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "sep config string",
|
||||
},
|
||||
"ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"meta": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"consumed_by": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
Description: "list of consumer nodes IDs",
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "sep description",
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "grid (platform) ID",
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "SEP name",
|
||||
},
|
||||
"obj_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"provided_by": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
Description: "list of provider nodes IDs",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "type of storage",
|
||||
},
|
||||
"enable": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "enable SEP after creation",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceSepDesSchemaMake(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,
|
||||
},
|
||||
"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 resourceSepDes() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
Create: resourceSepDesCreate,
|
||||
Read: resourceSepDesRead,
|
||||
Update: resourceSepDesEdit,
|
||||
Delete: resourceSepDesDelete,
|
||||
Exists: resourceSepDesExists,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &Timeout60s,
|
||||
Read: &Timeout30s,
|
||||
Update: &Timeout60s,
|
||||
Delete: &Timeout60s,
|
||||
Default: &Timeout60s,
|
||||
},
|
||||
|
||||
Schema: resourceSepDesSchemaMake(resourceSepSchemaMake()),
|
||||
|
||||
CustomizeDiff: customdiff.All(
|
||||
customdiff.IfValueChange("enable", func(old, new, meta interface{}) bool {
|
||||
if old.(bool) != new.(bool) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}, resourceSepChangeEnabled),
|
||||
customdiff.IfValueChange("consumed_by", func(old, new, meta interface{}) bool {
|
||||
o := old.([]interface{})
|
||||
n := new.([]interface{})
|
||||
|
||||
if len(o) != len(n) {
|
||||
return true
|
||||
} else if len(o) == 0 {
|
||||
return false
|
||||
}
|
||||
count := 0
|
||||
for i, v := range n {
|
||||
if v.(int) == o[i].(int) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count == 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}, resourceSepUpdateNodes),
|
||||
customdiff.IfValueChange("provided_by", func(old, new, meta interface{}) bool {
|
||||
o := old.([]interface{})
|
||||
n := new.([]interface{})
|
||||
|
||||
if len(o) != len(n) {
|
||||
return true
|
||||
} else if len(o) == 0 {
|
||||
return false
|
||||
}
|
||||
count := 0
|
||||
for i, v := range n {
|
||||
if v.(int) == o[i].(int) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count == 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}, resourceSepUpdateProviders),
|
||||
),
|
||||
}
|
||||
}
|
||||
54
decort/utility_sep_consumption.go
Normal file
54
decort/utility_sep_consumption.go
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
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"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
)
|
||||
|
||||
func utilitySepConsumptionCheckPresence(d *schema.ResourceData, m interface{}) (*SepConsumption, error) {
|
||||
controller := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
sepCons := &SepConsumption{}
|
||||
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
|
||||
sepConsRaw, err := controller.decortAPICall("POST", sepConsumptionAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(sepConsRaw), sepCons)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepCons, nil
|
||||
}
|
||||
66
decort/utility_sep_des.go
Normal file
66
decort/utility_sep_des.go
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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 utilitySepDesCheckPresence(d *schema.ResourceData, m interface{}) (*SepDes, error) {
|
||||
controller := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
sepDes := &SepDes{}
|
||||
|
||||
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("utilitySepDesCheckPresence: load sep")
|
||||
sepDesRaw, err := controller.decortAPICall("POST", sepGetAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(sepDesRaw), sepDes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if strings.ToLower(sepDes.Type) != "des" {
|
||||
return nil, errors.New("Invalid sep type")
|
||||
}
|
||||
|
||||
return sepDes, nil
|
||||
}
|
||||
57
decort/utility_sep_des_config.go
Normal file
57
decort/utility_sep_des_config.go
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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 utilitySepConfigDesCheckPresence(d *schema.ResourceData, m interface{}) (*DesConfigSep, error) {
|
||||
controller := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
sepConfigDes := &DesConfigSep{}
|
||||
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
|
||||
log.Debugf("utilitySepConfigDesCheckPresence: load sep")
|
||||
sepConfigDesRaw, err := controller.decortAPICall("POST", sepGetConfigAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(sepConfigDesRaw), sepConfigDes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepConfigDes, nil
|
||||
}
|
||||
58
decort/utility_sep_des_pool.go
Normal file
58
decort/utility_sep_des_pool.go
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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 utilitySepDesPoolCheckPresence(d *schema.ResourceData, m interface{}) (*DesConfigPool, error) {
|
||||
controller := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
sepDesPool := &DesConfigPool{}
|
||||
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
urlValues.Add("pool_name", d.Get("pool_name").(string))
|
||||
|
||||
log.Debugf("utilitySepDesPoolCheckPresence: load sep")
|
||||
sepDesPoolRaw, err := controller.decortAPICall("POST", sepGetPoolAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(sepDesPoolRaw), sepDesPool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepDesPool, nil
|
||||
}
|
||||
61
decort/utility_sep_disk_list.go
Normal file
61
decort/utility_sep_disk_list.go
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
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 utilitySepDiskListCheckPresence(d *schema.ResourceData, m interface{}) ([]int, error) {
|
||||
controller := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
sepDiskList := SepDiskList{}
|
||||
|
||||
urlValues.Add("sep_id", strconv.Itoa(d.Get("sep_id").(int)))
|
||||
|
||||
if poolName, ok := d.GetOk("pool_name"); ok {
|
||||
urlValues.Add("pool_name", poolName.(string))
|
||||
}
|
||||
|
||||
log.Debugf("utilitySepDiskListCheckPresence: load sep")
|
||||
sepDiskListRaw, err := controller.decortAPICall("POST", sepDiskListAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(sepDiskListRaw), &sepDiskList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepDiskList, nil
|
||||
}
|
||||
67
decort/utility_sep_dorado.go
Normal file
67
decort/utility_sep_dorado.go
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
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
|
||||
}
|
||||
57
decort/utility_sep_dorado_config.go
Normal file
57
decort/utility_sep_dorado_config.go
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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
|
||||
}
|
||||
58
decort/utility_sep_dorado_pool.go
Normal file
58
decort/utility_sep_dorado_pool.go
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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
|
||||
}
|
||||
67
decort/utility_sep_hitachi.go
Normal file
67
decort/utility_sep_hitachi.go
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
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
|
||||
}
|
||||
57
decort/utility_sep_hitachi_config.go
Normal file
57
decort/utility_sep_hitachi_config.go
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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
|
||||
}
|
||||
58
decort/utility_sep_hitachi_pool.go
Normal file
58
decort/utility_sep_hitachi_pool.go
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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
|
||||
}
|
||||
67
decort/utility_sep_tatlin.go
Normal file
67
decort/utility_sep_tatlin.go
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
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 utilitySepTatlinCheckPresence(d *schema.ResourceData, m interface{}) (*SepTatlin, error) {
|
||||
controller := m.(*ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
sepTatlin := &SepTatlin{}
|
||||
|
||||
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("utilitySepTatlinCheckPresence: load sep")
|
||||
sepTatlinRaw, err := controller.decortAPICall("POST", sepGetAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(sepTatlinRaw), sepTatlin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if strings.ToLower(sepTatlin.Type) != "tatlin" {
|
||||
return nil, errors.New("Invalid sep type")
|
||||
}
|
||||
|
||||
return sepTatlin, nil
|
||||
}
|
||||
57
decort/utility_sep_tatlin_config.go
Normal file
57
decort/utility_sep_tatlin_config.go
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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
|
||||
}
|
||||
58
decort/utility_sep_tatlin_pool.go
Normal file
58
decort/utility_sep_tatlin_pool.go
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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
|
||||
}
|
||||
44
samples/data_sep_consumption/main.tf
Normal file
44
samples/data_sep_consumption/main.tf
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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"
|
||||
controller_url = "https://alfa.dev.decs.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
#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
|
||||
}
|
||||
|
||||
data "decort_sep_consumption" "sd" {
|
||||
sep_id = 1206
|
||||
|
||||
}
|
||||
|
||||
output "test" {
|
||||
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips
|
||||
value = data.decort_sep_consumption.sd
|
||||
}
|
||||
41
samples/data_sep_des/main.tf
Normal file
41
samples/data_sep_des/main.tf
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
42
samples/data_sep_des_config/main.tf
Normal file
42
samples/data_sep_des_config/main.tf
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
43
samples/data_sep_des_pool/main.tf
Normal file
43
samples/data_sep_des_pool/main.tf
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
44
samples/data_sep_disk_list/main.tf
Normal file
44
samples/data_sep_disk_list/main.tf
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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"
|
||||
controller_url = "https://alfa.dev.decs.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
#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
|
||||
}
|
||||
|
||||
data "decort_sep_disk_list" "sd" {
|
||||
sep_id = 1206
|
||||
|
||||
}
|
||||
|
||||
output "test" {
|
||||
//value = tolist(data.decort_sep_des.sl.config)[0].api_ips
|
||||
value = data.decort_sep_disk_list.sd
|
||||
}
|
||||
41
samples/data_sep_dorado/main.tf
Normal file
41
samples/data_sep_dorado/main.tf
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
43
samples/data_sep_dorado_pool/main.tf
Normal file
43
samples/data_sep_dorado_pool/main.tf
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
41
samples/data_sep_hitachi/main.tf
Normal file
41
samples/data_sep_hitachi/main.tf
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
43
samples/data_sep_hitachi_pool/main.tf
Normal file
43
samples/data_sep_hitachi_pool/main.tf
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
39
samples/data_sep_list/main.tf
Normal file
39
samples/data_sep_list/main.tf
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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_list" "sl" {
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = data.decort_sep_list.sl
|
||||
}
|
||||
41
samples/data_sep_tatlin/main.tf
Normal file
41
samples/data_sep_tatlin/main.tf
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
43
samples/data_sep_tatlin_pool/main.tf
Normal file
43
samples/data_sep_tatlin_pool/main.tf
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
51
samples/resource_sep_des/main.tf
Normal file
51
samples/resource_sep_des/main.tf
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Пример использования
|
||||
Ресурса 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
|
||||
}
|
||||
Reference in New Issue
Block a user