parent
0adf28daf6
commit
be86069155
@ -1,10 +1,33 @@
|
|||||||
### Version 3.2.2
|
### Version 3.3.0
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
||||||
- Fix bug with getting kvmvm data_source
|
- Fix bug with getting k8s_wg from import
|
||||||
|
- Fix bug with getting k8s from import
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- Add enable/disable functionality for kvmvm resource
|
- Add data_source k8s
|
||||||
- Add status checker for kvmvm resource
|
- Add data_source k8s_list
|
||||||
|
- Add data_source k8s_list_deleted
|
||||||
|
- Add data_source k8s_wg_list
|
||||||
|
- Add data_source k8s_wg
|
||||||
|
- Add a vins_id to the k8s schema/state
|
||||||
|
- Add a ips from computes to the k8s group workers in schema/state
|
||||||
|
- Add a ips from computes to the k8s masters in schema/state
|
||||||
|
- Add a ips from computes to the k8s_wg in schema/state
|
||||||
|
- Change data_source vins, the schema/state is aligned with the platform
|
||||||
|
- Add data_source vins_audits
|
||||||
|
- Add data_source vins_ext_net_list
|
||||||
|
- Add data_source vins_ip_list
|
||||||
|
- Change data_source vins_list, the schema/state is aligned with the platform
|
||||||
|
- Add data_source vins_list_deleted
|
||||||
|
- Add data_source vins_nat_rule_list
|
||||||
|
- Add status checker for vins resource
|
||||||
|
- Add the ability to create and update ip reservations
|
||||||
|
- Add the ability to create and update nat_rule reservations
|
||||||
|
- Add enable/disable functionality for vins resource
|
||||||
|
- Add the ability to restart vnfDev
|
||||||
|
- Add the ability to redeploy vnfDev
|
||||||
|
- Add the ability to import vins
|
||||||
|
- Add warnings handling, which does not interrupt the work when the state is successfully created
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package dc
|
||||||
|
|
||||||
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
|
||||||
|
type Warnings struct {
|
||||||
|
diagnostics diag.Diagnostics
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Warnings) Add(err error) {
|
||||||
|
if w.diagnostics == nil {
|
||||||
|
w.diagnostics = diag.Diagnostics{}
|
||||||
|
}
|
||||||
|
diagFromErr := diag.FromErr(err)
|
||||||
|
diagFromErr[0].Severity = diag.Warning
|
||||||
|
w.diagnostics = append(w.diagnostics, diagFromErr[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w Warnings) Get() diag.Diagnostics {
|
||||||
|
return w.diagnostics
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
audits, err := utilityVinsAuditsCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
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(),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsExtNetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
extNetList, err := utilityVinsExtNetListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenVinsExtNetList(extNetList))
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsExtNetList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceVinsExtNetListRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
Schema: DataSourceVinsExtNetListchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsIpListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
ips, err := utilityVinsIpListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenVinsIpList(ips))
|
||||||
|
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. 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{
|
||||||
|
"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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
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,190 +1,164 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://github.com/rudecs/terraform-provider-decort
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package vins
|
package vins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenVinsList(vl VinsList) []map[string]interface{} {
|
func dataSourceVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
res := make([]map[string]interface{}, 0)
|
vinsList, err := utilityVinsListCheckPresence(ctx, d, m)
|
||||||
for _, v := range vl {
|
if err != nil {
|
||||||
temp := map[string]interface{}{
|
return diag.FromErr(err)
|
||||||
"account_id": v.AccountId,
|
}
|
||||||
"account_name": v.AccountName,
|
|
||||||
"created_by": v.CreatedBy,
|
id := uuid.New()
|
||||||
"created_time": v.CreatedTime,
|
d.SetId(id.String())
|
||||||
"deleted_by": v.DeletedBy,
|
d.Set("items", flattenVinsList(vinsList))
|
||||||
"deleted_time": v.DeletedTime,
|
|
||||||
"external_ip": v.ExternalIP,
|
return nil
|
||||||
"vins_id": v.ID,
|
}
|
||||||
"vins_name": v.Name,
|
|
||||||
"network": v.Network,
|
func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
|
||||||
"rg_id": v.RGID,
|
res := map[string]*schema.Schema{
|
||||||
"rg_name": v.RGName,
|
"include_deleted": {
|
||||||
"status": v.Status,
|
Type: schema.TypeBool,
|
||||||
"updated_by": v.UpdatedBy,
|
Optional: true,
|
||||||
"updated_time": v.UpdatedTime,
|
Default: false,
|
||||||
"vxlan_id": v.VXLanID,
|
Description: "include deleted computes",
|
||||||
}
|
},
|
||||||
res = append(res, temp)
|
"page": {
|
||||||
}
|
Type: schema.TypeInt,
|
||||||
return res
|
Optional: true,
|
||||||
}
|
Description: "Page number",
|
||||||
|
},
|
||||||
func dataSourceVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
"size": {
|
||||||
vinsList, err := utilityVinsListCheckPresence(ctx, d, m)
|
Type: schema.TypeInt,
|
||||||
if err != nil {
|
Optional: true,
|
||||||
return diag.FromErr(err)
|
Description: "Page size",
|
||||||
}
|
},
|
||||||
|
"items": {
|
||||||
id := uuid.New()
|
Type: schema.TypeList,
|
||||||
d.SetId(id.String())
|
Computed: true,
|
||||||
d.Set("items", flattenVinsList(vinsList))
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
return nil
|
"account_id": {
|
||||||
}
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
|
},
|
||||||
res := map[string]*schema.Schema{
|
"account_name": {
|
||||||
"include_deleted": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeBool,
|
Computed: true,
|
||||||
Optional: true,
|
},
|
||||||
Default: false,
|
"created_by": {
|
||||||
Description: "include deleted computes",
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"page": {
|
},
|
||||||
Type: schema.TypeInt,
|
"created_time": {
|
||||||
Optional: true,
|
Type: schema.TypeInt,
|
||||||
Description: "Page number",
|
Computed: true,
|
||||||
},
|
},
|
||||||
"size": {
|
"deleted_by": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Computed: true,
|
||||||
Description: "Page size",
|
},
|
||||||
},
|
"deleted_time": {
|
||||||
"items": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"external_ip": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeString,
|
||||||
"account_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"vins_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"account_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"vins_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"created_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"network": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"created_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"rg_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"deleted_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"rg_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"deleted_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"external_ip": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"updated_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"vins_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"updated_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"vins_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"vxlan_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"network": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"rg_id": {
|
},
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Computed: true,
|
return res
|
||||||
},
|
}
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
func DataSourceVinsList() *schema.Resource {
|
||||||
Computed: true,
|
return &schema.Resource{
|
||||||
},
|
SchemaVersion: 1,
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
ReadContext: dataSourceVinsListRead,
|
||||||
Computed: true,
|
|
||||||
},
|
Timeouts: &schema.ResourceTimeout{
|
||||||
"updated_by": {
|
Read: &constants.Timeout30s,
|
||||||
Type: schema.TypeString,
|
Default: &constants.Timeout60s,
|
||||||
Computed: true,
|
},
|
||||||
},
|
|
||||||
"updated_time": {
|
Schema: dataSourceVinsListSchemaMake(),
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Computed: true,
|
}
|
||||||
},
|
|
||||||
"vxlan_id": {
|
|
||||||
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(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
vinsList, err := utilityVinsListDeletedCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenVinsList(vinsList))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceVinsListDeletedSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page number",
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page size",
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsListDeleted() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceVinsListDeletedRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceVinsListDeletedSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsNatRuleListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
natRules, err := utilityVinsNatRuleListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenVinsNatRuleList(natRules))
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsNatRuleList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceVinsNatRuleListRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
Schema: DataSourceVinsNatRuleListSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,514 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
|
||||||
|
func flattenMGMT(mgmt *VNFConfigMGMT) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"ip_addr": mgmt.IPAddr,
|
||||||
|
"password": mgmt.Password,
|
||||||
|
"ssh_key": mgmt.SSHKey,
|
||||||
|
"user": mgmt.User,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenResources(resources *VNFConfigResources) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"cpu": resources.CPU,
|
||||||
|
"ram": resources.RAM,
|
||||||
|
"stack_id": resources.StackID,
|
||||||
|
"uuid": resources.UUID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenConfig(config VNFConfig) []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 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 VNFInterfaceList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
|
||||||
|
for _, vnfInterface := range interfaces {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"conn_id": vnfInterface.ConnID,
|
||||||
|
"conn_type": vnfInterface.ConnType,
|
||||||
|
"def_gw": vnfInterface.DefGW,
|
||||||
|
"flipgroup_id": vnfInterface.FlipGroupID,
|
||||||
|
"guid": vnfInterface.GUID,
|
||||||
|
"ip_address": vnfInterface.IPAddress,
|
||||||
|
"listen_ssh": vnfInterface.ListenSSH,
|
||||||
|
"mac": vnfInterface.MAC,
|
||||||
|
"name": vnfInterface.Name,
|
||||||
|
"net_id": vnfInterface.NetID,
|
||||||
|
"net_mask": vnfInterface.NetMask,
|
||||||
|
"net_type": vnfInterface.NetType,
|
||||||
|
"pci_slot": vnfInterface.PCISlot,
|
||||||
|
"qos": flattenQOS(vnfInterface.QOS),
|
||||||
|
"target": vnfInterface.Target,
|
||||||
|
"type": vnfInterface.Type,
|
||||||
|
"vnfs": vnfInterface.VNFS,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVNFDev(vnfDev VNFDev) []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),
|
||||||
|
"lock_status": vnfDev.LockStatus,
|
||||||
|
"milestones": vnfDev.Milestones,
|
||||||
|
"vnf_name": vnfDev.Name,
|
||||||
|
"status": vnfDev.Status,
|
||||||
|
"tech_status": vnfDev.TechStatus,
|
||||||
|
"type": vnfDev.Type,
|
||||||
|
"vins": vnfDev.VINS,
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenComputes(computes VINSComputeList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
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 ReservationList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, reservation := range reservations {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"client_type": reservation.ClientType,
|
||||||
|
"desc": reservation.Description,
|
||||||
|
"domainname": reservation.DomainName,
|
||||||
|
"hostname": reservation.HostName,
|
||||||
|
"ip": reservation.IP,
|
||||||
|
"mac": reservation.MAC,
|
||||||
|
"type": reservation.Type,
|
||||||
|
"vm_id": reservation.VMID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenDHCPConfig(config DHCPConfig) []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 DevicePrimary) []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 Devices) []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 DHCP) []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,
|
||||||
|
"status": dhcp.Status,
|
||||||
|
"tech_status": dhcp.TechStatus,
|
||||||
|
"type": dhcp.Type,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenGWConfig(config GWConfig) []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 GW) []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,
|
||||||
|
"status": gw.Status,
|
||||||
|
"tech_status": gw.TechStatus,
|
||||||
|
"type": gw.Type,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenRules(rules ListNATRules) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
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 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 NAT) []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,
|
||||||
|
"status": nat.Status,
|
||||||
|
"tech_status": nat.TechStatus,
|
||||||
|
"type": nat.Type,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVNFS(vnfs VNFS) []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 ListNATRules) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
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 VINSDetailed) {
|
||||||
|
d.Set("vins_id", vins.ID)
|
||||||
|
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||||
|
d.Set("_ckey", vins.CKey)
|
||||||
|
d.Set("account_id", vins.AccountID)
|
||||||
|
d.Set("account_name", vins.AccountName)
|
||||||
|
d.Set("computes", flattenComputes(vins.Computes))
|
||||||
|
d.Set("default_gw", vins.DefaultGW)
|
||||||
|
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||||
|
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("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))
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVinsData(d *schema.ResourceData, vins VINSDetailed) {
|
||||||
|
d.Set("vins_id", vins.ID)
|
||||||
|
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||||
|
d.Set("_ckey", vins.CKey)
|
||||||
|
d.Set("account_id", vins.AccountID)
|
||||||
|
d.Set("account_name", vins.AccountName)
|
||||||
|
d.Set("computes", flattenComputes(vins.Computes))
|
||||||
|
d.Set("default_gw", vins.DefaultGW)
|
||||||
|
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||||
|
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("user_managed", vins.UserManaged)
|
||||||
|
d.Set("vnfs", flattenVNFS(vins.VNFS))
|
||||||
|
d.Set("vxlan_id", vins.VXLanID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVinsAudits(auidts VINSAuditsList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, audit := range auidts {
|
||||||
|
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 ExtNetList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, extNet := range extNetList {
|
||||||
|
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 IPList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, ip := range ips {
|
||||||
|
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 VINSList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, v := range vl {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVinsNatRuleList(natRules NATRuleList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, natRule := range natRules {
|
||||||
|
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,94 +1,330 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@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.
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
You may obtain a copy of the License at
|
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
|
|
||||||
|
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,
|
Unless required by applicable law or agreed to in writing, software
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
See the License for the specific language governing permissions and
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
limitations under the License.
|
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.
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
Source code: https://github.com/rudecs/terraform-provider-decort
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
Please see README.md to learn where to place source code so that it
|
|
||||||
builds seamlessly.
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
|
||||||
*/
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
package vins
|
|
||||||
|
package vins
|
||||||
type Vins struct {
|
|
||||||
AccountId int `json:"accountId"`
|
type VINSRecord struct {
|
||||||
AccountName string `json:"accountName"`
|
AccountID uint64 `json:"accountId"`
|
||||||
CreatedBy string `json:"createdBy"`
|
AccountName string `json:"accountName"`
|
||||||
CreatedTime int `json:"createdTime"`
|
CreatedBy string `json:"createdBy"`
|
||||||
DeletedBy string `json:"deletedBy"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
DeletedTime int `json:"deletedTime"`
|
DeletedBy string `json:"deletedBy"`
|
||||||
ExternalIP string `json:"externalIP"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
ID int `json:"id"`
|
ExternalIP string `json:"externalIP"`
|
||||||
Name string `json:"name"`
|
ID uint64 `json:"id"`
|
||||||
Network string `json:"network"`
|
Name string `json:"name"`
|
||||||
RGID int `json:"rgId"`
|
Network string `json:"network"`
|
||||||
RGName string `json:"rgName"`
|
RGID uint64 `json:"rgId"`
|
||||||
Status string `json:"status"`
|
RGName string `json:"rgName"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
Status string `json:"status"`
|
||||||
UpdatedTime int `json:"updatedTime"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
VXLanID int `json:"vxlanId"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
}
|
VXLANID uint64 `json:"vxlanId"`
|
||||||
|
}
|
||||||
type VinsList []Vins
|
|
||||||
|
type VINSList []VINSRecord
|
||||||
type VinsSearchResp []VinsSearchRecord
|
|
||||||
|
type VINSAudits struct {
|
||||||
type VnfRecord struct {
|
Call string `json:"call"`
|
||||||
ID int `json:"id"`
|
ResponseTime float64 `json:"responsetime"`
|
||||||
AccountID int `json:"accountId"`
|
StatusCode uint64 `json:"statuscode"`
|
||||||
Type string `json:"type"` // "DHCP", "NAT", "GW" etc
|
Timestamp float64 `json:"timestamp"`
|
||||||
Config map[string]interface{} `json:"config"` // NOTE: VNF specs vary by VNF type
|
User string `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type VnfGwConfigRecord struct { // describes GW VNF config structure inside ViNS, as returned by API vins/get
|
type VINSAuditsList []VINSAudits
|
||||||
ExtNetID int `json:"ext_net_id"`
|
|
||||||
ExtNetIP string `json:"ext_net_ip"`
|
type VINSExtNet struct {
|
||||||
ExtNetMask int `json:"ext_net_mask"`
|
DefaultGW string `json:"default_gw"`
|
||||||
DefaultGW string `json:"default_gw"`
|
ExtNetID uint64 `json:"ext_net_id"`
|
||||||
}
|
IP string `json:"ip"`
|
||||||
type VinsRecord struct { // represents part of the response from API vins/get
|
PrefixLen uint64 `json:"prefixlen"`
|
||||||
ID int `json:"id"`
|
Status string `json:"status"`
|
||||||
Name string `json:"name"`
|
TechStatus string `json:"techStatus"`
|
||||||
IPCidr string `json:"network"`
|
}
|
||||||
VxLanID int `json:"vxlanId"`
|
|
||||||
ExternalIP string `json:"externalIP"`
|
type ExtNetList []VINSExtNet
|
||||||
AccountID int `json:"accountId"`
|
|
||||||
AccountName string `json:"accountName"`
|
type IP struct {
|
||||||
RgID int `json:"rgid"`
|
ClientType string `json:"clientType"`
|
||||||
RgName string `json:"rgName"`
|
DomainName string `json:"domainname"`
|
||||||
VNFs map[string]VnfRecord `json:"vnfs"`
|
HostName string `json:"hostname"`
|
||||||
Desc string `json:"desc"`
|
IP string `json:"ip"`
|
||||||
}
|
MAC string `json:"mac"`
|
||||||
|
Type string `json:"type"`
|
||||||
type VinsSearchRecord struct {
|
VMID uint64 `json:"vmId"`
|
||||||
ID int `json:"id"`
|
}
|
||||||
Name string `json:"name"`
|
|
||||||
IPCidr string `json:"network"`
|
type IPList []IP
|
||||||
VxLanID int `json:"vxlanId"`
|
|
||||||
ExternalIP string `json:"externalIP"`
|
type VNFDev struct {
|
||||||
AccountID int `json:"accountId"`
|
CKey string `json:"_ckey"`
|
||||||
AccountName string `json:"accountName"`
|
AccountID uint64 `json:"accountId"`
|
||||||
RgID int `json:"rgId"`
|
Capabilities []string `json:"capabilities"`
|
||||||
RgName string `json:"rgName"`
|
Config VNFConfig `json:"config"`
|
||||||
}
|
ConfigSaved bool `json:"configSaved"`
|
||||||
|
CustomPreConfig bool `json:"customPrecfg"`
|
||||||
|
Description string `json:"desc"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
Interfaces VNFInterfaceList `json:"interfaces"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
VINS []uint64 `json:"vins"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFConfig struct {
|
||||||
|
MGMT VNFConfigMGMT `json:"mgmt"`
|
||||||
|
Resources VNFConfigResources `json:"resources"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFConfigMGMT struct {
|
||||||
|
IPAddr string `json:"ipaddr"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
SSHKey string `json:"sshkey"`
|
||||||
|
User string `json:"user"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFConfigResources struct {
|
||||||
|
CPU uint64 `json:"cpu"`
|
||||||
|
RAM uint64 `json:"ram"`
|
||||||
|
StackID uint64 `json:"stackId"`
|
||||||
|
UUID string `json:"uuid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFInterface struct {
|
||||||
|
ConnID uint64 `json:"connId"`
|
||||||
|
ConnType string `json:"connType"`
|
||||||
|
DefGW string `json:"defGw"`
|
||||||
|
FlipGroupID uint64 `json:"flipgroupId"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
IPAddress string `json:"ipAddress"`
|
||||||
|
ListenSSH bool `json:"listenSsh"`
|
||||||
|
MAC string `json:"mac"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
NetID uint64 `json:"netId"`
|
||||||
|
NetMask uint64 `json:"netMask"`
|
||||||
|
NetType string `json:"netType"`
|
||||||
|
PCISlot uint64 `json:"pciSlot"`
|
||||||
|
QOS QOS `json:"qos"`
|
||||||
|
Target string `json:"target"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
VNFS []uint64 `json:"vnfs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type QOS struct {
|
||||||
|
ERate uint64 `json:"eRate"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
InBurst uint64 `json:"inBurst"`
|
||||||
|
InRate uint64 `json:"inRate"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFInterfaceList []VNFInterface
|
||||||
|
|
||||||
|
type VINSCompute struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VINSComputeList []VINSCompute
|
||||||
|
|
||||||
|
type VNFS struct {
|
||||||
|
DHCP DHCP `json:"DHCP"`
|
||||||
|
GW GW `json:"GW"`
|
||||||
|
NAT NAT `json:"NAT"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NAT struct {
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
Config NATConfig `json:"config"`
|
||||||
|
Devices Devices `json:"devices"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
OwnerID uint64 `json:"ownerId"`
|
||||||
|
OwnerType string `json:"ownerType"`
|
||||||
|
PureVirtual bool `json:"pureVirtual"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NATConfig struct {
|
||||||
|
NetMask uint64 `json:"netmask"`
|
||||||
|
Network string `json:"network"`
|
||||||
|
Rules ListNATRules `json:"rules"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ItemNATRule struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LocalIP string `json:"localIp"`
|
||||||
|
LocalPort uint64 `json:"localPort"`
|
||||||
|
Protocol string `json:"protocol"`
|
||||||
|
PublicPortEnd uint64 `json:"publicPortEnd"`
|
||||||
|
PublicPortStart uint64 `json:"publicPortStart"`
|
||||||
|
VMID uint64 `json:"vmId"`
|
||||||
|
VMName string `json:"vmName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListNATRules []ItemNATRule
|
||||||
|
|
||||||
|
type GW struct {
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
Config GWConfig `json:"config"`
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
Devices Devices `json:"devices"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
OwnerID uint64 `json:"ownerId"`
|
||||||
|
OwnerType string `json:"ownerType"`
|
||||||
|
PureVirtual bool `json:"pureVirtual"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GWConfig struct {
|
||||||
|
DefaultGW string `json:"default_gw"`
|
||||||
|
ExtNetID uint64 `json:"ext_net_id"`
|
||||||
|
ExtNetIP string `json:"ext_net_ip"`
|
||||||
|
ExtNetMask uint64 `json:"ext_netmask"`
|
||||||
|
QOS QOS `json:"qos"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Devices struct {
|
||||||
|
Primary DevicePrimary `json:"primary"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DevicePrimary struct {
|
||||||
|
DevID uint64 `json:"devId"`
|
||||||
|
IFace01 string `json:"iface01"`
|
||||||
|
IFace02 string `json:"iface02"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DHCP struct {
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
Config DHCPConfig `json:"config"`
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
Devices Devices `json:"devices"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
OwnerID uint64 `json:"ownerId"`
|
||||||
|
OwnerType string `json:"ownerType"`
|
||||||
|
PureVirtual bool `json:"pureVirtual"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DHCPConfig struct {
|
||||||
|
DefaultGW string `json:"default_gw"`
|
||||||
|
DNS []string `json:"dns"`
|
||||||
|
IPEnd string `json:"ip_end"`
|
||||||
|
IPStart string `json:"ip_start"`
|
||||||
|
Lease uint64 `json:"lease"`
|
||||||
|
Netmask uint64 `json:"netmask"`
|
||||||
|
Network string `json:"network"`
|
||||||
|
Reservations ReservationList `json:"reservations"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VINSDetailed struct {
|
||||||
|
VNFDev VNFDev `json:"VNFDev"`
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
AccountName string `json:"accountName"`
|
||||||
|
Computes VINSComputeList `json:"computes"`
|
||||||
|
DefaultGW string `json:"defaultGW"`
|
||||||
|
DefaultQOS QOS `json:"defaultQos"`
|
||||||
|
Description string `json:"desc"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
ManagerID uint64 `json:"managerId"`
|
||||||
|
ManagerType string `json:"managerType"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
NetMask uint64 `json:"netMask"`
|
||||||
|
Network string `json:"network"`
|
||||||
|
PreReservaionsNum uint64 `json:"preReservationsNum"`
|
||||||
|
Redundant bool `json:"redundant"`
|
||||||
|
RGID uint64 `json:"rgId"`
|
||||||
|
RGName string `json:"rgName"`
|
||||||
|
SecVNFDevID uint64 `json:"secVnfDevId"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
UserManaged bool `json:"userManaged"`
|
||||||
|
VNFS VNFS `json:"vnfs"`
|
||||||
|
VXLanID uint64 `json:"vxlanId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Reservation struct {
|
||||||
|
ClientType string `json:"clientType"`
|
||||||
|
Description string `json:"desc"`
|
||||||
|
DomainName string `json:"domainname"`
|
||||||
|
HostName string `json:"hostname"`
|
||||||
|
IP string `json:"ip"`
|
||||||
|
MAC string `json:"mac"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
VMID int `json:"vmId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReservationList []Reservation
|
||||||
|
|
||||||
|
type NATRule struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LocalIP string `json:"localIp"`
|
||||||
|
LocalPort uint64 `json:"localPort"`
|
||||||
|
Protocol string `json:"protocol"`
|
||||||
|
PublicPortEnd uint64 `json:"publicPortEnd"`
|
||||||
|
PublicPortStart uint64 `json:"publicPortStart"`
|
||||||
|
VMID uint64 `json:"vmId"`
|
||||||
|
VMName string `json:"vmName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NATRuleList []NATRule
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsAuditsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (VINSAuditsList, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
auditsList := VINSAuditsList{}
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
|
auidtsRaw, err := c.DecortAPICall(ctx, "POST", VinsAuditsAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(auidtsRaw), &auditsList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return auditsList, nil
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsExtNetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ExtNetList, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
extNet := ExtNetList{}
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
|
extNetRaw, err := c.DecortAPICall(ctx, "POST", VinsExtNetListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(extNetRaw), &extNet)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return extNet, nil
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsIpListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (IPList, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
ips := IPList{}
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
|
auidtsRaw, err := c.DecortAPICall(ctx, "POST", VinsIpListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(auidtsRaw), &ips)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ips, nil
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (VINSList, error) {
|
||||||
|
vinsList := VINSList{}
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
if page, ok := d.GetOk("page"); ok {
|
||||||
|
urlValues.Add("page", strconv.Itoa(page.(int)))
|
||||||
|
}
|
||||||
|
if size, ok := d.GetOk("size"); ok {
|
||||||
|
urlValues.Add("size", strconv.Itoa(size.(int)))
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("utilityVinsListDeletedCheckPresence")
|
||||||
|
vinsListRaw, err := c.DecortAPICall(ctx, "POST", VinsListDeletedAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(vinsListRaw), &vinsList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return vinsList, nil
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
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://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsNatRuleListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (NATRuleList, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
natRuleList := NATRuleList{}
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
|
auidtsRaw, err := c.DecortAPICall(ctx, "POST", VinsNatRuleListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(auidtsRaw), &natRuleList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return natRuleList, nil
|
||||||
|
}
|
Loading…
Reference in new issue