Compare commits

..

1 Commits

Author SHA1 Message Date
kjubybot
9d15af9259 k8s, k8s_wg: single worker add/delete support; github actions support 2022-03-28 15:31:01 +03:00
23 changed files with 62 additions and 1022 deletions

View File

@@ -1,4 +1,16 @@
### New features
- snapshot\_list datasource
- snapshot resource
- k8s: extnet\_id parameter
## 2.0
### New data sources
- image
- image\_list
- grid
- grid\_list
- image\_list\_stacks
### New resources
- image
- virtual\_image
- cdrom\_image
- delete\_images
- k8s
- k8s\_wg

View File

@@ -1,50 +0,0 @@
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: alpine
image: alpine:3.15
command:
- sleep
- infinity
'''
}
}
stages {
stage('Dependency check') {
environment {
DEPCHECKDB = credentials('depcheck-postgres')
}
steps {
container('alpine') {
sh 'apk update && apk add openjdk11 java-postgresql-jdbc'
dependencyCheck additionalArguments: '-f JSON -f HTML \
--dbDriverName org.postgresql.Driver \
--dbDriverPath /usr/share/java/postgresql-jdbc.jar \
--dbUser $DEPCHECKDB_USR \
--dbPassword $DEPCHECKDB_PSW \
--connectionString jdbc:postgresql://postgres-postgresql.postgres/depcheck', odcInstallation: 'depcheck'
}
}
}
stage('SonarQube analysis') {
environment {
SONARSCANNER_HOME = tool 'sonarscanner'
}
steps {
withSonarQubeEnv('sonarqube') {
sh '$SONARSCANNER_HOME/bin/sonar-scanner'
}
}
}
stage('SonarQube quality gate') {
steps {
waitForQualityGate webhookSecretId: 'sonar-webhook', abortPipeline: true
}
}
}
}

View File

@@ -10,12 +10,12 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
- Работа с Compute instances,
- Работа с disks,
- Работа с k8s,
- Работа с virtual network segments,
- Работа с image,
- Работа с reource groups,
- Работа с VINS,
- Работа с pfw,
- Работа с accounts,
- Работа с snapshots.
- Работа с accounts.
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
@@ -65,7 +65,7 @@ Linux:
```
Windows:
```powershell
%APPDATA%\terraform.d\plugins\${host_name}\${namespace}\${type}\${version}\${target}
%APPDATA%\terraform.d\plugins\${host_name}/${namespace}/${type}/${version}/${target}
```
ВНИМАНИЕ: для ОС Windows `%APP_DATA%` является каталогом, в котором будут помещены будущие файлы terraform.
Где:
@@ -107,11 +107,8 @@ terraform init
Более подробно о сборке провайдера можно найти по ссылке: https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers
## Примеры работы
Примеры работы можно найти:
- На вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
- В папке `samples`
Схемы к terraform'у доступны:
- В папке `docs`
Примеры работы можно найти на:
- Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
- В папке `samples`
Хорошей работы!

View File

@@ -9,12 +9,12 @@ NOTE: provider rc-1.25 is designed for DECORT API 3.7.x. For older API versions
- Work with Compute instances,
- Work with disks,
- Work with k8s,
- Work with virtual network segments,
- Work with image,
- Work with reource groups,
- Work with VINS,
- Work with pfw,
- Work with accounts,
- Work with snapshots.
- Work with accounts.
This provider supports Import operations on pre-existing resources.
@@ -110,9 +110,6 @@ More details about the provider's building process: https://learn.hashicorp.com/
## Examples and Samples
- Examples: https://github.com/rudecs/terraform-provider-decort/wiki
- Samples: see in repository `samples`
Terraform schemas in:
- See in repository `docs`
- Samples: in repository `samples`
Good work!

View File

@@ -27,14 +27,12 @@ package decort
import (
"bytes"
"crypto/tls"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
// "time"
@@ -380,31 +378,28 @@ func (config *ControllerCfg) decortAPICall(method string, api_name string, url_v
req.Header.Set("Authorization", fmt.Sprintf("bearer %s", config.jwt))
}
for i := 0; i < 5; i++ {
resp, err := config.cc_client.Do(req)
if err != nil {
return "", err
}
resp, err := config.cc_client.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
resp.Body.Close()
log.Debugf("decortAPICall: %s %s\n %s", method, api_name, body)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
log.Debugf("decortAPICall: %s %s\n %s", method, api_name, body)
if resp.StatusCode == http.StatusOK {
return string(body), nil
} else {
if resp.StatusCode == http.StatusInternalServerError {
log.Warnf("got 500, retrying %d/5", i+1)
time.Sleep(time.Second * 5)
continue
}
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
resp.StatusCode, req.URL, params_str, body)
}
if resp.StatusCode == http.StatusOK {
return string(body), nil
} else {
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
resp.StatusCode, req.URL, params_str, body)
}
return "", errors.New("number of retries exceeded")
/*
if resp.StatusCode == StatusServiceUnavailable {
return nil, fmt.Errorf("decortAPICall method called for incompatible authorization mode %q.", config.auth_mode_txt)
}
*/
}

View File

@@ -1,120 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func flattenSnapshotList(gl SnapshotList) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, item := range gl {
temp := map[string]interface{}{
"label": item.Label,
"guid": item.Guid,
"disks": item.Disks,
"timestamp": item.Timestamp,
}
res = append(res, temp)
}
return res
}
func dataSourceSnapshotListRead(d *schema.ResourceData, m interface{}) error {
snapshotList, err := utilitySnapshotListCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenSnapshotList(snapshotList))
return nil
}
func dataSourceSnapshotListSchemaMake() map[string]*schema.Schema {
rets := map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Description: "ID of the compute instance to create snapshot for.",
},
"items": {
Type: schema.TypeList,
Computed: true,
Description: "snapshot list",
Elem: &schema.Resource{
Schema: dataSourceSnapshotSchemaMake(),
},
},
}
return rets
}
func dataSourceSnapshotSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"label": {
Type: schema.TypeString,
Computed: true,
Description: "text label for snapshot. Must be unique among this compute snapshots.",
},
"disks": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"guid": {
Type: schema.TypeString,
Computed: true,
Description: "guid of the snapshot",
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
Description: "timestamp",
},
}
}
func dataSourceSnapshotList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSnapshotListRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSnapshotListSchemaMake(),
}
}

View File

@@ -36,7 +36,7 @@ import (
var Timeout30s = time.Second * 30
var Timeout60s = time.Second * 60
var Timeout180s = time.Second * 180
var Timeout20m = time.Minute * 20
var Timeout10m = time.Minute * 10
//
// structures related to /cloudapi/rg/list API
@@ -605,27 +605,11 @@ type K8sRecord struct {
Masters K8sNodeRecord `json:"masters"`
Workers []K8sNodeRecord `json:"workers"`
} `json:"k8sGroups"`
LbID int `json:"lbId"`
Name string `json:"name"`
RgID int `json:"rgId"`
RgName string `json:"rgName"`
}
//LbRecord represents load balancer instance
type LbRecord struct {
ID int `json:"id"`
Name string `json:"name"`
RgID int `json:"rgId"`
VinsID int `json:"vinsId"`
ExtNetID int `json:"extnetId"`
PrimaryNode struct {
BackendIP string `json:"backendIp"`
ComputeID int `json:"computeId"`
FrontendIP string `json:"frontendIp"`
NetworkID int `json:"networkId"`
} `json:"primaryNode"`
}
const K8sCreateAPI = "/restmachine/cloudapi/k8s/create"
const K8sGetAPI = "/restmachine/cloudapi/k8s/get"
const K8sUpdateAPI = "/restmachine/cloudapi/k8s/update"
@@ -639,8 +623,6 @@ const K8sWorkerDeleteAPI = "/restmachine/cloudapi/k8s/deleteWorkerFromGroup"
const K8sGetConfigAPI = "/restmachine/cloudapi/k8s/getConfig"
const LbGetAPI = "/restmachine/cloudapi/lb/get"
//Blasphemous workaround for parsing Result value
type TaskResult int
@@ -817,21 +799,3 @@ type Grid struct {
}
type GridList []Grid
/////////////////////
/// SNAPSHOT API ///
/////////////////////
const snapshotCreateAPI = "/restmachine/cloudapi/compute/snapshotCreate"
const snapshotDeleteAPI = "/restmachine/cloudapi/compute/snapshotDelete"
const snapshotRollbackAPI = "/restmachine/cloudapi/compute/snapshotRollback"
const snapshotListAPI = "/restmachine/cloudapi/compute/snapshotList"
type Snapshot struct {
Disks []int `json:"disks"`
Guid string `json:"guid"`
Label string `json:"label"`
Timestamp uint64 `json:"timestamp"`
}
type SnapshotList []Snapshot

View File

@@ -58,6 +58,7 @@ func parseNode(nodeList []interface{}) K8sNodeRecord {
func nodeToResource(node K8sNodeRecord) []interface{} {
mp := make(map[string]interface{})
mp["id"] = node.ID
mp["num"] = node.Num
mp["cpu"] = node.Cpu
mp["ram"] = node.Ram

View File

@@ -110,7 +110,6 @@ func Provider() *schema.Provider {
"decort_virtual_image": resourceVirtualImage(),
"decort_cdrom_image": resourceCDROMImage(),
"decort_delete_images": resourceDeleteImages(),
"decort_snapshot": resourceSnapshot(),
},
DataSourcesMap: map[string]*schema.Resource{
@@ -124,7 +123,6 @@ func Provider() *schema.Provider {
"decort_grid_list": dataSourceGridList(),
"decort_image_list": dataSourceImageList(),
"decort_image_list_stacks": dataSourceImageListStacks(),
"decort_snapshot_list": dataSourceSnapshotList(),
// "decort_pfw": dataSourcePfw(),
},

View File

@@ -73,11 +73,10 @@ func resourceK8sCreate(d *schema.ResourceData, m interface{}) error {
//}
urlValues.Add("withLB", strconv.FormatBool(true))
if extNet, ok := d.GetOk("extnet_id"); ok {
urlValues.Add("extnetId", strconv.Itoa(extNet.(int)))
} else {
urlValues.Add("extnetId", "0")
}
//if extNet, ok := d.GetOk("extnet_id"); ok {
//urlValues.Add("extnetId", strconv.Itoa(extNet.(int)))
//}
urlValues.Add("extnetId", strconv.Itoa(0))
//if desc, ok := d.GetOk("desc"); ok {
//urlValues.Add("desc", desc.(string))
@@ -122,21 +121,6 @@ func resourceK8sCreate(d *schema.ResourceData, m interface{}) error {
d.Set("default_wg_id", k8s.Groups.Workers[0].ID)
urlValues = &url.Values{}
urlValues.Add("lbId", strconv.Itoa(k8s.LbID))
resp, err = controller.decortAPICall("POST", LbGetAPI, urlValues)
if err != nil {
return err
}
var lb LbRecord
if err := json.Unmarshal([]byte(resp), &lb); err != nil {
return err
}
d.Set("extnet_id", lb.ExtNetID)
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
urlValues = &url.Values{}
urlValues.Add("k8sId", d.Id())
kubeconfig, err := controller.decortAPICall("POST", K8sGetConfigAPI, urlValues)
@@ -167,21 +151,6 @@ func resourceK8sRead(d *schema.ResourceData, m interface{}) error {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("lbId", strconv.Itoa(k8s.LbID))
resp, err := controller.decortAPICall("POST", LbGetAPI, urlValues)
if err != nil {
return err
}
var lb LbRecord
if err := json.Unmarshal([]byte(resp), &lb); err != nil {
return err
}
d.Set("extnet_id", lb.ExtNetID)
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
urlValues = &url.Values{}
urlValues.Add("k8sId", d.Id())
kubeconfig, err := controller.decortAPICall("POST", K8sGetConfigAPI, urlValues)
if err != nil {
@@ -334,13 +303,13 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
//Description: "Create k8s with load balancer if true.",
//},
"extnet_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
},
//"extnet_id": {
//Type: schema.TypeInt,
//Optional: true,
//ForceNew: true,
//Default: 0,
//Description: "ID of the external network to connect workers to.",
//},
//"desc": {
//Type: schema.TypeString,
@@ -348,12 +317,6 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
//Description: "Text description of this instance.",
//},
"lb_ip": {
Type: schema.TypeString,
Computed: true,
Description: "IP address of default load balancer.",
},
"default_wg_id": {
Type: schema.TypeInt,
Computed: true,
@@ -383,9 +346,9 @@ func resourceK8s() *schema.Resource {
},
Timeouts: &schema.ResourceTimeout{
Create: &Timeout20m,
Create: &Timeout10m,
Read: &Timeout30s,
Update: &Timeout20m,
Update: &Timeout10m,
Delete: &Timeout60s,
Default: &Timeout60s,
},

View File

@@ -238,9 +238,9 @@ func resourceK8sWg() *schema.Resource {
},
Timeouts: &schema.ResourceTimeout{
Create: &Timeout20m,
Create: &Timeout10m,
Read: &Timeout30s,
Update: &Timeout20m,
Update: &Timeout10m,
Delete: &Timeout60s,
Default: &Timeout60s,
},

View File

@@ -1,203 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: 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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
log "github.com/sirupsen/logrus"
)
func resourceSnapshotCreate(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSnapshotCreate: called for snapshot %s", d.Get("label").(string))
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("label", d.Get("label").(string))
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
snapshotId, err := controller.decortAPICall("POST", snapshotCreateAPI, urlValues)
if err != nil {
return err
}
snapshotId = strings.ReplaceAll(snapshotId, "\"", "")
d.SetId(snapshotId)
d.Set("guid", snapshotId)
err = resourceSnapshotRead(d, m)
if err != nil {
return err
}
return nil
}
func resourceSnapshotRead(d *schema.ResourceData, m interface{}) error {
snapshot, err := utilitySnapshotCheckPresence(d, m)
if err != nil {
return err
}
d.Set("timestamp", snapshot.Timestamp)
d.Set("guid", snapshot.Guid)
d.Set("disks", snapshot.Disks)
d.Set("label", snapshot.Label)
return nil
}
func resourceSnapshotDelete(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSnapshotDelete: called for %s, id: %s", d.Get("label").(string), d.Id())
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
urlValues.Add("label", d.Get("label").(string))
_, err := controller.decortAPICall("POST", snapshotDeleteAPI, urlValues)
if err != nil {
return err
}
d.SetId("")
return nil
}
func resourceSnapshotExists(d *schema.ResourceData, m interface{}) (bool, error) {
snapshot, err := utilitySnapshotCheckPresence(d, m)
if err != nil {
return false, err
}
if snapshot == nil {
return false, nil
}
return true, nil
}
func resourceSnapshotEdit(d *schema.ResourceData, m interface{}) error {
err := resourceSnapshotRead(d, m)
if err != nil {
return err
}
return nil
}
func resourceSnapshotRollback(d *schema.ResourceDiff, m interface{}) error {
c := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
urlValues.Add("label", d.Get("label").(string))
_, err := c.decortAPICall("POST", snapshotRollbackAPI, urlValues)
if err != nil {
return err
}
return nil
}
func resourceSnapshotSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Description: "ID of the compute instance to create snapshot for.",
},
"label": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "text label for snapshot. Must be unique among this compute snapshots.",
},
"rollback": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "is rollback the snapshot",
},
"disks": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"guid": {
Type: schema.TypeString,
Computed: true,
Description: "guid of the snapshot",
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
Description: "timestamp",
},
}
}
func resourceSnapshot() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Create: resourceSnapshotCreate,
Read: resourceSnapshotRead,
Update: resourceSnapshotEdit,
Delete: resourceSnapshotDelete,
Exists: resourceSnapshotExists,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Timeouts: &schema.ResourceTimeout{
Create: &Timeout60s,
Read: &Timeout30s,
Update: &Timeout60s,
Delete: &Timeout60s,
Default: &Timeout60s,
},
CustomizeDiff: customdiff.All(
customdiff.IfValueChange("rollback", func(old, new, meta interface{}) bool {
o := old.(bool)
if o != new.(bool) && o == false {
return true
}
return false
}, resourceSnapshotRollback),
),
Schema: resourceSnapshotSchemaMake(),
}
}

View File

@@ -1,55 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: 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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"errors"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySnapshotCheckPresence(d *schema.ResourceData, m interface{}) (*Snapshot, error) {
snapShotList, err := utilitySnapshotListCheckPresence(d, m)
if err != nil {
return nil, err
}
findId := ""
if (d.Get("guid").(string)) != "" {
findId = d.Get("guid").(string)
} else {
findId = d.Id()
}
for _, s := range snapShotList {
if s.Guid == findId {
return &s, nil
}
}
return nil, errors.New("snapshot not found")
}

View File

@@ -1,56 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: 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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"net/url"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySnapshotListCheckPresence(d *schema.ResourceData, m interface{}) (SnapshotList, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
resp, err := controller.decortAPICall("POST", snapshotListAPI, urlValues)
if err != nil {
return nil, err
}
if resp == "" {
return nil, nil
}
snapshotList := SnapshotList{}
if err := json.Unmarshal([]byte(resp), &snapshotList); err != nil {
//return nil, errors.New(fmt.Sprint("Can not unmarshall data to snapshotList: ", resp, " ", snapshotList))
return nil, err
}
return snapshotList, nil
}

View File

@@ -1,50 +0,0 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "decort_snapshot_list Data Source - terraform-provider-decort"
subcategory: ""
description: |-
---
# decort_snapshot_list (Data Source)
<!-- schema generated by tfplugindocs -->
## Schema
### Required
- **compute_id** (Number) ID of the compute instance to create snapshot for.
### Optional
- **id** (String) The ID of this resource.
- **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
### Read-Only
- **items** (List of Object) snapshot list (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:
- **disks** (List of Number)
- **guid** (String)
- **label** (String)
- **timestamp** (Number)

View File

@@ -24,7 +24,6 @@ description: |-
### Optional
- **extnet_id** (Number) ID of the external network to connect workers to. If omitted network will be chosen by the platfom.
- **id** (String) The ID of this resource.
- **masters** (Block List, Max: 1) Master node(s) configuration. (see [below for nested schema](#nestedblock--masters))
- **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
@@ -34,7 +33,6 @@ description: |-
- **default_wg_id** (Number) ID of default workers group for this instace.
- **kubeconfig** (String) Kubeconfig for cluster access.
- **lb_ip** (String) IP address of default load balancer.
<a id="nestedblock--masters"></a>
### Nested Schema for `masters`

View File

@@ -1,46 +0,0 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "decort_snapshot Resource - terraform-provider-decort"
subcategory: ""
description: |-
---
# decort_snapshot (Resource)
<!-- schema generated by tfplugindocs -->
## Schema
### Required
- **compute_id** (Number) ID of the compute instance to create snapshot for.
- **label** (String) text label for snapshot. Must be unique among this compute snapshots.
### Optional
- **id** (String) The ID of this resource.
- **rollback** (Boolean) is rollback the snapshot
- **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
### Read-Only
- **disks** (List of Number)
- **guid** (String) guid of the snapshot
- **timestamp** (Number) timestamp
<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`
Optional:
- **create** (String)
- **default** (String)
- **delete** (String)
- **read** (String)
- **update** (String)

View File

@@ -8,15 +8,11 @@
- image
- image_list
- image_list_stacks
- snapshot_list
- resources:
- image
- virtual_image
- cdrom_image
- delete_images
- k8s
- k8s_wg
- snapshot
## Как пользоваться примерами
1. Установить terraform

View File

@@ -1,40 +0,0 @@
/*
Пример использования
Получение списка snapshot
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
*/
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
controller_url = "https://mr4.digitalenergy.online"
#oauth2_url = <DECORT_SSO_URL>
oauth2_url = "https://sso.digitalenergy.online"
allow_unverified_ssl = true
}
data "decort_snapshot_list" "sl" {
#обязательный параметр
#id вычислительной мощности
#тип - число
compute_id = 24074
}
output "test" {
value = data.decort_snapshot_list.sl
}

View File

@@ -1,122 +0,0 @@
/*
Пример использования
Ресурсов k8s cluster
Ресурсы позволяет:
1. Создавать
2. Редактировать
3. Удалять
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform {
required_providers {
decort = {
source = "terraform.local/local/decort"
version = "1.0.0"
}
}
}
*/
provider "decort" {
authenticator = "oauth2"
oauth2_url = "https://sso.digitalenergy.online"
controller_url = "https://mr4.digitalenergy.online"
app_id = ""
app_secret = ""
}
resource "decort_k8s" "cluster" {
#имя кластера
#обязательный параметр
#при изменении - обновдяет имя кластера
#тип - строка
name = "tftest"
#id resource group
#обязательный параметр
#тип - число
rg_id = 776
#id catalogue item
#обязательный параметр
#тип - число
k8sci_id = 9
#имя для первой worker group, созданной в кластере
#обязательный параметр
#тип - строка
wg_name = "workers"
#настройка мастер node или nodes
#опциональный параметр
#максимальное кол-во элементов - 1
#тип - список нод
masters {
#кол-во node
#обязательный параметр
#тип - число
num = 1
#кол-во cpu
#обязательный параметр
#тип - число
cpu = 2
#кол-во RAM в Мбайтах
#обязательный параметр
#тип - число
ram = 2048
#размер диска в Гбайтах
#обязательный параметр
#тип - число
disk = 10
}
#настройка worker node или nodes
#опциональный параметр
#максимальное кол-во элементов - 1
#тип - список нод
workers {
#кол-во node
#обязательный параметр
#тип - число
num = 1
#кол-во cpu
#обязательный параметр
#тип - число
cpu = 2
#кол-во RAM в Мбайтах
#обязательный параметр
#тип - число
ram = 2048
#размер диска в Гбайтах
#обязательный параметр
#тип - число
disk = 10
}
}
output "test_cluster" {
value = decort_k8s.cluster
}
/*
output "kubeconfig"{
value = decort_k8s.cluster.kubeconfig
}
*/

View File

@@ -1,76 +0,0 @@
/*
Пример использования
Ресурсов worker group
Ресурсы позволяет:
1. Создавать
2. Редактировать
3. Удалять
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform {
required_providers {
decort = {
source = "terraform.local/local/decort"
version = "1.0.0"
}
}
}
*/
provider "decort" {
authenticator = "oauth2"
oauth2_url = "https://sso.digitalenergy.online"
controller_url = "https://mr4.digitalenergy.online"
app_id = ""
app_secret = ""
}
resource "decort_k8s_wg" "wg" {
#id экземпляра k8s
#обязательный параметр
#тип - число
k8s_id = 1234 //это значение должно быть и результат вызова decort_k8s.cluster.id
#имя worker group
#обязательный параметр
#тип - строка
name = "workers-2"
#количество worker node для создания
#опциональный параметр
#тип - число
#по - умолчанию - 1
num = 2
#количество cpu для 1 worker node
#опциональный параметр
#тип - число
#по - умолчанию - 1
cpu = 1
#количество RAM для одной worker node в Мбайтах
#опциональный параметр
#тип - число
#по-умолчанию - 1024
ram = 1024
#размер загрузочного диска для worker node, в Гбайтах
#опциональный параметр
#тип - число
#по - умолчанию - 0
#если установлен параметр 0, то размер диска будет равен размеру образа
disk = 10
}
output "test_wg" {
value = decort_k8s_wg.wg
}

View File

@@ -1,56 +0,0 @@
/*
Пример использования
Ресурса snapshot
Ресурс позволяет:
1. Создавать snapshot
2. Удалять snapshot
3. Откатывать snapshot
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
*/
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
controller_url = "https://mr4.digitalenergy.online"
#oauth2_url = <DECORT_SSO_URL>
oauth2_url = "https://sso.digitalenergy.online"
allow_unverified_ssl = true
}
resource "decort_snapshot" "s" {
#обязательный параметр
#id вычислительной мощности
#тип - число
compute_id = 24074
#обязательный параметр
#наименование snapshot
#тип - строка
label = "test_ssht_3"
#опциональный параметр
#флаг отката
#тип - булев тип
#по-уолчанию - false
#если флаг был измеен с false на true, то произойдет откат
#rollback = false
}
output "test" {
value = decort_snapshot.s
}

View File

@@ -1,7 +0,0 @@
sonar.projectKey=terraform-provider-decort-sast
sonar.dependencyCheck.jsonReportPath=dependency-check-report.json
sonar.dependencyCheck.htmlReportPath=dependency-check-report.html
sonar.exclusions=dependency-check-report.*
sonar.language=go