v3.1.0 See merge request rudecs/terraform-provider-decort!45gos_tech_4.4.3 v3.1.0
commit
775a0b5adb
@ -1,10 +1,21 @@
|
||||
### Bug fixes
|
||||
- fatal error when trying to retrieve compute boot disk if former does not have one
|
||||
- ignored timeouts
|
||||
- wrong handling of errors when attaching network interfaces and disks to kvmvm
|
||||
- error when importing kvmvm without image_id
|
||||
- state reading for kvmvm created from virtual image
|
||||
- type field usage in image
|
||||
- wrong API handle for image creation
|
||||
- updating description in kvmvm
|
||||
|
||||
### New features
|
||||
- parameter iotune in disk
|
||||
- migrated to terraform SDKv2
|
||||
- admin mode (activated by environment variable DECORT\_ADMIN\_MODE) for resources: account, k8s, image, disk, resgroup, kvmvm, vins
|
||||
- parameters sep\_id and pool in kvmvm
|
||||
- ipaType and IS parameters in kvmvm
|
||||
|
||||
### New datasources
|
||||
- lb
|
||||
- lb\_list
|
||||
- lb\_list\_deleted
|
||||
|
||||
### New resources
|
||||
- lb
|
||||
- lb\_backend
|
||||
- lb\_backend\_server
|
||||
- lb\_frontend
|
||||
- lb\_frontend\_bind
|
||||
|
@ -0,0 +1,167 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "decort_lb Data Source - decort"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
---
|
||||
|
||||
# decort_lb (Data Source)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `lb_id` (Number)
|
||||
|
||||
### Optional
|
||||
|
||||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `backends` (List of Object) (see [below for nested schema](#nestedatt--backends))
|
||||
- `created_by` (String)
|
||||
- `created_time` (Number)
|
||||
- `deleted_by` (String)
|
||||
- `deleted_time` (Number)
|
||||
- `desc` (String)
|
||||
- `dp_api_user` (String)
|
||||
- `extnet_id` (Number)
|
||||
- `frontends` (List of Object) (see [below for nested schema](#nestedatt--frontends))
|
||||
- `gid` (Number)
|
||||
- `guid` (Number)
|
||||
- `ha_mode` (Boolean)
|
||||
- `id` (String) The ID of this resource.
|
||||
- `image_id` (Number)
|
||||
- `milestones` (Number)
|
||||
- `name` (String)
|
||||
- `primary_node` (List of Object) (see [below for nested schema](#nestedatt--primary_node))
|
||||
- `rg_id` (Number)
|
||||
- `rg_name` (String)
|
||||
- `secondary_node` (List of Object) (see [below for nested schema](#nestedatt--secondary_node))
|
||||
- `status` (String)
|
||||
- `tech_status` (String)
|
||||
- `updated_by` (String)
|
||||
- `updated_time` (Number)
|
||||
- `vins_id` (Number)
|
||||
|
||||
<a id="nestedblock--timeouts"></a>
|
||||
### Nested Schema for `timeouts`
|
||||
|
||||
Optional:
|
||||
|
||||
- `default` (String)
|
||||
- `read` (String)
|
||||
|
||||
|
||||
<a id="nestedatt--backends"></a>
|
||||
### Nested Schema for `backends`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `algorithm` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `server_default_settings` (List of Object) (see [below for nested schema](#nestedobjatt--backends--server_default_settings))
|
||||
- `servers` (List of Object) (see [below for nested schema](#nestedobjatt--backends--servers))
|
||||
|
||||
<a id="nestedobjatt--backends--server_default_settings"></a>
|
||||
### Nested Schema for `backends.server_default_settings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `guid` (String)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `weight` (Number)
|
||||
|
||||
|
||||
<a id="nestedobjatt--backends--servers"></a>
|
||||
### Nested Schema for `backends.servers`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `address` (String)
|
||||
- `check` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
- `server_settings` (List of Object) (see [below for nested schema](#nestedobjatt--backends--servers--server_settings))
|
||||
|
||||
<a id="nestedobjatt--backends--servers--server_settings"></a>
|
||||
### Nested Schema for `backends.servers.server_settings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `guid` (String)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `weight` (Number)
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="nestedatt--frontends"></a>
|
||||
### Nested Schema for `frontends`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend` (String)
|
||||
- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--frontends--bindings))
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
|
||||
<a id="nestedobjatt--frontends--bindings"></a>
|
||||
### Nested Schema for `frontends.bindings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `address` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
|
||||
|
||||
|
||||
<a id="nestedatt--primary_node"></a>
|
||||
### Nested Schema for `primary_node`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend_ip` (String)
|
||||
- `compute_id` (Number)
|
||||
- `frontend_ip` (String)
|
||||
- `guid` (String)
|
||||
- `mgmt_ip` (String)
|
||||
- `network_id` (Number)
|
||||
|
||||
|
||||
<a id="nestedatt--secondary_node"></a>
|
||||
### Nested Schema for `secondary_node`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend_ip` (String)
|
||||
- `compute_id` (Number)
|
||||
- `frontend_ip` (String)
|
||||
- `guid` (String)
|
||||
- `mgmt_ip` (String)
|
||||
- `network_id` (Number)
|
||||
|
||||
|
@ -0,0 +1,175 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "decort_lb_list Data Source - decort"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
---
|
||||
|
||||
# decort_lb_list (Data Source)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Optional
|
||||
|
||||
- `includedeleted` (Boolean)
|
||||
- `page` (Number)
|
||||
- `size` (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:
|
||||
|
||||
- `backends` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends))
|
||||
- `created_by` (String)
|
||||
- `created_time` (Number)
|
||||
- `deleted_by` (String)
|
||||
- `deleted_time` (Number)
|
||||
- `desc` (String)
|
||||
- `dp_api_password` (String)
|
||||
- `dp_api_user` (String)
|
||||
- `extnet_id` (Number)
|
||||
- `frontends` (List of Object) (see [below for nested schema](#nestedobjatt--items--frontends))
|
||||
- `gid` (Number)
|
||||
- `guid` (Number)
|
||||
- `ha_mode` (Boolean)
|
||||
- `image_id` (Number)
|
||||
- `lb_id` (Number)
|
||||
- `milestones` (Number)
|
||||
- `name` (String)
|
||||
- `primary_node` (List of Object) (see [below for nested schema](#nestedobjatt--items--primary_node))
|
||||
- `rg_id` (Number)
|
||||
- `rg_name` (String)
|
||||
- `secondary_node` (List of Object) (see [below for nested schema](#nestedobjatt--items--secondary_node))
|
||||
- `status` (String)
|
||||
- `tech_status` (String)
|
||||
- `updated_by` (String)
|
||||
- `updated_time` (Number)
|
||||
- `vins_id` (Number)
|
||||
|
||||
<a id="nestedobjatt--items--backends"></a>
|
||||
### Nested Schema for `items.backends`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `algorithm` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `server_default_settings` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--server_default_settings))
|
||||
- `servers` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--servers))
|
||||
|
||||
<a id="nestedobjatt--items--backends--server_default_settings"></a>
|
||||
### Nested Schema for `items.backends.server_default_settings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `guid` (String)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `weight` (Number)
|
||||
|
||||
|
||||
<a id="nestedobjatt--items--backends--servers"></a>
|
||||
### Nested Schema for `items.backends.servers`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `address` (String)
|
||||
- `check` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
- `server_settings` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--servers--server_settings))
|
||||
|
||||
<a id="nestedobjatt--items--backends--servers--server_settings"></a>
|
||||
### Nested Schema for `items.backends.servers.server_settings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `guid` (String)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `weight` (Number)
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="nestedobjatt--items--frontends"></a>
|
||||
### Nested Schema for `items.frontends`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend` (String)
|
||||
- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--items--frontends--bindings))
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
|
||||
<a id="nestedobjatt--items--frontends--bindings"></a>
|
||||
### Nested Schema for `items.frontends.bindings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `address` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
|
||||
|
||||
|
||||
<a id="nestedobjatt--items--primary_node"></a>
|
||||
### Nested Schema for `items.primary_node`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend_ip` (String)
|
||||
- `compute_id` (Number)
|
||||
- `frontend_ip` (String)
|
||||
- `guid` (String)
|
||||
- `mgmt_ip` (String)
|
||||
- `network_id` (Number)
|
||||
|
||||
|
||||
<a id="nestedobjatt--items--secondary_node"></a>
|
||||
### Nested Schema for `items.secondary_node`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend_ip` (String)
|
||||
- `compute_id` (Number)
|
||||
- `frontend_ip` (String)
|
||||
- `guid` (String)
|
||||
- `mgmt_ip` (String)
|
||||
- `network_id` (Number)
|
||||
|
||||
|
@ -0,0 +1,174 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "decort_lb_list_deleted Data Source - decort"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
---
|
||||
|
||||
# decort_lb_list_deleted (Data Source)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Optional
|
||||
|
||||
- `page` (Number)
|
||||
- `size` (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:
|
||||
|
||||
- `backends` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends))
|
||||
- `created_by` (String)
|
||||
- `created_time` (Number)
|
||||
- `deleted_by` (String)
|
||||
- `deleted_time` (Number)
|
||||
- `desc` (String)
|
||||
- `dp_api_password` (String)
|
||||
- `dp_api_user` (String)
|
||||
- `extnet_id` (Number)
|
||||
- `frontends` (List of Object) (see [below for nested schema](#nestedobjatt--items--frontends))
|
||||
- `gid` (Number)
|
||||
- `guid` (Number)
|
||||
- `ha_mode` (Boolean)
|
||||
- `image_id` (Number)
|
||||
- `lb_id` (Number)
|
||||
- `milestones` (Number)
|
||||
- `name` (String)
|
||||
- `primary_node` (List of Object) (see [below for nested schema](#nestedobjatt--items--primary_node))
|
||||
- `rg_id` (Number)
|
||||
- `rg_name` (String)
|
||||
- `secondary_node` (List of Object) (see [below for nested schema](#nestedobjatt--items--secondary_node))
|
||||
- `status` (String)
|
||||
- `tech_status` (String)
|
||||
- `updated_by` (String)
|
||||
- `updated_time` (Number)
|
||||
- `vins_id` (Number)
|
||||
|
||||
<a id="nestedobjatt--items--backends"></a>
|
||||
### Nested Schema for `items.backends`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `algorithm` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `server_default_settings` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--server_default_settings))
|
||||
- `servers` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--servers))
|
||||
|
||||
<a id="nestedobjatt--items--backends--server_default_settings"></a>
|
||||
### Nested Schema for `items.backends.server_default_settings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `guid` (String)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `weight` (Number)
|
||||
|
||||
|
||||
<a id="nestedobjatt--items--backends--servers"></a>
|
||||
### Nested Schema for `items.backends.servers`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `address` (String)
|
||||
- `check` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
- `server_settings` (List of Object) (see [below for nested schema](#nestedobjatt--items--backends--servers--server_settings))
|
||||
|
||||
<a id="nestedobjatt--items--backends--servers--server_settings"></a>
|
||||
### Nested Schema for `items.backends.servers.server_settings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `guid` (String)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `weight` (Number)
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="nestedobjatt--items--frontends"></a>
|
||||
### Nested Schema for `items.frontends`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend` (String)
|
||||
- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--items--frontends--bindings))
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
|
||||
<a id="nestedobjatt--items--frontends--bindings"></a>
|
||||
### Nested Schema for `items.frontends.bindings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `address` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
|
||||
|
||||
|
||||
<a id="nestedobjatt--items--primary_node"></a>
|
||||
### Nested Schema for `items.primary_node`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend_ip` (String)
|
||||
- `compute_id` (Number)
|
||||
- `frontend_ip` (String)
|
||||
- `guid` (String)
|
||||
- `mgmt_ip` (String)
|
||||
- `network_id` (Number)
|
||||
|
||||
|
||||
<a id="nestedobjatt--items--secondary_node"></a>
|
||||
### Nested Schema for `items.secondary_node`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend_ip` (String)
|
||||
- `compute_id` (Number)
|
||||
- `frontend_ip` (String)
|
||||
- `guid` (String)
|
||||
- `mgmt_ip` (String)
|
||||
- `network_id` (Number)
|
||||
|
||||
|
@ -0,0 +1,87 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "decort_image_virtual Resource - decort"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
---
|
||||
|
||||
# decort_image_virtual (Resource)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `link_to` (Number) ID of real image to link this virtual image to upon creation
|
||||
- `name` (String) Name of the rescue disk
|
||||
|
||||
### Optional
|
||||
|
||||
- `permanently` (Boolean) whether to completely delete the image
|
||||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `account_id` (Number)
|
||||
- `acl` (String)
|
||||
- `architecture` (String)
|
||||
- `boot_type` (String)
|
||||
- `bootable` (Boolean)
|
||||
- `ckey` (String)
|
||||
- `compute_ci_id` (Number)
|
||||
- `deleted_time` (String)
|
||||
- `desc` (String)
|
||||
- `drivers` (List of String)
|
||||
- `enabled` (Boolean)
|
||||
- `gid` (Number)
|
||||
- `guid` (Number)
|
||||
- `history` (List of Object) (see [below for nested schema](#nestedatt--history))
|
||||
- `hot_resize` (Boolean)
|
||||
- `id` (String) The ID of this resource.
|
||||
- `image_id` (Number) Image id
|
||||
- `image_name` (String)
|
||||
- `last_modified` (Number)
|
||||
- `milestones` (Number)
|
||||
- `password` (String)
|
||||
- `pool_name` (String)
|
||||
- `provider_name` (String)
|
||||
- `purge_attempts` (Number)
|
||||
- `res_id` (String)
|
||||
- `rescuecd` (Boolean)
|
||||
- `sep_id` (Number)
|
||||
- `shared_with` (List of Number)
|
||||
- `size` (Number)
|
||||
- `status` (String)
|
||||
- `tech_status` (String)
|
||||
- `type` (String)
|
||||
- `unc_path` (String)
|
||||
- `username` (String)
|
||||
- `version` (String)
|
||||
|
||||
<a id="nestedblock--timeouts"></a>
|
||||
### Nested Schema for `timeouts`
|
||||
|
||||
Optional:
|
||||
|
||||
- `create` (String)
|
||||
- `default` (String)
|
||||
- `delete` (String)
|
||||
- `read` (String)
|
||||
- `update` (String)
|
||||
|
||||
|
||||
<a id="nestedatt--history"></a>
|
||||
### Nested Schema for `history`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `guid` (String)
|
||||
- `id` (Number)
|
||||
- `timestamp` (Number)
|
||||
|
||||
|
@ -0,0 +1,176 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "decort_lb Resource - decort"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
---
|
||||
|
||||
# decort_lb (Resource)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `extnet_id` (Number)
|
||||
- `name` (String)
|
||||
- `rg_id` (Number)
|
||||
- `start` (Boolean)
|
||||
- `vins_id` (Number)
|
||||
|
||||
### Optional
|
||||
|
||||
- `config_reset` (Boolean)
|
||||
- `desc` (String)
|
||||
- `enable` (Boolean)
|
||||
- `permanently` (Boolean)
|
||||
- `restart` (Boolean)
|
||||
- `restore` (Boolean)
|
||||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `backends` (List of Object) (see [below for nested schema](#nestedatt--backends))
|
||||
- `created_by` (String)
|
||||
- `created_time` (Number)
|
||||
- `deleted_by` (String)
|
||||
- `deleted_time` (Number)
|
||||
- `dp_api_user` (String)
|
||||
- `frontends` (List of Object) (see [below for nested schema](#nestedatt--frontends))
|
||||
- `gid` (Number)
|
||||
- `guid` (Number)
|
||||
- `ha_mode` (Boolean)
|
||||
- `id` (String) The ID of this resource.
|
||||
- `image_id` (Number)
|
||||
- `lb_id` (Number)
|
||||
- `milestones` (Number)
|
||||
- `primary_node` (List of Object) (see [below for nested schema](#nestedatt--primary_node))
|
||||
- `rg_name` (String)
|
||||
- `secondary_node` (List of Object) (see [below for nested schema](#nestedatt--secondary_node))
|
||||
- `status` (String)
|
||||
- `tech_status` (String)
|
||||
- `updated_by` (String)
|
||||
- `updated_time` (Number)
|
||||
|
||||
<a id="nestedblock--timeouts"></a>
|
||||
### Nested Schema for `timeouts`
|
||||
|
||||
Optional:
|
||||
|
||||
- `create` (String)
|
||||
- `default` (String)
|
||||
- `delete` (String)
|
||||
- `read` (String)
|
||||
- `update` (String)
|
||||
|
||||
|
||||
<a id="nestedatt--backends"></a>
|
||||
### Nested Schema for `backends`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `algorithm` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `server_default_settings` (List of Object) (see [below for nested schema](#nestedobjatt--backends--server_default_settings))
|
||||
- `servers` (List of Object) (see [below for nested schema](#nestedobjatt--backends--servers))
|
||||
|
||||
<a id="nestedobjatt--backends--server_default_settings"></a>
|
||||
### Nested Schema for `backends.server_default_settings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `guid` (String)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `weight` (Number)
|
||||
|
||||
|
||||
<a id="nestedobjatt--backends--servers"></a>
|
||||
### Nested Schema for `backends.servers`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `address` (String)
|
||||
- `check` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
- `server_settings` (List of Object) (see [below for nested schema](#nestedobjatt--backends--servers--server_settings))
|
||||
|
||||
<a id="nestedobjatt--backends--servers--server_settings"></a>
|
||||
### Nested Schema for `backends.servers.server_settings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `guid` (String)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `weight` (Number)
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="nestedatt--frontends"></a>
|
||||
### Nested Schema for `frontends`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend` (String)
|
||||
- `bindings` (List of Object) (see [below for nested schema](#nestedobjatt--frontends--bindings))
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
|
||||
<a id="nestedobjatt--frontends--bindings"></a>
|
||||
### Nested Schema for `frontends.bindings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `address` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
|
||||
|
||||
|
||||
<a id="nestedatt--primary_node"></a>
|
||||
### Nested Schema for `primary_node`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend_ip` (String)
|
||||
- `compute_id` (Number)
|
||||
- `frontend_ip` (String)
|
||||
- `guid` (String)
|
||||
- `mgmt_ip` (String)
|
||||
- `network_id` (Number)
|
||||
|
||||
|
||||
<a id="nestedatt--secondary_node"></a>
|
||||
### Nested Schema for `secondary_node`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `backend_ip` (String)
|
||||
- `compute_id` (Number)
|
||||
- `frontend_ip` (String)
|
||||
- `guid` (String)
|
||||
- `mgmt_ip` (String)
|
||||
- `network_id` (Number)
|
||||
|
||||
|
@ -0,0 +1,88 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "decort_lb_backend Resource - decort"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
---
|
||||
|
||||
# decort_lb_backend (Resource)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `lb_id` (Number) ID of the LB instance to backendCreate
|
||||
- `name` (String) Must be unique among all backends of this LB - name of the new backend to create
|
||||
|
||||
### Optional
|
||||
|
||||
- `algorithm` (String)
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `servers` (Block List) (see [below for nested schema](#nestedblock--servers))
|
||||
- `slowstart` (Number)
|
||||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||
- `weight` (Number)
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `guid` (String)
|
||||
- `id` (String) The ID of this resource.
|
||||
|
||||
<a id="nestedblock--servers"></a>
|
||||
### Nested Schema for `servers`
|
||||
|
||||
Optional:
|
||||
|
||||
- `address` (String)
|
||||
- `check` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
- `server_settings` (Block List) (see [below for nested schema](#nestedblock--servers--server_settings))
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `guid` (String)
|
||||
|
||||
<a id="nestedblock--servers--server_settings"></a>
|
||||
### Nested Schema for `servers.server_settings`
|
||||
|
||||
Optional:
|
||||
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `weight` (Number)
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `guid` (String)
|
||||
|
||||
|
||||
|
||||
<a id="nestedblock--timeouts"></a>
|
||||
### Nested Schema for `timeouts`
|
||||
|
||||
Optional:
|
||||
|
||||
- `create` (String)
|
||||
- `default` (String)
|
||||
- `delete` (String)
|
||||
- `read` (String)
|
||||
- `update` (String)
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "decort_lb_backend_server Resource - decort"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
---
|
||||
|
||||
# decort_lb_backend_server (Resource)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `address` (String) IP address of the server.
|
||||
- `backend_name` (String) Must be unique among all backends of this LB - name of the new backend to create
|
||||
- `lb_id` (Number) ID of the LB instance to backendCreate
|
||||
- `name` (String) Must be unique among all servers defined for this backend - name of the server definition to add.
|
||||
- `port` (Number) Port number on the server
|
||||
|
||||
### Optional
|
||||
|
||||
- `check` (String) set to disabled if this server should be used regardless of its state.
|
||||
- `downinter` (Number)
|
||||
- `fall` (Number)
|
||||
- `inter` (Number)
|
||||
- `maxconn` (Number)
|
||||
- `maxqueue` (Number)
|
||||
- `rise` (Number)
|
||||
- `slowstart` (Number)
|
||||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||
- `weight` (Number)
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `guid` (String)
|
||||
- `id` (String) The ID of this resource.
|
||||
|
||||
<a id="nestedblock--timeouts"></a>
|
||||
### Nested Schema for `timeouts`
|
||||
|
||||
Optional:
|
||||
|
||||
- `create` (String)
|
||||
- `default` (String)
|
||||
- `delete` (String)
|
||||
- `read` (String)
|
||||
- `update` (String)
|
||||
|
||||
|
@ -0,0 +1,56 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "decort_lb_frontend Resource - decort"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
---
|
||||
|
||||
# decort_lb_frontend (Resource)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `backend_name` (String)
|
||||
- `lb_id` (Number) ID of the LB instance to backendCreate
|
||||
- `name` (String)
|
||||
|
||||
### Optional
|
||||
|
||||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `bindings` (List of Object) (see [below for nested schema](#nestedatt--bindings))
|
||||
- `guid` (String)
|
||||
- `id` (String) The ID of this resource.
|
||||
|
||||
<a id="nestedblock--timeouts"></a>
|
||||
### Nested Schema for `timeouts`
|
||||
|
||||
Optional:
|
||||
|
||||
- `create` (String)
|
||||
- `default` (String)
|
||||
- `delete` (String)
|
||||
- `read` (String)
|
||||
- `update` (String)
|
||||
|
||||
|
||||
<a id="nestedatt--bindings"></a>
|
||||
### Nested Schema for `bindings`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `address` (String)
|
||||
- `guid` (String)
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
|
||||
|
@ -0,0 +1,46 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "decort_lb_frontend_bind Resource - decort"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
---
|
||||
|
||||
# decort_lb_frontend_bind (Resource)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `address` (String)
|
||||
- `frontend_name` (String) Must be unique among all backends of this LB - name of the new backend to create
|
||||
- `lb_id` (Number) ID of the LB instance to backendCreate
|
||||
- `name` (String)
|
||||
- `port` (Number)
|
||||
|
||||
### Optional
|
||||
|
||||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `guid` (String)
|
||||
- `id` (String) The ID of this resource.
|
||||
|
||||
<a id="nestedblock--timeouts"></a>
|
||||
### Nested Schema for `timeouts`
|
||||
|
||||
Optional:
|
||||
|
||||
- `create` (String)
|
||||
- `default` (String)
|
||||
- `delete` (String)
|
||||
- `read` (String)
|
||||
- `update` (String)
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
const lbListAPI = "/restmachine/cloudapi/lb/list"
|
||||
const lbListDeletedAPI = "/restmachine/cloudapi/lb/listDeleted"
|
||||
const lbGetAPI = "/restmachine/cloudapi/lb/get"
|
||||
const lbCreateAPI = "/restmachine/cloudapi/lb/create"
|
||||
const lbDeleteAPI = "/restmachine/cloudapi/lb/delete"
|
||||
const lbDisableAPI = "/restmachine/cloudapi/lb/disable"
|
||||
const lbEnableAPI = "/restmachine/cloudapi/lb/enable"
|
||||
const lbUpdateAPI = "/restmachine/cloudapi/lb/update"
|
||||
const lbStartAPI = "/restmachine/cloudapi/lb/start"
|
||||
const lbStopAPI = "/restmachine/cloudapi/lb/stop"
|
||||
const lbRestartAPI = "/restmachine/cloudapi/lb/restart"
|
||||
const lbRestoreAPI = "/restmachine/cloudapi/lb/restore"
|
||||
const lbConfigResetAPI = "/restmachine/cloudapi/lb/configReset"
|
||||
const lbBackendCreateAPI = "/restmachine/cloudapi/lb/backendCreate"
|
||||
const lbBackendDeleteAPI = "/restmachine/cloudapi/lb/backendDelete"
|
||||
const lbBackendUpdateAPI = "/restmachine/cloudapi/lb/backendUpdate"
|
||||
const lbBackendServerAddAPI = "/restmachine/cloudapi/lb/backendServerAdd"
|
||||
const lbBackendServerDeleteAPI = "/restmachine/cloudapi/lb/backendServerDelete"
|
||||
const lbBackendServerUpdateAPI = "/restmachine/cloudapi/lb/backendServerUpdate"
|
||||
const lbFrontendCreateAPI = "/restmachine/cloudapi/lb/frontendCreate"
|
||||
const lbFrontendDeleteAPI = "/restmachine/cloudapi/lb/frontendDelete"
|
||||
const lbFrontendBindAPI = "/restmachine/cloudapi/lb/frontendBind"
|
||||
const lbFrontendBindDeleteAPI = "/restmachine/cloudapi/lb/frontendBindDelete"
|
||||
const lbFrontendBindUpdateAPI = "/restmachine/cloudapi/lb/frontendBindingUpdate"
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"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 flattenLB(d *schema.ResourceData, lb *LoadBalancer) {
|
||||
d.Set("ha_mode", lb.HAMode)
|
||||
d.Set("backends", flattenLBBackends(lb.Backends))
|
||||
d.Set("created_by", lb.CreatedBy)
|
||||
d.Set("created_time", lb.CreatedTime)
|
||||
d.Set("deleted_by", lb.DeletedBy)
|
||||
d.Set("deleted_time", lb.DeletedTime)
|
||||
d.Set("desc", lb.Description)
|
||||
d.Set("dp_api_user", lb.DPAPIUser)
|
||||
d.Set("extnet_id", lb.ExtnetId)
|
||||
d.Set("frontends", flattenFrontends(lb.Frontends))
|
||||
d.Set("gid", lb.GID)
|
||||
d.Set("guid", lb.GUID)
|
||||
d.Set("image_id", lb.ImageId)
|
||||
d.Set("milestones", lb.Milestones)
|
||||
d.Set("name", lb.Name)
|
||||
d.Set("primary_node", flattenNode(lb.PrimaryNode))
|
||||
d.Set("rg_id", lb.RGID)
|
||||
d.Set("rg_name", lb.RGName)
|
||||
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
|
||||
d.Set("status", lb.Status)
|
||||
d.Set("tech_status", lb.TechStatus)
|
||||
d.Set("updated_by", lb.UpdatedBy)
|
||||
d.Set("updated_time", lb.UpdatedTime)
|
||||
d.Set("vins_id", lb.VinsId)
|
||||
}
|
||||
|
||||
func dataSourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
lb, err := utilityLBCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(lb.ID, 10))
|
||||
|
||||
flattenLB(d, lb)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceLB() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceLBRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dsLBSchemaMake(),
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
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 flattenLBList(lbl LBList) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(lbl))
|
||||
for _, lb := range lbl {
|
||||
temp := map[string]interface{}{
|
||||
"ha_mode": lb.HAMode,
|
||||
"backends": flattenLBBackends(lb.Backends),
|
||||
"created_by": lb.CreatedBy,
|
||||
"created_time": lb.CreatedTime,
|
||||
"deleted_by": lb.DeletedBy,
|
||||
"deleted_time": lb.DeletedTime,
|
||||
"desc": lb.Description,
|
||||
"dp_api_user": lb.DPAPIUser,
|
||||
"dp_api_password": lb.DPAPIPassword,
|
||||
"extnet_id": lb.ExtnetId,
|
||||
"frontends": flattenFrontends(lb.Frontends),
|
||||
"gid": lb.GID,
|
||||
"guid": lb.GUID,
|
||||
"image_id": lb.ImageId,
|
||||
"milestones": lb.Milestones,
|
||||
"name": lb.Name,
|
||||
"primary_node": flattenNode(lb.PrimaryNode),
|
||||
"rg_id": lb.RGID,
|
||||
"rg_name": lb.RGName,
|
||||
"secondary_node": flattenNode(lb.SecondaryNode),
|
||||
"status": lb.Status,
|
||||
"tech_status": lb.TechStatus,
|
||||
"updated_by": lb.UpdatedBy,
|
||||
"updated_time": lb.UpdatedTime,
|
||||
"vins_id": lb.VinsId,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceLBListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
lbList, err := utilityLBListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenLBList(lbList))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceLBList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceLBListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dsLBListSchemaMake(),
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
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 dataSourceLBListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
lbList, err := utilityLBListDeletedCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenLBList(lbList))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DataSourceLBListDeleted() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceLBListDeletedRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dsLBListDeletedSchemaMake(),
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
func flattenNode(node Node) []map[string]interface{} {
|
||||
temp := make([]map[string]interface{}, 0)
|
||||
n := map[string]interface{}{
|
||||
"backend_ip": node.BackendIp,
|
||||
"compute_id": node.ComputeId,
|
||||
"frontend_ip": node.FrontendIp,
|
||||
"guid": node.GUID,
|
||||
"mgmt_ip": node.MGMTIp,
|
||||
"network_id": node.NetworkId,
|
||||
}
|
||||
|
||||
temp = append(temp, n)
|
||||
|
||||
return temp
|
||||
}
|
||||
|
||||
func flattendBindings(bs []Binding) []map[string]interface{} {
|
||||
temp := make([]map[string]interface{}, 0, len(bs))
|
||||
for _, b := range bs {
|
||||
t := map[string]interface{}{
|
||||
"address": b.Address,
|
||||
"guid": b.GUID,
|
||||
"name": b.Name,
|
||||
"port": b.Port,
|
||||
}
|
||||
temp = append(temp, t)
|
||||
}
|
||||
return temp
|
||||
}
|
||||
|
||||
func flattenFrontends(fs []Frontend) []map[string]interface{} {
|
||||
temp := make([]map[string]interface{}, 0, len(fs))
|
||||
for _, f := range fs {
|
||||
t := map[string]interface{}{
|
||||
"backend": f.Backend,
|
||||
"bindings": flattendBindings(f.Bindings),
|
||||
"guid": f.GUID,
|
||||
"name": f.Name,
|
||||
}
|
||||
temp = append(temp, t)
|
||||
}
|
||||
|
||||
return temp
|
||||
}
|
||||
|
||||
func flattenServers(servers []Server) []map[string]interface{} {
|
||||
temp := make([]map[string]interface{}, 0, len(servers))
|
||||
for _, server := range servers {
|
||||
t := map[string]interface{}{
|
||||
"address": server.Address,
|
||||
"check": server.Check,
|
||||
"guid": server.GUID,
|
||||
"name": server.Name,
|
||||
"port": server.Port,
|
||||
"server_settings": flattenServerSettings(server.ServerSettings),
|
||||
}
|
||||
|
||||
temp = append(temp, t)
|
||||
}
|
||||
return temp
|
||||
}
|
||||
|
||||
func flattenServerSettings(defSet ServerSettings) []map[string]interface{} {
|
||||
temp := map[string]interface{}{
|
||||
"downinter": defSet.DownInter,
|
||||
"fall": defSet.Fall,
|
||||
"guid": defSet.GUID,
|
||||
"inter": defSet.Inter,
|
||||
"maxconn": defSet.MaxConn,
|
||||
"maxqueue": defSet.MaxQueue,
|
||||
"rise": defSet.Rise,
|
||||
"slowstart": defSet.SlowStart,
|
||||
"weight": defSet.Weight,
|
||||
}
|
||||
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenLBBackends(backends []Backend) []map[string]interface{} {
|
||||
temp := make([]map[string]interface{}, 0, len(backends))
|
||||
for _, item := range backends {
|
||||
t := map[string]interface{}{
|
||||
"algorithm": item.Algorithm,
|
||||
"guid": item.GUID,
|
||||
"name": item.Name,
|
||||
"server_default_settings": flattenServerSettings(item.ServerDefaultSettings),
|
||||
"servers": flattenServers(item.Servers),
|
||||
}
|
||||
|
||||
temp = append(temp, t)
|
||||
}
|
||||
return temp
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
func dsLBSchemaMake() map[string]*schema.Schema {
|
||||
sch := createLBSchema()
|
||||
sch["lb_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
}
|
||||
return sch
|
||||
}
|
||||
|
||||
func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: 0,
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: 0,
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dsLBItemSchemaMake(),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"includedeleted": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: 0,
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: 0,
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dsLBItemSchemaMake(),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dsLBItemSchemaMake() map[string]*schema.Schema {
|
||||
sch := createLBSchema()
|
||||
sch["dp_api_password"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
}
|
||||
return sch
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
func lbResourceSchemaMake() map[string]*schema.Schema {
|
||||
sch := createLBSchema()
|
||||
sch["rg_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
}
|
||||
sch["name"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
}
|
||||
|
||||
sch["extnet_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
}
|
||||
|
||||
sch["vins_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
}
|
||||
sch["start"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Required: true,
|
||||
}
|
||||
sch["desc"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
}
|
||||
|
||||
sch["enable"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
}
|
||||
|
||||
sch["restart"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
}
|
||||
|
||||
sch["restore"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
}
|
||||
|
||||
sch["config_reset"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
}
|
||||
|
||||
sch["permanently"] = &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
}
|
||||
return sch
|
||||
}
|
@ -0,0 +1,367 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
func createLBSchema() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"ha_mode": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"backends": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"algorithm": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"server_default_settings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"downinter": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"fall": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"inter": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"maxconn": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"maxqueue": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rise": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"slowstart": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"weight": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"servers": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"address": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"check": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"port": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"server_settings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"downinter": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"fall": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"inter": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"maxconn": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"maxqueue": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rise": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"slowstart": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"weight": {
|
||||
Type: schema.TypeInt,
|
||||
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,
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"dp_api_user": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"frontends": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"backend": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"bindings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"address": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"port": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"lb_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"primary_node": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"backend_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"frontend_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"mgmt_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"network_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"secondary_node": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"backend_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"frontend_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"mgmt_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"network_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
type LoadBalancer struct {
|
||||
HAMode bool `json:"HAmode"`
|
||||
ACL interface{} `json:"acl"`
|
||||
Backends []Backend `json:"backends"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
Description string `json:"desc"`
|
||||
DPAPIUser string `json:"dpApiUser"`
|
||||
ExtnetId uint64 `json:"extnetId"`
|
||||
Frontends []Frontend `json:"frontends"`
|
||||
GID uint64 `json:"gid"`
|
||||
GUID uint64 `json:"guid"`
|
||||
ID uint64 `json:"id"`
|
||||
ImageId uint64 `json:"imageId"`
|
||||
Milestones uint64 `json:"milestones"`
|
||||
Name string `json:"name"`
|
||||
PrimaryNode Node `json:"primaryNode"`
|
||||
RGID uint64 `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
SecondaryNode Node `json:"secondaryNode"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
VinsId uint64 `json:"vinsId"`
|
||||
}
|
||||
|
||||
type LoadBalancerDetailed struct {
|
||||
DPAPIPassword string `json:"dpApiPassword"`
|
||||
LoadBalancer
|
||||
}
|
||||
|
||||
type Backend struct {
|
||||
Algorithm string `json:"algorithm"`
|
||||
GUID string `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
ServerDefaultSettings ServerSettings `json:"serverDefaultSettings"`
|
||||
Servers []Server `json:"servers"`
|
||||
}
|
||||
|
||||
type LBList []LoadBalancerDetailed
|
||||
|
||||
type ServerSettings struct {
|
||||
Inter uint64 `json:"inter"`
|
||||
GUID string `json:"guid"`
|
||||
DownInter uint64 `json:"downinter"`
|
||||
Rise uint `json:"rise"`
|
||||
Fall uint `json:"fall"`
|
||||
SlowStart uint64 `json:"slowstart"`
|
||||
MaxConn uint `json:"maxconn"`
|
||||
MaxQueue uint `json:"maxqueue"`
|
||||
Weight uint `json:"weight"`
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
Address string `json:"address"`
|
||||
Check string `json:"check"`
|
||||
GUID string `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
Port uint `json:"port"`
|
||||
ServerSettings ServerSettings `json:"serverSettings"`
|
||||
}
|
||||
|
||||
type Node struct {
|
||||
BackendIp string `json:"backendIp"`
|
||||
ComputeId uint64 `json:"computeId"`
|
||||
FrontendIp string `json:"frontendIp"`
|
||||
GUID string `json:"guid"`
|
||||
MGMTIp string `json:"mgmtIp"`
|
||||
NetworkId uint64 `json:"networkId"`
|
||||
}
|
||||
|
||||
type Frontend struct {
|
||||
Backend string `json:"backend"`
|
||||
Bindings []Binding `json:"bindings"`
|
||||
GUID string `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Binding struct {
|
||||
Address string `json:"address"`
|
||||
GUID string `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
Port uint `json:"port"`
|
||||
}
|
@ -0,0 +1,281 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"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"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBCreate")
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("name", d.Get("name").(string))
|
||||
urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int)))
|
||||
urlValues.Add("extnetId", strconv.Itoa(d.Get("extnet_id").(int)))
|
||||
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||
urlValues.Add("start", strconv.FormatBool((d.Get("start").(bool))))
|
||||
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
urlValues.Add("desc", desc.(string))
|
||||
}
|
||||
|
||||
lbId, err := c.DecortAPICall(ctx, "POST", lbCreateAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(lbId)
|
||||
d.Set("lb_id", lbId)
|
||||
|
||||
_, err = utilityLBCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
diagnostics := resourceLBRead(ctx, d, m)
|
||||
if diagnostics != nil {
|
||||
return diagnostics
|
||||
}
|
||||
|
||||
urlValues = &url.Values{}
|
||||
|
||||
if enable, ok := d.GetOk("enable"); ok {
|
||||
api := lbDisableAPI
|
||||
if enable.(bool) {
|
||||
api = lbEnableAPI
|
||||
}
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", api, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
urlValues = &url.Values{}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBRead")
|
||||
|
||||
lb, err := utilityLBCheckPresence(ctx, d, m)
|
||||
if lb == nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.Set("ha_mode", lb.HAMode)
|
||||
d.Set("backends", flattenLBBackends(lb.Backends))
|
||||
d.Set("created_by", lb.CreatedBy)
|
||||
d.Set("created_time", lb.CreatedTime)
|
||||
d.Set("deleted_by", lb.DeletedBy)
|
||||
d.Set("deleted_time", lb.DeletedTime)
|
||||
d.Set("desc", lb.Description)
|
||||
d.Set("dp_api_user", lb.DPAPIUser)
|
||||
d.Set("extnet_id", lb.ExtnetId)
|
||||
d.Set("frontends", flattenFrontends(lb.Frontends))
|
||||
d.Set("gid", lb.GID)
|
||||
d.Set("guid", lb.GUID)
|
||||
d.Set("lb_id", lb.ID)
|
||||
d.Set("image_id", lb.ImageId)
|
||||
d.Set("milestones", lb.Milestones)
|
||||
d.Set("name", lb.Name)
|
||||
d.Set("primary_node", flattenNode(lb.PrimaryNode))
|
||||
d.Set("rg_id", lb.RGID)
|
||||
d.Set("rg_name", lb.RGName)
|
||||
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
|
||||
d.Set("status", lb.Status)
|
||||
d.Set("tech_status", lb.TechStatus)
|
||||
d.Set("updated_by", lb.UpdatedBy)
|
||||
d.Set("updated_time", lb.UpdatedTime)
|
||||
d.Set("vins_id", lb.VinsId)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBDelete")
|
||||
|
||||
lb, err := utilityLBCheckPresence(ctx, d, m)
|
||||
if lb == nil {
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
|
||||
if permanently, ok := d.GetOk("permanently"); ok {
|
||||
urlValues.Add("permanently", strconv.FormatBool(permanently.(bool)))
|
||||
}
|
||||
|
||||
_, err = c.DecortAPICall(ctx, "POST", lbDeleteAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBEdit")
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
if d.HasChange("enable") {
|
||||
api := lbDisableAPI
|
||||
enable := d.Get("enable").(bool)
|
||||
if enable {
|
||||
api = lbEnableAPI
|
||||
}
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", api, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
urlValues = &url.Values{}
|
||||
}
|
||||
|
||||
if d.HasChange("start") {
|
||||
api := lbStopAPI
|
||||
start := d.Get("start").(bool)
|
||||
if start {
|
||||
api = lbStartAPI
|
||||
}
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", api, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
urlValues = &url.Values{}
|
||||
}
|
||||
|
||||
if d.HasChange("desc") {
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
urlValues.Add("desc", d.Get("desc").(string))
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbUpdateAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
urlValues = &url.Values{}
|
||||
}
|
||||
|
||||
if d.HasChange("restart") {
|
||||
restart := d.Get("restart").(bool)
|
||||
if restart {
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbRestartAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
urlValues = &url.Values{}
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("restore") {
|
||||
restore := d.Get("restore").(bool)
|
||||
if restore {
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbRestoreAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
urlValues = &url.Values{}
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("config_reset") {
|
||||
cfgReset := d.Get("config_reset").(bool)
|
||||
if cfgReset {
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbConfigResetAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
urlValues = &url.Values{}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: перенести backend и frontend из ресурсов сюда
|
||||
|
||||
return resourceLBRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func ResourceLB() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceLBCreate,
|
||||
ReadContext: resourceLBRead,
|
||||
UpdateContext: resourceLBEdit,
|
||||
DeleteContext: resourceLBDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout60s,
|
||||
Read: &constants.Timeout30s,
|
||||
Update: &constants.Timeout60s,
|
||||
Delete: &constants.Timeout60s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: lbResourceSchemaMake(),
|
||||
}
|
||||
}
|
@ -0,0 +1,373 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceLBBackendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBBackendCreate")
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("backendName", d.Get("name").(string))
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
|
||||
if algorithm, ok := d.GetOk("algorithm"); ok {
|
||||
urlValues.Add("algorithm", algorithm.(string))
|
||||
}
|
||||
if inter, ok := d.GetOk("inter"); ok {
|
||||
urlValues.Add("inter", strconv.Itoa(inter.(int)))
|
||||
}
|
||||
if downinter, ok := d.GetOk("downinter"); ok {
|
||||
urlValues.Add("downinter", strconv.Itoa(downinter.(int)))
|
||||
}
|
||||
if rise, ok := d.GetOk("rise"); ok {
|
||||
urlValues.Add("rise", strconv.Itoa(rise.(int)))
|
||||
}
|
||||
if fall, ok := d.GetOk("fall"); ok {
|
||||
urlValues.Add("fall", strconv.Itoa(fall.(int)))
|
||||
}
|
||||
if slowstart, ok := d.GetOk("slowstart"); ok {
|
||||
urlValues.Add("slowstart", strconv.Itoa(slowstart.(int)))
|
||||
}
|
||||
if maxconn, ok := d.GetOk("maxconn"); ok {
|
||||
urlValues.Add("maxconn", strconv.Itoa(maxconn.(int)))
|
||||
}
|
||||
if maxqueue, ok := d.GetOk("maxqueue"); ok {
|
||||
urlValues.Add("maxqueue", strconv.Itoa(maxqueue.(int)))
|
||||
}
|
||||
if weight, ok := d.GetOk("weight"); ok {
|
||||
urlValues.Add("weight", strconv.Itoa(weight.(int)))
|
||||
}
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbBackendCreateAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("name").(string))
|
||||
|
||||
_, err = utilityLBBackendCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
diagnostics := resourceLBBackendRead(ctx, d, m)
|
||||
if diagnostics != nil {
|
||||
return diagnostics
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBBackendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBBackendRead")
|
||||
|
||||
b, err := utilityLBBackendCheckPresence(ctx, d, m)
|
||||
if b == nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
|
||||
|
||||
d.Set("lb_id", lbId)
|
||||
d.Set("name", b.Name)
|
||||
d.Set("algorithm", b.Algorithm)
|
||||
d.Set("guid", b.GUID)
|
||||
d.Set("downinter", b.ServerDefaultSettings.DownInter)
|
||||
d.Set("fall", b.ServerDefaultSettings.Fall)
|
||||
d.Set("inter", b.ServerDefaultSettings.Inter)
|
||||
d.Set("maxconn", b.ServerDefaultSettings.MaxConn)
|
||||
d.Set("maxqueue", b.ServerDefaultSettings.MaxQueue)
|
||||
d.Set("rise", b.ServerDefaultSettings.Rise)
|
||||
d.Set("slowstart", b.ServerDefaultSettings.SlowStart)
|
||||
d.Set("weight", b.ServerDefaultSettings.Weight)
|
||||
d.Set("servers", flattenServers(b.Servers))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBBackendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBBackendDelete")
|
||||
|
||||
lb, err := utilityLBBackendCheckPresence(ctx, d, m)
|
||||
if lb == nil {
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
urlValues.Add("backendName", d.Get("name").(string))
|
||||
|
||||
_, err = c.DecortAPICall(ctx, "POST", lbBackendDeleteAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBBackendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBBackendEdit")
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
urlValues.Add("backendName", d.Get("name").(string))
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
|
||||
if d.HasChange("algorithm") {
|
||||
urlValues.Add("algorithm", d.Get("algorithm").(string))
|
||||
}
|
||||
if d.HasChange("inter") {
|
||||
urlValues.Add("inter", strconv.Itoa(d.Get("inter").(int)))
|
||||
}
|
||||
if d.HasChange("downinter") {
|
||||
urlValues.Add("downinter", strconv.Itoa(d.Get("downinter").(int)))
|
||||
}
|
||||
if d.HasChange("rise") {
|
||||
urlValues.Add("rise", strconv.Itoa(d.Get("rise").(int)))
|
||||
}
|
||||
if d.HasChange("fall") {
|
||||
urlValues.Add("fall", strconv.Itoa(d.Get("fall").(int)))
|
||||
}
|
||||
if d.HasChange("slowstart") {
|
||||
urlValues.Add("slowstart", strconv.Itoa(d.Get("slowstart").(int)))
|
||||
}
|
||||
if d.HasChange("maxconn") {
|
||||
urlValues.Add("maxconn", strconv.Itoa(d.Get("maxconn").(int)))
|
||||
}
|
||||
if d.HasChange("maxqueue") {
|
||||
urlValues.Add("maxqueue", strconv.Itoa(d.Get("maxqueue").(int)))
|
||||
}
|
||||
if d.HasChange("weight") {
|
||||
urlValues.Add("weight", strconv.Itoa(d.Get("weight").(int)))
|
||||
}
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbBackendUpdateAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
//TODO: перенести servers сюда
|
||||
|
||||
return resourceLBBackendRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func ResourceLBBackend() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceLBBackendCreate,
|
||||
ReadContext: resourceLBBackendRead,
|
||||
UpdateContext: resourceLBBackendEdit,
|
||||
DeleteContext: resourceLBBackendDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout60s,
|
||||
Read: &constants.Timeout30s,
|
||||
Update: &constants.Timeout60s,
|
||||
Delete: &constants.Timeout60s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"lb_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the LB instance to backendCreate",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
||||
},
|
||||
"algorithm": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"roundrobin", "static-rr", "leastconn"}, false),
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"downinter": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"fall": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"inter": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"maxconn": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"maxqueue": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"rise": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"slowstart": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"weight": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"servers": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"address": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"check": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"port": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"server_settings": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"downinter": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"fall": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"inter": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"maxconn": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"maxqueue": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"rise": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"slowstart": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"weight": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
@ -0,0 +1,314 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceLBBackendServerCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBBackendServerCreate")
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("backendName", d.Get("backend_name").(string))
|
||||
urlValues.Add("serverName", d.Get("name").(string))
|
||||
urlValues.Add("address", d.Get("address").(string))
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
urlValues.Add("port", strconv.Itoa(d.Get("port").(int)))
|
||||
|
||||
if check, ok := d.GetOk("check"); ok {
|
||||
urlValues.Add("check", check.(string))
|
||||
}
|
||||
|
||||
if inter, ok := d.GetOk("inter"); ok {
|
||||
urlValues.Add("inter", strconv.Itoa(inter.(int)))
|
||||
}
|
||||
if downinter, ok := d.GetOk("downinter"); ok {
|
||||
urlValues.Add("downinter", strconv.Itoa(downinter.(int)))
|
||||
}
|
||||
if rise, ok := d.GetOk("rise"); ok {
|
||||
urlValues.Add("rise", strconv.Itoa(rise.(int)))
|
||||
}
|
||||
if fall, ok := d.GetOk("fall"); ok {
|
||||
urlValues.Add("fall", strconv.Itoa(fall.(int)))
|
||||
}
|
||||
if slowstart, ok := d.GetOk("slowstart"); ok {
|
||||
urlValues.Add("slowstart", strconv.Itoa(slowstart.(int)))
|
||||
}
|
||||
if maxconn, ok := d.GetOk("maxconn"); ok {
|
||||
urlValues.Add("maxconn", strconv.Itoa(maxconn.(int)))
|
||||
}
|
||||
if maxqueue, ok := d.GetOk("maxqueue"); ok {
|
||||
urlValues.Add("maxqueue", strconv.Itoa(maxqueue.(int)))
|
||||
}
|
||||
if weight, ok := d.GetOk("weight"); ok {
|
||||
urlValues.Add("weight", strconv.Itoa(weight.(int)))
|
||||
}
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbBackendServerAddAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("backend_name").(string) + "-" + d.Get("name").(string))
|
||||
|
||||
_, err = utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
diagnostics := resourceLBBackendServerRead(ctx, d, m)
|
||||
if diagnostics != nil {
|
||||
return diagnostics
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBBackendServerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBBackendServerRead")
|
||||
|
||||
s, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||
if s == nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
|
||||
backendName := strings.Split(d.Id(), "-")[1]
|
||||
|
||||
d.Set("lb_id", lbId)
|
||||
d.Set("backend_name", backendName)
|
||||
d.Set("name", s.Name)
|
||||
d.Set("port", s.Port)
|
||||
d.Set("address", s.Address)
|
||||
d.Set("check", s.Check)
|
||||
d.Set("guid", s.GUID)
|
||||
d.Set("downinter", s.ServerSettings.DownInter)
|
||||
d.Set("fall", s.ServerSettings.Fall)
|
||||
d.Set("inter", s.ServerSettings.Inter)
|
||||
d.Set("maxconn", s.ServerSettings.MaxConn)
|
||||
d.Set("maxqueue", s.ServerSettings.MaxQueue)
|
||||
d.Set("rise", s.ServerSettings.Rise)
|
||||
d.Set("slowstart", s.ServerSettings.SlowStart)
|
||||
d.Set("weight", s.ServerSettings.Weight)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBBackendServerDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBBackendServerDelete")
|
||||
|
||||
lb, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||
if lb == nil {
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
urlValues.Add("serverName", d.Get("name").(string))
|
||||
urlValues.Add("backendName", d.Get("backend_name").(string))
|
||||
|
||||
_, err = c.DecortAPICall(ctx, "POST", lbBackendServerDeleteAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBBackendServerEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBBackendServerEdit")
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
urlValues.Add("backendName", d.Get("backend_name").(string))
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
urlValues.Add("serverName", d.Get("name").(string))
|
||||
urlValues.Add("address", d.Get("address").(string))
|
||||
urlValues.Add("port", strconv.Itoa(d.Get("port").(int)))
|
||||
|
||||
if d.HasChange("check") {
|
||||
urlValues.Add("check", d.Get("check").(string))
|
||||
}
|
||||
if d.HasChange("inter") {
|
||||
urlValues.Add("inter", strconv.Itoa(d.Get("inter").(int)))
|
||||
}
|
||||
if d.HasChange("downinter") {
|
||||
urlValues.Add("downinter", strconv.Itoa(d.Get("downinter").(int)))
|
||||
}
|
||||
if d.HasChange("rise") {
|
||||
urlValues.Add("rise", strconv.Itoa(d.Get("rise").(int)))
|
||||
}
|
||||
if d.HasChange("fall") {
|
||||
urlValues.Add("fall", strconv.Itoa(d.Get("fall").(int)))
|
||||
}
|
||||
if d.HasChange("slowstart") {
|
||||
urlValues.Add("slowstart", strconv.Itoa(d.Get("slowstart").(int)))
|
||||
}
|
||||
if d.HasChange("maxconn") {
|
||||
urlValues.Add("maxconn", strconv.Itoa(d.Get("maxconn").(int)))
|
||||
}
|
||||
if d.HasChange("maxqueue") {
|
||||
urlValues.Add("maxqueue", strconv.Itoa(d.Get("maxqueue").(int)))
|
||||
}
|
||||
if d.HasChange("weight") {
|
||||
urlValues.Add("weight", strconv.Itoa(d.Get("weight").(int)))
|
||||
}
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbBackendServerUpdateAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
//TODO: перенести servers сюда
|
||||
|
||||
return resourceLBBackendServerRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func ResourceLBBackendServer() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceLBBackendServerCreate,
|
||||
ReadContext: resourceLBBackendServerRead,
|
||||
UpdateContext: resourceLBBackendServerEdit,
|
||||
DeleteContext: resourceLBBackendServerDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout60s,
|
||||
Read: &constants.Timeout30s,
|
||||
Update: &constants.Timeout60s,
|
||||
Delete: &constants.Timeout60s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"lb_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the LB instance to backendCreate",
|
||||
},
|
||||
"backend_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Must be unique among all servers defined for this backend - name of the server definition to add.",
|
||||
},
|
||||
"address": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "IP address of the server.",
|
||||
},
|
||||
"port": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Port number on the server",
|
||||
},
|
||||
"check": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"disabled", "enabled"}, false),
|
||||
Description: "set to disabled if this server should be used regardless of its state.",
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"downinter": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"fall": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"inter": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"maxconn": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"maxqueue": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"rise": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"slowstart": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"weight": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"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"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceLBFrontendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBFrontendCreate")
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("backendName", d.Get("backend_name").(string))
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
urlValues.Add("frontendName", d.Get("name").(string))
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbFrontendCreateAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("name").(string))
|
||||
|
||||
_, err = utilityLBFrontendCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
diagnostics := resourceLBFrontendRead(ctx, d, m)
|
||||
if diagnostics != nil {
|
||||
return diagnostics
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBFrontendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBFrontendRead")
|
||||
|
||||
f, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
||||
if f == nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
|
||||
d.Set("lb_id", lbId)
|
||||
d.Set("backend_name", f.Backend)
|
||||
d.Set("name", f.Name)
|
||||
d.Set("guid", f.GUID)
|
||||
d.Set("bindings", flattendBindings(f.Bindings))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBFrontendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBFrontendDelete")
|
||||
|
||||
lb, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
||||
if lb == nil {
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
urlValues.Add("frontendName", d.Get("name").(string))
|
||||
|
||||
_, err = c.DecortAPICall(ctx, "POST", lbFrontendDeleteAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBFrontendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
|
||||
//TODO: перенести bindings сюда
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ResourceLBFrontend() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceLBFrontendCreate,
|
||||
ReadContext: resourceLBFrontendRead,
|
||||
UpdateContext: resourceLBFrontendEdit,
|
||||
DeleteContext: resourceLBFrontendDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout60s,
|
||||
Read: &constants.Timeout30s,
|
||||
Update: &constants.Timeout60s,
|
||||
Delete: &constants.Timeout60s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"lb_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the LB instance to backendCreate",
|
||||
},
|
||||
"backend_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"bindings": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"address": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"port": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
@ -0,0 +1,201 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"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"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceLBFrontendBindCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBFrontendBindCreate")
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("frontendName", d.Get("frontend_name").(string))
|
||||
urlValues.Add("bindingName", d.Get("name").(string))
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
urlValues.Add("bindingAddress", d.Get("address").(string))
|
||||
urlValues.Add("bindingPort", strconv.Itoa(d.Get("port").(int)))
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbFrontendBindAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("frontend_name").(string) + "-" + d.Get("name").(string))
|
||||
|
||||
_, err = utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
diagnostics := resourceLBFrontendBindRead(ctx, d, m)
|
||||
if diagnostics != nil {
|
||||
return diagnostics
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBFrontendBindRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBFrontendBindRead")
|
||||
|
||||
b, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||
if b == nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
|
||||
frontendName := strings.Split(d.Id(), "-")[1]
|
||||
|
||||
d.Set("lb_id", lbId)
|
||||
d.Set("frontend_name", frontendName)
|
||||
d.Set("name", b.Name)
|
||||
d.Set("address", b.Address)
|
||||
d.Set("guid", b.GUID)
|
||||
d.Set("port", b.Port)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBFrontendBindDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBFrontendBindDelete")
|
||||
|
||||
b, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||
if b == nil {
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
urlValues.Add("bindingName", d.Get("name").(string))
|
||||
urlValues.Add("frontendName", d.Get("frontend_name").(string))
|
||||
|
||||
_, err = c.DecortAPICall(ctx, "POST", lbFrontendBindDeleteAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceLBFrontendBindEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceLBFrontendBindEdit")
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
urlValues.Add("frontendName", d.Get("frontend_name").(string))
|
||||
urlValues.Add("bindingName", d.Get("name").(string))
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
|
||||
if d.HasChange("address") {
|
||||
urlValues.Add("bindingAddress", d.Get("address").(string))
|
||||
}
|
||||
|
||||
if d.HasChange("port") {
|
||||
urlValues.Add("bindingPort", strconv.Itoa(d.Get("port").(int)))
|
||||
}
|
||||
|
||||
_, err := c.DecortAPICall(ctx, "POST", lbFrontendBindUpdateAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
return resourceLBFrontendBindRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func ResourceLBFrontendBind() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
CreateContext: resourceLBFrontendBindCreate,
|
||||
ReadContext: resourceLBFrontendBindRead,
|
||||
UpdateContext: resourceLBFrontendBindEdit,
|
||||
DeleteContext: resourceLBFrontendBindDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout60s,
|
||||
Read: &constants.Timeout30s,
|
||||
Update: &constants.Timeout60s,
|
||||
Delete: &constants.Timeout60s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"lb_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the LB instance to backendCreate",
|
||||
},
|
||||
"frontend_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
||||
},
|
||||
"address": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"port": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
@ -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>
|
||||
|
||||
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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityLBCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*LoadBalancer, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
if (d.Get("lb_id").(int)) != 0 {
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
} else {
|
||||
urlValues.Add("lbId", d.Id())
|
||||
}
|
||||
|
||||
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
lb := &LoadBalancer{}
|
||||
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||
}
|
||||
|
||||
return lb, nil
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityLBBackendCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Backend, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
bName := d.Get("name").(string)
|
||||
|
||||
if (d.Get("lb_id").(int)) != 0 {
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
} else {
|
||||
parameters := strings.Split(d.Id(), "-")
|
||||
urlValues.Add("lbId", parameters[0])
|
||||
bName = parameters[1]
|
||||
}
|
||||
|
||||
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
lb := &LoadBalancer{}
|
||||
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||
}
|
||||
|
||||
backends := lb.Backends
|
||||
for _, b := range backends {
|
||||
if b.Name == bName {
|
||||
return &b, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("can not find backend with name: %s for lb: %d", bName, lb.ID)
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityLBBackendServerCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Server, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
bName := d.Get("backend_name").(string)
|
||||
sName := d.Get("name").(string)
|
||||
|
||||
if (d.Get("lb_id").(int)) != 0 {
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
} else {
|
||||
parameters := strings.Split(d.Id(), "-")
|
||||
urlValues.Add("lbId", parameters[0])
|
||||
bName = parameters[1]
|
||||
sName = parameters[2]
|
||||
}
|
||||
|
||||
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
lb := &LoadBalancer{}
|
||||
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||
}
|
||||
|
||||
backend := &Backend{}
|
||||
backends := lb.Backends
|
||||
for i, b := range backends {
|
||||
if b.Name == bName {
|
||||
backend = &backends[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if backend.Name == "" {
|
||||
return nil, fmt.Errorf("can not find backend with name: %s for lb: %d", bName, lb.ID)
|
||||
}
|
||||
|
||||
for _, s := range backend.Servers {
|
||||
if s.Name == sName {
|
||||
return &s, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("can not find server with name: %s for backend: %s for lb: %d", sName, bName, lb.ID)
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityLBFrontendCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Frontend, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
fName := d.Get("name").(string)
|
||||
|
||||
if (d.Get("lb_id").(int)) != 0 {
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
} else {
|
||||
parameters := strings.Split(d.Id(), "-")
|
||||
urlValues.Add("lbId", parameters[0])
|
||||
fName = parameters[1]
|
||||
}
|
||||
|
||||
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
lb := &LoadBalancer{}
|
||||
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||
}
|
||||
|
||||
frontends := lb.Frontends
|
||||
for _, f := range frontends {
|
||||
if f.Name == fName {
|
||||
return &f, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("can not find frontend with name: %s for lb: %d", fName, lb.ID)
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityLBFrontendBindCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Binding, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
fName := d.Get("frontend_name").(string)
|
||||
bName := d.Get("name").(string)
|
||||
|
||||
if (d.Get("lb_id").(int)) != 0 {
|
||||
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
|
||||
} else {
|
||||
parameters := strings.Split(d.Id(), "-")
|
||||
urlValues.Add("lbId", parameters[0])
|
||||
fName = parameters[1]
|
||||
bName = parameters[2]
|
||||
}
|
||||
|
||||
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
lb := &LoadBalancer{}
|
||||
if err := json.Unmarshal([]byte(resp), lb); err != nil {
|
||||
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
|
||||
}
|
||||
|
||||
frontend := &Frontend{}
|
||||
frontends := lb.Frontends
|
||||
for i, f := range frontends {
|
||||
if f.Name == fName {
|
||||
frontend = &frontends[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if frontend.Name == "" {
|
||||
return nil, fmt.Errorf("can not find frontend with name: %s for lb: %d", fName, lb.ID)
|
||||
}
|
||||
|
||||
for _, b := range frontend.Bindings {
|
||||
if b.Name == bName {
|
||||
return &b, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("can not find bind with name: %s for frontend: %s for lb: %d", bName, fName, lb.ID)
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (LBList, error) {
|
||||
lbList := LBList{}
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
if includedeleted, ok := d.GetOk("includedeleted"); ok {
|
||||
urlValues.Add("includedeleted", strconv.FormatBool((includedeleted.(bool))))
|
||||
}
|
||||
|
||||
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("utilityLBListCheckPresence: load lb list")
|
||||
lbListRaw, err := c.DecortAPICall(ctx, "POST", lbListAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(lbListRaw), &lbList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lbList, 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>
|
||||
|
||||
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 lb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityLBListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (LBList, error) {
|
||||
lbList := LBList{}
|
||||
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("utilityLBListDeletedCheckPresence: load lb list")
|
||||
lbListRaw, err := c.DecortAPICall(ctx, "POST", lbListDeletedAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(lbListRaw), &lbList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lbList, nil
|
||||
}
|
Loading…
Reference in new issue