Compare commits
No commits in common. 'main' and '4.7.3' have entirely different histories.
@ -1,32 +1,16 @@
|
|||||||
## Version 4.8.1
|
## Version 4.7.3
|
||||||
|
|
||||||
### Добавлено
|
### Добавлено
|
||||||
|
|
||||||
#### kvmvm
|
#### kvmvm
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BATF-692 | Опциональное поле `preferred_cpu`в resources `decort_kvmvm, decort_cb_kvmvm` в cloudapi/kvmvm и cloudbroker/kvmvm |
|
| BATF-648 | Обязательные поля `net_type, net_id` в опциональный блок `libvirt_settings` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
||||||
| BATF-692 | Вычисляемое поле `preferred_cpu`в data_sources `decort_kvmvm, decort_kvmvm_list, decort_kvmvm_list_deleted, decort_cb_kvmvm, decort_cb_kvmvm_list, decort_cb_kvmvm_list_deleted ` в cloudapi/kvmvm и cloudbroker/kvmvm |
|
| BATF-648 | Опциональное поле `mtu` в опциональный блок `network` в resources `decort_cb_kvmvm, decort_kvmvm` в cloudbroker/kvmvm и cloudapi/kvmvm |
|
||||||
|
|
||||||
#### node
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BATF-686 | Вычисляемые поля `dpdk, uefi_firmware_file`в data_source `decort_cb_node_list` в cloudbroker/node |
|
|
||||||
| BATF-687 | Вычисляемые поля `dpdk, network_mode, to_active, to_installing, to_maintenance, to_restricted` в data_source `decort_cb_node` в cloudbroker/node |
|
|
||||||
|
|
||||||
#### sep
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BATF-689 | Вычисляемое поле `multipath_num` в resource `decort_cb_sep` и data_sources `decort_cb_sep, decort_cb_sep_list` в cloudbroker/kvmvm |
|
|
||||||
|
|
||||||
#### vins
|
|
||||||
| Идентификатор<br>задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BATF-678 | Вычисляемое поле `account_id` в блоке `reservations` в resource `decort_cb_vins` и data source `decort_cb_vins` в cloudbroker/vins |
|
|
||||||
|
|
||||||
### Удалено
|
### Удалено
|
||||||
|
|
||||||
#### sep
|
#### kvmvm
|
||||||
| Идентификатор<br>задачи | Описание |
|
| Идентификатор<br>задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BATF-688 | Вычисляемые поля `ckey,meta` в resource `decort_cb_sep` и data_sources `decort_cb_sep, decort_cb_sep_list` в cloudbroker/kvmvm |
|
| BATF-648 | Обязательное поле `mac` в опциональном блок `libvirt_settings` в resource `decort_cb_kvmvm` в cloudbroker/kvmvm |
|
@ -1,61 +0,0 @@
|
|||||||
---
|
|
||||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
|
||||||
page_title: "decort_cb_extnet_reserved_ip_list Data Source - terraform-provider-decort"
|
|
||||||
subcategory: ""
|
|
||||||
description: |-
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# decort_cb_extnet_reserved_ip_list (Data Source)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- schema generated by tfplugindocs -->
|
|
||||||
## Schema
|
|
||||||
|
|
||||||
### Required
|
|
||||||
|
|
||||||
- `account_id` (Number)
|
|
||||||
|
|
||||||
### Optional
|
|
||||||
|
|
||||||
- `extnet_id` (Number)
|
|
||||||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
|
||||||
|
|
||||||
### Read-Only
|
|
||||||
|
|
||||||
- `id` (String) The ID of this resource.
|
|
||||||
- `items` (List of Object) (see [below for nested schema](#nestedatt--items))
|
|
||||||
|
|
||||||
<a id="nestedblock--timeouts"></a>
|
|
||||||
### Nested Schema for `timeouts`
|
|
||||||
|
|
||||||
Optional:
|
|
||||||
|
|
||||||
- `default` (String)
|
|
||||||
- `read` (String)
|
|
||||||
|
|
||||||
|
|
||||||
<a id="nestedatt--items"></a>
|
|
||||||
### Nested Schema for `items`
|
|
||||||
|
|
||||||
Read-Only:
|
|
||||||
|
|
||||||
- `extnet_id` (Number)
|
|
||||||
- `reservations` (List of Object) (see [below for nested schema](#nestedobjatt--items--reservations))
|
|
||||||
|
|
||||||
<a id="nestedobjatt--items--reservations"></a>
|
|
||||||
### Nested Schema for `items.reservations`
|
|
||||||
|
|
||||||
Read-Only:
|
|
||||||
|
|
||||||
- `account_id` (Number)
|
|
||||||
- `client_type` (String)
|
|
||||||
- `domain_name` (String)
|
|
||||||
- `hostname` (String)
|
|
||||||
- `ip` (String)
|
|
||||||
- `mac` (String)
|
|
||||||
- `type` (String)
|
|
||||||
- `vm_id` (Number)
|
|
@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "decort_cb_grid_post_diagnosis Data Source - terraform-provider-decort"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# decort_cb_grid_post_diagnosis (Data Source)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `gid` (Number)
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `diagnosis` (String)
|
||||||
|
- `id` (String) The ID of this resource.
|
||||||
|
|
||||||
|
<a id="nestedblock--timeouts"></a>
|
||||||
|
### Nested Schema for `timeouts`
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `default` (String)
|
||||||
|
- `read` (String)
|
@ -1,61 +0,0 @@
|
|||||||
---
|
|
||||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
|
||||||
page_title: "decort_extnet_reserved_ip_list Data Source - terraform-provider-decort"
|
|
||||||
subcategory: ""
|
|
||||||
description: |-
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# decort_extnet_reserved_ip_list (Data Source)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- schema generated by tfplugindocs -->
|
|
||||||
## Schema
|
|
||||||
|
|
||||||
### Required
|
|
||||||
|
|
||||||
- `account_id` (Number)
|
|
||||||
|
|
||||||
### Optional
|
|
||||||
|
|
||||||
- `extnet_id` (Number)
|
|
||||||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
|
||||||
|
|
||||||
### Read-Only
|
|
||||||
|
|
||||||
- `id` (String) The ID of this resource.
|
|
||||||
- `items` (List of Object) (see [below for nested schema](#nestedatt--items))
|
|
||||||
|
|
||||||
<a id="nestedblock--timeouts"></a>
|
|
||||||
### Nested Schema for `timeouts`
|
|
||||||
|
|
||||||
Optional:
|
|
||||||
|
|
||||||
- `default` (String)
|
|
||||||
- `read` (String)
|
|
||||||
|
|
||||||
|
|
||||||
<a id="nestedatt--items"></a>
|
|
||||||
### Nested Schema for `items`
|
|
||||||
|
|
||||||
Read-Only:
|
|
||||||
|
|
||||||
- `extnet_id` (Number)
|
|
||||||
- `reservations` (List of Object) (see [below for nested schema](#nestedobjatt--items--reservations))
|
|
||||||
|
|
||||||
<a id="nestedobjatt--items--reservations"></a>
|
|
||||||
### Nested Schema for `items.reservations`
|
|
||||||
|
|
||||||
Read-Only:
|
|
||||||
|
|
||||||
- `account_id` (Number)
|
|
||||||
- `client_type` (String)
|
|
||||||
- `domain_name` (String)
|
|
||||||
- `hostname` (String)
|
|
||||||
- `ip` (String)
|
|
||||||
- `mac` (String)
|
|
||||||
- `type` (String)
|
|
||||||
- `vm_id` (Number)
|
|
@ -1,137 +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>
|
|
||||||
Tim Tkachev, <tvtkachev@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 extnet
|
|
||||||
|
|
||||||
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 dataSourceExtnetReservedIpRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
reservedList, err := utilityExtnetReservedIpCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
|
||||||
d.Set("items", flattenExtnetReservedIp(reservedList))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func dataSourceExtnetReservedIpSchemaMake() map[string]*schema.Schema {
|
|
||||||
res := map[string]*schema.Schema{
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
"extnet_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
},
|
|
||||||
"items": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"extnet_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"reservations": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: map[string]*schema.Schema{
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"client_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
"domain_name": {
|
|
||||||
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 res
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceExtnetReservedIp() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceExtnetReservedIpRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceExtnetReservedIpSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +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 extnet
|
|
||||||
|
|
||||||
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/extnet"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
|
||||||
)
|
|
||||||
|
|
||||||
func utilityExtnetReservedIpCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) ([]extnet.RecordReservedIP, error) {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := extnet.GetReservedIP{
|
|
||||||
AccountID: uint64(d.Get("account_id").(int)),
|
|
||||||
}
|
|
||||||
|
|
||||||
if extNetID, ok := d.GetOk("extnet_id"); ok {
|
|
||||||
req.ExtNetID = uint64(extNetID.(int))
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("utilityExtnetReservedIpCheckPresence")
|
|
||||||
res, err := c.CloudAPI().ExtNet().GetReservedIP(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return res, nil
|
|
||||||
}
|
|
@ -1,194 +1,277 @@
|
|||||||
/*
|
/*
|
||||||
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://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/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://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package vins
|
package vins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
"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/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"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/dc"
|
||||||
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceStaticRouteCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceStaticRouteCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
if _, ok := d.GetOk("vins_id"); ok {
|
if _, ok := d.GetOk("vins_id"); ok {
|
||||||
haveVinsID, err := existVinsID(ctx, d, m)
|
haveVinsID, err := existVinsID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveVinsID {
|
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))
|
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{
|
req := vins.StaticRouteAddRequest{
|
||||||
VINSID: uint64(d.Get("vins_id").(int)),
|
VINSID: uint64(d.Get("vins_id").(int)),
|
||||||
Destination: d.Get("destination").(string),
|
Destination: d.Get("destination").(string),
|
||||||
Netmask: d.Get("netmask").(string),
|
Netmask: d.Get("netmask").(string),
|
||||||
Gateway: d.Get("gateway").(string),
|
Gateway: d.Get("gateway").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().VINS().StaticRouteAdd(ctx, req)
|
if computesIDS, ok := d.GetOk("compute_ids"); ok {
|
||||||
if err != nil {
|
ids := computesIDS.([]interface{})
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
res := make([]uint64, 10)
|
||||||
|
|
||||||
staticRouteData, err := getStaticRouteData(ctx, d, m)
|
for _, id := range ids {
|
||||||
if err != nil {
|
computeId := uint64(id.(int))
|
||||||
d.SetId("")
|
res = append(res, computeId)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
req.ComputeIds = res
|
||||||
d.SetId(fmt.Sprintf("%d#%d", req.VINSID, staticRouteData.ID))
|
}
|
||||||
|
|
||||||
return resourceStaticRouteRead(ctx, d, m)
|
_, err := c.CloudAPI().VINS().StaticRouteAdd(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
func resourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
}
|
||||||
warnings := dc.Warnings{}
|
|
||||||
|
staticRouteData, err := getStaticRouteData(ctx, d, m)
|
||||||
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
if err != nil {
|
||||||
if err != nil {
|
d.SetId("")
|
||||||
d.SetId("")
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
d.SetId(fmt.Sprintf("%d#%d", req.VINSID, staticRouteData.ID))
|
||||||
flattenStaticRouteData(d, staticRouteData)
|
|
||||||
|
return resourceStaticRouteRead(ctx, d, m)
|
||||||
return warnings.Get()
|
}
|
||||||
}
|
|
||||||
|
func resourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
func resourceStaticRouteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
warnings := dc.Warnings{}
|
||||||
return nil
|
|
||||||
}
|
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
func resourceStaticRouteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
d.SetId("")
|
||||||
c := m.(*controller.ControllerCfg)
|
return diag.FromErr(err)
|
||||||
arr := strings.Split(d.Id(), "#")
|
}
|
||||||
if len(arr) != 2 {
|
|
||||||
return diag.FromErr(fmt.Errorf("broken state id"))
|
flattenStaticRouteData(d, staticRouteData)
|
||||||
}
|
|
||||||
|
return warnings.Get()
|
||||||
vinsId, _ := strconv.ParseUint(arr[0], 10, 64)
|
}
|
||||||
routeId, _ := strconv.ParseUint(arr[1], 10, 64)
|
|
||||||
|
func resourceStaticRouteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
req := vins.StaticRouteDelRequest{
|
c := m.(*controller.ControllerCfg)
|
||||||
VINSID: vinsId,
|
warnings := dc.Warnings{}
|
||||||
RouteId: routeId,
|
|
||||||
}
|
if _, ok := d.GetOk("vins_id"); ok {
|
||||||
|
haveVinsID, err := existVinsID(ctx, d, m)
|
||||||
_, err := c.CloudAPI().VINS().StaticRouteDel(ctx, req)
|
if err != nil {
|
||||||
if err != nil {
|
return diag.FromErr(err)
|
||||||
return diag.FromErr(err)
|
}
|
||||||
}
|
|
||||||
|
if !haveVinsID {
|
||||||
d.SetId("")
|
return diag.Errorf("resourceVinsUpdate: can't update Static Route because VinsID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
||||||
|
}
|
||||||
return nil
|
}
|
||||||
}
|
|
||||||
|
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
||||||
func resourceStaticRouteSchemaMake() map[string]*schema.Schema {
|
if err != nil {
|
||||||
rets := dataSourceStaticRouteSchemaMake()
|
d.SetId("")
|
||||||
rets["route_id"] = &schema.Schema{
|
return diag.FromErr(err)
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Computed: true,
|
|
||||||
Optional: true,
|
if d.HasChange("compute_ids") {
|
||||||
}
|
deletedIds := make([]uint64, 0)
|
||||||
rets["compute_ids"] = &schema.Schema{
|
addedIds := make([]uint64, 0)
|
||||||
Type: schema.TypeList,
|
|
||||||
Computed: true,
|
oldComputeIds, newComputeIds := d.GetChange("compute_ids")
|
||||||
Elem: &schema.Schema{
|
oldComputeIdsSlice := oldComputeIds.([]interface{})
|
||||||
Type: schema.TypeInt,
|
newComputeIdsSlice := newComputeIds.([]interface{})
|
||||||
},
|
|
||||||
}
|
for _, el := range oldComputeIdsSlice {
|
||||||
rets["destination"] = &schema.Schema{
|
if !isContainsIds(newComputeIdsSlice, el) {
|
||||||
Type: schema.TypeString,
|
convertedEl := uint64(el.(int))
|
||||||
Required: true,
|
deletedIds = append(deletedIds, convertedEl)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
rets["gateway"] = &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
for _, el := range newComputeIdsSlice {
|
||||||
Required: true,
|
if !isContainsIds(oldComputeIdsSlice, el) {
|
||||||
}
|
convertedEl := uint64(el.(int))
|
||||||
rets["netmask"] = &schema.Schema{
|
addedIds = append(addedIds, convertedEl)
|
||||||
Type: schema.TypeString,
|
}
|
||||||
Required: true,
|
}
|
||||||
}
|
|
||||||
|
if len(deletedIds) > 0 {
|
||||||
return rets
|
req := vins.StaticRouteAccessRevokeRequest{
|
||||||
}
|
VINSID: uint64(d.Get("vins_id").(int)),
|
||||||
|
RouteId: staticRouteData.ID,
|
||||||
func isContainsIds(els []interface{}, el interface{}) bool {
|
ComputeIds: deletedIds,
|
||||||
convEl := el.(int)
|
}
|
||||||
for _, elOld := range els {
|
|
||||||
if convEl == elOld.(int) {
|
_, err := c.CloudAPI().VINS().StaticRouteAccessRevoke(ctx, req)
|
||||||
return true
|
if err != nil {
|
||||||
}
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
return false
|
}
|
||||||
}
|
|
||||||
|
if len(addedIds) > 0 {
|
||||||
func ResourceStaticRoute() *schema.Resource {
|
req := vins.StaticRouteAccessGrantRequest{
|
||||||
return &schema.Resource{
|
VINSID: uint64(d.Get("vins_id").(int)),
|
||||||
SchemaVersion: 1,
|
RouteId: staticRouteData.ID,
|
||||||
|
ComputeIds: addedIds,
|
||||||
CreateContext: resourceStaticRouteCreate,
|
}
|
||||||
ReadContext: resourceStaticRouteRead,
|
|
||||||
UpdateContext: resourceStaticRouteUpdate,
|
_, err := c.CloudAPI().VINS().StaticRouteAccessGrant(ctx, req)
|
||||||
DeleteContext: resourceStaticRouteDelete,
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
Importer: &schema.ResourceImporter{
|
}
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
return append(warnings.Get(), resourceStaticRouteRead(ctx, d, m)...)
|
||||||
Create: &constants.Timeout20m,
|
}
|
||||||
Read: &constants.Timeout600s,
|
|
||||||
Update: &constants.Timeout20m,
|
func resourceStaticRouteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
Delete: &constants.Timeout600s,
|
c := m.(*controller.ControllerCfg)
|
||||||
Default: &constants.Timeout600s,
|
arr := strings.Split(d.Id(), "#")
|
||||||
},
|
if len(arr) != 2 {
|
||||||
|
return diag.FromErr(fmt.Errorf("broken state id"))
|
||||||
Schema: resourceStaticRouteSchemaMake(),
|
}
|
||||||
}
|
|
||||||
}
|
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,
|
||||||
|
Optional: true,
|
||||||
|
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,71 +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>
|
|
||||||
Tim Tkachev, <tvtkachev@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 extnet
|
|
||||||
|
|
||||||
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 dataSourceExtnetReservedIpRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
||||||
reservedList, err := utilityExtnetReservedIpCheckPresence(ctx, d, m)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
id := uuid.New()
|
|
||||||
d.SetId(id.String())
|
|
||||||
d.Set("items", flattenExtnetReservedIp(reservedList))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceExtnetReservedIp() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceExtnetReservedIpRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceExtnetReservedIpSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +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 extnet
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/extnet"
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
|
||||||
)
|
|
||||||
|
|
||||||
func utilityExtnetReservedIpCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) ([]extnet.RecordReservedIP, error) {
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
req := extnet.GetReservedIP{
|
|
||||||
AccountID: uint64(d.Get("account_id").(int)),
|
|
||||||
}
|
|
||||||
|
|
||||||
if extNetID, ok := d.GetOk("extnet_id"); ok {
|
|
||||||
req.ExtNetID = uint64(extNetID.(int))
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("utilityExtnetReservedIpCheckPresence")
|
|
||||||
res, err := c.CloudBroker().ExtNet().GetReservedIP(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return res, nil
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
Данный раздел описывает:
|
|
||||||
- Системные требования
|
|
||||||
- Установку провайдера
|
|
||||||
- Инициализацию провайдера
|
|
||||||
- Переключение режима работы между разными группами API
|
|
||||||
- Получение gid/grid_id площадки
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue