git test
This commit is contained in:
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
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 dataSourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
staticRoute, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(staticRoute.ID, 10))
|
||||
flattenStaticRouteData(d, staticRoute)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceStaticRouteSchemaMake() map[string]*schema.Schema {
|
||||
rets := map[string]*schema.Schema{
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Unique ID of the ViNS",
|
||||
},
|
||||
"route_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Unique ID of the static route",
|
||||
},
|
||||
"compute_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"destination": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"gateway": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"netmask": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
func DataSourceStaticRoute() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceStaticRouteRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceStaticRouteSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
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 dataSourceStaticRouteListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
staticRouteList, err := utilityStaticRouteListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenStaticRouteList(staticRouteList))
|
||||
d.Set("entry_count", staticRouteList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceStaticRouteListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of VINS",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"compute_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"destination": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"gateway": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"netmask": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"route_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceStaticRouteList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceStaticRouteListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceStaticRouteListSchemaMake(),
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,108 +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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
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 dataSourceVinsAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
audits, err := utilityVinsAuditsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsAudits(audits))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceVinsAuditsSchemaMake() map[string]*schema.Schema {
|
||||
rets := map[string]*schema.Schema{
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"call": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"response_time": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"statuscode": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"timestamp": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"user": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
func DataSourceVinsAudits() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceVinsAuditsRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: DataSourceVinsAuditsSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,116 +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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
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 dataSourceVinsExtNetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
extNetList, err := utilityVinsExtNetListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsExtNetList(extNetList))
|
||||
d.Set("entry_count", extNetList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceVinsExtNetListchemaMake() map[string]*schema.Schema {
|
||||
rets := map[string]*schema.Schema{
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"default_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"ext_net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"prefix_len": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
func DataSourceVinsExtNetList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceVinsExtNetListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: DataSourceVinsExtNetListchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,120 +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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
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 dataSourceVinsIpListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
ips, err := utilityVinsIpListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsIpList(ips))
|
||||
d.Set("entry_count", ips.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceVinsIpListSchemaMake() map[string]*schema.Schema {
|
||||
rets := map[string]*schema.Schema{
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Unique ID of the ViNS",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"client_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"domainname": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"hostname": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vm_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
func DataSourceVinsIpList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceVinsIpListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: DataSourceVinsIpListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,223 +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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
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 dataSourceVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
vinsList, err := utilityVinsListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsList(vinsList))
|
||||
d.Set("entry_count", vinsList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by Name",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by Account ID",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"ext_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by external IP address",
|
||||
},
|
||||
"vnf_dev_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by VNF Device id",
|
||||
},
|
||||
"include_deleted": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Include deleted computes",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "sort by status",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"zone_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Zone ID",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"external_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"free_ips": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"vins_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"network": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"vxlan_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceVinsList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceVinsListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceVinsListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,199 +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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
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 dataSourceVinsListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
vinsList, err := utilityVinsListDeletedCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsListDeleted(vinsList))
|
||||
d.Set("entry_count", vinsList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceVinsListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by account ID",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by resgroup ID",
|
||||
},
|
||||
"ext_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by external IP",
|
||||
},
|
||||
"vnfdev_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "find by VNF Device 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",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"external_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"vins_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"network": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"vxlan_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceVinsListDeleted() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceVinsListDeletedRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceVinsListDeletedSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,125 +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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
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 dataSourceVinsNatRuleListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
natRules, err := utilityVinsNatRuleListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsNatRuleList(natRules))
|
||||
d.Set("entry_count", natRules.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceVinsNatRuleListSchemaMake() map[string]*schema.Schema {
|
||||
rets := map[string]*schema.Schema{
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"local_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"local_port": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"protocol": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"public_port_end": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"public_port_start": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"vm_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"vm_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
func DataSourceVinsNatRuleList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceVinsNatRuleListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: DataSourceVinsNatRuleListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,630 +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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
)
|
||||
|
||||
func flattenMGMT(mgmt vins.RecordMGMT) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"ip_addr": mgmt.IPAddress,
|
||||
"password": mgmt.Password,
|
||||
"ssh_key": mgmt.SSHKey,
|
||||
"user": mgmt.User,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenResources(resources vins.RecordResources) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"cpu": resources.CPU,
|
||||
"ram": resources.RAM,
|
||||
"node_id": resources.NodeID,
|
||||
"uuid": resources.UUID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenConfig(config vins.RecordVNFConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"mgmt": flattenMGMT(config.MGMT),
|
||||
"resources": flattenResources(config.Resources),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenQOS(qos vins.QOS) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"e_rate": qos.ERate,
|
||||
"guid": qos.GUID,
|
||||
"in_brust": qos.InBurst,
|
||||
"in_rate": qos.InRate,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenInterfaces(interfaces []vins.ItemVNFInterface) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
||||
for _, vnfInterface := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"conn_id": vnfInterface.ConnID,
|
||||
"conn_type": vnfInterface.ConnType,
|
||||
"def_gw": vnfInterface.DefGW,
|
||||
"enabled": vnfInterface.Enabled,
|
||||
"enable_secgroups": vnfInterface.EnableSecGroups,
|
||||
"flipgroup_id": vnfInterface.FLIPGroupID,
|
||||
"guid": vnfInterface.GUID,
|
||||
"ip_address": vnfInterface.IPAddress,
|
||||
"listen_ssh": vnfInterface.ListenSSH,
|
||||
"mac": vnfInterface.MAC,
|
||||
"mtu": vnfInterface.MTU,
|
||||
"name": vnfInterface.Name,
|
||||
"net_id": vnfInterface.NetID,
|
||||
"net_mask": vnfInterface.NetMask,
|
||||
"net_type": vnfInterface.NetType,
|
||||
"node_id": vnfInterface.NodeID,
|
||||
"pci_slot": vnfInterface.PCISlot,
|
||||
"bus_number": vnfInterface.BusNumber,
|
||||
"qos": flattenQOS(vnfInterface.QOS),
|
||||
"sdn_interface_id": vnfInterface.SDNInterfaceID,
|
||||
"security_groups": vnfInterface.SecGroups,
|
||||
"target": vnfInterface.Target,
|
||||
"type": vnfInterface.Type,
|
||||
"vnfs": vnfInterface.VNFs,
|
||||
"libvirt_settings": flattenLibvirtSettings(vnfInterface.LibvirtSettings),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenLibvirtSettings(libvirtSettings vins.LibvirtSettings) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"guid": libvirtSettings.GUID,
|
||||
"txmode": libvirtSettings.TXMode,
|
||||
"ioeventfd": libvirtSettings.IOEventFD,
|
||||
"event_idx": libvirtSettings.EventIDx,
|
||||
"queues": libvirtSettings.Queues,
|
||||
"rx_queue_size": libvirtSettings.RXQueueSize,
|
||||
"tx_queue_size": libvirtSettings.TXQueueSize,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVNFDev(vnfDev vins.RecordVNFDev) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"_ckey": vnfDev.CKey,
|
||||
"account_id": vnfDev.AccountID,
|
||||
"capabilities": vnfDev.Capabilities,
|
||||
"config": flattenConfig(vnfDev.Config), //in progress
|
||||
"config_saved": vnfDev.ConfigSaved,
|
||||
"custom_pre_cfg": vnfDev.CustomPreConfig,
|
||||
"desc": vnfDev.Description,
|
||||
"gid": vnfDev.GID,
|
||||
"guid": vnfDev.GUID,
|
||||
"vnf_id": vnfDev.ID,
|
||||
"interfaces": flattenInterfaces(vnfDev.Interfaces),
|
||||
"live_migration_job_id": vnfDev.LiveMigrationJobID,
|
||||
"lock_status": vnfDev.LockStatus,
|
||||
"milestones": vnfDev.Milestones,
|
||||
"vnf_name": vnfDev.Name,
|
||||
"status": vnfDev.Status,
|
||||
"tech_status": vnfDev.TechStatus,
|
||||
"type": vnfDev.Type,
|
||||
"vnc_password": vnfDev.VNCPassword,
|
||||
"vins": vnfDev.VINS,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenComputes(computes vins.ListVINSComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(computes))
|
||||
for _, compute := range computes {
|
||||
temp := map[string]interface{}{
|
||||
"compute_id": compute.ID,
|
||||
"compute_name": compute.Name,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenReservations(reservations vins.ListReservations) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(reservations))
|
||||
for _, reservation := range reservations {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": reservation.AccountID,
|
||||
"ip": reservation.IP,
|
||||
"mac": reservation.MAC,
|
||||
"type": reservation.Type,
|
||||
"vm_id": reservation.VMID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenDHCPConfig(config vins.RecordDHCPConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"default_gw": config.DefaultGW,
|
||||
"dns": config.DNS,
|
||||
"ip_end": config.IPEnd,
|
||||
"ip_start": config.IPStart,
|
||||
"lease": config.Lease,
|
||||
"netmask": config.NetMask,
|
||||
"network": config.Network,
|
||||
"reservations": flattenReservations(config.Reservations),
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenPrimary(primary vins.RecordPrimary) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"dev_id": primary.DevID,
|
||||
"iface01": primary.IFace01,
|
||||
"iface02": primary.IFace02,
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenDevices(devices vins.RecordDevices) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"primary": flattenPrimary(devices.Primary),
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenDHCP(dhcp vins.RecordDHCP) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"_ckey": dhcp.CKey,
|
||||
"account_id": dhcp.AccountID,
|
||||
"config": flattenDHCPConfig(dhcp.Config),
|
||||
"created_time": dhcp.CreatedTime,
|
||||
"devices": flattenDevices(dhcp.Devices),
|
||||
"gid": dhcp.GID,
|
||||
"guid": dhcp.GUID,
|
||||
"dhcp_id": dhcp.ID,
|
||||
"lock_status": dhcp.LockStatus,
|
||||
"milestones": dhcp.Milestones,
|
||||
"owner_id": dhcp.OwnerID,
|
||||
"owner_type": dhcp.OwnerType,
|
||||
"pure_virtual": dhcp.PureVirtual,
|
||||
"routes": flattenStaticRoute(dhcp.Routes),
|
||||
"status": dhcp.Status,
|
||||
"tech_status": dhcp.TechStatus,
|
||||
"type": dhcp.Type,
|
||||
"zone_id": dhcp.ZoneID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenGWConfig(config vins.RecordGWConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"default_gw": config.DefaultGW,
|
||||
"ext_net_id": config.ExtNetID,
|
||||
"ext_net_ip": config.ExtNetIP,
|
||||
"ext_netmask": config.ExtNetMask,
|
||||
"qos": flattenQOS(config.QOS),
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenGW(gw vins.RecordGW) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"_ckey": gw.CKey,
|
||||
"account_id": gw.AccountID,
|
||||
"config": flattenGWConfig(gw.Config),
|
||||
"created_time": gw.CreatedTime,
|
||||
"devices": flattenDevices(gw.Devices),
|
||||
"gid": gw.GID,
|
||||
"guid": gw.GUID,
|
||||
"gw_id": gw.ID,
|
||||
"lock_status": gw.LockStatus,
|
||||
"milestones": gw.Milestones,
|
||||
"owner_id": gw.OwnerID,
|
||||
"owner_type": gw.OwnerType,
|
||||
"pure_virtual": gw.PureVirtual,
|
||||
"routes": flattenStaticRoute(gw.Routes),
|
||||
"status": gw.Status,
|
||||
"tech_status": gw.TechStatus,
|
||||
"type": gw.Type,
|
||||
"zone_id": gw.ZoneID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRules(rules vins.ListNATRulesConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(rules))
|
||||
for _, rule := range rules {
|
||||
tmp := map[string]interface{}{
|
||||
"rule_id": rule.ID,
|
||||
"local_ip": rule.LocalIP,
|
||||
"local_port": rule.LocalPort,
|
||||
"protocol": rule.Protocol,
|
||||
"public_port_end": rule.PublicPortEnd,
|
||||
"public_port_start": rule.PublicPortStart,
|
||||
"vm_id": rule.VMID,
|
||||
"vm_name": rule.VMName,
|
||||
}
|
||||
res = append(res, tmp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenNATConfig(config vins.NATConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"net_mask": config.NetMask,
|
||||
"network": config.Network,
|
||||
"rules": flattenRules(config.Rules),
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
|
||||
}
|
||||
|
||||
func flattenNAT(nat vins.RecordNAT) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"_ckey": nat.CKey,
|
||||
"account_id": nat.AccountID,
|
||||
"created_time": nat.CreatedTime,
|
||||
"config": flattenNATConfig(nat.Config),
|
||||
"devices": flattenDevices(nat.Devices),
|
||||
"gid": nat.GID,
|
||||
"guid": nat.GUID,
|
||||
"nat_id": nat.ID,
|
||||
"lock_status": nat.LockStatus,
|
||||
"milestones": nat.Milestones,
|
||||
"owner_id": nat.OwnerID,
|
||||
"owner_type": nat.OwnerType,
|
||||
"pure_virtual": nat.PureVirtual,
|
||||
"routes": flattenStaticRoute(nat.Routes),
|
||||
"status": nat.Status,
|
||||
"tech_status": nat.TechStatus,
|
||||
"type": nat.Type,
|
||||
"zone_id": nat.ZoneID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVNFS(vnfs vins.RecordVNFs) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"dhcp": flattenDHCP(vnfs.DHCP),
|
||||
"gw": flattenGW(vnfs.GW),
|
||||
"nat": flattenNAT(vnfs.NAT),
|
||||
}
|
||||
res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRuleBlock(rules vins.ListNATRulesConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(rules))
|
||||
for _, rule := range rules {
|
||||
tmp := map[string]interface{}{
|
||||
"int_ip": rule.LocalIP,
|
||||
"int_port": rule.LocalPort,
|
||||
"ext_port_start": rule.PublicPortStart,
|
||||
"ext_port_end": rule.PublicPortEnd,
|
||||
"proto": rule.Protocol,
|
||||
"rule_id": rule.ID,
|
||||
}
|
||||
res = append(res, tmp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVins(d *schema.ResourceData, vins *vins.RecordVINS) {
|
||||
d.Set("vins_id", vins.ID)
|
||||
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||
d.Set("account_id", vins.AccountID)
|
||||
d.Set("account_name", vins.AccountName)
|
||||
d.Set("computes", flattenComputes(vins.Computes))
|
||||
d.Set("created_by", vins.CreatedBy)
|
||||
d.Set("created_time", vins.CreatedTime)
|
||||
d.Set("default_gw", vins.DefaultGW)
|
||||
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||
d.Set("deleted_by", vins.DeletedBy)
|
||||
d.Set("deleted_time", vins.DeletedTime)
|
||||
d.Set("desc", vins.Description)
|
||||
d.Set("enable_secgroups", vins.EnableSecGroups)
|
||||
d.Set("gid", vins.GID)
|
||||
d.Set("guid", vins.GUID)
|
||||
d.Set("lock_status", vins.LockStatus)
|
||||
d.Set("manager_id", vins.ManagerID)
|
||||
d.Set("manager_type", vins.ManagerType)
|
||||
d.Set("milestones", vins.Milestones)
|
||||
d.Set("name", vins.Name)
|
||||
d.Set("net_mask", vins.NetMask)
|
||||
d.Set("network", vins.Network)
|
||||
d.Set("pre_reservations_num", vins.PreReservaionsNum)
|
||||
d.Set("redundant", vins.Redundant)
|
||||
d.Set("rg_id", vins.RGID)
|
||||
d.Set("rg_name", vins.RGName)
|
||||
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
|
||||
d.Set("status", vins.Status)
|
||||
d.Set("updated_by", vins.UpdatedBy)
|
||||
d.Set("updated_time", vins.UpdatedTime)
|
||||
d.Set("user_managed", vins.UserManaged)
|
||||
d.Set("vnfs", flattenVNFS(vins.VNFs))
|
||||
d.Set("vxlan_id", vins.VXLANID)
|
||||
d.Set("nat_rule", flattenRuleBlock(vins.VNFs.NAT.Config.Rules))
|
||||
d.Set("zone_id", vins.ZoneID)
|
||||
}
|
||||
|
||||
func flattenVinsData(d *schema.ResourceData, vins *vins.RecordVINS) {
|
||||
d.Set("vins_id", vins.ID)
|
||||
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||
d.Set("account_id", vins.AccountID)
|
||||
d.Set("account_name", vins.AccountName)
|
||||
d.Set("computes", flattenComputes(vins.Computes))
|
||||
d.Set("created_by", vins.CreatedBy)
|
||||
d.Set("created_time", vins.CreatedTime)
|
||||
d.Set("default_gw", vins.DefaultGW)
|
||||
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||
d.Set("deleted_by", vins.DeletedBy)
|
||||
d.Set("deleted_time", vins.DeletedTime)
|
||||
d.Set("desc", vins.Description)
|
||||
d.Set("gid", vins.GID)
|
||||
d.Set("guid", vins.GUID)
|
||||
d.Set("lock_status", vins.LockStatus)
|
||||
d.Set("manager_id", vins.ManagerID)
|
||||
d.Set("manager_type", vins.ManagerType)
|
||||
d.Set("milestones", vins.Milestones)
|
||||
d.Set("name", vins.Name)
|
||||
d.Set("net_mask", vins.NetMask)
|
||||
d.Set("network", vins.Network)
|
||||
d.Set("pre_reservations_num", vins.PreReservaionsNum)
|
||||
d.Set("redundant", vins.Redundant)
|
||||
d.Set("rg_id", vins.RGID)
|
||||
d.Set("rg_name", vins.RGName)
|
||||
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
|
||||
d.Set("status", vins.Status)
|
||||
d.Set("updated_by", vins.UpdatedBy)
|
||||
d.Set("updated_time", vins.UpdatedTime)
|
||||
d.Set("user_managed", vins.UserManaged)
|
||||
d.Set("vnfs", flattenVNFS(vins.VNFs))
|
||||
d.Set("vxlan_id", vins.VXLANID)
|
||||
d.Set("zone_id", vins.ZoneID)
|
||||
}
|
||||
|
||||
func flattenVinsAudits(audits vins.ListAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(audits))
|
||||
for _, audit := range audits {
|
||||
temp := map[string]interface{}{
|
||||
"call": audit.Call,
|
||||
"response_time": audit.ResponseTime,
|
||||
"statuscode": audit.StatusCode,
|
||||
"timestamp": audit.Timestamp,
|
||||
"user": audit.User,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVinsExtNetList(extNetList *vins.ListExtNets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(extNetList.Data))
|
||||
for _, extNet := range extNetList.Data {
|
||||
temp := map[string]interface{}{
|
||||
"default_gw": extNet.DefaultGW,
|
||||
"ext_net_id": extNet.ExtNetID,
|
||||
"ip": extNet.IP,
|
||||
"prefix_len": extNet.PrefixLen,
|
||||
"status": extNet.Status,
|
||||
"tech_status": extNet.TechStatus,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVinsIpList(ips *vins.ListIPs) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(ips.Data))
|
||||
for _, ip := range ips.Data {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": ip.ClientType,
|
||||
"domainname": ip.DomainName,
|
||||
"hostname": ip.Hostname,
|
||||
"ip": ip.IP,
|
||||
"mac": ip.MAC,
|
||||
"type": ip.Type,
|
||||
"vm_id": ip.VMID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(vl.Data))
|
||||
for _, v := range vl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": v.AccountID,
|
||||
"account_name": v.AccountName,
|
||||
"created_by": v.CreatedBy,
|
||||
"created_time": v.CreatedTime,
|
||||
"deleted_by": v.DeletedBy,
|
||||
"deleted_time": v.DeletedTime,
|
||||
"external_ip": v.ExternalIP,
|
||||
"extnet_id": v.ExtnetId,
|
||||
"free_ips": v.FreeIPs,
|
||||
"vins_id": v.ID,
|
||||
"vins_name": v.Name,
|
||||
"network": v.Network,
|
||||
"rg_id": v.RGID,
|
||||
"rg_name": v.RGName,
|
||||
"status": v.Status,
|
||||
"updated_by": v.UpdatedBy,
|
||||
"updated_time": v.UpdatedTime,
|
||||
"vxlan_id": v.VXLANID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVinsListDeleted(vl *vins.ListVINS) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(vl.Data))
|
||||
for _, v := range vl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": v.AccountID,
|
||||
"account_name": v.AccountName,
|
||||
"created_by": v.CreatedBy,
|
||||
"created_time": v.CreatedTime,
|
||||
"deleted_by": v.DeletedBy,
|
||||
"deleted_time": v.DeletedTime,
|
||||
"external_ip": v.ExternalIP,
|
||||
"vins_id": v.ID,
|
||||
"vins_name": v.Name,
|
||||
"network": v.Network,
|
||||
"rg_id": v.RGID,
|
||||
"rg_name": v.RGName,
|
||||
"status": v.Status,
|
||||
"updated_by": v.UpdatedBy,
|
||||
"updated_time": v.UpdatedTime,
|
||||
"vxlan_id": v.VXLANID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// /4.4.0
|
||||
func flattenStaticRouteList(sr *vins.ListStaticRoutes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(sr.Data))
|
||||
for _, staticRoute := range sr.Data {
|
||||
temp := map[string]interface{}{
|
||||
"route_id": staticRoute.ID,
|
||||
"destination": staticRoute.Destination,
|
||||
"gateway": staticRoute.Gateway,
|
||||
"guid": staticRoute.GUID,
|
||||
"netmask": staticRoute.Netmask,
|
||||
"compute_ids": staticRoute.ComputeIds,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenStaticRouteData(d *schema.ResourceData, route *vins.ItemRoutes) {
|
||||
d.Set("destination", route.Destination)
|
||||
d.Set("gateway", route.Gateway)
|
||||
d.Set("guid", route.GUID)
|
||||
d.Set("netmask", route.Netmask)
|
||||
d.Set("compute_ids", route.ComputeIds)
|
||||
d.Set("route_id", route.ID)
|
||||
}
|
||||
|
||||
func flattenStaticRoute(sr vins.ListRoutes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(sr))
|
||||
for _, staticRoute := range sr {
|
||||
temp := map[string]interface{}{
|
||||
"route_id": staticRoute.ID,
|
||||
"destination": staticRoute.Destination,
|
||||
"gateway": staticRoute.Gateway,
|
||||
"guid": staticRoute.GUID,
|
||||
"netmask": staticRoute.Netmask,
|
||||
"compute_ids": staticRoute.ComputeIds,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
func flattenVinsNatRuleList(natRules *vins.ListNATRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(natRules.Data))
|
||||
for _, natRule := range natRules.Data {
|
||||
temp := map[string]interface{}{
|
||||
"id": natRule.ID,
|
||||
"local_ip": natRule.LocalIP,
|
||||
"local_port": natRule.LocalPort,
|
||||
"protocol": natRule.Protocol,
|
||||
"public_port_end": natRule.PublicPortEnd,
|
||||
"public_port_start": natRule.PublicPortStart,
|
||||
"vm_id": natRule.VMID,
|
||||
"vm_name": natRule.VMName,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
rgId := uint64(d.Get("rg_id").(int))
|
||||
req := rg.ListRequest{}
|
||||
|
||||
rgList, err := c.CloudAPI().RG().List(ctx, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(rgList.FilterByID(rgId).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
extNetID := d.Get("ext_net_id").(int)
|
||||
|
||||
if extNetID == 0 || extNetID == -1 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
extNetIDParsed := uint64(extNetID)
|
||||
req := extnet.ListRequest{}
|
||||
|
||||
extNetList, err := c.CloudAPI().ExtNet().List(ctx, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(extNetList.FilterByID(extNetIDParsed).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
accountId := uint64(d.Get("account_id").(int))
|
||||
req := account.ListRequest{}
|
||||
|
||||
accountList, err := c.CloudAPI().Account().List(ctx, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(accountList.FilterByID(accountId).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
gid := uint64(d.Get("gid").(int))
|
||||
req := locations.ListRequest{}
|
||||
|
||||
locationList, err := c.CloudAPI().Locations().List(ctx, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(locationList.FilterByGID(gid).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existVinsID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
vinsID := uint64(d.Get("vins_id").(int))
|
||||
req := vins.ListRequest{}
|
||||
|
||||
vinsList, err := c.CloudAPI().VINS().List(ctx, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(vinsList.FilterByID(vinsID).Data) != 0, nil
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"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"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func resourceStaticRouteCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
if _, ok := d.GetOk("vins_id"); ok {
|
||||
haveVinsID, err := existVinsID(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !haveVinsID {
|
||||
return diag.Errorf("resourceStaticRouteCreate: can't create Static Route because Vins ID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
||||
}
|
||||
}
|
||||
|
||||
req := vins.StaticRouteAddRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
Destination: d.Get("destination").(string),
|
||||
Netmask: d.Get("netmask").(string),
|
||||
Gateway: d.Get("gateway").(string),
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().StaticRouteAdd(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
staticRouteData, err := getStaticRouteData(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(fmt.Sprintf("%d#%d", req.VINSID, staticRouteData.ID))
|
||||
|
||||
return resourceStaticRouteRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
flattenStaticRouteData(d, staticRouteData)
|
||||
|
||||
return warnings.Get()
|
||||
}
|
||||
|
||||
func resourceStaticRouteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceStaticRouteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
arr := strings.Split(d.Id(), "#")
|
||||
if len(arr) != 2 {
|
||||
return diag.FromErr(fmt.Errorf("broken state id"))
|
||||
}
|
||||
|
||||
vinsId, _ := strconv.ParseUint(arr[0], 10, 64)
|
||||
routeId, _ := strconv.ParseUint(arr[1], 10, 64)
|
||||
|
||||
req := vins.StaticRouteDelRequest{
|
||||
VINSID: vinsId,
|
||||
RouteId: routeId,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().StaticRouteDel(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceStaticRouteSchemaMake() map[string]*schema.Schema {
|
||||
rets := dataSourceStaticRouteSchemaMake()
|
||||
rets["route_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
}
|
||||
rets["compute_ids"] = &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
}
|
||||
rets["destination"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
}
|
||||
|
||||
rets["gateway"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
}
|
||||
rets["netmask"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
}
|
||||
|
||||
return rets
|
||||
}
|
||||
|
||||
func isContainsIds(els []interface{}, el interface{}) bool {
|
||||
convEl := el.(int)
|
||||
for _, elOld := range els {
|
||||
if convEl == elOld.(int) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ResourceStaticRoute() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceStaticRouteCreate,
|
||||
ReadContext: resourceStaticRouteRead,
|
||||
UpdateContext: resourceStaticRouteUpdate,
|
||||
DeleteContext: resourceStaticRouteDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout20m,
|
||||
Read: &constants.Timeout600s,
|
||||
Update: &constants.Timeout20m,
|
||||
Delete: &constants.Timeout600s,
|
||||
Default: &constants.Timeout600s,
|
||||
},
|
||||
|
||||
Schema: resourceStaticRouteSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,948 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"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"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
)
|
||||
|
||||
func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
if _, ok := d.GetOk("rg_id"); ok {
|
||||
haveRGID, err := existRGID(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !haveRGID {
|
||||
return diag.Errorf("resourceVinsCreate: can't create ViNS because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := d.GetOk("ext_net_id"); ok {
|
||||
haveExtNetID, err := existExtNetID(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !haveExtNetID {
|
||||
return diag.Errorf("resourceVinsCreate: can't create ViNS because ExtNetID %d is not allowed or does not exist", d.Get("ext_net_id").(int))
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := d.GetOk("account_id"); ok {
|
||||
haveAccountID, err := existAccountID(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !haveAccountID {
|
||||
return diag.Errorf("resourceVinsCreate: can't create ViNS because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := d.GetOk("gid"); ok {
|
||||
haveGID, err := existGID(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !haveGID {
|
||||
return diag.Errorf("resourceVinsCreate: can't create ViNS because GID %d is not allowed or does not exist", d.Get("gid").(int))
|
||||
}
|
||||
}
|
||||
|
||||
rgId, rgOk := d.GetOk("rg_id")
|
||||
accountId, accountIdOk := d.GetOk("account_id")
|
||||
if !rgOk && !accountIdOk {
|
||||
return diag.Errorf("resourceVinsCreate: no valid accountId or resource group ID specified")
|
||||
}
|
||||
|
||||
if rgOk {
|
||||
req := vins.CreateInRGRequest{
|
||||
Name: d.Get("name").(string),
|
||||
RGID: uint64(rgId.(int)),
|
||||
}
|
||||
|
||||
if ipcidr, ok := d.GetOk("ipcidr"); ok {
|
||||
req.IPCIDR = ipcidr.(string)
|
||||
}
|
||||
|
||||
//extnet v1
|
||||
req.ExtNetID = int64(d.Get("ext_net_id").(int))
|
||||
if extIp, ok := d.GetOk("ext_ip_addr"); ok {
|
||||
req.ExtIP = extIp.(string)
|
||||
}
|
||||
|
||||
//extnet v2
|
||||
if extNetResp, ok := d.GetOk("ext_net"); ok {
|
||||
extNetSl := extNetResp.([]interface{})
|
||||
extNet := extNetSl[0].(map[string]interface{})
|
||||
|
||||
req.ExtNetID = int64(extNet["ext_net_id"].(int))
|
||||
req.ExtIP = extNet["ext_net_ip"].(string)
|
||||
}
|
||||
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
req.Description = desc.(string)
|
||||
}
|
||||
if preReservationsNum, ok := d.GetOk("pre_reservations_num"); ok {
|
||||
req.PreReservationsNum = uint64(preReservationsNum.(int))
|
||||
}
|
||||
if dns, ok := d.GetOk("dns"); ok {
|
||||
dnsInterface := dns.(*schema.Set).List()
|
||||
req.DNSList = make([]string, 0, len(dnsInterface))
|
||||
for _, item := range dnsInterface {
|
||||
req.DNSList = append(req.DNSList, item.(string))
|
||||
}
|
||||
}
|
||||
|
||||
if zoneID, ok := d.GetOk("zone_id"); ok {
|
||||
req.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
|
||||
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
|
||||
|
||||
id, err := c.CloudAPI().VINS().CreateInRG(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(id, 10))
|
||||
} else if accountIdOk {
|
||||
req := vins.CreateInAccountRequest{
|
||||
Name: d.Get("name").(string),
|
||||
AccountID: uint64(accountId.(int)),
|
||||
}
|
||||
|
||||
if gid, ok := d.GetOk("gid"); ok {
|
||||
req.GID = uint64(gid.(int))
|
||||
}
|
||||
if ipcidr, ok := d.GetOk("ipcidr"); ok {
|
||||
req.IPCIDR = ipcidr.(string)
|
||||
}
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
req.Description = desc.(string)
|
||||
}
|
||||
if preReservationsNum, ok := d.GetOk("pre_reservations_num"); ok {
|
||||
req.PreReservationsNum = uint64(preReservationsNum.(int))
|
||||
}
|
||||
if dns, ok := d.GetOk("dns"); ok {
|
||||
dnsInterface := dns.(*schema.Set).List()
|
||||
req.DNSList = make([]string, 0, len(dnsInterface))
|
||||
for _, item := range dnsInterface {
|
||||
req.DNSList = append(req.DNSList, item.(string))
|
||||
}
|
||||
}
|
||||
|
||||
if zoneID, ok := d.GetOk("zone_id"); ok {
|
||||
req.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
|
||||
req.EnableSecGroups = d.Get("enable_secgroups").(bool)
|
||||
|
||||
id, err := c.CloudAPI().VINS().CreateInAccount(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(id, 10))
|
||||
}
|
||||
|
||||
vinsId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
|
||||
warnings := dc.Warnings{}
|
||||
if ipRes, ok := d.GetOk("ip"); ok {
|
||||
ipsSlice := ipRes.([]interface{})
|
||||
for _, ipInterfase := range ipsSlice {
|
||||
ip := ipInterfase.(map[string]interface{})
|
||||
|
||||
req := vins.IPReserveRequest{
|
||||
VINSID: vinsId,
|
||||
Type: ip["type"].(string),
|
||||
}
|
||||
|
||||
if ipAddr, ok := ip["ip_addr"]; ok {
|
||||
req.IPAddr = ipAddr.(string)
|
||||
}
|
||||
if macAddr, ok := ip["mac_addr"]; ok {
|
||||
req.MAC = macAddr.(string)
|
||||
}
|
||||
if computeId, ok := ip["compute_id"]; ok {
|
||||
req.ComputeID = uint64(computeId.(int))
|
||||
}
|
||||
_, err := c.CloudAPI().VINS().IPReserve(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if natRule, ok := d.GetOk("nat_rule"); ok {
|
||||
addedNatRules := natRule.([]interface{})
|
||||
if len(addedNatRules) > 0 {
|
||||
for _, natRuleInterface := range addedNatRules {
|
||||
natRule := natRuleInterface.(map[string]interface{})
|
||||
|
||||
req := vins.NATRuleAddRequest{
|
||||
VINSID: vinsId,
|
||||
IntIP: natRule["int_ip"].(string),
|
||||
IntPort: uint(natRule["int_port"].(int)),
|
||||
ExtPortStart: uint(natRule["ext_port_start"].(int)),
|
||||
ExtPortEnd: uint(natRule["ext_port_end"].(int)),
|
||||
Proto: natRule["proto"].(string),
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().NATRuleAdd(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return append(warnings.Get(), resourceVinsRead(ctx, d, m)...)
|
||||
}
|
||||
|
||||
func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
// c := m.(*controller.ControllerCfg)
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
vinsData, err := utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
// isEnabled := d.Get("enable").(bool)
|
||||
|
||||
hasChangeState := false
|
||||
|
||||
switch vinsData.Status {
|
||||
case status.Destroyed:
|
||||
d.Set("vins_id", 0)
|
||||
d.SetId("")
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceVinsCreate(ctx, d, m)
|
||||
case status.Deleted:
|
||||
// hasChangeState = true
|
||||
|
||||
// req := vins.RestoreRequest{
|
||||
// VINSID: vinsData.ID,
|
||||
// }
|
||||
|
||||
// _, err := c.CloudAPI().VINS().Restore(ctx, req)
|
||||
// if err != nil {
|
||||
// warnings.Add(err)
|
||||
// }
|
||||
case status.Modeled:
|
||||
return diag.Errorf("ViNS are in status: %s, please, contact support for more information", vinsData.Status)
|
||||
case status.Created:
|
||||
case status.Enabled:
|
||||
// if !isEnabled {
|
||||
// hasChangeState = true
|
||||
// req := vins.DisableEnableRequest{
|
||||
// VINSID: vinsData.ID,
|
||||
// }
|
||||
|
||||
// _, err := c.CloudAPI().VINS().Disable(ctx, req)
|
||||
// if err != nil {
|
||||
// warnings.Add(err)
|
||||
// }
|
||||
// }
|
||||
case status.Enabling:
|
||||
case status.Disabled:
|
||||
// if isEnabled {
|
||||
// hasChangeState = true
|
||||
// req := vins.DisableEnableRequest{
|
||||
// VINSID: vinsData.ID,
|
||||
// }
|
||||
|
||||
// _, err := c.CloudAPI().VINS().Enable(ctx, req)
|
||||
// if err != nil {
|
||||
// warnings.Add(err)
|
||||
// }
|
||||
// }
|
||||
case status.Disabling:
|
||||
case status.Deleting:
|
||||
return diag.Errorf("ViNS are in progress with status: %s", vinsData.Status)
|
||||
}
|
||||
|
||||
if hasChangeState {
|
||||
vinsData, err = utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
flattenVins(d, vinsData)
|
||||
|
||||
return warnings.Get()
|
||||
}
|
||||
|
||||
func isContainsIp(els []interface{}, el interface{}) bool {
|
||||
for _, elOld := range els {
|
||||
elOldConv := elOld.(map[string]interface{})
|
||||
elConv := el.(map[string]interface{})
|
||||
if elOldConv["ip_addr"].(string) == elConv["ip_addr"].(string) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isContainsNatRule(els []interface{}, el interface{}) bool {
|
||||
for _, elOld := range els {
|
||||
elOldConv := elOld.(map[string]interface{})
|
||||
elConv := el.(map[string]interface{})
|
||||
if elOldConv["int_ip"].(string) == elConv["int_ip"].(string) &&
|
||||
elOldConv["int_port"].(int) == elConv["int_port"].(int) &&
|
||||
elOldConv["ext_port_start"].(int) == elConv["ext_port_start"].(int) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
if _, ok := d.GetOk("rg_id"); ok {
|
||||
haveRGID, err := existRGID(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !haveRGID {
|
||||
return diag.Errorf("resourceVinsUpdate: can't update ViNS because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := d.GetOk("ext_net_id"); ok {
|
||||
haveExtNetID, err := existExtNetID(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !haveExtNetID {
|
||||
return diag.Errorf("resourceVinsUpdate: can't update ViNS because ExtNetID %d is not allowed or does not exist", d.Get("ext_net_id").(int))
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := d.GetOk("account_id"); ok {
|
||||
haveAccountID, err := existAccountID(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !haveAccountID {
|
||||
return diag.Errorf("resourceVinsUpdate: can't update ViNS because AccountID %d is not allowed or does not exist", d.Get("account_id").(int))
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := d.GetOk("gid"); ok {
|
||||
haveGID, err := existGID(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if !haveGID {
|
||||
return diag.Errorf("resourceVinsUpdate: can't update ViNS because GID %d is not allowed or does not exist", d.Get("gid").(int))
|
||||
}
|
||||
}
|
||||
|
||||
vinsData, err := utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
isEnabled := d.Get("enable").(bool)
|
||||
|
||||
hasChangeState := false
|
||||
|
||||
switch vinsData.Status {
|
||||
case status.Destroyed:
|
||||
d.SetId("")
|
||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||
// return resourceVinsCreate(ctx, d, m)
|
||||
case status.Deleted:
|
||||
if restore, ok := d.GetOk("restore"); ok && restore.(bool) {
|
||||
req := vins.RestoreRequest{
|
||||
VINSID: vinsData.ID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().Restore(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
hasChangeState = true
|
||||
}
|
||||
case status.Modeled:
|
||||
return diag.Errorf("ViNS are in status: %s, please, contact support for more information", vinsData.Status)
|
||||
case status.Created:
|
||||
case status.Enabled:
|
||||
if !isEnabled {
|
||||
req := vins.DisableEnableRequest{
|
||||
VINSID: vinsData.ID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().Disable(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
hasChangeState = true
|
||||
}
|
||||
case status.Enabling:
|
||||
case status.Disabled:
|
||||
if isEnabled {
|
||||
req := vins.DisableEnableRequest{
|
||||
VINSID: vinsData.ID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().Enable(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
hasChangeState = true
|
||||
}
|
||||
case status.Disabling:
|
||||
case status.Deleting:
|
||||
return diag.Errorf("ViNS are in progress with status: %s", vinsData.Status)
|
||||
}
|
||||
|
||||
if hasChangeState {
|
||||
vinsData, err = utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("enable") {
|
||||
enableOld, enableNew := d.GetChange("enable")
|
||||
if enableOld.(bool) && !enableNew.(bool) {
|
||||
req := vins.DisableEnableRequest{
|
||||
VINSID: vinsData.ID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().Disable(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
} else if !enableOld.(bool) && enableNew.(bool) {
|
||||
req := vins.DisableEnableRequest{
|
||||
VINSID: vinsData.ID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().Enable(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
if d.HasChange("ext_net_id") {
|
||||
//extnet v1
|
||||
oldExtNetId, newExtNedId := d.GetChange("ext_net_id")
|
||||
if oldExtNetId.(int) != newExtNedId.(int) {
|
||||
log.Debugf("resourceVinsUpdate: changing ViNS ID %s - ext_net_id %d -> %d", d.Id(), oldExtNetId.(int), newExtNedId.(int))
|
||||
|
||||
if oldExtNetId.(int) > 0 {
|
||||
// there was preexisting external net connection - disconnect ViNS
|
||||
req := vins.ExtNetDisconnectRequest{VINSID: vinsData.ID}
|
||||
|
||||
_, err := c.CloudAPI().VINS().ExtNetDisconnect(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if newExtNedId.(int) >= 0 {
|
||||
// new external network connection requested - connect ViNS
|
||||
req := vins.ExtNetConnectRequest{
|
||||
VINSID: vinsData.ID,
|
||||
NetID: uint64(newExtNedId.(int)),
|
||||
IP: "",
|
||||
}
|
||||
|
||||
extNetIp, ok := d.GetOk("ext_net_ip")
|
||||
if ok && extNetIp.(string) != "" {
|
||||
req.IP = extNetIp.(string)
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().ExtNetConnect(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if d.HasChange("ip") {
|
||||
deletedIps := make([]interface{}, 0)
|
||||
addedIps := make([]interface{}, 0)
|
||||
|
||||
oldIpInterface, newIpInterface := d.GetChange("ip")
|
||||
oldIpSlice := oldIpInterface.([]interface{})
|
||||
newIpSlice := newIpInterface.([]interface{})
|
||||
|
||||
for _, el := range oldIpSlice {
|
||||
if !isContainsIp(newIpSlice, el) {
|
||||
deletedIps = append(deletedIps, el)
|
||||
}
|
||||
}
|
||||
|
||||
for _, el := range newIpSlice {
|
||||
if !isContainsIp(oldIpSlice, el) {
|
||||
addedIps = append(addedIps, el)
|
||||
}
|
||||
}
|
||||
|
||||
if len(deletedIps) > 0 {
|
||||
for _, ipInterfase := range deletedIps {
|
||||
ip := ipInterfase.(map[string]interface{})
|
||||
req := vins.IPReleaseRequest{VINSID: vinsData.ID}
|
||||
|
||||
if ip["ip_addr"].(string) != "" {
|
||||
req.IPAddr = ip["ip_addr"].(string)
|
||||
}
|
||||
if ip["mac_addr"].(string) != "" {
|
||||
req.MAC = ip["mac_addr"].(string)
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().IPRelese(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(addedIps) > 0 {
|
||||
for _, ipInterfase := range addedIps {
|
||||
ip := ipInterfase.(map[string]interface{})
|
||||
req := vins.IPReserveRequest{
|
||||
VINSID: vinsData.ID,
|
||||
Type: ip["type"].(string),
|
||||
}
|
||||
|
||||
if ip["ip_addr"].(string) != "" {
|
||||
req.IPAddr = ip["ip_addr"].(string)
|
||||
}
|
||||
if ip["mac_addr"].(string) != "" {
|
||||
req.MAC = ip["mac_addr"].(string)
|
||||
}
|
||||
if ip["compute_id"].(int) != 0 {
|
||||
req.ComputeID = uint64(ip["compute_id"].(int))
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().IPReserve(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("nat_rule") {
|
||||
deletedNatRules := make([]interface{}, 0)
|
||||
addedNatRules := make([]interface{}, 0)
|
||||
|
||||
oldNatRulesInterface, newNatRulesInterface := d.GetChange("nat_rule")
|
||||
oldNatRulesSlice := oldNatRulesInterface.([]interface{})
|
||||
newNatRulesSlice := newNatRulesInterface.([]interface{})
|
||||
|
||||
for _, el := range oldNatRulesSlice {
|
||||
if !isContainsNatRule(newNatRulesSlice, el) {
|
||||
deletedNatRules = append(deletedNatRules, el)
|
||||
}
|
||||
}
|
||||
|
||||
for _, el := range newNatRulesSlice {
|
||||
if !isContainsNatRule(oldNatRulesSlice, el) {
|
||||
addedNatRules = append(addedNatRules, el)
|
||||
}
|
||||
}
|
||||
|
||||
if len(deletedNatRules) > 0 {
|
||||
for _, natRuleInterface := range deletedNatRules {
|
||||
natRule := natRuleInterface.(map[string]interface{})
|
||||
req := vins.NATRuleDelRequest{
|
||||
VINSID: vinsData.ID,
|
||||
RuleID: int64(natRule["rule_id"].(int)),
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().NATRuleDel(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(addedNatRules) > 0 {
|
||||
for _, natRuleInterface := range addedNatRules {
|
||||
natRule := natRuleInterface.(map[string]interface{})
|
||||
req := vins.NATRuleAddRequest{
|
||||
VINSID: vinsData.ID,
|
||||
IntIP: natRule["int_ip"].(string),
|
||||
IntPort: uint(natRule["int_port"].(int)),
|
||||
ExtPortStart: uint(natRule["ext_port_start"].(int)),
|
||||
}
|
||||
|
||||
if natRule["ext_port_end"].(int) != 0 {
|
||||
req.ExtPortEnd = uint(natRule["ext_port_end"].(int))
|
||||
}
|
||||
if natRule["proto"].(string) != "" {
|
||||
req.Proto = natRule["proto"].(string)
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().NATRuleAdd(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("dns") {
|
||||
// empty "dns" is allowed, it will update vnfs.dhcp.config.dns from current values to empty list
|
||||
dnsInterface := d.Get("dns").(*schema.Set).List()
|
||||
dnsList := make([]string, 0, len(dnsInterface))
|
||||
for _, item := range dnsInterface {
|
||||
dnsList = append(dnsList, item.(string))
|
||||
}
|
||||
|
||||
req := vins.DNSApplyRequest{
|
||||
VINSID: vinsData.ID,
|
||||
DNSList: dnsList,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().DNSApply(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("vnfdev_restart") {
|
||||
if oldRestart, newRestart := d.GetChange("vnfdev_restart"); oldRestart == false && newRestart == true {
|
||||
req := vins.VNFDevRestartRequest{VINSID: vinsData.ID}
|
||||
|
||||
_, err := c.CloudAPI().VINS().VNFDevRestart(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
if d.HasChange("vnfdev_redeploy") {
|
||||
if oldRedeploy, newRedeploy := d.GetChange("vnfdev_redeploy"); oldRedeploy == false && newRedeploy == true {
|
||||
req := vins.VNFDevRedeployRequest{VINSID: vinsData.ID}
|
||||
|
||||
_, err := c.CloudAPI().VINS().VNFDevRedeploy(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("zone_id") {
|
||||
zoneID := uint64(d.Get("zone_id").(int))
|
||||
|
||||
req := vins.MigrateToZoneRequest{
|
||||
VINSID: vinsData.ID,
|
||||
ZoneID: zoneID,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().MigrateToZone(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
|
||||
return append(warnings.Get(), resourceVinsRead(ctx, d, m)...)
|
||||
}
|
||||
|
||||
func resourceVinsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
vinsId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req := vins.DeleteRequest{
|
||||
VINSID: vinsId,
|
||||
Force: d.Get("force").(bool),
|
||||
Permanently: d.Get("permanently").(bool),
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().VINS().Delete(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func extNetSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"ext_net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Default: -1,
|
||||
Optional: true,
|
||||
},
|
||||
"ext_net_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ipSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"DHCP", "VIP", "EXCLUDED"}, false),
|
||||
},
|
||||
"ip_addr": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"mac_addr": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func natRuleSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"int_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"int_port": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"ext_port_start": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"ext_port_end": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"proto": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"tcp", "udp"}, false),
|
||||
Computed: true,
|
||||
},
|
||||
"rule_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
rets := dataSourceVinsSchemaMake()
|
||||
rets["name"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
}
|
||||
rets["rg_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
}
|
||||
rets["account_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
}
|
||||
rets["ext_net_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: -1,
|
||||
}
|
||||
rets["ext_ip_addr"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "",
|
||||
}
|
||||
rets["ipcidr"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
}
|
||||
rets["pre_reservations_num"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
}
|
||||
rets["gid"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
}
|
||||
rets["enable"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
}
|
||||
rets["permanently"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
rets["force"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
rets["ext_net"] = &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
MaxItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: extNetSchemaMake(),
|
||||
},
|
||||
}
|
||||
rets["ip"] = &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: ipSchemaMake(),
|
||||
},
|
||||
}
|
||||
rets["nat_rule"] = &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: natRuleSchemaMake(),
|
||||
},
|
||||
}
|
||||
rets["desc"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "",
|
||||
Description: "Optional user-defined text description of this ViNS.",
|
||||
}
|
||||
rets["restore"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
rets["vnfdev_restart"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
rets["vnfdev_redeploy"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
rets["dns"] = &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
}
|
||||
rets["vins_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||
}
|
||||
rets["zone_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "ID of the Zone to put ViNS into",
|
||||
}
|
||||
rets["enable_secgroups"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "enable security groups",
|
||||
}
|
||||
|
||||
return rets
|
||||
}
|
||||
|
||||
func ResourceVins() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceVinsCreate,
|
||||
ReadContext: resourceVinsRead,
|
||||
UpdateContext: resourceVinsUpdate,
|
||||
DeleteContext: resourceVinsDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout20m,
|
||||
Read: &constants.Timeout600s,
|
||||
Update: &constants.Timeout20m,
|
||||
Delete: &constants.Timeout600s,
|
||||
Default: &constants.Timeout600s,
|
||||
},
|
||||
|
||||
Schema: resourceVinsSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityDataStaticRouteCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ItemRoutes, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.StaticRouteListRequest{}
|
||||
var routeId uint64
|
||||
|
||||
if d.Id() != "" {
|
||||
arr := strings.Split(d.Id(), "#")
|
||||
if len(arr) != 2 {
|
||||
return nil, fmt.Errorf("broken state id")
|
||||
}
|
||||
|
||||
req.VINSID, _ = strconv.ParseUint(arr[0], 10, 64)
|
||||
routeId, _ = strconv.ParseUint(arr[1], 10, 64)
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
routeId = uint64(d.Get("route_id").(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityStaticRouteCheckPresence, vins_id: %v", req.VINSID)
|
||||
staticRouteList, err := c.CloudAPI().VINS().StaticRouteList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugf("utilityStaticRouteCheckPresence: ROUTE ID %v", routeId)
|
||||
|
||||
staticRoute := &vins.ItemRoutes{}
|
||||
for _, route := range staticRouteList.Data {
|
||||
if routeId == route.ID {
|
||||
staticRoute = &route
|
||||
return staticRoute, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("static route not found")
|
||||
}
|
||||
|
||||
func getStaticRouteData(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ItemRoutes, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.StaticRouteListRequest{}
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
|
||||
staticRouteList, err := c.CloudAPI().VINS().StaticRouteList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
destination := d.Get("destination").(string)
|
||||
gateway := d.Get("gateway").(string)
|
||||
|
||||
staticRoute := &vins.ItemRoutes{}
|
||||
for _, route := range staticRouteList.Data {
|
||||
if destination == route.Destination && gateway == route.Gateway {
|
||||
staticRoute = &route
|
||||
return staticRoute, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("static route not found")
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityStaticRouteListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListStaticRoutes, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.StaticRouteListRequest{}
|
||||
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
|
||||
log.Debugf("utilityStaticRouteListCheckPresence")
|
||||
staticRouteList, err := c.CloudAPI().VINS().StaticRouteList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return staticRouteList, nil
|
||||
}
|
||||
@@ -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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityDataVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.RecordVINS, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.GetRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
vinsId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = vinsId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
vins, err := c.CloudAPI().VINS().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vins, 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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityVinsAuditsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (vins.ListAudits, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.AuditsRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
vinsId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = vinsId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
audits, err := c.CloudAPI().VINS().Audits(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return audits, nil
|
||||
}
|
||||
@@ -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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityVinsExtNetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListExtNets, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.ExtNetListRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
}
|
||||
|
||||
if d.Id() != "" {
|
||||
vinsId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = vinsId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
extNetList, err := c.CloudAPI().VINS().ExtNetList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return extNetList, 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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityVinsIpListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListIPs, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.IPListRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
vinsId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = vinsId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
ips, err := c.CloudAPI().VINS().IPList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ips, nil
|
||||
}
|
||||
@@ -1,102 +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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListVINS, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.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 account_id, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(account_id.(int))
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
|
||||
if ext_ip, ok := d.GetOk("ext_ip"); ok {
|
||||
req.ExtIP = ext_ip.(string)
|
||||
}
|
||||
|
||||
if VNFDevId, ok := d.GetOk("vnfdev_id"); ok {
|
||||
req.VNFDevId = uint64(VNFDevId.(int))
|
||||
}
|
||||
|
||||
if includeDeleted, ok := d.GetOk("include_deleted"); ok {
|
||||
req.IncludeDeleted = includeDeleted.(bool)
|
||||
}
|
||||
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(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 zoneID, ok := d.GetOk("zone_id"); ok {
|
||||
req.ZoneID = uint64(zoneID.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityVinsListCheckPresence")
|
||||
vinsList, err := c.CloudAPI().VINS().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vinsList, nil
|
||||
}
|
||||
@@ -1,89 +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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityVinsListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListVINS, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.ListDeletedRequest{}
|
||||
|
||||
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 sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
|
||||
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 account_id, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(account_id.(int))
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
|
||||
if ext_ip, ok := d.GetOk("ext_ip"); ok {
|
||||
req.ExtIP = ext_ip.(string)
|
||||
}
|
||||
if VNFDevId, ok := d.GetOk("vnfdev_id"); ok {
|
||||
req.VNFDevID = uint64(VNFDevId.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityVinsListDeletedCheckPresence")
|
||||
vinsList, err := c.CloudAPI().VINS().ListDeleted(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vinsList, 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>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
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 vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityVinsNatRuleListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListNATRules, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.NATRuleListRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
vinsId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = vinsId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
natRuleList, err := c.CloudAPI().VINS().NATRuleList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return natRuleList, nil
|
||||
}
|
||||
Reference in New Issue
Block a user