parent
a355247845
commit
4d865ae921
@ -1,10 +1,51 @@
|
||||
### Version 3.3.1
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- Fix bug with sample decort_k8s_wg
|
||||
- Fix bug with the absence of an optional field ext_ip_addr with vins resource
|
||||
### Version 3.4.0
|
||||
|
||||
### Features
|
||||
|
||||
- Change cloud_init in vins resource, the field shows full information about the configuration made by the user
|
||||
- Add "seps" to the data source decort_account
|
||||
- Add "seps" to the resource decort_account
|
||||
- Add "shareable" to the data source decort_account_disk_list
|
||||
- Change "compute_id" and "compute_name" to "computes" in data source decort_disks
|
||||
- Change "compute_id" and "compute_name" to "computes" in resource decort_disks
|
||||
- Change "compute_id" and "compute_name" to "computes" in data source decort_disks_list
|
||||
- Add "shareable" to the data source decort_disk
|
||||
- Add "shareable" to the resource decort_disk
|
||||
- Add "shareable" to the data source decort_disk_list
|
||||
- Add optional field "share" to the resource decort_account_disk_list
|
||||
- Add "present_to" to the data source decort_disk
|
||||
- Add "present_to" to the data source decort_disk_list
|
||||
- Add "present_to" to the resource decort_disk
|
||||
- Add "shareable" to the data source decort_kvmvm
|
||||
- Add "shareable" to the resource decort_kvmvm
|
||||
- Add "size_max" to the data source decort_kvmvm
|
||||
- Add "size_max" to the resource decort_kvmvm
|
||||
- Add "size_used" to the data source decort_kvmvm
|
||||
- Add "size_used" to the resource decort_kvmvm
|
||||
- Add "present_to" to the data source decort_image
|
||||
- Add "present_to" to the resource decort_image
|
||||
- Add optional field "labels" to the resource decort_k8s
|
||||
- Add optional field "taints" to the resource decort_k8s
|
||||
- Add optional field "annotations" to the resource decort_k8s
|
||||
- Add optional field "sep_id" in block masters in the resource decort_k8s
|
||||
- Add optional field "sep_pool" in block masters in the resource decort_k8s
|
||||
- Add optional field "sep_id" in block workers in the resource decort_k8s
|
||||
- Add optional field "sep_pool" in block workers in the resource decort_k8s
|
||||
- Add "gid" to the data source decort_resgroup
|
||||
- Add "resources" to the data source decort_resgroup
|
||||
- Add "status" to the data source decort_resgroup
|
||||
- Add "vins" to the data source decort_resgroup
|
||||
- Add "vms" to the data source decort_resgroup
|
||||
- Add "gid" to the resource decort_resgroup
|
||||
- Add "resources" to the resource decort_resgroup
|
||||
- Add "status" to the resource decort_resgroup
|
||||
- Add "vins" to the resource decort_resgroup
|
||||
- Add "vms" to the resource decort_resgroup
|
||||
- Add optional field "force" to the resource decort_resgroup
|
||||
- Add optional field "permanently" to the resource decort_resgroup
|
||||
- Add optional field "reason" to the resource decort_resgroup
|
||||
- Add "resources" to the resource decort_resgroup
|
||||
- Add "gid" to the resource decort_resgroup
|
||||
- Add "resources" to the data source decort_resgroup
|
||||
- Add "gid" to the data source decort_resgroup
|
||||
- Change required field "account_id" to optional in data source decort_resgroup
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
FROM docker.io/hashicorp/terraform:latest
|
||||
|
||||
WORKDIR /opt/decort/tf/
|
||||
COPY provider.tf ./
|
||||
COPY terraform-provider-decort ./terraform.d/plugins/digitalenergy.online/decort/decort/3.3.1/linux_amd64/
|
||||
RUN terraform init
|
||||
|
||||
WORKDIR /tf
|
||||
COPY entrypoint.sh /
|
||||
ENTRYPOINT ["/entrypoint.sh", "/bin/terraform"]
|
@ -1,52 +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 go'
|
||||
dependencyCheck additionalArguments: '-f JSON -f HTML -n --enableExperimental \
|
||||
-l deplog \
|
||||
--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'
|
||||
sh 'cat deplog'
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
cp -aL /opt/decort/tf/* /opt/decort/tf/.* ./
|
||||
exec "$@"
|
@ -0,0 +1,115 @@
|
||||
package kvmvm
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/rudecs/terraform-provider-decort/internal/status"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func flattenComputeDisksDemo(disksList []DiskRecord, extraDisks []interface{}) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, disk := range disksList {
|
||||
if disk.Name == "bootdisk" || findInExtraDisks(disk.ID, extraDisks) { //skip main bootdisk and extraDisks
|
||||
continue
|
||||
}
|
||||
temp := map[string]interface{}{
|
||||
"disk_name": disk.Name,
|
||||
"disk_id": disk.ID,
|
||||
"disk_type": disk.Type,
|
||||
"sep_id": disk.SepID,
|
||||
"shareable": disk.Shareable,
|
||||
"size_max": disk.SizeMax,
|
||||
"size_used": disk.SizeUsed,
|
||||
"pool": disk.Pool,
|
||||
"desc": disk.Desc,
|
||||
"image_id": disk.ImageID,
|
||||
"size": disk.SizeMax,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenCompute(d *schema.ResourceData, compFacts string) error {
|
||||
// This function expects that compFacts string contains response from API compute/get,
|
||||
// i.e. detailed information about compute instance.
|
||||
//
|
||||
// NOTE: this function modifies ResourceData argument - as such it should never be called
|
||||
// from resourceComputeExists(...) method
|
||||
model := ComputeGetResp{}
|
||||
log.Debugf("flattenCompute: ready to unmarshal string %s", compFacts)
|
||||
err := json.Unmarshal([]byte(compFacts), &model)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("flattenCompute: ID %d, RG ID %d", model.ID, model.RgID)
|
||||
|
||||
d.SetId(fmt.Sprintf("%d", model.ID))
|
||||
// d.Set("compute_id", model.ID) - we should NOT set compute_id in the schema here: if it was set - it is already set, if it wasn't - we shouldn't
|
||||
d.Set("name", model.Name)
|
||||
d.Set("rg_id", model.RgID)
|
||||
d.Set("rg_name", model.RgName)
|
||||
d.Set("account_id", model.AccountID)
|
||||
d.Set("account_name", model.AccountName)
|
||||
d.Set("driver", model.Driver)
|
||||
d.Set("cpu", model.Cpu)
|
||||
d.Set("ram", model.Ram)
|
||||
// d.Set("boot_disk_size", model.BootDiskSize) - bootdiskSize key in API compute/get is always zero, so we set boot_disk_size in another way
|
||||
if model.VirtualImageID != 0 {
|
||||
d.Set("image_id", model.VirtualImageID)
|
||||
} else {
|
||||
d.Set("image_id", model.ImageID)
|
||||
}
|
||||
d.Set("description", model.Desc)
|
||||
d.Set("enabled", false)
|
||||
if model.Status == status.Enabled {
|
||||
d.Set("enabled", true)
|
||||
}
|
||||
|
||||
//d.Set("cloud_init", "applied") // NOTE: for existing compute we hard-code this value as an indicator for DiffSuppress fucntion
|
||||
//d.Set("status", model.Status)
|
||||
//d.Set("tech_status", model.TechStatus)
|
||||
d.Set("started", false)
|
||||
if model.TechStatus == "STARTED" {
|
||||
d.Set("started", true)
|
||||
}
|
||||
|
||||
bootDisk := findBootDisk(model.Disks)
|
||||
|
||||
d.Set("boot_disk_size", bootDisk.SizeMax)
|
||||
d.Set("boot_disk_id", bootDisk.ID) // we may need boot disk ID in resize operations
|
||||
d.Set("sep_id", bootDisk.SepID)
|
||||
d.Set("pool", bootDisk.Pool)
|
||||
|
||||
//if len(model.Disks) > 0 {
|
||||
//log.Debugf("flattenCompute: calling parseComputeDisksToExtraDisks for %d disks", len(model.Disks))
|
||||
//if err = d.Set("extra_disks", parseComputeDisksToExtraDisks(model.Disks)); err != nil {
|
||||
//return err
|
||||
//}
|
||||
//}
|
||||
|
||||
if len(model.Interfaces) > 0 {
|
||||
log.Debugf("flattenCompute: calling parseComputeInterfacesToNetworks for %d interfaces", len(model.Interfaces))
|
||||
if err = d.Set("network", parseComputeInterfacesToNetworks(model.Interfaces)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(model.OsUsers) > 0 {
|
||||
log.Debugf("flattenCompute: calling parseOsUsers for %d logins", len(model.OsUsers))
|
||||
if err = d.Set("os_users", parseOsUsers(model.OsUsers)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = d.Set("disks", flattenComputeDisksDemo(model.Disks, d.Get("extra_disks").(*schema.Set).List()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package rg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func flattenAccountSeps(seps map[string]map[string]ResourceSep) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for sepKey, sepVal := range seps {
|
||||
for dataKey, dataVal := range sepVal {
|
||||
temp := map[string]interface{}{
|
||||
"sep_id": sepKey,
|
||||
"data_name": dataKey,
|
||||
"disk_size": dataVal.DiskSize,
|
||||
"disk_size_max": dataVal.DiskSizeMax,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenAccResource(r Resource) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"cpu": r.CPU,
|
||||
"disksize": r.Disksize,
|
||||
"extips": r.Extips,
|
||||
"exttraffic": r.Exttraffic,
|
||||
"gpu": r.GPU,
|
||||
"ram": r.RAM,
|
||||
"seps": flattenAccountSeps(r.SEPs),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRgResources(r Resources) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"current": flattenAccResource(r.Current),
|
||||
"reserved": flattenAccResource(r.Reserved),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenDataResgroup(d *schema.ResourceData, details ResgroupGetResp) error {
|
||||
// NOTE: this function modifies ResourceData argument - as such it should never be called
|
||||
// from resourceRsgroupExists(...) method
|
||||
// log.Debugf("%s", rg_facts)
|
||||
|
||||
log.Debugf("flattenResgroup: decoded RG name %q / ID %d, account ID %d",
|
||||
details.Name, details.ID, details.AccountID)
|
||||
|
||||
d.SetId(fmt.Sprintf("%d", details.ID))
|
||||
d.Set("rg_id", details.ID)
|
||||
d.Set("name", details.Name)
|
||||
d.Set("account_name", details.AccountName)
|
||||
d.Set("account_id", details.AccountID)
|
||||
d.Set("gid", details.GridID)
|
||||
d.Set("description", details.Desc)
|
||||
d.Set("status", details.Status)
|
||||
d.Set("def_net_type", details.DefaultNetType)
|
||||
d.Set("def_net_id", details.DefaultNetID)
|
||||
d.Set("resources", flattenRgResources(details.Resources))
|
||||
d.Set("vins", details.Vins)
|
||||
d.Set("vms", details.Computes)
|
||||
log.Debugf("flattenResgroup: calling flattenQuota()")
|
||||
if err := d.Set("quota", parseQuota(details.Quota)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func flattenResgroup(d *schema.ResourceData, details ResgroupGetResp) error {
|
||||
// NOTE: this function modifies ResourceData argument - as such it should never be called
|
||||
// from resourceRsgroupExists(...) method
|
||||
// log.Debugf("%s", rg_facts)
|
||||
//log.Debugf("flattenResgroup: ready to decode response body from API")
|
||||
//details := ResgroupGetResp{}
|
||||
//err := json.Unmarshal([]byte(rg_facts), &details)
|
||||
//if err != nil {
|
||||
//return err
|
||||
//}
|
||||
|
||||
log.Debugf("flattenResgroup: decoded RG name %q / ID %d, account ID %d",
|
||||
details.Name, details.ID, details.AccountID)
|
||||
|
||||
d.SetId(fmt.Sprintf("%d", details.ID))
|
||||
d.Set("rg_id", details.ID)
|
||||
d.Set("name", details.Name)
|
||||
d.Set("account_name", details.AccountName)
|
||||
d.Set("account_id", details.AccountID)
|
||||
d.Set("gid", details.GridID)
|
||||
d.Set("description", details.Desc)
|
||||
d.Set("status", details.Status)
|
||||
d.Set("def_net_type", details.DefaultNetType)
|
||||
d.Set("def_net_id", details.DefaultNetID)
|
||||
d.Set("resources", flattenRgResources(details.Resources))
|
||||
d.Set("vins", details.Vins)
|
||||
d.Set("vms", details.Computes)
|
||||
log.Debugf("flattenResgroup: calling flattenQuota()")
|
||||
if err := d.Set("quota", parseQuota(details.Quota)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = " digitalenergy.online/decort/decort"
|
||||
version = "3.3.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
Loading…
Reference in new issue