git test
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func DataSourceAvailableSEPAndPoolsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
sepList, err := utilityAvailableSEPAndPoolsListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
|
||||
flattenAvailableSEPList(d, sepList)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceAvailableSEPAndPoolsList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: DataSourceAvailableSEPAndPoolsListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceAvailableSEPListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceSepRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
desSep, err := utilitySepCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
flattenSep(d, desSep)
|
||||
d.SetId(strconv.Itoa(d.Get("sep_id").(int)))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceSep() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceSepRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepCSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceSepConfigRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
sepConfig, err := utilitySepConfigCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
|
||||
data, _ := json.Marshal(sepConfig)
|
||||
d.Set("config", string(data))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceSepConfig() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceSepConfigRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepConfigSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceSepConsumptionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
sepCons, err := utilitySepConsumptionCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
|
||||
flattenSepConsumption(d, sepCons)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceSepConsumption() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceSepConsumptionRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepConsumptionSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceSepDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
sepDiskList, err := utilitySepDiskListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", sepDiskList)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceSepDiskList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceSepDiskListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepDiskListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceSepListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
sepList, err := utilitySepListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
|
||||
d.Set("items", flattenSepListItems(sepList))
|
||||
d.Set("entry_count", sepList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceSepList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceSepListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceSepPoolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
sepPool, err := utilitySepPoolCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("pool", flattenSepPool(sepPool))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceSepPool() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceSepPoolRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepPoolSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceSepTemplateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
sepTemplate, err := utilitySepTemplateCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
|
||||
d.Set("sep_template", sepTemplate)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceSepTemplate() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceSepTemplateRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceSepTemplateSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
)
|
||||
|
||||
func flattenSep(d *schema.ResourceData, desSep *sep.RecordSEP) {
|
||||
d.Set("consumed_by", desSep.ConsumedBy)
|
||||
d.Set("desc", desSep.Description)
|
||||
d.Set("gid", desSep.GID)
|
||||
d.Set("guid", desSep.GUID)
|
||||
d.Set("sep_id", desSep.ID)
|
||||
d.Set("milestones", desSep.Milestones)
|
||||
d.Set("multipath_num", desSep.MultipathNum)
|
||||
d.Set("name", desSep.Name)
|
||||
d.Set("obj_status", desSep.ObjStatus)
|
||||
d.Set("provided_by", desSep.ProvidedBy)
|
||||
d.Set("shared_with", desSep.SharedWith)
|
||||
d.Set("tech_status", desSep.TechStatus)
|
||||
d.Set("type", desSep.Type)
|
||||
data, _ := json.Marshal(desSep.Config)
|
||||
d.Set("config", string(data))
|
||||
}
|
||||
|
||||
func flattenSepListItems(sl *sep.ListSEP) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, item := range sl.Data {
|
||||
data, _ := json.Marshal(item.Config)
|
||||
temp := map[string]interface{}{
|
||||
"consumed_by": item.ConsumedBy,
|
||||
"desc": item.Description,
|
||||
"gid": item.GID,
|
||||
"guid": item.GUID,
|
||||
"sep_id": item.ID,
|
||||
"milestones": item.Milestones,
|
||||
"name": item.Name,
|
||||
"multipath_num": item.MultipathNum,
|
||||
"obj_status": item.ObjStatus,
|
||||
"provided_by": item.ProvidedBy,
|
||||
"shared_with": item.SharedWith,
|
||||
"tech_status": item.TechStatus,
|
||||
"type": item.Type,
|
||||
"config": string(data),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenSepPool(rp *sep.RecordPool) []map[string]interface{} {
|
||||
sh := make([]map[string]interface{}, 0)
|
||||
res := map[string]interface{}{
|
||||
"access_account_ids": rp.AccessAccountIDs,
|
||||
"access_res_group_ids": rp.AccessResGroupIDs,
|
||||
"name": rp.Name,
|
||||
"pagecache_ratio": rp.PageCacheRatio,
|
||||
"reference_id": rp.ReferenceID,
|
||||
"types": rp.Types,
|
||||
"uris": flattenSepPoolUris(rp),
|
||||
"usage_limit": rp.UsageLimit,
|
||||
}
|
||||
sh = append(sh, res)
|
||||
return sh
|
||||
}
|
||||
|
||||
func flattenSepPoolUris(rp *sep.RecordPool) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, ur := range rp.URIs {
|
||||
temp := map[string]interface{}{
|
||||
"ip": ur.IP,
|
||||
"port": ur.Port,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenSepConsumption(d *schema.ResourceData, sepCons *sep.RecordConsumption) {
|
||||
d.Set("type", sepCons.Type)
|
||||
d.Set("total", flattenSepConsumptionTotal(sepCons.Total))
|
||||
d.Set("by_pool", flattenSepConsumptionPools(sepCons))
|
||||
}
|
||||
|
||||
func flattenSepConsumptionTotal(sc sep.Total) []map[string]interface{} {
|
||||
sh := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"capacity_limit": sc.CapacityLimit,
|
||||
"disk_count": sc.DiskCount,
|
||||
"disk_usage": sc.DiskUsage,
|
||||
"snapshot_count": sc.SnapshotCount,
|
||||
"snapshot_usage": sc.SnapshotUsage,
|
||||
"usage": sc.Usage,
|
||||
"usage_limit": sc.UsageLimit,
|
||||
}
|
||||
sh = append(sh, temp)
|
||||
return sh
|
||||
}
|
||||
|
||||
func flattenSepConsumptionPools(bp *sep.RecordConsumption) []map[string]interface{} {
|
||||
sh := make([]map[string]interface{}, 0)
|
||||
for key, value := range bp.ByPool {
|
||||
temp := map[string]interface{}{
|
||||
"name": key,
|
||||
"disk_count": value.DiskCount,
|
||||
"disk_usage": value.DiskUsage,
|
||||
"snapshot_count": value.SnapshotCount,
|
||||
"snapshot_usage": value.SnapshotUsage,
|
||||
"usage": value.Usage,
|
||||
"usage_limit": value.UsageLimit,
|
||||
}
|
||||
sh = append(sh, temp)
|
||||
}
|
||||
return sh
|
||||
}
|
||||
|
||||
func flattenAvailableSEPList(d *schema.ResourceData, sepList *sep.ListAvailableSEP) {
|
||||
d.Set("items", flattenSEPDataList(sepList.Data))
|
||||
d.Set("entry_count", sepList.EntryCount)
|
||||
}
|
||||
|
||||
func flattenSEPDataList(sepDataList []sep.SEPData) []map[string]interface{} {
|
||||
sh := make([]map[string]interface{}, 0)
|
||||
|
||||
for _, sepData := range sepDataList {
|
||||
temp := map[string]interface{}{
|
||||
"sep_id": sepData.SEPID,
|
||||
"sep_name": sepData.SEPName,
|
||||
"sep_type": sepData.SEPType,
|
||||
"pools": flattenPoolList(sepData.Pools),
|
||||
}
|
||||
sh = append(sh, temp)
|
||||
}
|
||||
|
||||
return sh
|
||||
}
|
||||
|
||||
func flattenPoolList(pools []sep.Pool) []map[string]interface{} {
|
||||
sh := make([]map[string]interface{}, 0)
|
||||
|
||||
for _, pool := range pools {
|
||||
temp := map[string]interface{}{
|
||||
"name": pool.Name,
|
||||
"types": pool.Types,
|
||||
"system": pool.System,
|
||||
}
|
||||
sh = append(sh, temp)
|
||||
}
|
||||
|
||||
return sh
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/ic"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg) diag.Diagnostics {
|
||||
var errs []error
|
||||
|
||||
gid := uint64(d.Get("gid").(int))
|
||||
|
||||
if err := ic.ExistGID(ctx, gid, c); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
return dc.ErrorsToDiagnostics(errs)
|
||||
}
|
||||
@@ -1,571 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||
)
|
||||
|
||||
func resourceSepCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceSepCreate: called for sep %s", d.Get("name").(string))
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
if diags := checkParamsExistence(ctx, d, c); diags != nil {
|
||||
return diags
|
||||
}
|
||||
|
||||
req := sep.CreateRequest{
|
||||
GID: uint64(d.Get("gid").(int)),
|
||||
Name: d.Get("name").(string),
|
||||
SEPType: d.Get("type").(string),
|
||||
Config: d.Get("config").(string),
|
||||
}
|
||||
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
req.Description = desc.(string)
|
||||
}
|
||||
if enable, ok := d.GetOk("enable"); ok {
|
||||
req.Enable = enable.(bool)
|
||||
}
|
||||
|
||||
sepId, err := c.CloudBroker().SEP().Create(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(sepId, 10))
|
||||
d.Set("sep_id", sepId)
|
||||
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
if enable, ok := d.GetOk("enable"); ok {
|
||||
log.Debugf("resourceSepCreate, Enable: enable=%t sep_id %d after completing its resource configuration", enable, sepId)
|
||||
err := resourceSepChangeEnabled(ctx, d, m)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if accountIds, ok := d.GetOk("account_ids"); ok {
|
||||
log.Debugf("resourceSepCreate, accessGrant: accountIds=%v sep_id %d after completing its resource configuration", accountIds, sepId)
|
||||
err := resourceSepChangeAccess(ctx, d, m)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if accessToPool, ok := d.GetOk("access_to_pool"); ok {
|
||||
log.Debugf("resourceSepCreate, accessToPool: accessToPool=%v sep_id %d after completing its resource configuration", accessToPool, sepId)
|
||||
err := resourceSepChangeAccessToPool(ctx, d, m)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if pools, ok := d.GetOk("pools"); ok {
|
||||
log.Debugf("resourceSepCreate, pools: pools=%v sep_id %d after completing its resource configuration", pools, sepId)
|
||||
err := resourceSepChangePools(ctx, d, m)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if consumedBy, ok := d.GetOk("consumed_by"); ok && consumedBy.(*schema.Set).Len() > 0 {
|
||||
log.Debugf("resourceSepCreate, consumed_by: consumed_by=%v sep_id %d after completing its resource configuration", consumedBy, sepId)
|
||||
err := resourceSepAddConsumerNodes(ctx, d, m)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if providedBy, ok := d.GetOk("provided_by"); ok && len(providedBy.([]interface{})) > 0 {
|
||||
log.Debugf("resourceSepCreate, provided_by: provided_by=%v sep_id %d after completing its resource configuration", providedBy, sepId)
|
||||
err := resourceSepAddProviderNodes(ctx, d, m)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
return append(resourceSepRead(ctx, d, m), warnings.Get()...)
|
||||
}
|
||||
|
||||
func resourceSepRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceSepRead: called for %s id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
|
||||
sepRec, err := utilitySepCheckPresence(ctx, d, m)
|
||||
if sepRec == nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
flattenSep(d, sepRec)
|
||||
|
||||
log.Debugf("resourceSepRead: after flattenSep: %s id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceSepDelete: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
|
||||
sepDes, err := utilitySepCheckPresence(ctx, d, m)
|
||||
if sepDes == nil {
|
||||
d.SetId("")
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.DeleteRequest{
|
||||
SEPID: sepDes.ID,
|
||||
}
|
||||
|
||||
_, err = c.CloudBroker().SEP().Delete(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
return diag.Errorf(
|
||||
"SEP upgrade is not possible via terraform")
|
||||
|
||||
}
|
||||
|
||||
func resourceSepChangeAccess(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepChangeAccess: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
oldSet, newSet := d.GetChange("account_ids")
|
||||
|
||||
deletedAccounts := (oldSet.(*schema.Set).Difference(newSet.(*schema.Set))).List()
|
||||
var accountDelIds []uint64
|
||||
for _, deletedInterface := range deletedAccounts {
|
||||
deletedItem := deletedInterface.(int)
|
||||
accountDelIds = append(accountDelIds, uint64(deletedItem))
|
||||
}
|
||||
if len(accountDelIds) != 0 {
|
||||
for _, acc := range accountDelIds {
|
||||
reqDel := sep.AccessRevokeRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
AccountID: acc,
|
||||
}
|
||||
_, err := c.CloudBroker().SEP().AccessRevoke(ctx, reqDel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addedAccounts := (oldSet.(*schema.Set).Difference(newSet.(*schema.Set))).List()
|
||||
var accountAddIds []uint64
|
||||
for _, addedInterface := range addedAccounts {
|
||||
addedItem := addedInterface.(int)
|
||||
accountAddIds = append(accountAddIds, uint64(addedItem))
|
||||
}
|
||||
if len(accountAddIds) != 0 {
|
||||
for _, acc := range accountAddIds {
|
||||
reqDel := sep.AccessGrantRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
AccountID: acc,
|
||||
}
|
||||
_, err := c.CloudBroker().SEP().AccessGrant(ctx, reqDel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepChangeAccessToPool(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepChangeAccessToPool: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
oldAccessToPool, newAccessToPool := d.GetChange("access_to_pool")
|
||||
|
||||
oldAccess := oldAccessToPool.([]interface{})[0].(map[string]interface{})
|
||||
if oldAccess["pool_name"] != "" {
|
||||
revokeReq := sep.AccessRevokeToPoolRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
PoolName: oldAccess["pool_name"].(string),
|
||||
}
|
||||
|
||||
if oldAccId, ok := oldAccess["account_id_pool"]; ok {
|
||||
revokeReq.AccountID = uint64(oldAccId.(int))
|
||||
}
|
||||
|
||||
if oldRgId, ok := oldAccess["rg_id"]; ok {
|
||||
revokeReq.RGID = uint64(oldRgId.(int))
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().SEP().AccessRevokeToPool(ctx, revokeReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
newAccess := newAccessToPool.([]interface{})[0].(map[string]interface{})
|
||||
if newAccess["pool_name"] != "" {
|
||||
grantReq := sep.AccessGrantToPoolRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
PoolName: newAccess["pool_name"].(string),
|
||||
}
|
||||
|
||||
if newAccId, ok := newAccess["account_id_pool"]; ok {
|
||||
grantReq.AccountID = uint64(newAccId.(int))
|
||||
}
|
||||
|
||||
if newRgId, ok := newAccess["rg_id"]; ok {
|
||||
grantReq.RGID = uint64(newRgId.(int))
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().SEP().AccessGrantToPool(ctx, grantReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepChangePools(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepChangePools: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
oldPoolsInterface, newPoolsInterface := d.GetChange("pools")
|
||||
|
||||
oldPoolsList := oldPoolsInterface.(*schema.Set).Difference(newPoolsInterface.(*schema.Set)).List()
|
||||
for _, pool := range oldPoolsList {
|
||||
delPoolReq := sep.DelPoolRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
PoolName: pool.(string),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().SEP().DelPool(ctx, delPoolReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
newPoolsList := newPoolsInterface.(*schema.Set).Difference(oldPoolsInterface.(*schema.Set)).List()
|
||||
for _, pool := range newPoolsList {
|
||||
poolItem := pool.(map[string]interface{})
|
||||
|
||||
accessAccountIDs := []uint64{}
|
||||
|
||||
for _, v := range poolItem["access_account_ids"].([]interface{}) {
|
||||
accessAccountIDs = append(accessAccountIDs, uint64(v.(int)))
|
||||
}
|
||||
accessResGroupIDs := []uint64{}
|
||||
for _, v := range poolItem["access_res_group_ids"].([]interface{}) {
|
||||
accessResGroupIDs = append(accessResGroupIDs, uint64(v.(int)))
|
||||
}
|
||||
|
||||
types := []string{}
|
||||
for _, v := range poolItem["types"].([]interface{}) {
|
||||
types = append(types, v.(string))
|
||||
}
|
||||
|
||||
uris := []UrisModel{}
|
||||
list := poolItem["uris"].(*schema.Set).List()
|
||||
for _, v := range list {
|
||||
if m, ok := v.(map[string]interface{}); ok {
|
||||
uris = append(uris, UrisModel{IP: m["ip"].(string),
|
||||
Port: uint64(m["port"].(int)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
poolValue := PoolModel{
|
||||
AccessAccountIDs: accessAccountIDs,
|
||||
AccessResGroupIDs: accessResGroupIDs,
|
||||
Name: poolItem["name"].(string),
|
||||
Types: types,
|
||||
Uris: uris,
|
||||
UsageLimit: uint64(poolItem["usage_limit"].(int)),
|
||||
}
|
||||
marshalPool, _ := json.Marshal(poolValue)
|
||||
log.Debugf(string(marshalPool))
|
||||
addPoolReq := sep.AddPoolRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
Pool: string(marshalPool),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().SEP().AddPool(ctx, addPoolReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepUpdateConfig(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
validateReq := sep.ConfigValidateRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
Config: d.Get("config").(string),
|
||||
}
|
||||
_, err := c.CloudBroker().SEP().ConfigValidate(ctx, validateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
insertReq := sep.ConfigInsertRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
Config: d.Get("config").(string),
|
||||
}
|
||||
_, err = c.CloudBroker().SEP().ConfigInsert(ctx, insertReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepFieldEdit(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
fieldConfig := d.Get("field_edit").([]interface{})
|
||||
field := fieldConfig[0].(map[string]interface{})
|
||||
req := sep.ConfigFieldEditRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
FieldName: field["field_name"].(string),
|
||||
FieldValue: field["field_value"].(string),
|
||||
FieldType: field["field_type"].(string),
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().SEP().ConfigFieldEdit(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepChangeEnabled(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
sepID := uint64(d.Get("sep_id").(int))
|
||||
|
||||
if d.Get("enable").(bool) {
|
||||
req := sep.EnableRequest{
|
||||
SEPID: sepID,
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().SEP().Enable(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
req := sep.DisableRequest{
|
||||
SEPID: sepID,
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().SEP().Disable(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepUpdateNodes(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepUpdateNodes: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
oldSet, newSet := d.GetChange("consumed_by")
|
||||
|
||||
deletedConsumed := (oldSet.(*schema.Set).Difference(newSet.(*schema.Set))).List()
|
||||
var consumerDelIds []uint64
|
||||
for _, deletedInterface := range deletedConsumed {
|
||||
deletedItem := deletedInterface.(int)
|
||||
consumerDelIds = append(consumerDelIds, uint64(deletedItem))
|
||||
}
|
||||
if len(consumerDelIds) != 0 {
|
||||
reqDel := sep.DelConsumerNodesRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
ConsumerNIDs: consumerDelIds,
|
||||
}
|
||||
_, err := c.CloudBroker().SEP().DelConsumerNodes(ctx, reqDel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
addedConsumed := (newSet.(*schema.Set).Difference(oldSet.(*schema.Set))).List()
|
||||
var consumerAddIds []uint64
|
||||
for _, addedInterface := range addedConsumed {
|
||||
AddedItem := addedInterface.(int)
|
||||
consumerAddIds = append(consumerAddIds, uint64(AddedItem))
|
||||
}
|
||||
if len(consumerAddIds) != 0 {
|
||||
reqAdd := sep.AddConsumerNodesRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
ConsumerNIDs: consumerAddIds,
|
||||
}
|
||||
_, err := c.CloudBroker().SEP().AddConsumerNodes(ctx, reqAdd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepUpdateProviders(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepUpdateProviders: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.AddProviderNodesRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
}
|
||||
|
||||
var providerNIDs []uint64
|
||||
for _, item := range d.Get("provided_by").([]interface{}) {
|
||||
providerNIDs = append(providerNIDs, uint64(item.(int)))
|
||||
}
|
||||
req.ProviderNIDs = providerNIDs
|
||||
|
||||
_, err := c.CloudBroker().SEP().AddProviderNodes(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepAddConsumerNodes(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepAddConsumerNodes: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
var consumerNIDs []uint64
|
||||
for _, item := range d.Get("consumed_by").(*schema.Set).List() {
|
||||
consumerNIDs = append(consumerNIDs, uint64(item.(int)))
|
||||
}
|
||||
|
||||
if len(consumerNIDs) > 0 {
|
||||
reqAdd := sep.AddConsumerNodesRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
ConsumerNIDs: consumerNIDs,
|
||||
}
|
||||
_, err := c.CloudBroker().SEP().AddConsumerNodes(ctx, reqAdd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepAddProviderNodes(ctx context.Context, d *schema.ResourceData, m interface{}) error {
|
||||
log.Debugf("resourceSepAddProviderNodes: called for %s, id: %d", d.Get("name").(string), d.Get("sep_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
var providerNIDs []uint64
|
||||
for _, item := range d.Get("provided_by").([]interface{}) {
|
||||
providerNIDs = append(providerNIDs, uint64(item.(int)))
|
||||
}
|
||||
|
||||
if len(providerNIDs) > 0 {
|
||||
reqAdd := sep.AddProviderNodesRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
ProviderNIDs: providerNIDs,
|
||||
}
|
||||
_, err := c.CloudBroker().SEP().AddProviderNodes(ctx, reqAdd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ResourceSep() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceSepCreate,
|
||||
ReadContext: resourceSepRead,
|
||||
UpdateContext: resourceSepUpdate,
|
||||
DeleteContext: resourceSepDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout600s,
|
||||
Read: &constants.Timeout300s,
|
||||
Update: &constants.Timeout600s,
|
||||
Delete: &constants.Timeout300s,
|
||||
Default: &constants.Timeout300s,
|
||||
},
|
||||
|
||||
Schema: resourceSepSchemaMake(),
|
||||
}
|
||||
}
|
||||
|
||||
type PoolModel struct {
|
||||
AccessAccountIDs []uint64 `json:"accessAccountIds"`
|
||||
AccessResGroupIDs []uint64 `json:"accessResGroupIds"`
|
||||
Name string `json:"name"`
|
||||
Types []string `json:"types"`
|
||||
Uris []UrisModel `json:"uris"`
|
||||
UsageLimit uint64 `json:"usage_limit"`
|
||||
}
|
||||
|
||||
type UrisModel struct {
|
||||
IP string `json:"ip"`
|
||||
|
||||
Port uint64 `json:"port"`
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func resourceSepConfigCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceSepConfigCreate: called for sep id %d", d.Get("sep_id").(int))
|
||||
|
||||
if _, ok := d.GetOk("sep_id"); ok {
|
||||
sepConfig, err := utilitySepConfigCheckPresence(ctx, d, m)
|
||||
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if sepConfig == nil {
|
||||
return diag.Errorf("provided sep id config does not exist")
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
}
|
||||
|
||||
return resourceSepConfigRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceSepConfigRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceSepConfigRead: called for sep id: %d", d.Get("sep_id").(int))
|
||||
|
||||
sepConfig, err := utilitySepConfigCheckPresence(ctx, d, m)
|
||||
if sepConfig == nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
data, _ := json.Marshal(sepConfig)
|
||||
d.Set("config", string(data))
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepConfigDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceSepConfigUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceSepConfigEdit: called for sep id: %d", d.Get("sep_id").(int))
|
||||
|
||||
if d.HasChange("config") {
|
||||
err := resourceSepUpdateConfig(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("field_edit") {
|
||||
err := resourceSepFieldEdit(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return resourceSepConfigRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func ResourceSepConfig() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceSepConfigCreate,
|
||||
ReadContext: resourceSepConfigRead,
|
||||
UpdateContext: resourceSepConfigUpdate,
|
||||
DeleteContext: resourceSepConfigDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout600s,
|
||||
Read: &constants.Timeout300s,
|
||||
Update: &constants.Timeout600s,
|
||||
Delete: &constants.Timeout300s,
|
||||
Default: &constants.Timeout300s,
|
||||
},
|
||||
|
||||
Schema: resourceSepConfigSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,804 +0,0 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
)
|
||||
|
||||
func dataSourceSepCSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "sep type des id",
|
||||
},
|
||||
"config": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "config",
|
||||
},
|
||||
"consumed_by": {
|
||||
Type: schema.TypeSet,
|
||||
Computed: true,
|
||||
Description: "consumed by",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "description",
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "gid",
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "guid",
|
||||
},
|
||||
"multipath_num": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "multipath_num",
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "milestones",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "name",
|
||||
},
|
||||
"obj_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "object status",
|
||||
},
|
||||
"provided_by": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "provided by",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"shared_with": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "shared with",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "tech status",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "type",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceSepConfigSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "storage endpoint provider ID",
|
||||
},
|
||||
"config": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "sep config json string",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceSepTemplateSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"sep_type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"des", "hitachi", "dorado", "tatlin", "shared", "local", "ustor"}, false),
|
||||
Description: "type of sep",
|
||||
},
|
||||
"lang": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"ru", "en"}, false),
|
||||
Description: "language",
|
||||
},
|
||||
"sep_template": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceSepConsumptionSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "sep id",
|
||||
},
|
||||
"by_pool": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "consumption divided by pool",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "pool name",
|
||||
},
|
||||
"disk_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "number of disks",
|
||||
},
|
||||
"disk_usage": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "disk usage",
|
||||
},
|
||||
"snapshot_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "number of snapshots",
|
||||
},
|
||||
"snapshot_usage": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "snapshot usage",
|
||||
},
|
||||
"usage": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "usage",
|
||||
},
|
||||
"usage_limit": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "usage limit",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"total": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "total consumption",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"capacity_limit": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "capacity limit",
|
||||
},
|
||||
"disk_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "number of disks",
|
||||
},
|
||||
"disk_usage": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "disk usage",
|
||||
},
|
||||
"snapshot_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "number of snapshots",
|
||||
},
|
||||
"snapshot_usage": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "snapshot usage",
|
||||
},
|
||||
"usage": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "usage",
|
||||
},
|
||||
"usage_limit": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "usage limit",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "sep type",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
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 dataSourceSepListSchemaMake() map[string]*schema.Schema {
|
||||
rets := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "find by id",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "find by name",
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "find by gid",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "find by sep type",
|
||||
},
|
||||
"provided_by": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "find by provided physical node id",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "find by techStatus",
|
||||
},
|
||||
"consumed_by": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "find by consumed physical node id",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "page size",
|
||||
},
|
||||
"sep_ids": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Description: "sort by list of SEP identifiers",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "sep list",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"config": {
|
||||
Description: "config",
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"consumed_by": {
|
||||
Type: schema.TypeSet,
|
||||
Computed: true,
|
||||
Description: "consumed by",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "description",
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "gid",
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "guid",
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "sep id",
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "milestones",
|
||||
},
|
||||
"multipath_num": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "multipath_num",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "name",
|
||||
},
|
||||
"obj_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "object status",
|
||||
},
|
||||
"provided_by": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "provided by",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"shared_with": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "shared with",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "tech status",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "type",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "entryCount",
|
||||
},
|
||||
}
|
||||
|
||||
return rets
|
||||
}
|
||||
|
||||
func dataSourceSepPoolSchemaMake() 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,
|
||||
Description: "pool",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"access_account_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "access account ids",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"access_res_group_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "access res group ids",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "name",
|
||||
},
|
||||
"pagecache_ratio": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "pagecache_ratio",
|
||||
},
|
||||
"reference_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "reference_id",
|
||||
},
|
||||
"types": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "types",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"uris": {
|
||||
Type: schema.TypeSet,
|
||||
Computed: true,
|
||||
Description: "uris",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "ip",
|
||||
},
|
||||
"port": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "port",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"usage_limit": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "usage limit",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceSepSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "grid (platform) ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "SEP name",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"des", "hitachi", "dorado", "tatlin", "shared", "local", "ustor"}, false),
|
||||
Description: "type of storage",
|
||||
},
|
||||
"access_to_pool": {
|
||||
Type: schema.TypeSet,
|
||||
MaxItems: 1,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "grant or revoke access to pool",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "pool name",
|
||||
},
|
||||
"account_id_pool": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "account id to grant/revoke access to the specified pool sep",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "resource group id to grant/revoke access to the specified pool sep",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"account_ids": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Description: "lift of account ids to have access to sep",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"enable": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "enable SEP after creation",
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "sep type des id",
|
||||
},
|
||||
"pools": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Description: "add/delete pools to/from sep",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"access_account_ids": {
|
||||
Type: schema.TypeList,
|
||||
Required: true,
|
||||
Description: "access account ids",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"access_res_group_ids": {
|
||||
Type: schema.TypeList,
|
||||
Required: true,
|
||||
Description: "access res group ids",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "name",
|
||||
},
|
||||
"types": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Description: "types",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"uris": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Description: "uris",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "ip",
|
||||
},
|
||||
"port": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "port",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"usage_limit": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "usage limit",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"config": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "sep config string",
|
||||
DiffSuppressFunc: resourceSepDiffSupperss,
|
||||
},
|
||||
"consumed_by": {
|
||||
Type: schema.TypeSet,
|
||||
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",
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "guid",
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "milestones",
|
||||
},
|
||||
"multipath_num": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "multipath_num",
|
||||
},
|
||||
"obj_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "object status",
|
||||
},
|
||||
"provided_by": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
Description: "list of provider nodes IDs",
|
||||
},
|
||||
"shared_with": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
Description: "list of shared with ids",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "tech status",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceSepConfigSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "sep id",
|
||||
},
|
||||
"config": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "config json string",
|
||||
},
|
||||
"field_edit": {
|
||||
Type: schema.TypeList,
|
||||
MaxItems: 1,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"field_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "field name",
|
||||
},
|
||||
"field_value": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "field value",
|
||||
},
|
||||
"field_type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "field type",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceAvailableSEPListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Account ID",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Resource group ID",
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Number of available SEP entries",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "List of available SEPs",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "SEP ID",
|
||||
},
|
||||
"sep_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "SEP name",
|
||||
},
|
||||
"sep_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "SEP type",
|
||||
},
|
||||
"pools": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "List of pools in the SEP",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Pool name",
|
||||
},
|
||||
"types": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "List of pool types",
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"system": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "Is system pool",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAvailableSEPAndPoolsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*sep.ListAvailableSEP, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.ListAvailableSEPAndPoolsRequest{}
|
||||
|
||||
if AccountID, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(AccountID.(int))
|
||||
}
|
||||
if RGID, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(RGID.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityAvailableSEPAndPoolsListCheckPresence: load sep and pools list")
|
||||
sepList, err := c.CloudBroker().SEP().ListAvailableSEPAndPools(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepList, nil
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilitySepCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*sep.RecordSEP, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.GetRequest{}
|
||||
|
||||
if d.Get("sep_id") != nil {
|
||||
if d.Get("sep_id").(int) == 0 {
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.SEPID = id
|
||||
} else {
|
||||
req.SEPID = uint64(d.Get("sep_id").(int))
|
||||
}
|
||||
} else {
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.SEPID = id
|
||||
}
|
||||
|
||||
log.Debugf("utilitySepCheckPresence: load sep")
|
||||
sep, err := c.CloudBroker().SEP().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sep, nil
|
||||
}
|
||||
|
||||
func resourceSepDiffSupperss(key, oldVal, newVal string, d *schema.ResourceData) bool {
|
||||
var v1, v2 interface{}
|
||||
json.Unmarshal([]byte(newVal), &v1)
|
||||
json.Unmarshal([]byte(oldVal), &v2)
|
||||
if reflect.DeepEqual(v1, v2) {
|
||||
log.Debugf("resourceSepDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=TRUE", key, oldVal, newVal)
|
||||
return true
|
||||
}
|
||||
log.Debugf("resourceSepDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=FALSE", key, oldVal, newVal)
|
||||
return false
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilitySepConfigCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*sep.SEPConfig, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.GetConfigRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
}
|
||||
|
||||
log.Debugf("utilitySepConfigCheckPresence: load sep config")
|
||||
sepConfig, err := c.CloudBroker().SEP().GetConfig(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepConfig, nil
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilitySepConsumptionCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*sep.RecordConsumption, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.ConsumptionRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
}
|
||||
|
||||
sepCons, err := c.CloudBroker().SEP().Consumption(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepCons, nil
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilitySepDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) ([]uint64, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.DiskListRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
}
|
||||
|
||||
if poolName, ok := d.GetOk("pool_name"); ok {
|
||||
req.PoolName = poolName.(string)
|
||||
}
|
||||
|
||||
log.Debugf("utilitySepDiskListCheckPresence: load sep")
|
||||
sepDiskList, err := c.CloudBroker().SEP().DiskList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepDiskList, nil
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilitySepListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*sep.ListSEP, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.ListRequest{}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if gid, ok := d.GetOk("gid"); ok {
|
||||
req.GID = uint64(gid.(int))
|
||||
}
|
||||
if type_, ok := d.GetOk("type"); ok {
|
||||
req.Type = type_.(string)
|
||||
}
|
||||
if provided_by, ok := d.GetOk("provided_by"); ok {
|
||||
req.ProvidedBy = uint64(provided_by.(int))
|
||||
}
|
||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
if consumed_by, ok := d.GetOk("consumed_by"); ok {
|
||||
req.ConsumedBy = uint64(consumed_by.(int))
|
||||
}
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
if sepIds, ok := d.GetOk("sep_ids"); ok {
|
||||
ids := sepIds.([]interface{})
|
||||
for _, id := range ids {
|
||||
req.SepIDs = append(req.SepIDs, uint64(id.(int)))
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("utilitySepListCheckPresence: load image list")
|
||||
sepList, err := c.CloudBroker().SEP().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepList, nil
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilitySepPoolCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*sep.RecordPool, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.GetPoolRequest{
|
||||
SEPID: uint64(d.Get("sep_id").(int)),
|
||||
PoolName: d.Get("pool_name").(string),
|
||||
}
|
||||
|
||||
log.Debugf("utilitySepDesPoolCheckPresence: load pool")
|
||||
sepPool, err := c.CloudBroker().SEP().GetPool(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sepPool, nil
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilitySepTemplateCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sep.GetTemplateRequest{
|
||||
SepType: d.Get("sep_type").(string),
|
||||
Language: d.Get("lang").(string),
|
||||
}
|
||||
|
||||
log.Debugf("utilitySepTemplateCheckPresence: load sep template")
|
||||
sepTemplate, err := c.CloudBroker().SEP().GetTemplate(ctx, req)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return sepTemplate, nil
|
||||
}
|
||||
Reference in New Issue
Block a user