Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8516e0419a | ||
|
|
e12afbe1ad | ||
|
|
c0c9dc8131 | ||
|
|
c3bc6ef5da | ||
|
|
4d865ae921 | ||
|
|
a355247845 | ||
|
|
be86069155 | ||
|
|
0adf28daf6 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -2,7 +2,7 @@ name: Release
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
### Version 3.2.1
|
### Version 3.4.1
|
||||||
|
|
||||||
### Bug fixes
|
### Features
|
||||||
|
|
||||||
- Fix bug with creating kvmvm. Now, the resource kvmvm creates with user defined network.
|
- Add the affinity_label field into the kvmvm resource
|
||||||
|
- Add affinity_rules blocks into the kvmvm resource
|
||||||
|
- Add anti-affinity_rules blocks into the kvmvm resource
|
||||||
|
- Update samples for the kvmvm resource
|
||||||
|
|||||||
10
Dockerfile
10
Dockerfile
@@ -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.2.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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
8
Makefile
8
Makefile
@@ -6,16 +6,16 @@ NAME=terraform-provider-decort
|
|||||||
BINARY=${NAME}.exe
|
BINARY=${NAME}.exe
|
||||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||||
MAINPATH = ./cmd/decort/
|
MAINPATH = ./cmd/decort/
|
||||||
VERSION=3.2.1
|
VERSION=1.1
|
||||||
#OS_ARCH=darwin_amd64
|
#OS_ARCH=darwin_amd64
|
||||||
#OS_ARCH=windows_amd64
|
OS_ARCH=windows_amd64
|
||||||
#OS_ARCH=linux_amd64
|
#OS_ARCH=linux_amd64
|
||||||
|
|
||||||
default: install
|
default: install
|
||||||
|
|
||||||
image:
|
image:
|
||||||
GOOS=linux GOARCH=amd64 go build -o terraform-provider-decort ./cmd/decort/
|
GOOS=linux GOARCH=amd64 go build -o terraform-provider-decort ./cmd/decort/
|
||||||
docker build . -t rudecs/tf:3.2.1
|
docker build . -t rudecs/tf:3.2.2
|
||||||
rm terraform-provider-decort
|
rm terraform-provider-decort
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@@ -52,4 +52,4 @@ test:
|
|||||||
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
|
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
|
||||||
|
|
||||||
testacc:
|
testacc:
|
||||||
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
|
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
|
||||||
|
|||||||
13
README.md
13
README.md
@@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
Terraform provider для платформы Digital Energy Cloud Orchestration Technology (DECORT)
|
Terraform provider для платформы Digital Energy Cloud Orchestration Technology (DECORT)
|
||||||
|
|
||||||
Внимание: провайдер версии 3.x разработан для DECORT API 3.8.x.
|
## Соответсвие версий платформы версиям провайдера
|
||||||
Для более старых версий можно использовать:
|
|
||||||
|
|
||||||
- DECORT API 3.7.x - версия провайдера rc-1.25
|
| Версия DECORT API | Версия провайдера Terraform |
|
||||||
- DECORT API 3.6.x - версия провайдера rc-1.10
|
| ------ | ------ |
|
||||||
- DECORT API до 3.6.0 - terraform DECS provider (https://github.com/rudecs/terraform-provider-decs)
|
| 3.8.5 | 3.4.x |
|
||||||
|
| 3.8.0 - 3.8.4 | 3.3.1 |
|
||||||
|
| 3.7.x | rc-1.25 |
|
||||||
|
| 3.6.x | rc-1.10 |
|
||||||
|
| до 3.6.0 | [terraform-provider-decs](https://github.com/rudecs/terraform-provider-decs) |
|
||||||
|
|
||||||
## Режимы работы
|
## Режимы работы
|
||||||
|
|
||||||
|
|||||||
12
README_EN.md
12
README_EN.md
@@ -2,11 +2,15 @@
|
|||||||
|
|
||||||
Terraform provider for Digital Energy Cloud Orchestration Technology (DECORT) platform
|
Terraform provider for Digital Energy Cloud Orchestration Technology (DECORT) platform
|
||||||
|
|
||||||
NOTE: provider 3.x is designed for DECORT API 3.8.x. For older API versions please use:
|
## Mapping of platform versions with provider versions
|
||||||
|
|
||||||
- DECORT API 3.7.x versions - provider verion rc-1.25
|
| DECORT API version | Terraform provider version |
|
||||||
- DECORT API 3.6.x versions - provider version rc-1.10
|
| ------ | ------ |
|
||||||
- DECORT API versions prior to 3.6.0 - Terraform DECS provider (https://github.com/rudecs/terraform-provider-decs)
|
| 3.8.5 | 3.4.x |
|
||||||
|
| 3.8.0 - 3.8.4 | 3.3.1 |
|
||||||
|
| 3.7.x | rc-1.25 |
|
||||||
|
| 3.6.x | rc-1.10 |
|
||||||
|
| до 3.6.0 | [terraform-provider-decs](https://github.com/rudecs/terraform-provider-decs) |
|
||||||
|
|
||||||
## Working modes
|
## Working modes
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
cp -aL /opt/decort/tf/* /opt/decort/tf/.* ./
|
|
||||||
exec "$@"
|
|
||||||
60
go.mod
60
go.mod
@@ -3,68 +3,68 @@ module github.com/rudecs/terraform-provider-decort
|
|||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/golang-jwt/jwt/v4 v4.4.2
|
github.com/golang-jwt/jwt/v4 v4.4.3
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/hashicorp/terraform-plugin-docs v0.13.0
|
github.com/hashicorp/terraform-plugin-docs v0.13.0
|
||||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2
|
golang.org/x/net v0.4.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||||
github.com/Masterminds/semver/v3 v3.1.1 // indirect
|
github.com/Masterminds/semver/v3 v3.2.0 // indirect
|
||||||
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
|
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
|
||||||
github.com/agext/levenshtein v1.2.2 // indirect
|
github.com/agext/levenshtein v1.2.3 // indirect
|
||||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||||
github.com/armon/go-radix v1.0.0 // indirect
|
github.com/armon/go-radix v1.0.0 // indirect
|
||||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||||
github.com/fatih/color v1.13.0 // indirect
|
github.com/fatih/color v1.13.0 // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/google/go-cmp v0.5.8 // indirect
|
github.com/google/go-cmp v0.5.9 // indirect
|
||||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||||
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
|
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||||
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
|
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
|
||||||
github.com/hashicorp/go-hclog v1.2.1 // indirect
|
github.com/hashicorp/go-hclog v1.4.0 // indirect
|
||||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||||
github.com/hashicorp/go-plugin v1.4.4 // indirect
|
github.com/hashicorp/go-plugin v1.4.8 // indirect
|
||||||
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
||||||
github.com/hashicorp/go-version v1.6.0 // indirect
|
github.com/hashicorp/go-version v1.6.0 // indirect
|
||||||
github.com/hashicorp/hc-install v0.4.0 // indirect
|
github.com/hashicorp/hc-install v0.4.0 // indirect
|
||||||
github.com/hashicorp/hcl/v2 v2.13.0 // indirect
|
github.com/hashicorp/hcl/v2 v2.15.0 // indirect
|
||||||
github.com/hashicorp/logutils v1.0.0 // indirect
|
github.com/hashicorp/logutils v1.0.0 // indirect
|
||||||
github.com/hashicorp/terraform-exec v0.17.2 // indirect
|
github.com/hashicorp/terraform-exec v0.17.3 // indirect
|
||||||
github.com/hashicorp/terraform-json v0.14.0 // indirect
|
github.com/hashicorp/terraform-json v0.14.0 // indirect
|
||||||
github.com/hashicorp/terraform-plugin-go v0.12.0 // indirect
|
github.com/hashicorp/terraform-plugin-go v0.14.2 // indirect
|
||||||
github.com/hashicorp/terraform-plugin-log v0.6.0 // indirect
|
github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect
|
||||||
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect
|
github.com/hashicorp/terraform-registry-address v0.1.0 // indirect
|
||||||
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
|
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
|
||||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
|
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||||
github.com/huandu/xstrings v1.3.2 // indirect
|
github.com/huandu/xstrings v1.4.0 // indirect
|
||||||
github.com/imdario/mergo v0.3.13 // indirect
|
github.com/imdario/mergo v0.3.13 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||||
github.com/mitchellh/cli v1.1.4 // indirect
|
github.com/mitchellh/cli v1.1.5 // indirect
|
||||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||||
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
|
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||||
github.com/oklog/run v1.0.0 // indirect
|
github.com/oklog/run v1.1.0 // indirect
|
||||||
github.com/posener/complete v1.2.3 // indirect
|
github.com/posener/complete v1.2.3 // indirect
|
||||||
github.com/russross/blackfriday v1.6.0 // indirect
|
github.com/russross/blackfriday v1.6.0 // indirect
|
||||||
github.com/shopspring/decimal v1.3.1 // indirect
|
github.com/shopspring/decimal v1.3.1 // indirect
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
github.com/spf13/cast v1.5.0 // indirect
|
||||||
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
|
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
|
||||||
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
|
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
|
||||||
github.com/vmihailenco/tagparser v0.1.1 // indirect
|
github.com/vmihailenco/tagparser v0.1.2 // indirect
|
||||||
github.com/zclconf/go-cty v1.10.0 // indirect
|
github.com/zclconf/go-cty v1.12.1 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
|
golang.org/x/crypto v0.4.0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
golang.org/x/sys v0.3.0 // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.5.0 // indirect
|
||||||
google.golang.org/appengine v1.6.6 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
|
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
|
||||||
google.golang.org/grpc v1.48.0 // indirect
|
google.golang.org/grpc v1.51.0 // indirect
|
||||||
google.golang.org/protobuf v1.28.0 // indirect
|
google.golang.org/protobuf v1.28.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
81
go.sum
81
go.sum
@@ -6,9 +6,14 @@ github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJ
|
|||||||
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||||
|
github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
|
||||||
|
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
|
||||||
github.com/Masterminds/sprig/v3 v3.2.0/go.mod h1:tWhwTbUTndesPNeF0C900vKoq283u6zp4APT9vaF3SI=
|
github.com/Masterminds/sprig/v3 v3.2.0/go.mod h1:tWhwTbUTndesPNeF0C900vKoq283u6zp4APT9vaF3SI=
|
||||||
|
github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk=
|
||||||
github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8=
|
github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8=
|
||||||
github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk=
|
github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk=
|
||||||
|
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
|
||||||
|
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
|
||||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||||
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
|
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
|
||||||
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
|
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
|
||||||
@@ -18,9 +23,12 @@ github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk
|
|||||||
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
|
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
|
||||||
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
|
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
|
||||||
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||||
|
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||||
|
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||||
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
|
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
|
||||||
|
github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=
|
||||||
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
|
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
|
||||||
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
|
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
|
||||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
|
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
|
||||||
@@ -70,6 +78,8 @@ github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti
|
|||||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||||
github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
|
github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
|
||||||
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||||
|
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
|
||||||
|
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
@@ -98,6 +108,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
@@ -116,11 +128,15 @@ github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUK
|
|||||||
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs=
|
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs=
|
||||||
github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw=
|
github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw=
|
||||||
github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
|
github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
|
||||||
|
github.com/hashicorp/go-hclog v1.4.0 h1:ctuWFGrhFha8BnnzxqeRGidlEcQkDyL5u8J8t5eA11I=
|
||||||
|
github.com/hashicorp/go-hclog v1.4.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
|
||||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||||
github.com/hashicorp/go-plugin v1.4.4 h1:NVdrSdFRt3SkZtNckJ6tog7gbpRrcbOjQi/rgF7JYWQ=
|
github.com/hashicorp/go-plugin v1.4.4 h1:NVdrSdFRt3SkZtNckJ6tog7gbpRrcbOjQi/rgF7JYWQ=
|
||||||
github.com/hashicorp/go-plugin v1.4.4/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
|
github.com/hashicorp/go-plugin v1.4.4/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
|
||||||
|
github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM=
|
||||||
|
github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
|
||||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
||||||
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
@@ -132,29 +148,46 @@ github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH9
|
|||||||
github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI=
|
github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI=
|
||||||
github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc=
|
github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc=
|
||||||
github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0=
|
github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0=
|
||||||
|
github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8=
|
||||||
|
github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng=
|
||||||
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
|
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
|
||||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||||
github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad8zszYZ73Go=
|
github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad8zszYZ73Go=
|
||||||
github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8=
|
github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8=
|
||||||
|
github.com/hashicorp/terraform-exec v0.17.3 h1:MX14Kvnka/oWGmIkyuyvL6POx25ZmKrjlaclkx3eErU=
|
||||||
|
github.com/hashicorp/terraform-exec v0.17.3/go.mod h1:+NELG0EqQekJzhvikkeQsOAZpsw0cv/03rbeQJqscAI=
|
||||||
github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s=
|
github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s=
|
||||||
github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM=
|
github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM=
|
||||||
github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY=
|
github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY=
|
||||||
github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ=
|
github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ=
|
||||||
github.com/hashicorp/terraform-plugin-go v0.12.0 h1:6wW9mT1dSs0Xq4LR6HXj1heQ5ovr5GxXNJwkErZzpJw=
|
github.com/hashicorp/terraform-plugin-go v0.12.0 h1:6wW9mT1dSs0Xq4LR6HXj1heQ5ovr5GxXNJwkErZzpJw=
|
||||||
github.com/hashicorp/terraform-plugin-go v0.12.0/go.mod h1:kwhmaWHNDvT1B3QiSJdAtrB/D4RaKSY/v3r2BuoWK4M=
|
github.com/hashicorp/terraform-plugin-go v0.12.0/go.mod h1:kwhmaWHNDvT1B3QiSJdAtrB/D4RaKSY/v3r2BuoWK4M=
|
||||||
|
github.com/hashicorp/terraform-plugin-go v0.14.2 h1:rhsVEOGCnY04msNymSvbUsXfRLKh9znXZmHlf5e8mhE=
|
||||||
|
github.com/hashicorp/terraform-plugin-go v0.14.2/go.mod h1:Q12UjumPNGiFsZffxOsA40Tlz1WVXt2Evh865Zj0+UA=
|
||||||
github.com/hashicorp/terraform-plugin-log v0.6.0 h1:/Vq78uSIdUSZ3iqDc9PESKtwt8YqNKN6u+khD+lLjuw=
|
github.com/hashicorp/terraform-plugin-log v0.6.0 h1:/Vq78uSIdUSZ3iqDc9PESKtwt8YqNKN6u+khD+lLjuw=
|
||||||
github.com/hashicorp/terraform-plugin-log v0.6.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
|
github.com/hashicorp/terraform-plugin-log v0.6.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
|
||||||
|
github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs=
|
||||||
|
github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
|
||||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0 h1:7gDAcfto/C4Cjtf90SdukQshsxdMxJ/P69QxiF3digI=
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0 h1:7gDAcfto/C4Cjtf90SdukQshsxdMxJ/P69QxiF3digI=
|
||||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0/go.mod h1:/WYikYjhKB7c2j1HmXZhRsAARldRb4M38bLCLOhC3so=
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0/go.mod h1:/WYikYjhKB7c2j1HmXZhRsAARldRb4M38bLCLOhC3so=
|
||||||
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 h1:zHcMbxY0+rFO9gY99elV/XC/UnQVg7FhRCbj1i5b7vM=
|
||||||
|
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1/go.mod h1:+tNlb0wkfdsDJ7JEiERLz4HzM19HyiuIoGzTsM7rPpw=
|
||||||
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg=
|
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg=
|
||||||
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI=
|
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI=
|
||||||
|
github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U=
|
||||||
|
github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A=
|
||||||
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
|
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
|
||||||
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
|
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
|
||||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
|
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
|
||||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
||||||
|
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
||||||
|
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
||||||
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||||
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
|
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
|
||||||
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||||
|
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||||
|
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
|
||||||
|
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||||
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
||||||
@@ -180,12 +213,18 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO
|
|||||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
||||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||||
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
|
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
|
||||||
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
github.com/mitchellh/cli v1.1.4 h1:qj8czE26AU4PbiaPXK5uVmMSM+V5BYsFBiM9HhGRLUA=
|
github.com/mitchellh/cli v1.1.4 h1:qj8czE26AU4PbiaPXK5uVmMSM+V5BYsFBiM9HhGRLUA=
|
||||||
github.com/mitchellh/cli v1.1.4/go.mod h1:vTLESy5mRhKOs9KDp0/RATawxP1UqBmdrpVRMnpcvKQ=
|
github.com/mitchellh/cli v1.1.4/go.mod h1:vTLESy5mRhKOs9KDp0/RATawxP1UqBmdrpVRMnpcvKQ=
|
||||||
|
github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng=
|
||||||
|
github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4=
|
||||||
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
|
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
|
||||||
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
||||||
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
||||||
@@ -195,6 +234,8 @@ github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJ
|
|||||||
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
|
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
|
||||||
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
|
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
|
||||||
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||||
@@ -204,6 +245,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
|
|||||||
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758=
|
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758=
|
||||||
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
|
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
|
||||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||||
|
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
|
||||||
|
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@@ -245,12 +288,17 @@ github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvC
|
|||||||
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
|
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
|
||||||
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
|
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
|
||||||
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||||
|
github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc=
|
||||||
|
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||||
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
||||||
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
|
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
||||||
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
|
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
|
||||||
github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0=
|
github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0=
|
||||||
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
|
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
|
||||||
|
github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY=
|
||||||
|
github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA=
|
||||||
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
|
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
|
||||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
@@ -261,12 +309,17 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh
|
|||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
|
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||||
|
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
|
||||||
|
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
@@ -275,6 +328,7 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r
|
|||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
@@ -284,6 +338,10 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
|||||||
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
|
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||||
|
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
||||||
|
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@@ -291,6 +349,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ
|
|||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
@@ -311,20 +370,34 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||||
|
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||||
|
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
@@ -332,12 +405,16 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
|||||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
|
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
|
||||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
|
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||||
|
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
google.golang.org/genproto v0.0.0-20200711021454-869866162049 h1:YFTFpQhgvrLrmxtiIncJxFXeCyq84ixuKWVCaCAi9Oc=
|
google.golang.org/genproto v0.0.0-20200711021454-869866162049 h1:YFTFpQhgvrLrmxtiIncJxFXeCyq84ixuKWVCaCAi9Oc=
|
||||||
google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
|
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70=
|
||||||
|
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
@@ -346,6 +423,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp
|
|||||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||||
google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w=
|
google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w=
|
||||||
google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
||||||
|
google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U=
|
||||||
|
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
@@ -361,6 +440,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
|
|||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
|
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||||
|
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -28,3 +29,4 @@ var Timeout180s = time.Second * 180
|
|||||||
var Timeout300s = time.Second * 300
|
var Timeout300s = time.Second * 300
|
||||||
var Timeout600s = time.Second * 600
|
var Timeout600s = time.Second * 600
|
||||||
var Timeout20m = time.Minute * 20
|
var Timeout20m = time.Minute * 20
|
||||||
|
var Timeout30m = time.Minute * 30
|
||||||
|
|||||||
53
internal/dc/warnings.go
Normal file
53
internal/dc/warnings.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Diagnostics Collector
|
||||||
|
package dc
|
||||||
|
|
||||||
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
|
||||||
|
type Warnings struct {
|
||||||
|
diagnostics diag.Diagnostics
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Warnings) Add(err error) {
|
||||||
|
if w.diagnostics == nil {
|
||||||
|
w.diagnostics = diag.Diagnostics{}
|
||||||
|
}
|
||||||
|
diagFromErr := diag.FromErr(err)
|
||||||
|
diagFromErr[0].Severity = diag.Warning
|
||||||
|
w.diagnostics = append(w.diagnostics, diagFromErr[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w Warnings) Get() diag.Diagnostics {
|
||||||
|
return w.diagnostics
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ import (
|
|||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/disks"
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/disks"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/extnet"
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/extnet"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/image"
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/image"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/lb"
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/lb"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/locations"
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/locations"
|
||||||
@@ -39,7 +40,18 @@ func NewDataSourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_account": account.DataSourceAccount(),
|
"decort_account": account.DataSourceAccount(),
|
||||||
"decort_resgroup": rg.DataSourceResgroup(),
|
"decort_resgroup": rg.DataSourceResgroup(),
|
||||||
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
||||||
|
"decort_k8s": k8s.DataSourceK8s(),
|
||||||
|
"decort_k8s_list": k8s.DataSourceK8sList(),
|
||||||
|
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
||||||
|
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||||
|
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||||
"decort_vins": vins.DataSourceVins(),
|
"decort_vins": vins.DataSourceVins(),
|
||||||
|
"decort_vins_list": vins.DataSourceVinsList(),
|
||||||
|
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
||||||
|
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
||||||
|
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
||||||
|
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
||||||
|
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
||||||
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
||||||
"decort_disk": disks.DataSourceDisk(),
|
"decort_disk": disks.DataSourceDisk(),
|
||||||
"decort_disk_list": disks.DataSourceDiskList(),
|
"decort_disk_list": disks.DataSourceDiskList(),
|
||||||
@@ -71,7 +83,6 @@ func NewDataSourcesMap() map[string]*schema.Resource {
|
|||||||
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
||||||
"decort_extnet": extnet.DataSourceExtnet(),
|
"decort_extnet": extnet.DataSourceExtnet(),
|
||||||
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
||||||
"decort_vins_list": vins.DataSourceVinsList(),
|
|
||||||
"decort_locations_list": locations.DataSourceLocationsList(),
|
"decort_locations_list": locations.DataSourceLocationsList(),
|
||||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||||
"decort_image_list": image.DataSourceImageList(),
|
"decort_image_list": image.DataSourceImageList(),
|
||||||
|
|||||||
@@ -141,6 +141,22 @@ func flattenAccResources(r Resources) []map[string]interface{} {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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{} {
|
func flattenAccResource(r Resource) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
@@ -150,6 +166,7 @@ func flattenAccResource(r Resource) []map[string]interface{} {
|
|||||||
"exttraffic": r.Exttraffic,
|
"exttraffic": r.Exttraffic,
|
||||||
"gpu": r.GPU,
|
"gpu": r.GPU,
|
||||||
"ram": r.RAM,
|
"ram": r.RAM,
|
||||||
|
"seps": flattenAccountSeps(r.SEPs),
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
return res
|
return res
|
||||||
@@ -161,6 +178,7 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"dc_location": {
|
"dc_location": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -199,6 +217,30 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"data_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -231,6 +273,30 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"data_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func flattenAccountDisksList(adl AccountDisksList) []map[string]interface{} {
|
|||||||
"disk_name": ad.Name,
|
"disk_name": ad.Name,
|
||||||
"pool": ad.Pool,
|
"pool": ad.Pool,
|
||||||
"sep_id": ad.SepId,
|
"sep_id": ad.SepId,
|
||||||
|
"shareable": ad.Shareable,
|
||||||
"size_max": ad.SizeMax,
|
"size_max": ad.SizeMax,
|
||||||
"type": ad.Type,
|
"type": ad.Type,
|
||||||
}
|
}
|
||||||
@@ -98,6 +99,10 @@ func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"shareable": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"size_max": {
|
"size_max": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -89,13 +89,19 @@ type AccountCloudApi struct {
|
|||||||
|
|
||||||
type AccountCloudApiList []AccountCloudApi
|
type AccountCloudApiList []AccountCloudApi
|
||||||
|
|
||||||
|
type ResourceSep struct {
|
||||||
|
DiskSize float64 `json:"disksize"`
|
||||||
|
DiskSizeMax int `json:"disksizemax"`
|
||||||
|
}
|
||||||
|
|
||||||
type Resource struct {
|
type Resource struct {
|
||||||
CPU int `json:"cpu"`
|
CPU int `json:"cpu"`
|
||||||
Disksize int `json:"disksize"`
|
Disksize int `json:"disksize"`
|
||||||
Extips int `json:"extips"`
|
Extips int `json:"extips"`
|
||||||
Exttraffic int `json:"exttraffic"`
|
Exttraffic int `json:"exttraffic"`
|
||||||
GPU int `json:"gpu"`
|
GPU int `json:"gpu"`
|
||||||
RAM int `json:"ram"`
|
RAM int `json:"ram"`
|
||||||
|
SEPs map[string]map[string]ResourceSep `json:"seps"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Resources struct {
|
type Resources struct {
|
||||||
@@ -147,12 +153,13 @@ type AccountCompute struct {
|
|||||||
type AccountComputesList []AccountCompute
|
type AccountComputesList []AccountCompute
|
||||||
|
|
||||||
type AccountDisk struct {
|
type AccountDisk struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
SepId int `json:"sepId"`
|
SepId int `json:"sepId"`
|
||||||
SizeMax int `json:"sizeMax"`
|
Shareable bool `json:"shareable"`
|
||||||
Type string `json:"type"`
|
SizeMax int `json:"sizeMax"`
|
||||||
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountDisksList []AccountDisk
|
type AccountDisksList []AccountDisk
|
||||||
|
|||||||
@@ -593,6 +593,30 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"data_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -625,6 +649,30 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"data_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,4 +47,6 @@ const (
|
|||||||
|
|
||||||
disksSnapshotDeleteAPI = "/restmachine/cloudapi/disks/snapshotDelete"
|
disksSnapshotDeleteAPI = "/restmachine/cloudapi/disks/snapshotDelete"
|
||||||
disksSnapshotRollbackAPI = "/restmachine/cloudapi/disks/snapshotRollback"
|
disksSnapshotRollbackAPI = "/restmachine/cloudapi/disks/snapshotRollback"
|
||||||
|
disksShareAPI = "/restmachine/cloudapi/disks/share"
|
||||||
|
disksUnshareAPI = "/restmachine/cloudapi/disks/unshare"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
d.Set("account_name", disk.AccountName)
|
d.Set("account_name", disk.AccountName)
|
||||||
d.Set("acl", string(diskAcl))
|
d.Set("acl", string(diskAcl))
|
||||||
d.Set("boot_partition", disk.BootPartition)
|
d.Set("boot_partition", disk.BootPartition)
|
||||||
d.Set("compute_id", disk.ComputeID)
|
d.Set("computes", flattenDiskComputes(disk.Computes))
|
||||||
d.Set("compute_name", disk.ComputeName)
|
|
||||||
d.Set("created_time", disk.CreatedTime)
|
d.Set("created_time", disk.CreatedTime)
|
||||||
d.Set("deleted_time", disk.DeletedTime)
|
d.Set("deleted_time", disk.DeletedTime)
|
||||||
d.Set("desc", disk.Desc)
|
d.Set("desc", disk.Desc)
|
||||||
@@ -84,6 +83,7 @@ func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
d.Set("passwd", disk.Passwd)
|
d.Set("passwd", disk.Passwd)
|
||||||
d.Set("pci_slot", disk.PciSlot)
|
d.Set("pci_slot", disk.PciSlot)
|
||||||
d.Set("pool", disk.Pool)
|
d.Set("pool", disk.Pool)
|
||||||
|
d.Set("present_to", disk.PresentTo)
|
||||||
d.Set("purge_attempts", disk.PurgeAttempts)
|
d.Set("purge_attempts", disk.PurgeAttempts)
|
||||||
d.Set("purge_time", disk.PurgeTime)
|
d.Set("purge_time", disk.PurgeTime)
|
||||||
d.Set("reality_device_number", disk.RealityDeviceNumber)
|
d.Set("reality_device_number", disk.RealityDeviceNumber)
|
||||||
@@ -93,6 +93,7 @@ func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
d.Set("role", disk.Role)
|
d.Set("role", disk.Role)
|
||||||
d.Set("sep_id", disk.SepID)
|
d.Set("sep_id", disk.SepID)
|
||||||
d.Set("sep_type", disk.SepType)
|
d.Set("sep_type", disk.SepType)
|
||||||
|
d.Set("shareable", disk.Shareable)
|
||||||
d.Set("size_max", disk.SizeMax)
|
d.Set("size_max", disk.SizeMax)
|
||||||
d.Set("size_used", disk.SizeUsed)
|
d.Set("size_used", disk.SizeUsed)
|
||||||
d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots))
|
d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots))
|
||||||
@@ -130,15 +131,21 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Number of disk partitions",
|
Description: "Number of disk partitions",
|
||||||
},
|
},
|
||||||
"compute_id": {
|
"computes": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Compute ID",
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
"compute_name": {
|
"compute_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Compute name",
|
},
|
||||||
|
"compute_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"created_time": {
|
"created_time": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
@@ -316,6 +323,13 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Pool for disk location",
|
Description: "Pool for disk location",
|
||||||
},
|
},
|
||||||
|
"present_to": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
},
|
||||||
"purge_attempts": {
|
"purge_attempts": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -361,6 +375,10 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform",
|
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform",
|
||||||
},
|
},
|
||||||
|
"shareable": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"size_max": {
|
"size_max": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -42,6 +42,18 @@ import (
|
|||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func flattenDiskComputes(computes map[string]string) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for computeKey, computeVal := range computes {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"compute_id": computeKey,
|
||||||
|
"compute_name": computeVal,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
func flattenIOTune(iot IOTune) []map[string]interface{} {
|
func flattenIOTune(iot IOTune) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
@@ -72,9 +84,8 @@ func flattenDiskList(dl DisksList) []map[string]interface{} {
|
|||||||
"account_id": disk.AccountID,
|
"account_id": disk.AccountID,
|
||||||
"account_name": disk.AccountName,
|
"account_name": disk.AccountName,
|
||||||
"acl": string(diskAcl),
|
"acl": string(diskAcl),
|
||||||
|
"computes": flattenDiskComputes(disk.Computes),
|
||||||
"boot_partition": disk.BootPartition,
|
"boot_partition": disk.BootPartition,
|
||||||
"compute_id": disk.ComputeID,
|
|
||||||
"compute_name": disk.ComputeName,
|
|
||||||
"created_time": disk.CreatedTime,
|
"created_time": disk.CreatedTime,
|
||||||
"deleted_time": disk.DeletedTime,
|
"deleted_time": disk.DeletedTime,
|
||||||
"desc": disk.Desc,
|
"desc": disk.Desc,
|
||||||
@@ -99,6 +110,7 @@ func flattenDiskList(dl DisksList) []map[string]interface{} {
|
|||||||
"passwd": disk.Passwd,
|
"passwd": disk.Passwd,
|
||||||
"pci_slot": disk.PciSlot,
|
"pci_slot": disk.PciSlot,
|
||||||
"pool": disk.Pool,
|
"pool": disk.Pool,
|
||||||
|
"present_to": disk.PresentTo,
|
||||||
"purge_attempts": disk.PurgeAttempts,
|
"purge_attempts": disk.PurgeAttempts,
|
||||||
"purge_time": disk.PurgeTime,
|
"purge_time": disk.PurgeTime,
|
||||||
"reality_device_number": disk.RealityDeviceNumber,
|
"reality_device_number": disk.RealityDeviceNumber,
|
||||||
@@ -108,6 +120,7 @@ func flattenDiskList(dl DisksList) []map[string]interface{} {
|
|||||||
"role": disk.Role,
|
"role": disk.Role,
|
||||||
"sep_id": disk.SepID,
|
"sep_id": disk.SepID,
|
||||||
"sep_type": disk.SepType,
|
"sep_type": disk.SepType,
|
||||||
|
"shareable": disk.Shareable,
|
||||||
"size_max": disk.SizeMax,
|
"size_max": disk.SizeMax,
|
||||||
"size_used": disk.SizeUsed,
|
"size_used": disk.SizeUsed,
|
||||||
"snapshots": flattenDiskSnapshotList(disk.Snapshots),
|
"snapshots": flattenDiskSnapshotList(disk.Snapshots),
|
||||||
@@ -199,15 +212,21 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Number of disk partitions",
|
Description: "Number of disk partitions",
|
||||||
},
|
},
|
||||||
"compute_id": {
|
"computes": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Compute ID",
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
"compute_name": {
|
"compute_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Compute name",
|
},
|
||||||
|
"compute_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"created_time": {
|
"created_time": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
@@ -400,6 +419,13 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Pool for disk location",
|
Description: "Pool for disk location",
|
||||||
},
|
},
|
||||||
|
"present_to": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
},
|
||||||
"purge_attempts": {
|
"purge_attempts": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -445,6 +471,10 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform",
|
Description: "Type SEP. Defines the type of storage system and contains one of the values set in the cloud platform",
|
||||||
},
|
},
|
||||||
|
"shareable": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"size_max": {
|
"size_max": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -37,9 +37,8 @@ type Disk struct {
|
|||||||
AccountID int `json:"accountId"`
|
AccountID int `json:"accountId"`
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
BootPartition int `json:"bootPartition"`
|
BootPartition int `json:"bootPartition"`
|
||||||
|
Computes map[string]string `json:"computes"`
|
||||||
CreatedTime uint64 `json:"creationTime"`
|
CreatedTime uint64 `json:"creationTime"`
|
||||||
ComputeID int `json:"computeId"`
|
|
||||||
ComputeName string `json:"computeName"`
|
|
||||||
DeletedTime uint64 `json:"deletionTime"`
|
DeletedTime uint64 `json:"deletionTime"`
|
||||||
DeviceName string `json:"devicename"`
|
DeviceName string `json:"devicename"`
|
||||||
Desc string `json:"desc"`
|
Desc string `json:"desc"`
|
||||||
@@ -63,6 +62,7 @@ type Disk struct {
|
|||||||
ParentId int `json:"parentId"`
|
ParentId int `json:"parentId"`
|
||||||
PciSlot int `json:"pciSlot"`
|
PciSlot int `json:"pciSlot"`
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
PresentTo []int `json:"presentTo"`
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||||
RealityDeviceNumber int `json:"realityDeviceNumber"`
|
RealityDeviceNumber int `json:"realityDeviceNumber"`
|
||||||
@@ -71,6 +71,7 @@ type Disk struct {
|
|||||||
ResName string `json:"resName"`
|
ResName string `json:"resName"`
|
||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
SepType string `json:"sepType"`
|
SepType string `json:"sepType"`
|
||||||
|
Shareable bool `json:"shareable"`
|
||||||
SepID int `json:"sepId"` // NOTE: absent from compute/get output
|
SepID int `json:"sepId"` // NOTE: absent from compute/get output
|
||||||
SizeMax int `json:"sizeMax"`
|
SizeMax int `json:"sizeMax"`
|
||||||
SizeUsed int `json:"sizeUsed"` // sum over all snapshots of this disk to report total consumed space
|
SizeUsed int `json:"sizeUsed"` // sum over all snapshots of this disk to report total consumed space
|
||||||
@@ -173,3 +174,8 @@ type Unattached struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UnattachedList []Unattached
|
type UnattachedList []Unattached
|
||||||
|
|
||||||
|
type Pair struct {
|
||||||
|
intPort int
|
||||||
|
extPortStart int
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import (
|
|||||||
|
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/dc"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/status"
|
"github.com/rudecs/terraform-provider-decort/internal/status"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
@@ -112,6 +113,15 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
urlValues = &url.Values{}
|
urlValues = &url.Values{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if shareable := d.Get("shareable"); shareable.(bool) == true {
|
||||||
|
urlValues.Add("diskId", diskId)
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", disksShareAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
dgn := resourceDiskRead(ctx, d, m)
|
dgn := resourceDiskRead(ctx, d, m)
|
||||||
if dgn != nil {
|
if dgn != nil {
|
||||||
return dgn
|
return dgn
|
||||||
@@ -123,6 +133,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
warnings := dc.Warnings{}
|
||||||
|
|
||||||
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
disk, err := utilityDiskCheckPresence(ctx, d, m)
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
@@ -133,17 +144,21 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasChangeState := false
|
||||||
if disk.Status == status.Destroyed || disk.Status == status.Purged {
|
if disk.Status == status.Destroyed || disk.Status == status.Purged {
|
||||||
d.Set("disk_id", 0)
|
d.Set("disk_id", 0)
|
||||||
return resourceDiskCreate(ctx, d, m)
|
return resourceDiskCreate(ctx, d, m)
|
||||||
} else if disk.Status == status.Deleted {
|
} else if disk.Status == status.Deleted {
|
||||||
|
hasChangeState = true
|
||||||
urlValues.Add("diskId", d.Id())
|
urlValues.Add("diskId", d.Id())
|
||||||
urlValues.Add("reason", d.Get("reason").(string))
|
urlValues.Add("reason", d.Get("reason").(string))
|
||||||
|
|
||||||
_, err := c.DecortAPICall(ctx, "POST", disksRestoreAPI, urlValues)
|
_, err := c.DecortAPICall(ctx, "POST", disksRestoreAPI, urlValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if hasChangeState {
|
||||||
urlValues = &url.Values{}
|
urlValues = &url.Values{}
|
||||||
disk, err = utilityDiskCheckPresence(ctx, d, m)
|
disk, err = utilityDiskCheckPresence(ctx, d, m)
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
@@ -161,8 +176,7 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
d.Set("account_name", disk.AccountName)
|
d.Set("account_name", disk.AccountName)
|
||||||
d.Set("acl", string(diskAcl))
|
d.Set("acl", string(diskAcl))
|
||||||
d.Set("boot_partition", disk.BootPartition)
|
d.Set("boot_partition", disk.BootPartition)
|
||||||
d.Set("compute_id", disk.ComputeID)
|
d.Set("computes", flattenDiskComputes(disk.Computes))
|
||||||
d.Set("compute_name", disk.ComputeName)
|
|
||||||
d.Set("created_time", disk.CreatedTime)
|
d.Set("created_time", disk.CreatedTime)
|
||||||
d.Set("deleted_time", disk.DeletedTime)
|
d.Set("deleted_time", disk.DeletedTime)
|
||||||
d.Set("desc", disk.Desc)
|
d.Set("desc", disk.Desc)
|
||||||
@@ -185,6 +199,7 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
d.Set("passwd", disk.Passwd)
|
d.Set("passwd", disk.Passwd)
|
||||||
d.Set("pci_slot", disk.PciSlot)
|
d.Set("pci_slot", disk.PciSlot)
|
||||||
d.Set("pool", disk.Pool)
|
d.Set("pool", disk.Pool)
|
||||||
|
d.Set("present_to", disk.PresentTo)
|
||||||
d.Set("purge_attempts", disk.PurgeAttempts)
|
d.Set("purge_attempts", disk.PurgeAttempts)
|
||||||
d.Set("purge_time", disk.PurgeTime)
|
d.Set("purge_time", disk.PurgeTime)
|
||||||
d.Set("reality_device_number", disk.RealityDeviceNumber)
|
d.Set("reality_device_number", disk.RealityDeviceNumber)
|
||||||
@@ -196,13 +211,14 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
|||||||
d.Set("sep_type", disk.SepType)
|
d.Set("sep_type", disk.SepType)
|
||||||
d.Set("size_max", disk.SizeMax)
|
d.Set("size_max", disk.SizeMax)
|
||||||
d.Set("size_used", disk.SizeUsed)
|
d.Set("size_used", disk.SizeUsed)
|
||||||
|
d.Set("shareable", disk.Shareable)
|
||||||
d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots))
|
d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots))
|
||||||
d.Set("status", disk.Status)
|
d.Set("status", disk.Status)
|
||||||
d.Set("tech_status", disk.TechStatus)
|
d.Set("tech_status", disk.TechStatus)
|
||||||
d.Set("type", disk.Type)
|
d.Set("type", disk.Type)
|
||||||
d.Set("vmid", disk.VMID)
|
d.Set("vmid", disk.VMID)
|
||||||
|
|
||||||
return nil
|
return warnings.Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
@@ -215,18 +231,6 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if disk.Status == status.Destroyed || disk.Status == status.Purged {
|
|
||||||
return resourceDiskCreate(ctx, d, m)
|
|
||||||
} else if disk.Status == status.Deleted {
|
|
||||||
urlValues.Add("diskId", d.Id())
|
|
||||||
urlValues.Add("reason", d.Get("reason").(string))
|
|
||||||
|
|
||||||
_, err := c.DecortAPICall(ctx, "POST", disksRestoreAPI, urlValues)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
urlValues = &url.Values{}
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.HasChange("size_max") {
|
if d.HasChange("size_max") {
|
||||||
oldSize, newSize := d.GetChange("size_max")
|
oldSize, newSize := d.GetChange("size_max")
|
||||||
@@ -283,6 +287,24 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
urlValues = &url.Values{}
|
urlValues = &url.Values{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.HasChange("shareable") {
|
||||||
|
oldShare, newShare := d.GetChange("shareable")
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
urlValues.Add("diskId", d.Id())
|
||||||
|
if oldShare.(bool) == false && newShare.(bool) == true {
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", disksShareAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if oldShare.(bool) == true && newShare.(bool) == false {
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", disksUnshareAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return resourceDiskRead(ctx, d, m)
|
return resourceDiskRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,6 +363,13 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Pool for disk location",
|
Description: "Pool for disk location",
|
||||||
},
|
},
|
||||||
|
"present_to": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
},
|
||||||
"sep_id": {
|
"sep_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -360,7 +389,6 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
ValidateFunc: validation.StringInSlice([]string{"D", "B", "T"}, false),
|
ValidateFunc: validation.StringInSlice([]string{"D", "B", "T"}, false),
|
||||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
|
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
|
||||||
},
|
},
|
||||||
|
|
||||||
"detach": {
|
"detach": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -379,6 +407,11 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: "",
|
Default: "",
|
||||||
Description: "Reason for deletion",
|
Description: "Reason for deletion",
|
||||||
},
|
},
|
||||||
|
"shareable": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
|
||||||
"disk_id": {
|
"disk_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
@@ -399,15 +432,21 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Number of disk partitions",
|
Description: "Number of disk partitions",
|
||||||
},
|
},
|
||||||
"compute_id": {
|
"computes": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Compute ID",
|
Elem: &schema.Resource{
|
||||||
},
|
Schema: map[string]*schema.Schema{
|
||||||
"compute_name": {
|
"compute_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Compute name",
|
},
|
||||||
|
"compute_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"created_time": {
|
"created_time": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -80,6 +81,7 @@ func flattenImage(d *schema.ResourceData, img *ImageExtend) {
|
|||||||
d.Set("pool_name", img.Pool)
|
d.Set("pool_name", img.Pool)
|
||||||
d.Set("provider_name", img.ProviderName)
|
d.Set("provider_name", img.ProviderName)
|
||||||
d.Set("purge_attempts", img.PurgeAttempts)
|
d.Set("purge_attempts", img.PurgeAttempts)
|
||||||
|
d.Set("present_to", img.PresentTo)
|
||||||
d.Set("res_id", img.ResId)
|
d.Set("res_id", img.ResId)
|
||||||
d.Set("rescuecd", img.RescueCD)
|
d.Set("rescuecd", img.RescueCD)
|
||||||
d.Set("sep_id", img.SepId)
|
d.Set("sep_id", img.SepId)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -161,6 +162,13 @@ func dataSourceImageExtendSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"present_to": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
},
|
||||||
"res_id": {
|
"res_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -134,6 +135,7 @@ type ImageExtend struct {
|
|||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
ProviderName string `json:"provider_name"`
|
ProviderName string `json:"provider_name"`
|
||||||
|
PresentTo []int `json:"presentTo"`
|
||||||
PurgeAttempts int `json:"purgeAttempts"`
|
PurgeAttempts int `json:"purgeAttempts"`
|
||||||
ResId string `json:"resId"`
|
ResId string `json:"resId"`
|
||||||
RescueCD bool `json:"rescuecd"`
|
RescueCD bool `json:"rescuecd"`
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -31,19 +32,23 @@ Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
|||||||
|
|
||||||
package k8s
|
package k8s
|
||||||
|
|
||||||
const K8sCreateAPI = "/restmachine/cloudapi/k8s/create"
|
const (
|
||||||
const K8sGetAPI = "/restmachine/cloudapi/k8s/get"
|
K8sCreateAPI = "/restmachine/cloudapi/k8s/create"
|
||||||
const K8sUpdateAPI = "/restmachine/cloudapi/k8s/update"
|
K8sGetAPI = "/restmachine/cloudapi/k8s/get"
|
||||||
const K8sDeleteAPI = "/restmachine/cloudapi/k8s/delete"
|
K8sUpdateAPI = "/restmachine/cloudapi/k8s/update"
|
||||||
|
K8sDeleteAPI = "/restmachine/cloudapi/k8s/delete"
|
||||||
|
K8sListAPI = "/restmachine/cloudapi/k8s/list"
|
||||||
|
K8sListDeletedAPI = "/restmachine/cloudapi/k8s/listDeleted"
|
||||||
|
|
||||||
const K8sWgCreateAPI = "/restmachine/cloudapi/k8s/workersGroupAdd"
|
K8sWgCreateAPI = "/restmachine/cloudapi/k8s/workersGroupAdd"
|
||||||
const K8sWgDeleteAPI = "/restmachine/cloudapi/k8s/workersGroupDelete"
|
K8sWgDeleteAPI = "/restmachine/cloudapi/k8s/workersGroupDelete"
|
||||||
|
|
||||||
const K8sWorkerAddAPI = "/restmachine/cloudapi/k8s/workerAdd"
|
K8sWorkerAddAPI = "/restmachine/cloudapi/k8s/workerAdd"
|
||||||
const K8sWorkerDeleteAPI = "/restmachine/cloudapi/k8s/deleteWorkerFromGroup"
|
K8sWorkerDeleteAPI = "/restmachine/cloudapi/k8s/deleteWorkerFromGroup"
|
||||||
|
|
||||||
const K8sGetConfigAPI = "/restmachine/cloudapi/k8s/getConfig"
|
K8sGetConfigAPI = "/restmachine/cloudapi/k8s/getConfig"
|
||||||
|
|
||||||
const LbGetAPI = "/restmachine/cloudapi/lb/get"
|
LbGetAPI = "/restmachine/cloudapi/lb/get"
|
||||||
|
|
||||||
const AsyncTaskGetAPI = "/restmachine/cloudapi/tasks/get"
|
AsyncTaskGetAPI = "/restmachine/cloudapi/tasks/get"
|
||||||
|
)
|
||||||
|
|||||||
451
internal/service/cloudapi/k8s/data_source_k8s.go
Normal file
451
internal/service/cloudapi/k8s/data_source_k8s.go
Normal file
@@ -0,0 +1,451 @@
|
|||||||
|
/*
|
||||||
|
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 k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"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"
|
||||||
|
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
k8s, err := utilityDataK8sCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId(strconv.FormatUint(k8s.ID, 10))
|
||||||
|
|
||||||
|
k8sList, err := utilityK8sListCheckPresence(ctx, d, m, K8sListAPI)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
curK8s := K8SItem{}
|
||||||
|
for _, k8sCluster := range k8sList {
|
||||||
|
if k8sCluster.ID == k8s.ID {
|
||||||
|
curK8s = k8sCluster
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if curK8s.ID == 0 {
|
||||||
|
return diag.Errorf("Cluster with id %d not found in List clusters", k8s.ID)
|
||||||
|
}
|
||||||
|
d.Set("vins_id", curK8s.VINSID)
|
||||||
|
|
||||||
|
masterComputeList := make([]kvmvm.ComputeGetResp, 0, len(k8s.K8SGroups.Masters.DetailedInfo))
|
||||||
|
workersComputeList := make([]kvmvm.ComputeGetResp, 0, len(k8s.K8SGroups.Workers))
|
||||||
|
for _, masterNode := range k8s.K8SGroups.Masters.DetailedInfo {
|
||||||
|
compute, err := utilityComputeCheckPresence(ctx, d, m, masterNode.ID)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
masterComputeList = append(masterComputeList, *compute)
|
||||||
|
}
|
||||||
|
for _, worker := range k8s.K8SGroups.Workers {
|
||||||
|
for _, info := range worker.DetailedInfo {
|
||||||
|
compute, err := utilityComputeCheckPresence(ctx, d, m, info.ID)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
workersComputeList = append(workersComputeList, *compute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("k8sId", d.Id())
|
||||||
|
kubeconfig, err := c.DecortAPICall(ctx, "POST", K8sGetConfigAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("could not get kubeconfig: %v", err)
|
||||||
|
}
|
||||||
|
d.Set("kubeconfig", kubeconfig)
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
urlValues.Add("lbId", strconv.FormatUint(k8s.LBID, 10))
|
||||||
|
resp, err := c.DecortAPICall(ctx, "POST", LbGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var lb LbRecord
|
||||||
|
if err := json.Unmarshal([]byte(resp), &lb); err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.Set("extnet_id", lb.ExtNetID)
|
||||||
|
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
|
||||||
|
|
||||||
|
flattenK8sData(d, *k8s, masterComputeList, workersComputeList)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func aclListSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"explicit": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"user_group_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func aclGroupSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"account_acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: aclListSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"k8s_acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: aclListSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"rg_acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: aclListSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func detailedInfoSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"compute_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"interfaces": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: interfacesSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"natable_vins_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"natable_vins_network": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func interfacesSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"def_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ip_address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func masterGroupSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"detailed_info": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: detailedInfoSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"disk": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"master_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"num": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func k8sGroupListSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"annotations": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"detailed_info": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: detailedInfoSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"disk": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"num": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"taints": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceK8sSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"k8s_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
"acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: aclGroupSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"bservice_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"k8sci_id": {
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
"extnet_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
||||||
|
},
|
||||||
|
"k8s_ci_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"masters": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: masterGroupSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"workers": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: k8sGroupListSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lb_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "IP address of default load balancer.",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rg_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"kubeconfig": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Kubeconfig for cluster access.",
|
||||||
|
},
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceK8s() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceK8sRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceK8sSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
300
internal/service/cloudapi/k8s/data_source_k8s_list.go
Normal file
300
internal/service/cloudapi/k8s/data_source_k8s_list.go
Normal file
@@ -0,0 +1,300 @@
|
|||||||
|
/*
|
||||||
|
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 k8s
|
||||||
|
|
||||||
|
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 dataSourceK8sListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
k8sList, err := utilityK8sListCheckPresence(ctx, d, m, K8sListAPI)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
flattenK8sList(d, k8sList)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func serviceAccountSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func k8sWorkersGroupsSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"annotations": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"detailed_info": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: detailedInfoSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"disk": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"detailed_info_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"num": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"taints": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func createK8sListSchema() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"includedeleted": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"acl": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"bservice_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ci_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"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,
|
||||||
|
},
|
||||||
|
"extnet_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"k8s_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"k8s_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rg_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"service_account": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: serviceAccountSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"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,
|
||||||
|
},
|
||||||
|
"workers_groups": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: k8sWorkersGroupsSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceK8sListSchemaMake() map[string]*schema.Schema {
|
||||||
|
k8sListSchema := createK8sListSchema()
|
||||||
|
return k8sListSchema
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceK8sList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceK8sListRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceK8sListSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
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 k8s
|
||||||
|
|
||||||
|
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 dataSourceK8sListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
k8sList, err := utilityK8sListCheckPresence(ctx, d, m, K8sListDeletedAPI)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
flattenK8sList(d, k8sList)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceK8sListDeletedSchemaMake() map[string]*schema.Schema {
|
||||||
|
k8sListDeleted := createK8sListSchema()
|
||||||
|
delete(k8sListDeleted, "includedeleted")
|
||||||
|
return k8sListDeleted
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceK8sListDeleted() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceK8sListDeletedRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceK8sListDeletedSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
180
internal/service/cloudapi/k8s/data_source_k8s_wg.go
Normal file
180
internal/service/cloudapi/k8s/data_source_k8s_wg.go
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
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 k8s
|
||||||
|
|
||||||
|
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"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
log.Debugf("dataSourceK8sWgRead: called with k8s id %d", d.Get("k8s_id").(int))
|
||||||
|
|
||||||
|
k8s, err := utilityDataK8sCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId(strconv.Itoa(d.Get("wg_id").(int)))
|
||||||
|
|
||||||
|
var id int
|
||||||
|
if d.Id() != "" {
|
||||||
|
id, err = strconv.Atoi(d.Id())
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
id = d.Get("wg_id").(int)
|
||||||
|
}
|
||||||
|
|
||||||
|
curWg := K8SGroup{}
|
||||||
|
for _, wg := range k8s.K8SGroups.Workers {
|
||||||
|
if wg.ID == uint64(id) {
|
||||||
|
curWg = wg
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if curWg.ID == 0 {
|
||||||
|
return diag.Errorf("Not found wg with id: %v in k8s cluster: %v", id, k8s.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
workersComputeList := make([]kvmvm.ComputeGetResp, 0, 0)
|
||||||
|
for _, info := range curWg.DetailedInfo {
|
||||||
|
compute, err := utilityComputeCheckPresence(ctx, d, m, info.ID)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
workersComputeList = append(workersComputeList, *compute)
|
||||||
|
}
|
||||||
|
|
||||||
|
flattenWgData(d, curWg, workersComputeList)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceK8sWgSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"k8s_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "ID of k8s instance.",
|
||||||
|
},
|
||||||
|
"wg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "ID of k8s worker Group.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Name of the worker group.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"num": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Number of worker nodes to create.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Worker node CPU count.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Worker node RAM in MB.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"disk": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.",
|
||||||
|
},
|
||||||
|
"detailed_info": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: detailedInfoSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"taints": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceK8sWg() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceK8sWgRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceK8sWgSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
134
internal/service/cloudapi/k8s/data_source_k8s_wg_list.go
Normal file
134
internal/service/cloudapi/k8s/data_source_k8s_wg_list.go
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
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 k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"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"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityK8sWgListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (K8SGroupList, error) {
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
|
||||||
|
|
||||||
|
resp, err := c.DecortAPICall(ctx, "POST", K8sGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var k8s K8SRecord
|
||||||
|
if err := json.Unmarshal([]byte(resp), &k8s); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return k8s.K8SGroups.Workers, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceK8sWgListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
wgList, err := utilityK8sWgListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(strconv.Itoa(d.Get("k8s_id").(int)))
|
||||||
|
|
||||||
|
workersComputeList := make(map[uint64][]kvmvm.ComputeGetResp)
|
||||||
|
for _, worker := range wgList {
|
||||||
|
workersComputeList[worker.ID] = make([]kvmvm.ComputeGetResp, 0, len(worker.DetailedInfo))
|
||||||
|
for _, info := range worker.DetailedInfo {
|
||||||
|
compute, err := utilityComputeCheckPresence(ctx, d, m, info.ID)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
workersComputeList[worker.ID] = append(workersComputeList[worker.ID], *compute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flattenItemsWg(d, wgList, workersComputeList)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func wgSchemaMake() map[string]*schema.Schema {
|
||||||
|
wgSchema := dataSourceK8sWgSchemaMake()
|
||||||
|
delete(wgSchema, "k8s_id")
|
||||||
|
wgSchema["wg_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "ID of k8s worker Group.",
|
||||||
|
}
|
||||||
|
return wgSchema
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceK8sWgListSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"k8s_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: wgSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceK8sWgList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceK8sWgListRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceK8sWgListSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
319
internal/service/cloudapi/k8s/flattens.go
Normal file
319
internal/service/cloudapi/k8s/flattens.go
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
/*
|
||||||
|
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 k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func flattenAclList(aclList ACLList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, acl := range aclList {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"explicit": acl.Explicit,
|
||||||
|
"guid": acl.GUID,
|
||||||
|
"right": acl.Right,
|
||||||
|
"status": acl.Status,
|
||||||
|
"type": acl.Type,
|
||||||
|
"user_group_id": acl.UserGroupID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenAcl(acl ACLGroup) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"account_acl": flattenAclList(acl.AccountACL),
|
||||||
|
"k8s_acl": flattenAclList(acl.K8SACL),
|
||||||
|
"rg_acl": flattenAclList(acl.RGACL),
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenInterfaces(interfaces []kvmvm.InterfaceRecord) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, interfaceCompute := range interfaces {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"def_gw": interfaceCompute.DefaultGW,
|
||||||
|
"ip_address": interfaceCompute.IPAddress,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenDetailedInfo(detailedInfoList DetailedInfoList, computes []kvmvm.ComputeGetResp) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
if computes != nil {
|
||||||
|
for i, detailedInfo := range detailedInfoList {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"compute_id": detailedInfo.ID,
|
||||||
|
"name": detailedInfo.Name,
|
||||||
|
"status": detailedInfo.Status,
|
||||||
|
"tech_status": detailedInfo.TechStatus,
|
||||||
|
"interfaces": flattenInterfaces(computes[i].Interfaces),
|
||||||
|
"natable_vins_ip": computes[i].NatableVinsIP,
|
||||||
|
"natable_vins_network": computes[i].NatableVinsNet,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, detailedInfo := range detailedInfoList {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"compute_id": detailedInfo.ID,
|
||||||
|
"name": detailedInfo.Name,
|
||||||
|
"status": detailedInfo.Status,
|
||||||
|
"tech_status": detailedInfo.TechStatus,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenMasterGroup(mastersGroup MasterGroup, masters []kvmvm.ComputeGetResp) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"cpu": mastersGroup.CPU,
|
||||||
|
"detailed_info": flattenDetailedInfo(mastersGroup.DetailedInfo, masters),
|
||||||
|
"disk": mastersGroup.Disk,
|
||||||
|
"master_id": mastersGroup.ID,
|
||||||
|
"name": mastersGroup.Name,
|
||||||
|
"num": mastersGroup.Num,
|
||||||
|
"ram": mastersGroup.RAM,
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenK8sGroup(k8SGroupList K8SGroupList, workers []kvmvm.ComputeGetResp) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, k8sGroup := range k8SGroupList {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"annotations": k8sGroup.Annotations,
|
||||||
|
"cpu": k8sGroup.CPU,
|
||||||
|
"detailed_info": flattenDetailedInfo(k8sGroup.DetailedInfo, workers),
|
||||||
|
"disk": k8sGroup.Disk,
|
||||||
|
"guid": k8sGroup.GUID,
|
||||||
|
"id": k8sGroup.ID,
|
||||||
|
"labels": k8sGroup.Labels,
|
||||||
|
"name": k8sGroup.Name,
|
||||||
|
"num": k8sGroup.Num,
|
||||||
|
"ram": k8sGroup.RAM,
|
||||||
|
"taints": k8sGroup.Taints,
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenK8sGroups(k8sGroups K8SGroups, masters []kvmvm.ComputeGetResp, workers []kvmvm.ComputeGetResp) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"masters": flattenMasterGroup(k8sGroups.Masters, masters),
|
||||||
|
"workers": flattenK8sGroup(k8sGroups.Workers, workers),
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenK8sData(d *schema.ResourceData, k8s K8SRecord, masters []kvmvm.ComputeGetResp, workers []kvmvm.ComputeGetResp) {
|
||||||
|
d.Set("acl", flattenAcl(k8s.ACL))
|
||||||
|
d.Set("account_id", k8s.AccountID)
|
||||||
|
d.Set("account_name", k8s.AccountName)
|
||||||
|
d.Set("bservice_id", k8s.BServiceID)
|
||||||
|
d.Set("k8sci_id", k8s.CIID)
|
||||||
|
d.Set("created_by", k8s.CreatedBy)
|
||||||
|
d.Set("created_time", k8s.CreatedTime)
|
||||||
|
d.Set("deleted_by", k8s.DeletedBy)
|
||||||
|
d.Set("deleted_time", k8s.DeletedTime)
|
||||||
|
d.Set("k8s_ci_name", k8s.K8CIName)
|
||||||
|
d.Set("masters", flattenMasterGroup(k8s.K8SGroups.Masters, masters))
|
||||||
|
d.Set("workers", flattenK8sGroup(k8s.K8SGroups.Workers, workers))
|
||||||
|
d.Set("lb_id", k8s.LBID)
|
||||||
|
d.Set("name", k8s.Name)
|
||||||
|
d.Set("rg_id", k8s.RGID)
|
||||||
|
d.Set("rg_name", k8s.RGName)
|
||||||
|
d.Set("status", k8s.Status)
|
||||||
|
d.Set("tech_status", k8s.TechStatus)
|
||||||
|
d.Set("updated_by", k8s.UpdatedBy)
|
||||||
|
d.Set("updated_time", k8s.UpdatedTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenServiceAccount(serviceAccount ServiceAccount) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"guid": serviceAccount.GUID,
|
||||||
|
"password": serviceAccount.Password,
|
||||||
|
"username": serviceAccount.Username,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenWorkersGroup(workersGroups K8SGroupList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, worker := range workersGroups {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"annotations": worker.Annotations,
|
||||||
|
"cpu": worker.CPU,
|
||||||
|
"detailed_info": flattenDetailedInfo(worker.DetailedInfo, nil),
|
||||||
|
"disk": worker.Disk,
|
||||||
|
"guid": worker.GUID,
|
||||||
|
"detailed_info_id": worker.ID,
|
||||||
|
"labels": worker.Labels,
|
||||||
|
"name": worker.Name,
|
||||||
|
"num": worker.Num,
|
||||||
|
"ram": worker.RAM,
|
||||||
|
"taints": worker.Taints,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenConfig(config interface{}) map[string]interface{} {
|
||||||
|
return config.(map[string]interface{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenK8sItems(k8sItems K8SList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, item := range k8sItems {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"account_id": item.AccountID,
|
||||||
|
"account_name": item.Name,
|
||||||
|
"acl": item.ACL,
|
||||||
|
"bservice_id": item.BServiceID,
|
||||||
|
"ci_id": item.CIID,
|
||||||
|
"created_by": item.CreatedBy,
|
||||||
|
"created_time": item.CreatedTime,
|
||||||
|
"deleted_by": item.DeletedBy,
|
||||||
|
"deleted_time": item.DeletedTime,
|
||||||
|
"desc": item.Description,
|
||||||
|
"extnet_id": item.ExtNetID,
|
||||||
|
"gid": item.GID,
|
||||||
|
"guid": item.GUID,
|
||||||
|
"k8s_id": item.ID,
|
||||||
|
"lb_id": item.LBID,
|
||||||
|
"milestones": item.Milestones,
|
||||||
|
"k8s_name": item.Name,
|
||||||
|
"rg_id": item.RGID,
|
||||||
|
"rg_name": item.RGName,
|
||||||
|
"service_account": flattenServiceAccount(item.ServiceAccount),
|
||||||
|
"status": item.Status,
|
||||||
|
"tech_status": item.TechStatus,
|
||||||
|
"updated_by": item.UpdatedBy,
|
||||||
|
"updated_time": item.UpdatedTime,
|
||||||
|
"vins_id": item.VINSID,
|
||||||
|
"workers_groups": flattenWorkersGroup(item.WorkersGroup),
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenK8sList(d *schema.ResourceData, k8sItems K8SList) {
|
||||||
|
d.Set("items", flattenK8sItems(k8sItems))
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenResourceK8s(d *schema.ResourceData, k8s K8SRecord, masters []kvmvm.ComputeGetResp, workers []kvmvm.ComputeGetResp) {
|
||||||
|
d.Set("acl", flattenAcl(k8s.ACL))
|
||||||
|
d.Set("account_id", k8s.AccountID)
|
||||||
|
d.Set("account_name", k8s.AccountName)
|
||||||
|
d.Set("bservice_id", k8s.BServiceID)
|
||||||
|
d.Set("created_by", k8s.CreatedBy)
|
||||||
|
d.Set("created_time", k8s.CreatedTime)
|
||||||
|
d.Set("deleted_by", k8s.DeletedBy)
|
||||||
|
d.Set("deleted_time", k8s.DeletedTime)
|
||||||
|
d.Set("k8s_ci_name", k8s.K8CIName)
|
||||||
|
d.Set("masters", flattenMasterGroup(k8s.K8SGroups.Masters, masters))
|
||||||
|
d.Set("workers", flattenK8sGroup(k8s.K8SGroups.Workers, workers))
|
||||||
|
d.Set("lb_id", k8s.LBID)
|
||||||
|
d.Set("rg_id", k8s.RGID)
|
||||||
|
d.Set("rg_name", k8s.RGName)
|
||||||
|
d.Set("status", k8s.Status)
|
||||||
|
d.Set("tech_status", k8s.TechStatus)
|
||||||
|
d.Set("updated_by", k8s.UpdatedBy)
|
||||||
|
d.Set("updated_time", k8s.UpdatedTime)
|
||||||
|
d.Set("default_wg_id", k8s.K8SGroups.Workers[0].ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenWgData(d *schema.ResourceData, wg K8SGroup, computes []kvmvm.ComputeGetResp) {
|
||||||
|
d.Set("annotations", wg.Annotations)
|
||||||
|
d.Set("cpu", wg.CPU)
|
||||||
|
d.Set("detailed_info", flattenDetailedInfo(wg.DetailedInfo, computes))
|
||||||
|
d.Set("disk", wg.Disk)
|
||||||
|
d.Set("guid", wg.GUID)
|
||||||
|
d.Set("labels", wg.Labels)
|
||||||
|
d.Set("name", wg.Name)
|
||||||
|
d.Set("num", wg.Num)
|
||||||
|
d.Set("ram", wg.RAM)
|
||||||
|
d.Set("taints", wg.Taints)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenWgList(wgList K8SGroupList, computesMap map[uint64][]kvmvm.ComputeGetResp) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, wg := range wgList {
|
||||||
|
computes := computesMap[wg.ID]
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"annotations": wg.Annotations,
|
||||||
|
"cpu": wg.CPU,
|
||||||
|
"wg_id": wg.ID,
|
||||||
|
"detailed_info": flattenDetailedInfo(wg.DetailedInfo, computes),
|
||||||
|
"disk": wg.Disk,
|
||||||
|
"guid": wg.GUID,
|
||||||
|
"labels": wg.Labels,
|
||||||
|
"name": wg.Name,
|
||||||
|
"num": wg.Num,
|
||||||
|
"ram": wg.RAM,
|
||||||
|
"taints": wg.Taints,
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenItemsWg(d *schema.ResourceData, wgList K8SGroupList, computes map[uint64][]kvmvm.ComputeGetResp) {
|
||||||
|
d.Set("items", flattenWgList(wgList, computes))
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -48,6 +49,8 @@ type K8sNodeRecord struct {
|
|||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
} `json:"detailedInfo"`
|
} `json:"detailedInfo"`
|
||||||
|
SepID int `json:"SepId"`
|
||||||
|
SepPool string `json:"SepPool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//K8sRecord represents k8s instance
|
//K8sRecord represents k8s instance
|
||||||
@@ -64,8 +67,11 @@ type K8sRecord struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
RgID int `json:"rgId"`
|
RgID int `json:"rgId"`
|
||||||
RgName string `json:"rgName"`
|
RgName string `json:"rgName"`
|
||||||
|
VinsID int `json:"vinsId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type K8sRecordList []K8sRecord
|
||||||
|
|
||||||
//LbRecord represents load balancer instance
|
//LbRecord represents load balancer instance
|
||||||
type LbRecord struct {
|
type LbRecord struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
@@ -129,3 +135,124 @@ type SshKeyConfig struct {
|
|||||||
SshKey string
|
SshKey string
|
||||||
UserShell string
|
UserShell string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FromSDK
|
||||||
|
type K8SGroup struct {
|
||||||
|
Annotations []string `json:"annotations"`
|
||||||
|
CPU uint64 `json:"cpu"`
|
||||||
|
DetailedInfo DetailedInfoList `json:"detailedInfo"`
|
||||||
|
Disk uint64 `json:"disk"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
Labels []string `json:"labels"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Num uint64 `json:"num"`
|
||||||
|
RAM uint64 `json:"ram"`
|
||||||
|
Taints []string `json:"taints"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type K8SGroupList []K8SGroup
|
||||||
|
|
||||||
|
type DetailedInfo struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DetailedInfoList []DetailedInfo
|
||||||
|
|
||||||
|
type K8SRecord struct {
|
||||||
|
ACL ACLGroup `json:"ACL"`
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
AccountName string `json:"accountName"`
|
||||||
|
BServiceID uint64 `json:"bserviceId"`
|
||||||
|
CIID uint64 `json:"ciId"`
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
K8CIName string `json:"k8ciName"`
|
||||||
|
K8SGroups K8SGroups `json:"k8sGroups"`
|
||||||
|
LBID uint64 `json:"lbId"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
RGID uint64 `json:"rgId"`
|
||||||
|
RGName string `json:"rgName"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type K8SRecordList []K8SRecord
|
||||||
|
|
||||||
|
type K8SGroups struct {
|
||||||
|
Masters MasterGroup `json:"masters"`
|
||||||
|
Workers K8SGroupList `json:"workers"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MasterGroup struct {
|
||||||
|
CPU uint64 `json:"cpu"`
|
||||||
|
DetailedInfo DetailedInfoList `json:"detailedInfo"`
|
||||||
|
Disk uint64 `json:"disk"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Num uint64 `json:"num"`
|
||||||
|
RAM uint64 `json:"ram"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ACLGroup struct {
|
||||||
|
AccountACL ACLList `json:"accountAcl"`
|
||||||
|
K8SACL ACLList `json:"k8sAcl"`
|
||||||
|
RGACL ACLList `json:"rgAcl"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ACL struct {
|
||||||
|
Explicit bool `json:"explicit"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
Right string `json:"right"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
UserGroupID string `json:"userGroupId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ACLList []ACL
|
||||||
|
|
||||||
|
type K8SItem struct {
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
AccountName string `json:"accountName"`
|
||||||
|
ACL []interface{} `json:"acl"`
|
||||||
|
BServiceID uint64 `json:"bserviceId"`
|
||||||
|
CIID uint64 `json:"ciId"`
|
||||||
|
Config interface{} `json:"config"`
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
Description string `json:"desc"`
|
||||||
|
ExtNetID uint64 `json:"extnetId"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LBID uint64 `json:"lbId"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
RGID uint64 `json:"rgId"`
|
||||||
|
RGName string `json:"rgName"`
|
||||||
|
ServiceAccount ServiceAccount `json:"serviceAccount"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
VINSID uint64 `json:"vinsId"`
|
||||||
|
WorkersGroup K8SGroupList `json:"workersGroups"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServiceAccount struct {
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type K8SList []K8SItem
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -55,10 +56,12 @@ func parseNode(nodeList []interface{}) K8sNodeRecord {
|
|||||||
node := nodeList[0].(map[string]interface{})
|
node := nodeList[0].(map[string]interface{})
|
||||||
|
|
||||||
return K8sNodeRecord{
|
return K8sNodeRecord{
|
||||||
Num: node["num"].(int),
|
Num: node["num"].(int),
|
||||||
Cpu: node["cpu"].(int),
|
Cpu: node["cpu"].(int),
|
||||||
Ram: node["ram"].(int),
|
Ram: node["ram"].(int),
|
||||||
Disk: node["disk"].(int),
|
Disk: node["disk"].(int),
|
||||||
|
SepID: node["sep_id"].(int),
|
||||||
|
SepPool: node["sep_pool"].(string),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,3 +106,75 @@ func nodeK8sSubresourceSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mastersSchemaMake() map[string]*schema.Schema {
|
||||||
|
masters := masterGroupSchemaMake()
|
||||||
|
masters["num"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Number of nodes to create.",
|
||||||
|
}
|
||||||
|
masters["sep_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
masters["sep_pool"] = &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
masters["cpu"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "Node CPU count.",
|
||||||
|
}
|
||||||
|
masters["ram"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "Node RAM in MB.",
|
||||||
|
}
|
||||||
|
masters["disk"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "Node boot disk size in GB.",
|
||||||
|
}
|
||||||
|
return masters
|
||||||
|
}
|
||||||
|
|
||||||
|
func workersSchemaMake() map[string]*schema.Schema {
|
||||||
|
workers := k8sGroupListSchemaMake()
|
||||||
|
workers["num"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Number of nodes to create.",
|
||||||
|
}
|
||||||
|
workers["sep_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
workers["sep_pool"] = &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
workers["cpu"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "Node CPU count.",
|
||||||
|
}
|
||||||
|
workers["ram"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "Node RAM in MB.",
|
||||||
|
}
|
||||||
|
workers["disk"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Description: "Node boot disk size in GB.",
|
||||||
|
}
|
||||||
|
return workers
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -44,6 +45,7 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -67,6 +69,8 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
urlValues.Add("masterCpu", strconv.Itoa(masterNode.Cpu))
|
urlValues.Add("masterCpu", strconv.Itoa(masterNode.Cpu))
|
||||||
urlValues.Add("masterRam", strconv.Itoa(masterNode.Ram))
|
urlValues.Add("masterRam", strconv.Itoa(masterNode.Ram))
|
||||||
urlValues.Add("masterDisk", strconv.Itoa(masterNode.Disk))
|
urlValues.Add("masterDisk", strconv.Itoa(masterNode.Disk))
|
||||||
|
urlValues.Add("masterSepId", strconv.Itoa(masterNode.SepID))
|
||||||
|
urlValues.Add("masterSepPool", masterNode.SepPool)
|
||||||
|
|
||||||
var workerNode K8sNodeRecord
|
var workerNode K8sNodeRecord
|
||||||
if workers, ok := d.GetOk("workers"); ok {
|
if workers, ok := d.GetOk("workers"); ok {
|
||||||
@@ -78,11 +82,35 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
urlValues.Add("workerCpu", strconv.Itoa(workerNode.Cpu))
|
urlValues.Add("workerCpu", strconv.Itoa(workerNode.Cpu))
|
||||||
urlValues.Add("workerRam", strconv.Itoa(workerNode.Ram))
|
urlValues.Add("workerRam", strconv.Itoa(workerNode.Ram))
|
||||||
urlValues.Add("workerDisk", strconv.Itoa(workerNode.Disk))
|
urlValues.Add("workerDisk", strconv.Itoa(workerNode.Disk))
|
||||||
|
urlValues.Add("workerSepId", strconv.Itoa(workerNode.SepID))
|
||||||
|
urlValues.Add("workerSepPool", workerNode.SepPool)
|
||||||
|
|
||||||
//if withLB, ok := d.GetOk("with_lb"); ok {
|
if labels, ok := d.GetOk("labels"); ok {
|
||||||
//urlValues.Add("withLB", strconv.FormatBool(withLB.(bool)))
|
labels := labels.([]interface{})
|
||||||
//}
|
for _, label := range labels {
|
||||||
urlValues.Add("withLB", strconv.FormatBool(true))
|
urlValues.Add("labels", label.(string))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if taints, ok := d.GetOk("taints"); ok {
|
||||||
|
taints := taints.([]interface{})
|
||||||
|
for _, taint := range taints {
|
||||||
|
urlValues.Add("taints", taint.(string))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if annotations, ok := d.GetOk("annotations"); ok {
|
||||||
|
annotations := annotations.([]interface{})
|
||||||
|
for _, annotation := range annotations {
|
||||||
|
urlValues.Add("annotations", annotation.(string))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if withLB, ok := d.GetOk("with_lb"); ok {
|
||||||
|
urlValues.Add("withLB", strconv.FormatBool(withLB.(bool)))
|
||||||
|
} else {
|
||||||
|
urlValues.Add("withLB", strconv.FormatBool(true))
|
||||||
|
}
|
||||||
|
|
||||||
if extNet, ok := d.GetOk("extnet_id"); ok {
|
if extNet, ok := d.GetOk("extnet_id"); ok {
|
||||||
urlValues.Add("extnetId", strconv.Itoa(extNet.(int)))
|
urlValues.Add("extnetId", strconv.Itoa(extNet.(int)))
|
||||||
@@ -90,9 +118,9 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
urlValues.Add("extnetId", "0")
|
urlValues.Add("extnetId", "0")
|
||||||
}
|
}
|
||||||
|
|
||||||
//if desc, ok := d.GetOk("desc"); ok {
|
if desc, ok := d.GetOk("desc"); ok {
|
||||||
//urlValues.Add("desc", desc.(string))
|
urlValues.Add("desc", desc.(string))
|
||||||
//}
|
}
|
||||||
|
|
||||||
resp, err := c.DecortAPICall(ctx, "POST", K8sCreateAPI, urlValues)
|
resp, err := c.DecortAPICall(ctx, "POST", K8sCreateAPI, urlValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -126,59 +154,56 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
time.Sleep(time.Second * 10)
|
time.Sleep(time.Second * 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
k8s, err := utilityK8sCheckPresence(ctx, d, m)
|
return resourceK8sRead(ctx, d, m)
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.Set("default_wg_id", k8s.Groups.Workers[0].ID)
|
|
||||||
|
|
||||||
urlValues = &url.Values{}
|
|
||||||
urlValues.Add("lbId", strconv.Itoa(k8s.LbID))
|
|
||||||
|
|
||||||
resp, err = c.DecortAPICall(ctx, "POST", LbGetAPI, urlValues)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var lb LbRecord
|
|
||||||
if err := json.Unmarshal([]byte(resp), &lb); err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
d.Set("extnet_id", lb.ExtNetID)
|
|
||||||
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
|
|
||||||
|
|
||||||
urlValues = &url.Values{}
|
|
||||||
urlValues.Add("k8sId", d.Id())
|
|
||||||
kubeconfig, err := c.DecortAPICall(ctx, "POST", K8sGetConfigAPI, urlValues)
|
|
||||||
if err != nil {
|
|
||||||
log.Warnf("could not get kubeconfig: %v", err)
|
|
||||||
}
|
|
||||||
d.Set("kubeconfig", kubeconfig)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceK8sRead: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
|
|
||||||
|
|
||||||
k8s, err := utilityK8sCheckPresence(ctx, d, m)
|
k8s, err := utilityDataK8sCheckPresence(ctx, d, m)
|
||||||
if k8s == nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
k8sList, err := utilityK8sListCheckPresence(ctx, d, m, K8sListAPI)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
curK8s := K8SItem{}
|
||||||
|
for _, k8sCluster := range k8sList {
|
||||||
|
if k8sCluster.ID == k8s.ID {
|
||||||
|
curK8s = k8sCluster
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if curK8s.ID == 0 {
|
||||||
|
return diag.Errorf("Cluster with id %d not found", k8s.ID)
|
||||||
|
}
|
||||||
|
d.Set("vins_id", curK8s.VINSID)
|
||||||
|
|
||||||
d.Set("name", k8s.Name)
|
masterComputeList := make([]kvmvm.ComputeGetResp, 0, len(k8s.K8SGroups.Masters.DetailedInfo))
|
||||||
d.Set("rg_id", k8s.RgID)
|
workersComputeList := make([]kvmvm.ComputeGetResp, 0, len(k8s.K8SGroups.Workers))
|
||||||
d.Set("k8sci_id", k8s.CI)
|
for _, masterNode := range k8s.K8SGroups.Masters.DetailedInfo {
|
||||||
d.Set("wg_name", k8s.Groups.Workers[0].Name)
|
compute, err := utilityComputeCheckPresence(ctx, d, m, masterNode.ID)
|
||||||
d.Set("masters", nodeToResource(k8s.Groups.Masters))
|
if err != nil {
|
||||||
d.Set("workers", nodeToResource(k8s.Groups.Workers[0]))
|
return diag.FromErr(err)
|
||||||
d.Set("default_wg_id", k8s.Groups.Workers[0].ID)
|
}
|
||||||
|
masterComputeList = append(masterComputeList, *compute)
|
||||||
|
}
|
||||||
|
for _, worker := range k8s.K8SGroups.Workers {
|
||||||
|
for _, info := range worker.DetailedInfo {
|
||||||
|
compute, err := utilityComputeCheckPresence(ctx, d, m, info.ID)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
workersComputeList = append(workersComputeList, *compute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flattenResourceK8s(d, *k8s, masterComputeList, workersComputeList)
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
urlValues.Add("lbId", strconv.Itoa(k8s.LbID))
|
urlValues.Add("lbId", strconv.FormatUint(k8s.LBID, 10))
|
||||||
|
|
||||||
resp, err := c.DecortAPICall(ctx, "POST", LbGetAPI, urlValues)
|
resp, err := c.DecortAPICall(ctx, "POST", LbGetAPI, urlValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -225,21 +250,21 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
wg := k8s.Groups.Workers[0]
|
wg := k8s.K8SGroups.Workers[0]
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
urlValues.Add("k8sId", d.Id())
|
urlValues.Add("k8sId", d.Id())
|
||||||
urlValues.Add("workersGroupId", strconv.Itoa(wg.ID))
|
urlValues.Add("workersGroupId", strconv.FormatUint(wg.ID, 10))
|
||||||
|
|
||||||
newWorkers := parseNode(d.Get("workers").([]interface{}))
|
newWorkers := parseNode(d.Get("workers").([]interface{}))
|
||||||
|
|
||||||
if newWorkers.Num > wg.Num {
|
if uint64(newWorkers.Num) > wg.Num {
|
||||||
urlValues.Add("num", strconv.Itoa(newWorkers.Num-wg.Num))
|
urlValues.Add("num", strconv.FormatUint(uint64(newWorkers.Num)-wg.Num, 10))
|
||||||
if _, err := c.DecortAPICall(ctx, "POST", K8sWorkerAddAPI, urlValues); err != nil {
|
if _, err := c.DecortAPICall(ctx, "POST", K8sWorkerAddAPI, urlValues); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i := wg.Num - 1; i >= newWorkers.Num; i-- {
|
for i := int(wg.Num) - 1; i >= newWorkers.Num; i-- {
|
||||||
urlValues.Set("workerId", strconv.Itoa(wg.DetailedInfo[i].ID))
|
urlValues.Set("workerId", strconv.FormatUint(wg.DetailedInfo[i].ID, 10))
|
||||||
if _, err := c.DecortAPICall(ctx, "POST", K8sWorkerDeleteAPI, urlValues); err != nil {
|
if _, err := c.DecortAPICall(ctx, "POST", K8sWorkerDeleteAPI, urlValues); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -281,57 +306,73 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
Required: true,
|
Required: true,
|
||||||
Description: "Name of the cluster.",
|
Description: "Name of the cluster.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "Resource group ID that this instance belongs to.",
|
Description: "Resource group ID that this instance belongs to.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"k8sci_id": {
|
"k8sci_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "ID of the k8s catalog item to base this instance on.",
|
Description: "ID of the k8s catalog item to base this instance on.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"wg_name": {
|
"wg_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "Name for first worker group created with cluster.",
|
Description: "Name for first worker group created with cluster.",
|
||||||
},
|
},
|
||||||
|
"labels": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"taints": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
"masters": {
|
"masters": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
MaxItems: 1,
|
MaxItems: 1,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: nodeK8sSubresourceSchemaMake(),
|
Schema: mastersSchemaMake(),
|
||||||
},
|
},
|
||||||
Description: "Master node(s) configuration.",
|
Description: "Master node(s) configuration.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"workers": {
|
"workers": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
MaxItems: 1,
|
MaxItems: 1,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: nodeK8sSubresourceSchemaMake(),
|
Schema: workersSchemaMake(),
|
||||||
},
|
},
|
||||||
Description: "Worker node(s) configuration.",
|
Description: "Worker node(s) configuration.",
|
||||||
},
|
},
|
||||||
|
"with_lb": {
|
||||||
//"with_lb": {
|
Type: schema.TypeBool,
|
||||||
//Type: schema.TypeBool,
|
Optional: true,
|
||||||
//Optional: true,
|
ForceNew: true,
|
||||||
//ForceNew: true,
|
Default: true,
|
||||||
//Default: true,
|
Description: "Create k8s with load balancer if true.",
|
||||||
//Description: "Create k8s with load balancer if true.",
|
},
|
||||||
//},
|
|
||||||
|
|
||||||
"extnet_id": {
|
"extnet_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@@ -339,30 +380,95 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
|
||||||
},
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Text description of this instance.",
|
||||||
|
},
|
||||||
|
|
||||||
//"desc": {
|
"acl": {
|
||||||
//Type: schema.TypeString,
|
Type: schema.TypeList,
|
||||||
//Optional: true,
|
Computed: true,
|
||||||
//Description: "Text description of this instance.",
|
Elem: &schema.Resource{
|
||||||
//},
|
Schema: aclGroupSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"bservice_id": {
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
"k8s_ci_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lb_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"lb_ip": {
|
"lb_ip": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "IP address of default load balancer.",
|
Description: "IP address of default load balancer.",
|
||||||
},
|
},
|
||||||
|
"rg_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
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,
|
||||||
|
},
|
||||||
"default_wg_id": {
|
"default_wg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "ID of default workers group for this instace.",
|
Description: "ID of default workers group for this instace.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"kubeconfig": {
|
"kubeconfig": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Kubeconfig for cluster access.",
|
Description: "Kubeconfig for cluster access.",
|
||||||
},
|
},
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "ID of default vins for this instace.",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,7 +486,7 @@ func ResourceK8s() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Create: &constants.Timeout600s,
|
Create: &constants.Timeout30m,
|
||||||
Read: &constants.Timeout300s,
|
Read: &constants.Timeout300s,
|
||||||
Update: &constants.Timeout300s,
|
Update: &constants.Timeout300s,
|
||||||
Delete: &constants.Timeout300s,
|
Delete: &constants.Timeout300s,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -35,11 +36,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -91,23 +94,51 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
//time.Sleep(time.Second * 5)
|
//time.Sleep(time.Second * 5)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return nil
|
return resourceK8sWgRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceK8sWgRead: called with k8s id %d", d.Get("k8s_id").(int))
|
log.Debugf("resourceK8sWgRead: called with %v", d.Id())
|
||||||
|
|
||||||
wg, err := utilityK8sWgCheckPresence(ctx, d, m)
|
k8s, err := utilityDataK8sCheckPresence(ctx, d, m)
|
||||||
if wg == nil {
|
if err != nil {
|
||||||
d.SetId("")
|
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("name", wg.Name)
|
var id int
|
||||||
d.Set("num", wg.Num)
|
if d.Id() != "" {
|
||||||
d.Set("cpu", wg.Cpu)
|
id, err = strconv.Atoi(strings.Split(d.Id(), "#")[0])
|
||||||
d.Set("ram", wg.Ram)
|
if err != nil {
|
||||||
d.Set("disk", wg.Disk)
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
id = d.Get("wg_id").(int)
|
||||||
|
}
|
||||||
|
|
||||||
|
curWg := K8SGroup{}
|
||||||
|
for _, wg := range k8s.K8SGroups.Workers {
|
||||||
|
if wg.ID == uint64(id) {
|
||||||
|
curWg = wg
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if curWg.ID == 0 {
|
||||||
|
return diag.Errorf("Not found wg with id: %v in k8s cluster: %v", id, k8s.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
workersComputeList := make([]kvmvm.ComputeGetResp, 0, 0)
|
||||||
|
for _, info := range curWg.DetailedInfo {
|
||||||
|
compute, err := utilityComputeCheckPresence(ctx, d, m, info.ID)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
workersComputeList = append(workersComputeList, *compute)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(strings.Split(d.Id(), "#")[0])
|
||||||
|
d.Set("k8s_id", k8s.ID)
|
||||||
|
d.Set("wg_id", curWg.ID)
|
||||||
|
flattenWgData(d, curWg, workersComputeList)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -126,15 +157,15 @@ func resourceK8sWgUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
|
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
|
||||||
urlValues.Add("workersGroupId", d.Id())
|
urlValues.Add("workersGroupId", d.Id())
|
||||||
|
|
||||||
if newNum := d.Get("num").(int); newNum > wg.Num {
|
if newNum := d.Get("num").(int); uint64(newNum) > wg.Num {
|
||||||
urlValues.Add("num", strconv.Itoa(newNum-wg.Num))
|
urlValues.Add("num", strconv.FormatUint(uint64(newNum)-wg.Num, 10))
|
||||||
_, err := c.DecortAPICall(ctx, "POST", K8sWorkerAddAPI, urlValues)
|
_, err := c.DecortAPICall(ctx, "POST", K8sWorkerAddAPI, urlValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i := wg.Num - 1; i >= newNum; i-- {
|
for i := int(wg.Num) - 1; i >= newNum; i-- {
|
||||||
urlValues.Set("workerId", strconv.Itoa(wg.DetailedInfo[i].ID))
|
urlValues.Set("workerId", strconv.FormatUint(wg.DetailedInfo[i].ID, 10))
|
||||||
_, err := c.DecortAPICall(ctx, "POST", K8sWorkerDeleteAPI, urlValues)
|
_, err := c.DecortAPICall(ctx, "POST", K8sWorkerDeleteAPI, urlValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
@@ -159,7 +190,7 @@ func resourceK8sWgDelete(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
|
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
|
||||||
urlValues.Add("workersGroupId", strconv.Itoa(wg.ID))
|
urlValues.Add("workersGroupId", strconv.FormatUint(wg.ID, 10))
|
||||||
|
|
||||||
_, err = c.DecortAPICall(ctx, "POST", K8sWgDeleteAPI, urlValues)
|
_, err = c.DecortAPICall(ctx, "POST", K8sWgDeleteAPI, urlValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -215,6 +246,43 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
|
|||||||
Default: 0,
|
Default: 0,
|
||||||
Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.",
|
Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.",
|
||||||
},
|
},
|
||||||
|
"wg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "ID of k8s worker Group.",
|
||||||
|
},
|
||||||
|
"detailed_info": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: detailedInfoSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"labels": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"taints": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -35,12 +36,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityK8sCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*K8sRecord, error) {
|
func utilityK8sCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*K8SRecord, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
urlValues.Add("k8sId", d.Id())
|
urlValues.Add("k8sId", d.Id())
|
||||||
@@ -54,10 +58,76 @@ func utilityK8sCheckPresence(ctx context.Context, d *schema.ResourceData, m inte
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var k8s K8sRecord
|
k8s := K8SRecord{}
|
||||||
if err := json.Unmarshal([]byte(resp), &k8s); err != nil {
|
if err := json.Unmarshal([]byte(resp), &k8s); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &k8s, nil
|
return &k8s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func utilityComputeCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}, computeID uint64) (*kvmvm.ComputeGetResp, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
urlValues.Add("computeId", strconv.FormatUint(computeID, 10))
|
||||||
|
|
||||||
|
computeRaw, err := c.DecortAPICall(ctx, "POST", kvmvm.ComputeGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
compute := &kvmvm.ComputeGetResp{}
|
||||||
|
err = json.Unmarshal([]byte(computeRaw), compute)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return compute, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func utilityDataK8sCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*K8SRecord, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
if d.Get("k8s_id") != 0 && d.Get("k8s_id") != nil {
|
||||||
|
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
|
||||||
|
} else if id := d.Id(); id != "" {
|
||||||
|
if strings.Contains(id, "#") {
|
||||||
|
urlValues.Add("k8sId", strings.Split(d.Id(), "#")[1])
|
||||||
|
} else {
|
||||||
|
urlValues.Add("k8sId", d.Id())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
k8sRaw, err := c.DecortAPICall(ctx, "POST", K8sGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
k8s := &K8SRecord{}
|
||||||
|
err = json.Unmarshal([]byte(k8sRaw), k8s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return k8s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}, api string) (K8SList, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("includedeleted", "false")
|
||||||
|
urlValues.Add("page", "0")
|
||||||
|
urlValues.Add("size", "0")
|
||||||
|
|
||||||
|
k8sListRaw, err := c.DecortAPICall(ctx, "POST", api, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
k8sList := K8SList{}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(k8sListRaw), &k8sList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return k8sList, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -34,6 +35,7 @@ package k8s
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ import (
|
|||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityK8sWgCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*K8sNodeRecord, error) {
|
func utilityK8sWgCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*K8SGroup, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
|
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
|
||||||
@@ -52,24 +54,29 @@ func utilityK8sWgCheckPresence(ctx context.Context, d *schema.ResourceData, m in
|
|||||||
}
|
}
|
||||||
|
|
||||||
if resp == "" {
|
if resp == "" {
|
||||||
return nil, nil
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var k8s K8sRecord
|
var k8s K8SRecord
|
||||||
if err := json.Unmarshal([]byte(resp), &k8s); err != nil {
|
if err := json.Unmarshal([]byte(resp), &k8s); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := strconv.Atoi(d.Id())
|
var id int
|
||||||
if err != nil {
|
if d.Id() != "" {
|
||||||
return nil, err
|
id, err = strconv.Atoi(d.Id())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
id = d.Get("wg_id").(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, wg := range k8s.Groups.Workers {
|
for _, wg := range k8s.K8SGroups.Workers {
|
||||||
if wg.ID == id {
|
if wg.ID == uint64(id) {
|
||||||
return &wg, nil
|
return &wg, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, fmt.Errorf("Not found wg with id: %v in k8s cluster: %v", id, k8s.ID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,4 +49,17 @@ const (
|
|||||||
ComputeUpdateAPI = "/restmachine/cloudapi/compute/update"
|
ComputeUpdateAPI = "/restmachine/cloudapi/compute/update"
|
||||||
ComputeDiskAddAPI = "/restmachine/cloudapi/compute/diskAdd"
|
ComputeDiskAddAPI = "/restmachine/cloudapi/compute/diskAdd"
|
||||||
ComputeDiskDeleteAPI = "/restmachine/cloudapi/compute/diskDel"
|
ComputeDiskDeleteAPI = "/restmachine/cloudapi/compute/diskDel"
|
||||||
|
ComputeRestoreAPI = "/restmachine/cloudapi/compute/restore"
|
||||||
|
ComputeEnableAPI = "/restmachine/cloudapi/compute/enable"
|
||||||
|
ComputeDisableAPI = "/restmachine/cloudapi/compute/disable"
|
||||||
|
|
||||||
|
//affinity and anti-affinity
|
||||||
|
ComputeAffinityLabelSetAPI = "/restmachine/cloudapi/compute/affinityLabelSet"
|
||||||
|
ComputeAffinityLabelRemoveAPI = "/restmachine/cloudapi/compute/affinityLabelRemove"
|
||||||
|
ComputeAffinityRuleAddAPI = "/restmachine/cloudapi/compute/affinityRuleAdd"
|
||||||
|
ComputeAffinityRuleRemoveAPI = "/restmachine/cloudapi/compute/affinityRuleRemove"
|
||||||
|
ComputeAffinityRulesClearAPI = "/restmachine/cloudapi/compute/affinityRulesClear"
|
||||||
|
ComputeAntiAffinityRuleAddAPI = "/restmachine/cloudapi/compute/antiAffinityRuleAdd"
|
||||||
|
ComputeAntiAffinityRuleRemoveAPI = "/restmachine/cloudapi/compute/antiAffinityRuleRemove"
|
||||||
|
ComputeAntiAffinityRulesClearAPI = "/restmachine/cloudapi/compute/antiAffinityRulesClear"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import (
|
|||||||
// "net/url"
|
// "net/url"
|
||||||
|
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/status"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
@@ -123,10 +124,10 @@ func findInExtraDisks(DiskId uint, ExtraDisks []interface{}) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenComputeDisksDemo(disksList []DiskRecord, extraDisks []interface{}) []map[string]interface{} {
|
func flattenDataComputeDisksDemo(disksList []DiskRecord, extraDisks []interface{}) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, disk := range disksList {
|
for _, disk := range disksList {
|
||||||
if disk.Name == "bootdisk" || findInExtraDisks(disk.ID, extraDisks) { //skip main bootdisk and extraDisks
|
if findInExtraDisks(disk.ID, extraDisks) { //skip main bootdisk and extraDisks
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
@@ -134,6 +135,9 @@ func flattenComputeDisksDemo(disksList []DiskRecord, extraDisks []interface{}) [
|
|||||||
"disk_id": disk.ID,
|
"disk_id": disk.ID,
|
||||||
"disk_type": disk.Type,
|
"disk_type": disk.Type,
|
||||||
"sep_id": disk.SepID,
|
"sep_id": disk.SepID,
|
||||||
|
"shareable": disk.Shareable,
|
||||||
|
"size_max": disk.SizeMax,
|
||||||
|
"size_used": disk.SizeUsed,
|
||||||
"pool": disk.Pool,
|
"pool": disk.Pool,
|
||||||
"desc": disk.Desc,
|
"desc": disk.Desc,
|
||||||
"image_id": disk.ImageID,
|
"image_id": disk.ImageID,
|
||||||
@@ -144,7 +148,7 @@ func flattenComputeDisksDemo(disksList []DiskRecord, extraDisks []interface{}) [
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenCompute(d *schema.ResourceData, compFacts string) error {
|
func flattenDataCompute(d *schema.ResourceData, compFacts string) error {
|
||||||
// This function expects that compFacts string contains response from API compute/get,
|
// This function expects that compFacts string contains response from API compute/get,
|
||||||
// i.e. detailed information about compute instance.
|
// i.e. detailed information about compute instance.
|
||||||
//
|
//
|
||||||
@@ -176,14 +180,17 @@ func flattenCompute(d *schema.ResourceData, compFacts string) error {
|
|||||||
d.Set("image_id", model.ImageID)
|
d.Set("image_id", model.ImageID)
|
||||||
}
|
}
|
||||||
d.Set("description", model.Desc)
|
d.Set("description", model.Desc)
|
||||||
d.Set("cloud_init", "applied") // NOTE: for existing compute we hard-code this value as an indicator for DiffSuppress fucntion
|
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("status", model.Status)
|
||||||
// d.Set("tech_status", model.TechStatus)
|
// d.Set("tech_status", model.TechStatus)
|
||||||
|
d.Set("started", false)
|
||||||
if model.TechStatus == "STARTED" {
|
if model.TechStatus == "STARTED" {
|
||||||
d.Set("started", true)
|
d.Set("started", true)
|
||||||
} else {
|
|
||||||
d.Set("started", false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bootDisk := findBootDisk(model.Disks)
|
bootDisk := findBootDisk(model.Disks)
|
||||||
@@ -214,7 +221,7 @@ func flattenCompute(d *schema.ResourceData, compFacts string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = d.Set("disks", flattenComputeDisksDemo(model.Disks, d.Get("extra_disks").(*schema.Set).List()))
|
err = d.Set("disks", flattenDataComputeDisksDemo(model.Disks, d.Get("extra_disks").(*schema.Set).List()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -231,7 +238,7 @@ func dataSourceComputeRead(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = flattenCompute(d, compFacts); err != nil {
|
if err = flattenDataCompute(d, compFacts); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,6 +277,12 @@ func DataSourceCompute() *schema.Resource {
|
|||||||
Description: "ID of the resource group where this compute instance is located.",
|
Description: "ID of the resource group where this compute instance is located.",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"enabled": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
Description: "If true - enable the compute, else - disable",
|
||||||
|
},
|
||||||
|
|
||||||
"rg_name": {
|
"rg_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -339,16 +352,71 @@ func DataSourceCompute() *schema.Resource {
|
|||||||
Description: "IDs of the extra disk(s) attached to this compute.",
|
Description: "IDs of the extra disk(s) attached to this compute.",
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
"disks": {
|
||||||
"disks": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Elem: &schema.Resource{
|
Schema: map[string]*schema.Schema{
|
||||||
Schema: dataSourceDiskSchemaMake(), // ID, type, name, size, account ID, SEP ID, SEP type, pool, status, tech status, compute ID, image ID
|
"disk_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Name for disk",
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Disk size in GiB",
|
||||||
|
},
|
||||||
|
"disk_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
||||||
|
},
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Storage endpoint provider ID; by default the same with boot disk",
|
||||||
|
},
|
||||||
|
"shareable": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"size_used": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"pool": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Pool name; by default will be chosen automatically",
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Optional description",
|
||||||
|
},
|
||||||
|
"image_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Specify image id for create disk from template",
|
||||||
|
},
|
||||||
|
"disk_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Disk ID",
|
||||||
|
},
|
||||||
|
"permanently": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Disk deletion status",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Description: "Detailed specification for all disks attached to this compute instance (including bood disk).",
|
|
||||||
},
|
},
|
||||||
*/
|
},
|
||||||
|
|
||||||
"network": {
|
"network": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
@@ -384,7 +452,7 @@ func DataSourceCompute() *schema.Resource {
|
|||||||
"started": {
|
"started": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: true,
|
Computed: true,
|
||||||
Description: "Is compute started.",
|
Description: "Is compute started.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
115
internal/service/cloudapi/kvmvm/flattens.go
Normal file
115
internal/service/cloudapi/kvmvm/flattens.go
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -72,6 +72,7 @@ type DiskRecord struct {
|
|||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
SepType string `json:"sepType"`
|
SepType string `json:"sepType"`
|
||||||
SepID int `json:"sepId"` // NOTE: absent from compute/get output
|
SepID int `json:"sepId"` // NOTE: absent from compute/get output
|
||||||
|
Shareable bool `json:"shareable"`
|
||||||
SizeMax int `json:"sizeMax"`
|
SizeMax int `json:"sizeMax"`
|
||||||
SizeUsed int `json:"sizeUsed"` // sum over all snapshots of this disk to report total consumed space
|
SizeUsed int `json:"sizeUsed"` // sum over all snapshots of this disk to report total consumed space
|
||||||
Snapshots []SnapshotRecord `json:"snapshots"`
|
Snapshots []SnapshotRecord `json:"snapshots"`
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ package kvmvm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -41,6 +42,7 @@ import (
|
|||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/statefuncs"
|
"github.com/rudecs/terraform-provider-decort/internal/statefuncs"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/status"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
@@ -208,7 +210,33 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if enabled, ok := d.GetOk("enabled"); ok {
|
||||||
|
api := ComputeDisableAPI
|
||||||
|
if enabled.(bool) {
|
||||||
|
api = ComputeEnableAPI
|
||||||
|
}
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("computeId", fmt.Sprintf("%d", compId))
|
||||||
|
log.Debugf("resourceComputeCreate: enable=%t Compute ID %d after completing its resource configuration", compId, enabled)
|
||||||
|
if _, err := c.DecortAPICall(ctx, "POST", api, urlValues); err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if !cleanup {
|
if !cleanup {
|
||||||
|
if affinityLabel, ok := d.GetOk("affinity_label"); ok {
|
||||||
|
affinityLabel := affinityLabel.(string)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
urlValues.Add("affinityLabel", affinityLabel)
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAffinityLabelSetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
if disks, ok := d.GetOk("disks"); ok {
|
if disks, ok := d.GetOk("disks"); ok {
|
||||||
log.Debugf("resourceComputeCreate: Create disks on ComputeID: %d", compId)
|
log.Debugf("resourceComputeCreate: Create disks on ComputeID: %d", compId)
|
||||||
addedDisks := disks.([]interface{})
|
addedDisks := disks.([]interface{})
|
||||||
@@ -243,6 +271,52 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ars, ok := d.GetOk("affinity_rules"); ok {
|
||||||
|
log.Debugf("resourceComputeCreate: Create affinity rules on ComputeID: %d", compId)
|
||||||
|
addedAR := ars.([]interface{})
|
||||||
|
if len(addedAR) > 0 {
|
||||||
|
for _, ar := range addedAR {
|
||||||
|
arConv := ar.(map[string]interface{})
|
||||||
|
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
urlValues.Add("topology", arConv["topology"].(string))
|
||||||
|
urlValues.Add("policy", arConv["policy"].(string))
|
||||||
|
urlValues.Add("mode", arConv["mode"].(string))
|
||||||
|
urlValues.Add("key", arConv["key"].(string))
|
||||||
|
urlValues.Add("value", arConv["value"].(string))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAffinityRuleAddAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
cleanup = true
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ars, ok := d.GetOk("anti_affinity_rules"); ok {
|
||||||
|
log.Debugf("resourceComputeCreate: Create anti affinity rules on ComputeID: %d", compId)
|
||||||
|
addedAR := ars.([]interface{})
|
||||||
|
if len(addedAR) > 0 {
|
||||||
|
for _, ar := range addedAR {
|
||||||
|
arConv := ar.(map[string]interface{})
|
||||||
|
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
urlValues.Add("topology", arConv["topology"].(string))
|
||||||
|
urlValues.Add("policy", arConv["policy"].(string))
|
||||||
|
urlValues.Add("mode", arConv["mode"].(string))
|
||||||
|
urlValues.Add("key", arConv["key"].(string))
|
||||||
|
urlValues.Add("value", arConv["value"].(string))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAntiAffinityRuleAddAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
cleanup = true
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", compId, d.Get("name").(string))
|
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", compId, d.Get("name").(string))
|
||||||
@@ -258,6 +332,8 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
log.Debugf("resourceComputeRead: called for Compute name %s, RG ID %d",
|
log.Debugf("resourceComputeRead: called for Compute name %s, RG ID %d",
|
||||||
d.Get("name").(string), d.Get("rg_id").(int))
|
d.Get("name").(string), d.Get("rg_id").(int))
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
compFacts, err := utilityComputeCheckPresence(ctx, d, m)
|
compFacts, err := utilityComputeCheckPresence(ctx, d, m)
|
||||||
if compFacts == "" {
|
if compFacts == "" {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -267,6 +343,49 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compute := &ComputeGetResp{}
|
||||||
|
err = json.Unmarshal([]byte(compFacts), compute)
|
||||||
|
|
||||||
|
log.Debugf("resourceComputeRead: compute is: %+v", compute)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch compute.Status {
|
||||||
|
case status.Deleted:
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeRestoreAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
_, err = c.DecortAPICall(ctx, "POST", ComputeEnableAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
case status.Destroyed:
|
||||||
|
d.SetId("")
|
||||||
|
return resourceComputeCreate(ctx, d, m)
|
||||||
|
case status.Disabled:
|
||||||
|
log.Debugf("The compute is in status: %s, may troubles can be occured with update. Please, enable compute first.", compute.Status)
|
||||||
|
case status.Redeploying:
|
||||||
|
case status.Deleting:
|
||||||
|
case status.Destroying:
|
||||||
|
return diag.Errorf("The compute is in progress with status: %s", compute.Status)
|
||||||
|
case status.Modeled:
|
||||||
|
return diag.Errorf("The compute is in status: %s, please, contant the support for more information", compute.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
compFacts, err = utilityComputeCheckPresence(ctx, d, m)
|
||||||
|
log.Debugf("resourceComputeRead: after changes compute is: %s", compFacts)
|
||||||
|
if compFacts == "" {
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
// Compute with such name and RG ID was not found
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if err = flattenCompute(d, compFacts); err != nil {
|
if err = flattenCompute(d, compFacts); err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -283,6 +402,56 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
computeRaw, err := utilityComputeCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
compute := &ComputeGetResp{}
|
||||||
|
err = json.Unmarshal([]byte(computeRaw), compute)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("enabled") {
|
||||||
|
enabled := d.Get("enabled")
|
||||||
|
api := ComputeDisableAPI
|
||||||
|
if enabled.(bool) {
|
||||||
|
api = ComputeEnableAPI
|
||||||
|
}
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
log.Debugf("resourceComputeUpdate: enable=%t Compute ID %s after completing its resource configuration", d.Id(), enabled)
|
||||||
|
if _, err := c.DecortAPICall(ctx, "POST", api, urlValues); err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check compute statuses
|
||||||
|
switch compute.Status {
|
||||||
|
case status.Deleted:
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeRestoreAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
_, err = c.DecortAPICall(ctx, "POST", ComputeEnableAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
case status.Destroyed:
|
||||||
|
d.SetId("")
|
||||||
|
return resourceComputeCreate(ctx, d, m)
|
||||||
|
case status.Disabled:
|
||||||
|
log.Debugf("The compute is in status: %s, may troubles can be occured with update. Please, enable compute first.", compute.Status)
|
||||||
|
case status.Redeploying:
|
||||||
|
case status.Deleting:
|
||||||
|
case status.Destroying:
|
||||||
|
return diag.Errorf("The compute is in progress with status: %s", compute.Status)
|
||||||
|
case status.Modeled:
|
||||||
|
return diag.Errorf("The compute is in status: %s, please, contant the support for more information", compute.Status)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
1. Resize CPU/RAM
|
1. Resize CPU/RAM
|
||||||
2. Resize (grow) boot disk
|
2. Resize (grow) boot disk
|
||||||
@@ -348,7 +517,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4. Calculate and apply changes to network connections
|
// 4. Calculate and apply changes to network connections
|
||||||
err := utilityComputeNetworksConfigure(ctx, d, m, true, false) // pass do_delta = true to apply changes, if any
|
err = utilityComputeNetworksConfigure(ctx, d, m, true, false) // pass do_delta = true to apply changes, if any
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -465,6 +634,155 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.HasChange("affinity_label") {
|
||||||
|
affinityLabel := d.Get("affinity_label").(string)
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
if affinityLabel == "" {
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAffinityLabelRemoveAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
urlValues.Add("affinityLabel", affinityLabel)
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAffinityLabelSetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("affinity_rules") {
|
||||||
|
deletedAR := make([]interface{}, 0)
|
||||||
|
addedAR := make([]interface{}, 0)
|
||||||
|
|
||||||
|
oldAR, newAR := d.GetChange("affinity_rules")
|
||||||
|
oldConv := oldAR.([]interface{})
|
||||||
|
newConv := newAR.([]interface{})
|
||||||
|
|
||||||
|
if len(newConv) == 0 {
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAffinityRulesClearAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, el := range oldConv {
|
||||||
|
if !isContainsAR(newConv, el) {
|
||||||
|
deletedAR = append(deletedAR, el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, el := range newConv {
|
||||||
|
if !isContainsAR(oldConv, el) {
|
||||||
|
addedAR = append(addedAR, el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(deletedAR) > 0 {
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
for _, ar := range deletedAR {
|
||||||
|
arConv := ar.(map[string]interface{})
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
urlValues.Add("topology", arConv["topology"].(string))
|
||||||
|
urlValues.Add("policy", arConv["policy"].(string))
|
||||||
|
urlValues.Add("mode", arConv["mode"].(string))
|
||||||
|
urlValues.Add("key", arConv["key"].(string))
|
||||||
|
urlValues.Add("value", arConv["value"].(string))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAffinityRuleRemoveAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(addedAR) > 0 {
|
||||||
|
for _, ar := range addedAR {
|
||||||
|
arConv := ar.(map[string]interface{})
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
urlValues.Add("topology", arConv["topology"].(string))
|
||||||
|
urlValues.Add("policy", arConv["policy"].(string))
|
||||||
|
urlValues.Add("mode", arConv["mode"].(string))
|
||||||
|
urlValues.Add("key", arConv["key"].(string))
|
||||||
|
urlValues.Add("value", arConv["value"].(string))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAffinityRuleAddAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("anti_affinity_rules") {
|
||||||
|
deletedAR := make([]interface{}, 0)
|
||||||
|
addedAR := make([]interface{}, 0)
|
||||||
|
|
||||||
|
oldAR, newAR := d.GetChange("anti_affinity_rules")
|
||||||
|
oldConv := oldAR.([]interface{})
|
||||||
|
newConv := newAR.([]interface{})
|
||||||
|
|
||||||
|
if len(newConv) == 0 {
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAntiAffinityRulesClearAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, el := range oldConv {
|
||||||
|
if !isContainsAR(newConv, el) {
|
||||||
|
deletedAR = append(deletedAR, el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, el := range newConv {
|
||||||
|
if !isContainsAR(oldConv, el) {
|
||||||
|
addedAR = append(addedAR, el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(deletedAR) > 0 {
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
for _, ar := range deletedAR {
|
||||||
|
arConv := ar.(map[string]interface{})
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
urlValues.Add("topology", arConv["topology"].(string))
|
||||||
|
urlValues.Add("policy", arConv["policy"].(string))
|
||||||
|
urlValues.Add("mode", arConv["mode"].(string))
|
||||||
|
urlValues.Add("key", arConv["key"].(string))
|
||||||
|
urlValues.Add("value", arConv["value"].(string))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAntiAffinityRuleRemoveAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(addedAR) > 0 {
|
||||||
|
for _, ar := range addedAR {
|
||||||
|
arConv := ar.(map[string]interface{})
|
||||||
|
urlValues.Add("computeId", d.Id())
|
||||||
|
urlValues.Add("topology", arConv["topology"].(string))
|
||||||
|
urlValues.Add("policy", arConv["policy"].(string))
|
||||||
|
urlValues.Add("mode", arConv["mode"].(string))
|
||||||
|
urlValues.Add("key", arConv["key"].(string))
|
||||||
|
urlValues.Add("value", arConv["value"].(string))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", ComputeAntiAffinityRuleAddAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// we may reuse dataSourceComputeRead here as we maintain similarity
|
// we may reuse dataSourceComputeRead here as we maintain similarity
|
||||||
// between Compute resource and Compute data source schemas
|
// between Compute resource and Compute data source schemas
|
||||||
return resourceComputeRead(ctx, d, m)
|
return resourceComputeRead(ctx, d, m)
|
||||||
@@ -481,6 +799,21 @@ func isContainsDisk(els []interface{}, el interface{}) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isContainsAR(els []interface{}, el interface{}) bool {
|
||||||
|
for _, elOld := range els {
|
||||||
|
elOldConv := elOld.(map[string]interface{})
|
||||||
|
elConv := el.(map[string]interface{})
|
||||||
|
if elOldConv["key"].(string) == elConv["key"].(string) &&
|
||||||
|
elOldConv["value"].(string) == elConv["value"].(string) &&
|
||||||
|
elOldConv["mode"].(string) == elConv["mode"].(string) &&
|
||||||
|
elOldConv["topology"].(string) == elConv["topology"].(string) &&
|
||||||
|
elOldConv["policy"].(string) == elConv["policy"].(string) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
// NOTE: this function destroys target Compute instance "permanently", so
|
// NOTE: this function destroys target Compute instance "permanently", so
|
||||||
// there is no way to restore it.
|
// there is no way to restore it.
|
||||||
@@ -554,6 +887,86 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Description: "This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.",
|
Description: "This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"affinity_label": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Set affinity label for compute",
|
||||||
|
},
|
||||||
|
|
||||||
|
"affinity_rules": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"topology": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"node", "compute"}, false),
|
||||||
|
Description: "compute or node, for whom rule applies",
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"RECOMMENDED", "REQUIRED"}, false),
|
||||||
|
Description: "RECOMMENDED or REQUIRED, the degree of 'strictness' of this rule",
|
||||||
|
},
|
||||||
|
"mode": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"EQ", "NE", "ANY"}, false),
|
||||||
|
Description: "EQ or NE or ANY - the comparison mode is 'value', recorded by the specified 'key'",
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "key that are taken into account when analyzing this rule will be identified",
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "value that must match the key to be taken into account when analyzing this rule",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"anti_affinity_rules": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"topology": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"node", "compute"}, false),
|
||||||
|
Description: "compute or node, for whom rule applies",
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"RECOMMENDED", "REQUIRED"}, false),
|
||||||
|
Description: "RECOMMENDED or REQUIRED, the degree of 'strictness' of this rule",
|
||||||
|
},
|
||||||
|
"mode": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"EQ", "NE", "ANY"}, false),
|
||||||
|
Description: "EQ or NE or ANY - the comparison mode is 'value', recorded by the specified 'key'",
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "key that are taken into account when analyzing this rule will be identified",
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "value that must match the key to be taken into account when analyzing this rule",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
"disks": {
|
"disks": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -583,6 +996,18 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Storage endpoint provider ID; by default the same with boot disk",
|
Description: "Storage endpoint provider ID; by default the same with boot disk",
|
||||||
},
|
},
|
||||||
|
"shareable": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"size_used": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"pool": {
|
"pool": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -671,11 +1096,18 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
},
|
},
|
||||||
|
|
||||||
"cloud_init": {
|
"cloud_init": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "applied",
|
Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.",
|
||||||
DiffSuppressFunc: cloudInitDiffSupperss,
|
//Default: "applied",
|
||||||
Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.",
|
//DiffSuppressFunc: cloudInitDiffSupperss,
|
||||||
|
},
|
||||||
|
|
||||||
|
"enabled": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Description: "If true - enable compute, else - disable",
|
||||||
},
|
},
|
||||||
|
|
||||||
// The rest are Compute properties, which are "computed" once it is created
|
// The rest are Compute properties, which are "computed" once it is created
|
||||||
@@ -715,7 +1147,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
|||||||
"started": {
|
"started": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: true,
|
Computed: true,
|
||||||
Description: "Is compute started.",
|
Description: "Is compute started.",
|
||||||
},
|
},
|
||||||
"detach_disks": {
|
"detach_disks": {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -34,10 +35,11 @@ package rg
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
log "github.com/sirupsen/logrus"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
// "net/url"
|
// "net/url"
|
||||||
|
|
||||||
@@ -45,53 +47,31 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenResgroup(d *schema.ResourceData, rg_facts string) error {
|
func utilityDataResgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*ResgroupGetResp, error) {
|
||||||
// NOTE: this function modifies ResourceData argument - as such it should never be called
|
c := m.(*controller.ControllerCfg)
|
||||||
// from resourceRsgroupExists(...) method
|
urlValues := &url.Values{}
|
||||||
// log.Debugf("%s", rg_facts)
|
rgData := &ResgroupGetResp{}
|
||||||
log.Debugf("flattenResgroup: ready to decode response body from API")
|
|
||||||
details := ResgroupGetResp{}
|
urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int)))
|
||||||
err := json.Unmarshal([]byte(rg_facts), &details)
|
rgRaw, err := c.DecortAPICall(ctx, "POST", ResgroupGetAPI, urlValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("flattenResgroup: decoded RG name %q / ID %d, account ID %d",
|
err = json.Unmarshal([]byte(rgRaw), rgData)
|
||||||
details.Name, details.ID, details.AccountID)
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
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("grid_id", 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("vins", details.Vins)
|
|
||||||
d.Set("computes", details.Computes)
|
|
||||||
*/
|
|
||||||
|
|
||||||
log.Debugf("flattenResgroup: calling flattenQuota()")
|
|
||||||
if err = d.Set("quota", parseQuota(details.Quota)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
return rgData, nil
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
rg_facts, err := utilityResgroupCheckPresence(ctx, d, m)
|
rg, err := utilityDataResgroupCheckPresence(ctx, d, m)
|
||||||
if rg_facts == "" {
|
if err != nil {
|
||||||
// if empty string is returned from utilityResgroupCheckPresence then there is no
|
|
||||||
// such resource group and err tells so - just return it to the calling party
|
|
||||||
d.SetId("") // ensure ID is empty in this case
|
d.SetId("") // ensure ID is empty in this case
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
return diag.FromErr(flattenDataResgroup(d, *rg))
|
||||||
return diag.FromErr(flattenResgroup(d, rg_facts))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceResgroup() *schema.Resource {
|
func DataSourceResgroup() *schema.Resource {
|
||||||
@@ -126,7 +106,7 @@ func DataSourceResgroup() *schema.Resource {
|
|||||||
|
|
||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Optional: true,
|
||||||
Description: "Unique ID of the account, which this resource group belongs to.",
|
Description: "Unique ID of the account, which this resource group belongs to.",
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -135,15 +115,11 @@ func DataSourceResgroup() *schema.Resource {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "User-defined text description of this resource group.",
|
Description: "User-defined text description of this resource group.",
|
||||||
},
|
},
|
||||||
|
"gid": {
|
||||||
/* commented out, as in this version of provider we use default Grid ID
|
|
||||||
"grid_id": {
|
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Unique ID of the grid, where this resource group is deployed.",
|
Description: "Unique ID of the grid, where this resource group is deployed.",
|
||||||
},
|
},
|
||||||
*/
|
|
||||||
|
|
||||||
"quota": {
|
"quota": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@@ -165,32 +141,150 @@ func DataSourceResgroup() *schema.Resource {
|
|||||||
Description: "ID of the default network for this resource group (if any).",
|
Description: "ID of the default network for this resource group (if any).",
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
"resources": {
|
||||||
"status": {
|
Type: schema.TypeList,
|
||||||
Type: schema.TypeString,
|
Computed: true,
|
||||||
Computed: true,
|
Elem: &schema.Resource{
|
||||||
Description: "Current status of this resource group.",
|
Schema: map[string]*schema.Schema{
|
||||||
},
|
"current": {
|
||||||
|
Type: schema.TypeList,
|
||||||
"vins": {
|
Computed: true,
|
||||||
Type: schema.TypeList, // this is a list of ints
|
Elem: &schema.Resource{
|
||||||
Computed: true,
|
Schema: map[string]*schema.Schema{
|
||||||
MaxItems: LimitMaxVinsPerResgroup,
|
"cpu": {
|
||||||
Elem: &schema.Schema{
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeInt,
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disksize": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"extips": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"exttraffic": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"data_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"reserved": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disksize": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"extips": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"exttraffic": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"data_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Description: "List of VINs deployed in this resource group.",
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
"computes": {
|
"status": {
|
||||||
Type: schema.TypeList, //t his is a list of ints
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Description: "Current status of this resource group.",
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
},
|
|
||||||
Description: "List of computes deployed in this resource group.",
|
"vins": {
|
||||||
|
Type: schema.TypeList, // this is a list of ints
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
*/
|
Description: "List of VINs deployed in this resource group.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"vms": {
|
||||||
|
Type: schema.TypeList, //t his is a list of ints
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
Description: "List of computes deployed in this resource group.",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
145
internal/service/cloudapi/rg/flattens.go
Normal file
145
internal/service/cloudapi/rg/flattens.go
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -91,27 +92,28 @@ type AccountAclRecord struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ResgroupGetResp struct {
|
type ResgroupGetResp struct {
|
||||||
ACLs []UserAclRecord `json:"ACLs"`
|
Resources Resources `json:"Resources"`
|
||||||
Usage UsageRecord `json:"Resources"`
|
ACLs []UserAclRecord `json:"ACLs"`
|
||||||
AccountID int `json:"accountId"`
|
//Usage UsageRecord `json:"Resources"`
|
||||||
AccountName string `json:"accountName"`
|
AccountID int `json:"accountId"`
|
||||||
GridID int `json:"gid"`
|
AccountName string `json:"accountName"`
|
||||||
CreatedBy string `json:"createdBy"`
|
GridID int `json:"gid"`
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedBy string `json:"createdBy"`
|
||||||
DefaultNetID int `json:"def_net_id"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
DefaultNetType string `json:"def_net_type"`
|
DefaultNetID int `json:"def_net_id"`
|
||||||
DeletedBy string `json:"deletedBy"`
|
DefaultNetType string `json:"def_net_type"`
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedBy string `json:"deletedBy"`
|
||||||
Desc string `json:"desc"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
ID uint `json:"id"`
|
Desc string `json:"desc"`
|
||||||
LockStatus string `json:"lockStatus"`
|
ID uint `json:"id"`
|
||||||
Name string `json:"name"`
|
LockStatus string `json:"lockStatus"`
|
||||||
Quota QuotaRecord `json:"resourceLimits"`
|
Name string `json:"name"`
|
||||||
Status string `json:"status"`
|
Quota QuotaRecord `json:"resourceLimits"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
Status string `json:"status"`
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
Vins []int `json:"vins"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
Computes []int `json:"vms"`
|
Vins []int `json:"vins"`
|
||||||
|
Computes []int `json:"vms"`
|
||||||
|
|
||||||
Ignored map[string]interface{} `json:"-"`
|
Ignored map[string]interface{} `json:"-"`
|
||||||
}
|
}
|
||||||
@@ -147,3 +149,23 @@ type UsageRecord struct {
|
|||||||
Current ResourceRecord `json:"Current"`
|
Current ResourceRecord `json:"Current"`
|
||||||
Reserved ResourceRecord `json:"Reserved"`
|
Reserved ResourceRecord `json:"Reserved"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ResourceSep struct {
|
||||||
|
DiskSize float64 `json:"disksize"`
|
||||||
|
DiskSizeMax int `json:"disksizemax"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Resource struct {
|
||||||
|
CPU int `json:"cpu"`
|
||||||
|
Disksize int `json:"disksize"`
|
||||||
|
Extips int `json:"extips"`
|
||||||
|
Exttraffic int `json:"exttraffic"`
|
||||||
|
GPU int `json:"gpu"`
|
||||||
|
RAM int `json:"ram"`
|
||||||
|
SEPs map[string]map[string]ResourceSep `json:"seps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Resources struct {
|
||||||
|
Current Resource `json:"Current"`
|
||||||
|
Reserved Resource `json:"Reserved"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -33,9 +34,9 @@ package rg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
@@ -133,16 +134,11 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
|
|||||||
d.SetId(api_resp) // rg/create API returns ID of the newly creted resource group on success
|
d.SetId(api_resp) // rg/create API returns ID of the newly creted resource group on success
|
||||||
// rg.ID, _ = strconv.Atoi(api_resp)
|
// rg.ID, _ = strconv.Atoi(api_resp)
|
||||||
if !set_quota {
|
if !set_quota {
|
||||||
resp, err := utilityResgroupCheckPresence(ctx, d, m)
|
rg, err := utilityResgroupCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rg := ResgroupGetResp{}
|
|
||||||
if err := json.Unmarshal([]byte(resp), &rg); err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.Set("quota", parseQuota(rg.Quota))
|
d.Set("quota", parseQuota(rg.Quota))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,14 +151,14 @@ func resourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interfa
|
|||||||
d.Get("name").(string), d.Get("account_id").(int))
|
d.Get("name").(string), d.Get("account_id").(int))
|
||||||
|
|
||||||
rg_facts, err := utilityResgroupCheckPresence(ctx, d, m)
|
rg_facts, err := utilityResgroupCheckPresence(ctx, d, m)
|
||||||
if rg_facts == "" {
|
if err != nil {
|
||||||
// if empty string is returned from utilityResgroupCheckPresence then there is no
|
// if empty string is returned from utilityResgroupCheckPresence then there is no
|
||||||
// such resource group and err tells so - just return it to the calling party
|
// such resource group and err tells so - just return it to the calling party
|
||||||
d.SetId("") // ensure ID is empty
|
d.SetId("") // ensure ID is empty
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return diag.FromErr(flattenResgroup(d, rg_facts))
|
return diag.FromErr(flattenResgroup(d, *rg_facts))
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
@@ -272,24 +268,21 @@ func resourceResgroupDelete(ctx context.Context, d *schema.ResourceData, m inter
|
|||||||
log.Debugf("resourceResgroupDelete: called for RG name %s, account ID %d",
|
log.Debugf("resourceResgroupDelete: called for RG name %s, account ID %d",
|
||||||
d.Get("name").(string), d.Get("account_id").(int))
|
d.Get("name").(string), d.Get("account_id").(int))
|
||||||
|
|
||||||
rg_facts, err := utilityResgroupCheckPresence(ctx, d, m)
|
c := m.(*controller.ControllerCfg)
|
||||||
if rg_facts == "" {
|
url_values := &url.Values{}
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
url_values.Add("rgId", d.Id())
|
||||||
}
|
if force, ok := d.GetOk("force"); ok {
|
||||||
// the target RG does not exist - in this case according to Terraform best practice
|
url_values.Add("force", strconv.FormatBool(force.(bool)))
|
||||||
// we exit from Destroy method without error
|
}
|
||||||
return nil
|
if permanently, ok := d.GetOk("permanently"); ok {
|
||||||
|
url_values.Add("permanently", strconv.FormatBool(permanently.(bool)))
|
||||||
|
}
|
||||||
|
if reason, ok := d.GetOk("reason"); ok {
|
||||||
|
url_values.Add("reason", reason.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
url_values := &url.Values{}
|
_, err := c.DecortAPICall(ctx, "POST", ResgroupDeleteAPI, url_values)
|
||||||
url_values.Add("rgId", d.Id())
|
|
||||||
url_values.Add("force", "1")
|
|
||||||
url_values.Add("permanently", "1")
|
|
||||||
url_values.Add("reason", "Destroyed by DECORT Terraform provider")
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
|
||||||
_, err = c.DecortAPICall(ctx, "POST", ResgroupDeleteAPI, url_values)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -297,6 +290,257 @@ func resourceResgroupDelete(ctx context.Context, d *schema.ResourceData, m inter
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ResourceRgSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ValidateFunc: validation.IntAtLeast(1),
|
||||||
|
Description: "Unique ID of the account, which this resource group belongs to.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
ForceNew: true, // change of Grid ID will require new RG
|
||||||
|
Description: "Unique ID of the grid, where this resource group is deployed.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
Description: "Name of this resource group. Names are case sensitive and unique within the context of a account.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"def_net_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Default: "PRIVATE",
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "PUBLIC", "NONE"}, false),
|
||||||
|
Description: "Type of the network, which this resource group will use as default for its computes - PRIVATE or PUBLIC or NONE.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"def_net_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "ID of the default network for this resource group (if any).",
|
||||||
|
},
|
||||||
|
|
||||||
|
"ipcidr": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Address of the netowrk inside the private network segment (aka ViNS) if def_net_type=PRIVATE",
|
||||||
|
},
|
||||||
|
|
||||||
|
"ext_net_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Default: 0,
|
||||||
|
Description: "ID of the external network for default ViNS. Pass 0 if def_net_type=PUBLIC or no external connection required for the defult ViNS when def_net_type=PRIVATE",
|
||||||
|
},
|
||||||
|
|
||||||
|
"ext_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "IP address on the external netowrk to request when def_net_type=PRIVATE and ext_net_id is not 0",
|
||||||
|
},
|
||||||
|
|
||||||
|
"quota": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
MaxItems: 1,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: quotaRgSubresourceSchemaMake(),
|
||||||
|
},
|
||||||
|
Description: "Quota settings for this resource group.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"description": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "User-defined text description of this resource group.",
|
||||||
|
},
|
||||||
|
"force": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
Description: "Set to True if you want force delete non-empty RG",
|
||||||
|
},
|
||||||
|
"permanently": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
Description: "Set to True if you want force delete non-empty RG",
|
||||||
|
},
|
||||||
|
"reason": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Set to True if you want force delete non-empty RG",
|
||||||
|
},
|
||||||
|
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Name of the account, which this resource group belongs to.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"resources": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"current": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disksize": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"extips": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"exttraffic": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"data_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"reserved": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disksize": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"extips": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"exttraffic": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"seps": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"sep_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"data_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"disk_size_max": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Current status of this resource group.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"vins": {
|
||||||
|
Type: schema.TypeList, //this is a list of ints
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
Description: "List of VINs deployed in this resource group.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"vms": {
|
||||||
|
Type: schema.TypeList, //t his is a list of ints
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
Description: "List of computes deployed in this resource group.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"computes": {
|
||||||
|
Type: schema.TypeList, //this is a list of ints
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
Description: "List of computes deployed in this resource group.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func ResourceResgroup() *schema.Resource {
|
func ResourceResgroup() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
@@ -318,113 +562,6 @@ func ResourceResgroup() *schema.Resource {
|
|||||||
Default: &constants.Timeout300s,
|
Default: &constants.Timeout300s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: ResourceRgSchemaMake(),
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Name of this resource group. Names are case sensitive and unique within the context of a account.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
ValidateFunc: validation.IntAtLeast(1),
|
|
||||||
Description: "Unique ID of the account, which this resource group belongs to.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"def_net_type": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Default: "PRIVATE",
|
|
||||||
ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "PUBLIC", "NONE"}, false),
|
|
||||||
Description: "Type of the network, which this resource group will use as default for its computes - PRIVATE or PUBLIC or NONE.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"def_net_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the default network for this resource group (if any).",
|
|
||||||
},
|
|
||||||
|
|
||||||
"ipcidr": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Address of the netowrk inside the private network segment (aka ViNS) if def_net_type=PRIVATE",
|
|
||||||
},
|
|
||||||
|
|
||||||
"ext_net_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Default: 0,
|
|
||||||
Description: "ID of the external network for default ViNS. Pass 0 if def_net_type=PUBLIC or no external connection required for the defult ViNS when def_net_type=PRIVATE",
|
|
||||||
},
|
|
||||||
|
|
||||||
"ext_ip": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "IP address on the external netowrk to request when def_net_type=PRIVATE and ext_net_id is not 0",
|
|
||||||
},
|
|
||||||
|
|
||||||
/* commented out, as in this version of provider we use default Grid ID
|
|
||||||
"grid_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Default: 0, // if 0 is passed, default Grid ID will be used
|
|
||||||
// DefaultFunc: utilityResgroupGetDefaultGridID,
|
|
||||||
ForceNew: true, // change of Grid ID will require new RG
|
|
||||||
Description: "Unique ID of the grid, where this resource group is deployed.",
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
|
|
||||||
"quota": {
|
|
||||||
Type: schema.TypeList,
|
|
||||||
Optional: true,
|
|
||||||
Computed: true,
|
|
||||||
MaxItems: 1,
|
|
||||||
Elem: &schema.Resource{
|
|
||||||
Schema: quotaRgSubresourceSchemaMake(),
|
|
||||||
},
|
|
||||||
Description: "Quota settings for this resource group.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"description": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
Description: "User-defined text description of this resource group.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Name of the account, which this resource group belongs to.",
|
|
||||||
},
|
|
||||||
|
|
||||||
/*
|
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Current status of this resource group.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"vins": {
|
|
||||||
Type: schema.TypeList, // this is a list of ints
|
|
||||||
Computed: true,
|
|
||||||
MaxItems: LimitMaxVinsPerResgroup,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
Description: "List of VINs deployed in this resource group.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"computes": {
|
|
||||||
Type: schema.TypeList, // this is a list of ints
|
|
||||||
Computed: true,
|
|
||||||
Elem: &schema.Schema{
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
},
|
|
||||||
Description: "List of computes deployed in this resource group.",
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -34,19 +35,17 @@ package rg
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
// On success this function returns a string, as returned by API rg/get, which could be unmarshalled
|
// On success this function returns a string, as returned by API rg/get, which could be unmarshalled
|
||||||
// into ResgroupGetResp structure
|
// into ResgroupGetResp structure
|
||||||
func utilityResgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) {
|
func utilityResgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*ResgroupGetResp, error) {
|
||||||
// This function tries to locate resource group by one of the following algorithms depending
|
// This function tries to locate resource group by one of the following algorithms depending
|
||||||
// on the parameters passed:
|
// on the parameters passed:
|
||||||
// - if resource group ID is specified -> by RG ID
|
// - if resource group ID is specified -> by RG ID
|
||||||
@@ -67,73 +66,21 @@ func utilityResgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
|||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
// make it possible to use "read" & "check presence" functions with RG ID set so
|
if d.Id() != "" {
|
||||||
// that Import of RG resource is possible
|
urlValues.Add("rgId", d.Id())
|
||||||
idSet := false
|
|
||||||
theId, err := strconv.Atoi(d.Id())
|
|
||||||
if err != nil || theId <= 0 {
|
|
||||||
rgId, argSet := d.GetOk("rg_id")
|
|
||||||
if argSet {
|
|
||||||
theId = rgId.(int)
|
|
||||||
idSet = true
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
idSet = true
|
urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if idSet {
|
rgData := &ResgroupGetResp{}
|
||||||
// go straight for the RG by its ID
|
rgRaw, err := c.DecortAPICall(ctx, "POST", ResgroupGetAPI, urlValues)
|
||||||
log.Debugf("utilityResgroupCheckPresence: locating RG by its ID %d", theId)
|
|
||||||
urlValues.Add("rgId", fmt.Sprintf("%d", theId))
|
|
||||||
rgFacts, err := c.DecortAPICall(ctx, "POST", ResgroupGetAPI, urlValues)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return rgFacts, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
rgName, argSet := d.GetOk("name")
|
|
||||||
if !argSet {
|
|
||||||
// no RG ID and no RG name - we cannot locate resource group in this case
|
|
||||||
return "", fmt.Errorf("Cannot check resource group presence if name is empty and no resource group ID specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Valid account ID is required to locate a resource group
|
|
||||||
// obtain Account ID by account name - it should not be zero on success
|
|
||||||
|
|
||||||
urlValues.Add("includedeleted", "false")
|
|
||||||
apiResp, err := c.DecortAPICall(ctx, "POST", ResgroupListAPI, urlValues)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
// log.Debugf("%s", apiResp)
|
|
||||||
log.Debugf("utilityResgroupCheckPresence: ready to decode response body from %s", ResgroupListAPI)
|
err = json.Unmarshal([]byte(rgRaw), rgData)
|
||||||
model := ResgroupListResp{}
|
|
||||||
err = json.Unmarshal([]byte(apiResp), &model)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return rgData, nil
|
||||||
log.Debugf("utilityResgroupCheckPresence: traversing decoded Json of length %d", len(model))
|
|
||||||
for index, item := range model {
|
|
||||||
// match by RG name & account ID
|
|
||||||
if item.Name == rgName.(string) && item.AccountID == d.Get("account_id").(int) {
|
|
||||||
log.Debugf("utilityResgroupCheckPresence: match RG name %s / ID %d, account ID %d at index %d",
|
|
||||||
item.Name, item.ID, item.AccountID, index)
|
|
||||||
|
|
||||||
// not all required information is returned by rg/list API, so we need to initiate one more
|
|
||||||
// call to rg/get to obtain extra data to complete Resource population.
|
|
||||||
// Namely, we need resource quota settings
|
|
||||||
reqValues := &url.Values{}
|
|
||||||
reqValues.Add("rgId", fmt.Sprintf("%d", item.ID))
|
|
||||||
apiResp, err := c.DecortAPICall(ctx, "POST", ResgroupGetAPI, reqValues)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiResp, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "", fmt.Errorf("Cannot find RG name %s owned by account ID %d", rgName, d.Get("account_id").(int))
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -32,14 +32,27 @@ Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
|||||||
|
|
||||||
package vins
|
package vins
|
||||||
|
|
||||||
const VinsListAPI = "/restmachine/cloudapi/vins/list"
|
const (
|
||||||
const VinsGetAPI = "/restmachine/cloudapi/vins/get"
|
VinsAuditsAPI = "/restmachine/cloudapi/vins/audits"
|
||||||
const VinsSearchAPI = "/restmachine/cloudapi/vins/search"
|
VinsCreateInAccountAPI = "/restmachine/cloudapi/vins/createInAccount"
|
||||||
|
VinsCreateInRgAPI = "/restmachine/cloudapi/vins/createInRG"
|
||||||
const VinsCreateInAccountAPI = "/restmachine/cloudapi/vins/createInAccount"
|
VinsDeleteAPI = "/restmachine/cloudapi/vins/delete"
|
||||||
const VinsCreateInRgAPI = "/restmachine/cloudapi/vins/createInRG"
|
VinsDisableAPI = "/restmachine/cloudapi/vins/disable"
|
||||||
|
VinsEnableAPI = "/restmachine/cloudapi/vins/enable"
|
||||||
const VinsExtNetConnectAPI = "/restmachine/cloudapi/vins/extNetConnect"
|
VinsExtNetConnectAPI = "/restmachine/cloudapi/vins/extNetConnect"
|
||||||
const VinsExtNetDisconnectAPI = "/restmachine/cloudapi/vins/extNetDisconnect"
|
VinsExtNetDisconnectAPI = "/restmachine/cloudapi/vins/extNetDisconnect"
|
||||||
|
VinsExtNetListAPI = "/restmachine/cloudapi/vins/extNetList"
|
||||||
const VinsDeleteAPI = "/restmachine/cloudapi/vins/delete"
|
VinsGetAPI = "/restmachine/cloudapi/vins/get"
|
||||||
|
VinsIpListAPI = "/restmachine/cloudapi/vins/ipList"
|
||||||
|
VinsIpReleaseAPI = "/restmachine/cloudapi/vins/ipRelease"
|
||||||
|
VinsIpReserveAPI = "/restmachine/cloudapi/vins/ipReserve"
|
||||||
|
VinsListAPI = "/restmachine/cloudapi/vins/list"
|
||||||
|
VinsListDeletedAPI = "/restmachine/cloudapi/vins/listDeleted"
|
||||||
|
VinsNatRuleAddAPI = "/restmachine/cloudapi/vins/natRuleAdd"
|
||||||
|
VinsNatRuleDelAPI = "/restmachine/cloudapi/vins/natRuleDel"
|
||||||
|
VinsNatRuleListAPI = "/restmachine/cloudapi/vins/natRuleList"
|
||||||
|
VinsRestoreAPI = "/restmachine/cloudapi/vins/restore"
|
||||||
|
VinsSearchAPI = "/restmachine/cloudapi/vins/search"
|
||||||
|
VinsVnfdevRedeployAPI = "/restmachine/cloudapi/vins/vnfdevRedeploy"
|
||||||
|
VinsVnfdevRestartAPI = "/restmachine/cloudapi/vins/vnfdevRestart"
|
||||||
|
)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -33,79 +34,863 @@ package vins
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"strconv"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
// "net/url"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
// vins_facts is a response string from API vins/get
|
func dataSourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
func flattenVins(d *schema.ResourceData, vins_facts string) diag.Diagnostics {
|
vins, err := utilityDataVinsCheckPresence(ctx, d, m)
|
||||||
// NOTE: this function modifies ResourceData argument - as such it should never be called
|
|
||||||
// from resourceVinsExists(...) method
|
|
||||||
// log.Debugf("flattenVins: ready to decode response body from API %s", vins_facts)
|
|
||||||
vinsRecord := VinsRecord{}
|
|
||||||
err := json.Unmarshal([]byte(vins_facts), &vinsRecord)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("flattenVins: decoded ViNS name:ID %s:%d, account ID %d, RG ID %d",
|
d.SetId(strconv.FormatUint(vins.ID, 10))
|
||||||
vinsRecord.Name, vinsRecord.ID, vinsRecord.AccountID, vinsRecord.RgID)
|
flattenVinsData(d, *vins)
|
||||||
|
|
||||||
d.SetId(fmt.Sprintf("%d", vinsRecord.ID))
|
|
||||||
d.Set("name", vinsRecord.Name)
|
|
||||||
d.Set("account_id", vinsRecord.AccountID)
|
|
||||||
d.Set("account_name", vinsRecord.AccountName)
|
|
||||||
d.Set("rg_id", vinsRecord.RgID)
|
|
||||||
d.Set("description", vinsRecord.Desc)
|
|
||||||
d.Set("ipcidr", vinsRecord.IPCidr)
|
|
||||||
|
|
||||||
noExtNetConnection := true
|
|
||||||
for _, value := range vinsRecord.VNFs {
|
|
||||||
if value.Type == "GW" {
|
|
||||||
log.Debugf("flattenVins: discovered GW VNF ID %d in ViNS ID %d", value.ID, vinsRecord.ID)
|
|
||||||
extNetID, idOk := value.Config["ext_net_id"] // NOTE: unknown numbers are unmarshalled to float64. This is by design!
|
|
||||||
extNetIP, ipOk := value.Config["ext_net_ip"]
|
|
||||||
if idOk && ipOk {
|
|
||||||
log.Debugf("flattenVins: ViNS ext_net_id=%d, ext_net_ip=%s", int(extNetID.(float64)), extNetIP.(string))
|
|
||||||
d.Set("ext_ip_addr", extNetIP.(string))
|
|
||||||
d.Set("ext_net_id", int(extNetID.(float64)))
|
|
||||||
} else {
|
|
||||||
return diag.Errorf("Failed to unmarshal VNF GW Config - structure is invalid.")
|
|
||||||
}
|
|
||||||
noExtNetConnection = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if noExtNetConnection {
|
|
||||||
d.Set("ext_ip_addr", "")
|
|
||||||
d.Set("ext_net_id", 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("flattenVins: EXTRA CHECK - schema rg_id=%d, ext_net_id=%d", d.Get("rg_id").(int), d.Get("ext_net_id").(int))
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func vnfConfigMGMTSchemaMake() map[string]*schema.Schema {
|
||||||
vinsFacts, err := utilityVinsCheckPresence(ctx, d, m)
|
return map[string]*schema.Schema{
|
||||||
if vinsFacts == "" {
|
"ip_addr": {
|
||||||
// if empty string is returned from utilityVinsCheckPresence then there is no
|
Type: schema.TypeString,
|
||||||
// such ViNS and err tells so - just return it to the calling party
|
Computed: true,
|
||||||
d.SetId("") // ensure ID is empty in this case
|
},
|
||||||
return diag.FromErr(err)
|
"password": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ssh_key": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return flattenVins(d, vinsFacts)
|
func vnfConfigResourcesSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"cpu": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ram": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"stack_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"uuid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func qosSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"e_rate": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"in_brust": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"in_rate": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func vnfInterfaceSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"conn_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"conn_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"def_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"flipgroup_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ip_address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"listen_ssh": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"mac": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_mask": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"pci_slot": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"qos": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: qosSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"target": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vnfs": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func vnfConfigSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"mgmt": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: vnfConfigMGMTSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"resources": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: vnfConfigResourcesSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func vnfDevSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"_ckey": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Unique ID of the account, which this ViNS belongs to.",
|
||||||
|
},
|
||||||
|
"capabilities": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: vnfConfigSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"config_saved": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"custom_pre_cfg": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vnf_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"interfaces": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: vnfInterfaceSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"lock_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vnf_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vins": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func vinsComputeSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"compute_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"compute_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func reservationSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"client_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"domainname": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"hostname": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"mac": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vm_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func dhcpConfigSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"default_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"dns": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ip_end": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ip_start": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lease": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"netmask": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"reservations": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: reservationSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func devicesPrimarySchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"dev_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"iface01": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"iface02": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func devicesSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"primary": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: devicesPrimarySchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func dhcpSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"_ckey": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dhcpConfigSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"created_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"devices": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: devicesSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"dhcp_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lock_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"owner_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"owner_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"pure_virtual": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func gwConfigSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"default_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ext_net_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ext_net_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ext_netmask": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"qos": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: qosSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func gwSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"_ckey": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: gwConfigSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"created_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"devices": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: devicesSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"gw_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lock_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"owner_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"owner_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"pure_virtual": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func rulesSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"rule_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"local_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"local_port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"protocol": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"public_port_end": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"public_port_start": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vm_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vm_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func configSchrmaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"net_mask": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: rulesSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func natSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"_ckey": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"created_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: configSchrmaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"devices": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: devicesSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"nat_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lock_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"owner_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"owner_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"pure_virtual": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func vnfsSchemaMake() map[string]*schema.Schema {
|
||||||
|
return map[string]*schema.Schema{
|
||||||
|
"dhcp": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: dhcpSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gw": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: gwSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"nat": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: natSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||||
|
rets := map[string]*schema.Schema{
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||||
|
},
|
||||||
|
|
||||||
|
"vnf_dev": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: vnfDevSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"_ckey": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Unique ID of the account, which this ViNS belongs to.",
|
||||||
|
},
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Name of the account, which this ViNS belongs to.",
|
||||||
|
},
|
||||||
|
"computes": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: vinsComputeSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"default_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"default_qos": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: qosSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"desc": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Description: "User-defined text description of this ViNS.",
|
||||||
|
},
|
||||||
|
"gid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"guid": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"lock_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"manager_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"manager_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"milestones": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"net_mask": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"pre_reservations_num": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"redundant": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
Description: "Unique ID of the resource group, where this ViNS is belongs to (for ViNS created at resource group level, 0 otherwise).",
|
||||||
|
},
|
||||||
|
"rg_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"sec_vnf_dev_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"user_managed": {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vnfs": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: vnfsSchemaMake(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"vxlan_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return rets
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceVins() *schema.Resource {
|
func DataSourceVins() *schema.Resource {
|
||||||
@@ -119,63 +904,6 @@ func DataSourceVins() *schema.Resource {
|
|||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: dataSourceVinsSchemaMake(),
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
Description: "Name of the ViNS. Names are case sensitive and unique within the context of an account or resource group.",
|
|
||||||
},
|
|
||||||
|
|
||||||
/*
|
|
||||||
"vins_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Unique ID of the resource group, where this ViNS is belongs to (for ViNS created at resource group level, 0 otherwise).",
|
|
||||||
},
|
|
||||||
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Unique ID of the account, which this ViNS belongs to.",
|
|
||||||
},
|
|
||||||
|
|
||||||
// the rest of attributes are computed
|
|
||||||
"account_name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Name of the account, which this ViNS belongs to.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"description": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "User-defined text description of this ViNS.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"ext_ip_addr": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "IP address of the external connection (valid for ViNS connected to external network, empty string otherwise).",
|
|
||||||
},
|
|
||||||
|
|
||||||
"ext_net_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
Description: "ID of the external network this ViNS is connected to (-1 means no external connection).",
|
|
||||||
},
|
|
||||||
|
|
||||||
"ipcidr": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Computed: true,
|
|
||||||
Description: "Network address used by this ViNS.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
106
internal/service/cloudapi/vins/data_source_vins_audits.go
Normal file
106
internal/service/cloudapi/vins/data_source_vins_audits.go
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
audits, err := utilityVinsAuditsCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenVinsAudits(audits))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsAuditsSchemaMake() map[string]*schema.Schema {
|
||||||
|
rets := map[string]*schema.Schema{
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"call": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"response_time": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"statuscode": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
Type: schema.TypeFloat,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsAudits() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceVinsAuditsRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
Schema: DataSourceVinsAuditsSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
110
internal/service/cloudapi/vins/data_source_vins_ext_net_list.go
Normal file
110
internal/service/cloudapi/vins/data_source_vins_ext_net_list.go
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsExtNetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
extNetList, err := utilityVinsExtNetListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenVinsExtNetList(extNetList))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsExtNetListchemaMake() map[string]*schema.Schema {
|
||||||
|
rets := map[string]*schema.Schema{
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"default_gw": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ext_net_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"prefix_len": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"tech_status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsExtNetList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceVinsExtNetListRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
Schema: DataSourceVinsExtNetListchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
114
internal/service/cloudapi/vins/data_source_vins_ip_list.go
Normal file
114
internal/service/cloudapi/vins/data_source_vins_ip_list.go
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsIpListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
ips, err := utilityVinsIpListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenVinsIpList(ips))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsIpListSchemaMake() map[string]*schema.Schema {
|
||||||
|
rets := map[string]*schema.Schema{
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"client_type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"domainname": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"hostname": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"mac": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vm_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsIpList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceVinsIpListRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
Schema: DataSourceVinsIpListSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,190 +1,164 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://github.com/rudecs/terraform-provider-decort
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package vins
|
package vins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenVinsList(vl VinsList) []map[string]interface{} {
|
func dataSourceVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
res := make([]map[string]interface{}, 0)
|
vinsList, err := utilityVinsListCheckPresence(ctx, d, m)
|
||||||
for _, v := range vl {
|
if err != nil {
|
||||||
temp := map[string]interface{}{
|
return diag.FromErr(err)
|
||||||
"account_id": v.AccountId,
|
}
|
||||||
"account_name": v.AccountName,
|
|
||||||
"created_by": v.CreatedBy,
|
id := uuid.New()
|
||||||
"created_time": v.CreatedTime,
|
d.SetId(id.String())
|
||||||
"deleted_by": v.DeletedBy,
|
d.Set("items", flattenVinsList(vinsList))
|
||||||
"deleted_time": v.DeletedTime,
|
|
||||||
"external_ip": v.ExternalIP,
|
return nil
|
||||||
"vins_id": v.ID,
|
}
|
||||||
"vins_name": v.Name,
|
|
||||||
"network": v.Network,
|
func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
|
||||||
"rg_id": v.RGID,
|
res := map[string]*schema.Schema{
|
||||||
"rg_name": v.RGName,
|
"include_deleted": {
|
||||||
"status": v.Status,
|
Type: schema.TypeBool,
|
||||||
"updated_by": v.UpdatedBy,
|
Optional: true,
|
||||||
"updated_time": v.UpdatedTime,
|
Default: false,
|
||||||
"vxlan_id": v.VXLanID,
|
Description: "include deleted computes",
|
||||||
}
|
},
|
||||||
res = append(res, temp)
|
"page": {
|
||||||
}
|
Type: schema.TypeInt,
|
||||||
return res
|
Optional: true,
|
||||||
}
|
Description: "Page number",
|
||||||
|
},
|
||||||
func dataSourceVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
"size": {
|
||||||
vinsList, err := utilityVinsListCheckPresence(ctx, d, m)
|
Type: schema.TypeInt,
|
||||||
if err != nil {
|
Optional: true,
|
||||||
return diag.FromErr(err)
|
Description: "Page size",
|
||||||
}
|
},
|
||||||
|
"items": {
|
||||||
id := uuid.New()
|
Type: schema.TypeList,
|
||||||
d.SetId(id.String())
|
Computed: true,
|
||||||
d.Set("items", flattenVinsList(vinsList))
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
return nil
|
"account_id": {
|
||||||
}
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
|
},
|
||||||
res := map[string]*schema.Schema{
|
"account_name": {
|
||||||
"include_deleted": {
|
Type: schema.TypeString,
|
||||||
Type: schema.TypeBool,
|
Computed: true,
|
||||||
Optional: true,
|
},
|
||||||
Default: false,
|
"created_by": {
|
||||||
Description: "include deleted computes",
|
Type: schema.TypeString,
|
||||||
},
|
Computed: true,
|
||||||
"page": {
|
},
|
||||||
Type: schema.TypeInt,
|
"created_time": {
|
||||||
Optional: true,
|
Type: schema.TypeInt,
|
||||||
Description: "Page number",
|
Computed: true,
|
||||||
},
|
},
|
||||||
"size": {
|
"deleted_by": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Computed: true,
|
||||||
Description: "Page size",
|
},
|
||||||
},
|
"deleted_time": {
|
||||||
"items": {
|
Type: schema.TypeInt,
|
||||||
Type: schema.TypeList,
|
Computed: true,
|
||||||
Computed: true,
|
},
|
||||||
Elem: &schema.Resource{
|
"external_ip": {
|
||||||
Schema: map[string]*schema.Schema{
|
Type: schema.TypeString,
|
||||||
"account_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"vins_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"account_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"vins_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"created_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"network": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"created_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"rg_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"deleted_by": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"rg_name": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"deleted_time": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"status": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"external_ip": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"updated_by": {
|
||||||
},
|
Type: schema.TypeString,
|
||||||
"vins_id": {
|
Computed: true,
|
||||||
Type: schema.TypeInt,
|
},
|
||||||
Computed: true,
|
"updated_time": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"vins_name": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
"vxlan_id": {
|
||||||
},
|
Type: schema.TypeInt,
|
||||||
"network": {
|
Computed: true,
|
||||||
Type: schema.TypeString,
|
},
|
||||||
Computed: true,
|
},
|
||||||
},
|
},
|
||||||
"rg_id": {
|
},
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Computed: true,
|
return res
|
||||||
},
|
}
|
||||||
"rg_name": {
|
|
||||||
Type: schema.TypeString,
|
func DataSourceVinsList() *schema.Resource {
|
||||||
Computed: true,
|
return &schema.Resource{
|
||||||
},
|
SchemaVersion: 1,
|
||||||
"status": {
|
|
||||||
Type: schema.TypeString,
|
ReadContext: dataSourceVinsListRead,
|
||||||
Computed: true,
|
|
||||||
},
|
Timeouts: &schema.ResourceTimeout{
|
||||||
"updated_by": {
|
Read: &constants.Timeout30s,
|
||||||
Type: schema.TypeString,
|
Default: &constants.Timeout60s,
|
||||||
Computed: true,
|
},
|
||||||
},
|
|
||||||
"updated_time": {
|
Schema: dataSourceVinsListSchemaMake(),
|
||||||
Type: schema.TypeInt,
|
}
|
||||||
Computed: true,
|
}
|
||||||
},
|
|
||||||
"vxlan_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Computed: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func DataSourceVinsList() *schema.Resource {
|
|
||||||
return &schema.Resource{
|
|
||||||
SchemaVersion: 1,
|
|
||||||
|
|
||||||
ReadContext: dataSourceVinsListRead,
|
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
|
||||||
Read: &constants.Timeout30s,
|
|
||||||
Default: &constants.Timeout60s,
|
|
||||||
},
|
|
||||||
|
|
||||||
Schema: dataSourceVinsListSchemaMake(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
158
internal/service/cloudapi/vins/data_source_vins_list_deleted.go
Normal file
158
internal/service/cloudapi/vins/data_source_vins_list_deleted.go
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
vinsList, err := utilityVinsListDeletedCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenVinsList(vinsList))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataSourceVinsListDeletedSchemaMake() map[string]*schema.Schema {
|
||||||
|
res := map[string]*schema.Schema{
|
||||||
|
"page": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page number",
|
||||||
|
},
|
||||||
|
"size": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Description: "Page size",
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"account_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"account_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"created_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"created_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"deleted_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"deleted_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"external_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vins_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rg_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rg_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_by": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"updated_time": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vxlan_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsListDeleted() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceVinsListDeletedRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
|
||||||
|
Schema: dataSourceVinsListDeletedSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
118
internal/service/cloudapi/vins/data_source_vins_nat_rule_list.go
Normal file
118
internal/service/cloudapi/vins/data_source_vins_nat_rule_list.go
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dataSourceVinsNatRuleListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
natRules, err := utilityVinsNatRuleListCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
id := uuid.New()
|
||||||
|
d.SetId(id.String())
|
||||||
|
d.Set("items", flattenVinsNatRuleList(natRules))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsNatRuleListSchemaMake() map[string]*schema.Schema {
|
||||||
|
rets := map[string]*schema.Schema{
|
||||||
|
"vins_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Required: true,
|
||||||
|
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"local_ip": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"local_port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"protocol": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"public_port_end": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"public_port_start": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vm_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"vm_name": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return rets
|
||||||
|
}
|
||||||
|
|
||||||
|
func DataSourceVinsNatRuleList() *schema.Resource {
|
||||||
|
return &schema.Resource{
|
||||||
|
SchemaVersion: 1,
|
||||||
|
|
||||||
|
ReadContext: dataSourceVinsNatRuleListRead,
|
||||||
|
|
||||||
|
Timeouts: &schema.ResourceTimeout{
|
||||||
|
Read: &constants.Timeout30s,
|
||||||
|
Default: &constants.Timeout60s,
|
||||||
|
},
|
||||||
|
Schema: DataSourceVinsNatRuleListSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
514
internal/service/cloudapi/vins/flattens.go
Normal file
514
internal/service/cloudapi/vins/flattens.go
Normal file
@@ -0,0 +1,514 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
|
||||||
|
func flattenMGMT(mgmt *VNFConfigMGMT) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"ip_addr": mgmt.IPAddr,
|
||||||
|
"password": mgmt.Password,
|
||||||
|
"ssh_key": mgmt.SSHKey,
|
||||||
|
"user": mgmt.User,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenResources(resources *VNFConfigResources) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"cpu": resources.CPU,
|
||||||
|
"ram": resources.RAM,
|
||||||
|
"stack_id": resources.StackID,
|
||||||
|
"uuid": resources.UUID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenConfig(config VNFConfig) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"mgmt": flattenMGMT(&config.MGMT),
|
||||||
|
"resources": flattenResources(&config.Resources),
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenQOS(qos QOS) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"e_rate": qos.ERate,
|
||||||
|
"guid": qos.GUID,
|
||||||
|
"in_brust": qos.InBurst,
|
||||||
|
"in_rate": qos.InRate,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenInterfaces(interfaces VNFInterfaceList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
|
||||||
|
for _, vnfInterface := range interfaces {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"conn_id": vnfInterface.ConnID,
|
||||||
|
"conn_type": vnfInterface.ConnType,
|
||||||
|
"def_gw": vnfInterface.DefGW,
|
||||||
|
"flipgroup_id": vnfInterface.FlipGroupID,
|
||||||
|
"guid": vnfInterface.GUID,
|
||||||
|
"ip_address": vnfInterface.IPAddress,
|
||||||
|
"listen_ssh": vnfInterface.ListenSSH,
|
||||||
|
"mac": vnfInterface.MAC,
|
||||||
|
"name": vnfInterface.Name,
|
||||||
|
"net_id": vnfInterface.NetID,
|
||||||
|
"net_mask": vnfInterface.NetMask,
|
||||||
|
"net_type": vnfInterface.NetType,
|
||||||
|
"pci_slot": vnfInterface.PCISlot,
|
||||||
|
"qos": flattenQOS(vnfInterface.QOS),
|
||||||
|
"target": vnfInterface.Target,
|
||||||
|
"type": vnfInterface.Type,
|
||||||
|
"vnfs": vnfInterface.VNFS,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVNFDev(vnfDev VNFDev) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"_ckey": vnfDev.CKey,
|
||||||
|
"account_id": vnfDev.AccountID,
|
||||||
|
"capabilities": vnfDev.Capabilities,
|
||||||
|
"config": flattenConfig(vnfDev.Config), //in progress
|
||||||
|
"config_saved": vnfDev.ConfigSaved,
|
||||||
|
"custom_pre_cfg": vnfDev.CustomPreConfig,
|
||||||
|
"desc": vnfDev.Description,
|
||||||
|
"gid": vnfDev.GID,
|
||||||
|
"guid": vnfDev.GUID,
|
||||||
|
"vnf_id": vnfDev.ID,
|
||||||
|
"interfaces": flattenInterfaces(vnfDev.Interfaces),
|
||||||
|
"lock_status": vnfDev.LockStatus,
|
||||||
|
"milestones": vnfDev.Milestones,
|
||||||
|
"vnf_name": vnfDev.Name,
|
||||||
|
"status": vnfDev.Status,
|
||||||
|
"tech_status": vnfDev.TechStatus,
|
||||||
|
"type": vnfDev.Type,
|
||||||
|
"vins": vnfDev.VINS,
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenComputes(computes VINSComputeList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, compute := range computes {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"compute_id": compute.ID,
|
||||||
|
"compute_name": compute.Name,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenReservations(reservations ReservationList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, reservation := range reservations {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"client_type": reservation.ClientType,
|
||||||
|
"desc": reservation.Description,
|
||||||
|
"domainname": reservation.DomainName,
|
||||||
|
"hostname": reservation.HostName,
|
||||||
|
"ip": reservation.IP,
|
||||||
|
"mac": reservation.MAC,
|
||||||
|
"type": reservation.Type,
|
||||||
|
"vm_id": reservation.VMID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenDHCPConfig(config DHCPConfig) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"default_gw": config.DefaultGW,
|
||||||
|
"dns": config.DNS,
|
||||||
|
"ip_end": config.IPEnd,
|
||||||
|
"ip_start": config.IPStart,
|
||||||
|
"lease": config.Lease,
|
||||||
|
"netmask": config.Netmask,
|
||||||
|
"network": config.Network,
|
||||||
|
"reservations": flattenReservations(config.Reservations),
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenPrimary(primary DevicePrimary) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"dev_id": primary.DevID,
|
||||||
|
"iface01": primary.IFace01,
|
||||||
|
"iface02": primary.IFace02,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenDevices(devices Devices) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"primary": flattenPrimary(devices.Primary),
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenDHCP(dhcp DHCP) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"_ckey": dhcp.CKey,
|
||||||
|
"account_id": dhcp.AccountID,
|
||||||
|
"config": flattenDHCPConfig(dhcp.Config),
|
||||||
|
"created_time": dhcp.CreatedTime,
|
||||||
|
"devices": flattenDevices(dhcp.Devices),
|
||||||
|
"gid": dhcp.GID,
|
||||||
|
"guid": dhcp.GUID,
|
||||||
|
"dhcp_id": dhcp.ID,
|
||||||
|
"lock_status": dhcp.LockStatus,
|
||||||
|
"milestones": dhcp.Milestones,
|
||||||
|
"owner_id": dhcp.OwnerID,
|
||||||
|
"owner_type": dhcp.OwnerType,
|
||||||
|
"pure_virtual": dhcp.PureVirtual,
|
||||||
|
"status": dhcp.Status,
|
||||||
|
"tech_status": dhcp.TechStatus,
|
||||||
|
"type": dhcp.Type,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenGWConfig(config GWConfig) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"default_gw": config.DefaultGW,
|
||||||
|
"ext_net_id": config.ExtNetID,
|
||||||
|
"ext_net_ip": config.ExtNetIP,
|
||||||
|
"ext_netmask": config.ExtNetMask,
|
||||||
|
"qos": flattenQOS(config.QOS),
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenGW(gw GW) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"_ckey": gw.CKey,
|
||||||
|
"account_id": gw.AccountID,
|
||||||
|
"config": flattenGWConfig(gw.Config),
|
||||||
|
"created_time": gw.CreatedTime,
|
||||||
|
"devices": flattenDevices(gw.Devices),
|
||||||
|
"gid": gw.GID,
|
||||||
|
"guid": gw.GUID,
|
||||||
|
"gw_id": gw.ID,
|
||||||
|
"lock_status": gw.LockStatus,
|
||||||
|
"milestones": gw.Milestones,
|
||||||
|
"owner_id": gw.OwnerID,
|
||||||
|
"owner_type": gw.OwnerType,
|
||||||
|
"pure_virtual": gw.PureVirtual,
|
||||||
|
"status": gw.Status,
|
||||||
|
"tech_status": gw.TechStatus,
|
||||||
|
"type": gw.Type,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenRules(rules ListNATRules) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, rule := range rules {
|
||||||
|
tmp := map[string]interface{}{
|
||||||
|
"rule_id": rule.ID,
|
||||||
|
"local_ip": rule.LocalIP,
|
||||||
|
"local_port": rule.LocalPort,
|
||||||
|
"protocol": rule.Protocol,
|
||||||
|
"public_port_end": rule.PublicPortEnd,
|
||||||
|
"public_port_start": rule.PublicPortStart,
|
||||||
|
"vm_id": rule.VMID,
|
||||||
|
"vm_name": rule.VMName,
|
||||||
|
}
|
||||||
|
res = append(res, tmp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenNATConfig(config NATConfig) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"net_mask": config.NetMask,
|
||||||
|
"network": config.Network,
|
||||||
|
"rules": flattenRules(config.Rules),
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenNAT(nat NAT) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"_ckey": nat.CKey,
|
||||||
|
"account_id": nat.AccountID,
|
||||||
|
"created_time": nat.CreatedTime,
|
||||||
|
"config": flattenNATConfig(nat.Config),
|
||||||
|
"devices": flattenDevices(nat.Devices),
|
||||||
|
"gid": nat.GID,
|
||||||
|
"guid": nat.GUID,
|
||||||
|
"nat_id": nat.ID,
|
||||||
|
"lock_status": nat.LockStatus,
|
||||||
|
"milestones": nat.Milestones,
|
||||||
|
"owner_id": nat.OwnerID,
|
||||||
|
"owner_type": nat.OwnerType,
|
||||||
|
"pure_virtual": nat.PureVirtual,
|
||||||
|
"status": nat.Status,
|
||||||
|
"tech_status": nat.TechStatus,
|
||||||
|
"type": nat.Type,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVNFS(vnfs VNFS) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"dhcp": flattenDHCP(vnfs.DHCP),
|
||||||
|
"gw": flattenGW(vnfs.GW),
|
||||||
|
"nat": flattenNAT(vnfs.NAT),
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenRuleBlock(rules ListNATRules) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, rule := range rules {
|
||||||
|
tmp := map[string]interface{}{
|
||||||
|
"int_ip": rule.LocalIP,
|
||||||
|
"int_port": rule.LocalPort,
|
||||||
|
"ext_port_start": rule.PublicPortStart,
|
||||||
|
"ext_port_end": rule.PublicPortEnd,
|
||||||
|
"proto": rule.Protocol,
|
||||||
|
"rule_id": rule.ID,
|
||||||
|
}
|
||||||
|
res = append(res, tmp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVins(d *schema.ResourceData, vins VINSDetailed) {
|
||||||
|
d.Set("vins_id", vins.ID)
|
||||||
|
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||||
|
d.Set("_ckey", vins.CKey)
|
||||||
|
d.Set("account_id", vins.AccountID)
|
||||||
|
d.Set("account_name", vins.AccountName)
|
||||||
|
d.Set("computes", flattenComputes(vins.Computes))
|
||||||
|
d.Set("default_gw", vins.DefaultGW)
|
||||||
|
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||||
|
d.Set("desc", vins.Description)
|
||||||
|
d.Set("gid", vins.GID)
|
||||||
|
d.Set("guid", vins.GUID)
|
||||||
|
d.Set("lock_status", vins.LockStatus)
|
||||||
|
d.Set("manager_id", vins.ManagerID)
|
||||||
|
d.Set("manager_type", vins.ManagerType)
|
||||||
|
d.Set("milestones", vins.Milestones)
|
||||||
|
d.Set("name", vins.Name)
|
||||||
|
d.Set("net_mask", vins.NetMask)
|
||||||
|
d.Set("network", vins.Network)
|
||||||
|
d.Set("pre_reservations_num", vins.PreReservaionsNum)
|
||||||
|
d.Set("redundant", vins.Redundant)
|
||||||
|
d.Set("rg_id", vins.RGID)
|
||||||
|
d.Set("rg_name", vins.RGName)
|
||||||
|
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
|
||||||
|
d.Set("status", vins.Status)
|
||||||
|
d.Set("user_managed", vins.UserManaged)
|
||||||
|
d.Set("vnfs", flattenVNFS(vins.VNFS))
|
||||||
|
d.Set("vxlan_id", vins.VXLanID)
|
||||||
|
d.Set("nat_rule", flattenRuleBlock(vins.VNFS.NAT.Config.Rules))
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVinsData(d *schema.ResourceData, vins VINSDetailed) {
|
||||||
|
d.Set("vins_id", vins.ID)
|
||||||
|
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||||
|
d.Set("_ckey", vins.CKey)
|
||||||
|
d.Set("account_id", vins.AccountID)
|
||||||
|
d.Set("account_name", vins.AccountName)
|
||||||
|
d.Set("computes", flattenComputes(vins.Computes))
|
||||||
|
d.Set("default_gw", vins.DefaultGW)
|
||||||
|
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||||
|
d.Set("desc", vins.Description)
|
||||||
|
d.Set("gid", vins.GID)
|
||||||
|
d.Set("guid", vins.GUID)
|
||||||
|
d.Set("lock_status", vins.LockStatus)
|
||||||
|
d.Set("manager_id", vins.ManagerID)
|
||||||
|
d.Set("manager_type", vins.ManagerType)
|
||||||
|
d.Set("milestones", vins.Milestones)
|
||||||
|
d.Set("name", vins.Name)
|
||||||
|
d.Set("net_mask", vins.NetMask)
|
||||||
|
d.Set("network", vins.Network)
|
||||||
|
d.Set("pre_reservations_num", vins.PreReservaionsNum)
|
||||||
|
d.Set("redundant", vins.Redundant)
|
||||||
|
d.Set("rg_id", vins.RGID)
|
||||||
|
d.Set("rg_name", vins.RGName)
|
||||||
|
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
|
||||||
|
d.Set("status", vins.Status)
|
||||||
|
d.Set("user_managed", vins.UserManaged)
|
||||||
|
d.Set("vnfs", flattenVNFS(vins.VNFS))
|
||||||
|
d.Set("vxlan_id", vins.VXLanID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVinsAudits(auidts VINSAuditsList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, audit := range auidts {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"call": audit.Call,
|
||||||
|
"response_time": audit.ResponseTime,
|
||||||
|
"statuscode": audit.StatusCode,
|
||||||
|
"timestamp": audit.Timestamp,
|
||||||
|
"user": audit.User,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVinsExtNetList(extNetList ExtNetList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, extNet := range extNetList {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"default_gw": extNet.DefaultGW,
|
||||||
|
"ext_net_id": extNet.ExtNetID,
|
||||||
|
"ip": extNet.IP,
|
||||||
|
"prefix_len": extNet.PrefixLen,
|
||||||
|
"status": extNet.Status,
|
||||||
|
"tech_status": extNet.TechStatus,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVinsIpList(ips IPList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, ip := range ips {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"client_type": ip.ClientType,
|
||||||
|
"domainname": ip.DomainName,
|
||||||
|
"hostname": ip.HostName,
|
||||||
|
"ip": ip.IP,
|
||||||
|
"mac": ip.MAC,
|
||||||
|
"type": ip.Type,
|
||||||
|
"vm_id": ip.VMID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVinsList(vl VINSList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, v := range vl {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"account_id": v.AccountID,
|
||||||
|
"account_name": v.AccountName,
|
||||||
|
"created_by": v.CreatedBy,
|
||||||
|
"created_time": v.CreatedTime,
|
||||||
|
"deleted_by": v.DeletedBy,
|
||||||
|
"deleted_time": v.DeletedTime,
|
||||||
|
"external_ip": v.ExternalIP,
|
||||||
|
"vins_id": v.ID,
|
||||||
|
"vins_name": v.Name,
|
||||||
|
"network": v.Network,
|
||||||
|
"rg_id": v.RGID,
|
||||||
|
"rg_name": v.RGName,
|
||||||
|
"status": v.Status,
|
||||||
|
"updated_by": v.UpdatedBy,
|
||||||
|
"updated_time": v.UpdatedTime,
|
||||||
|
"vxlan_id": v.VXLANID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenVinsNatRuleList(natRules NATRuleList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, natRule := range natRules {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"id": natRule.ID,
|
||||||
|
"local_ip": natRule.LocalIP,
|
||||||
|
"local_port": natRule.LocalPort,
|
||||||
|
"protocol": natRule.Protocol,
|
||||||
|
"public_port_end": natRule.PublicPortEnd,
|
||||||
|
"public_port_start": natRule.PublicPortStart,
|
||||||
|
"vm_id": natRule.VMID,
|
||||||
|
"vm_name": natRule.VMName,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -1,94 +1,330 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
You may obtain a copy of the License at
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
Unless required by applicable law or agreed to in writing, software
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
See the License for the specific language governing permissions and
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
limitations under the License.
|
See the License for the specific language governing permissions and
|
||||||
*/
|
limitations under the License.
|
||||||
|
*/
|
||||||
/*
|
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
/*
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
Source code: https://github.com/rudecs/terraform-provider-decort
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
Please see README.md to learn where to place source code so that it
|
|
||||||
builds seamlessly.
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
|
||||||
*/
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
package vins
|
|
||||||
|
package vins
|
||||||
type Vins struct {
|
|
||||||
AccountId int `json:"accountId"`
|
type VINSRecord struct {
|
||||||
AccountName string `json:"accountName"`
|
AccountID uint64 `json:"accountId"`
|
||||||
CreatedBy string `json:"createdBy"`
|
AccountName string `json:"accountName"`
|
||||||
CreatedTime int `json:"createdTime"`
|
CreatedBy string `json:"createdBy"`
|
||||||
DeletedBy string `json:"deletedBy"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
DeletedTime int `json:"deletedTime"`
|
DeletedBy string `json:"deletedBy"`
|
||||||
ExternalIP string `json:"externalIP"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
ID int `json:"id"`
|
ExternalIP string `json:"externalIP"`
|
||||||
Name string `json:"name"`
|
ID uint64 `json:"id"`
|
||||||
Network string `json:"network"`
|
Name string `json:"name"`
|
||||||
RGID int `json:"rgId"`
|
Network string `json:"network"`
|
||||||
RGName string `json:"rgName"`
|
RGID uint64 `json:"rgId"`
|
||||||
Status string `json:"status"`
|
RGName string `json:"rgName"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
Status string `json:"status"`
|
||||||
UpdatedTime int `json:"updatedTime"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
VXLanID int `json:"vxlanId"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
}
|
VXLANID uint64 `json:"vxlanId"`
|
||||||
|
}
|
||||||
type VinsList []Vins
|
|
||||||
|
type VINSList []VINSRecord
|
||||||
type VinsSearchResp []VinsSearchRecord
|
|
||||||
|
type VINSAudits struct {
|
||||||
type VnfRecord struct {
|
Call string `json:"call"`
|
||||||
ID int `json:"id"`
|
ResponseTime float64 `json:"responsetime"`
|
||||||
AccountID int `json:"accountId"`
|
StatusCode uint64 `json:"statuscode"`
|
||||||
Type string `json:"type"` // "DHCP", "NAT", "GW" etc
|
Timestamp float64 `json:"timestamp"`
|
||||||
Config map[string]interface{} `json:"config"` // NOTE: VNF specs vary by VNF type
|
User string `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type VnfGwConfigRecord struct { // describes GW VNF config structure inside ViNS, as returned by API vins/get
|
type VINSAuditsList []VINSAudits
|
||||||
ExtNetID int `json:"ext_net_id"`
|
|
||||||
ExtNetIP string `json:"ext_net_ip"`
|
type VINSExtNet struct {
|
||||||
ExtNetMask int `json:"ext_net_mask"`
|
DefaultGW string `json:"default_gw"`
|
||||||
DefaultGW string `json:"default_gw"`
|
ExtNetID uint64 `json:"ext_net_id"`
|
||||||
}
|
IP string `json:"ip"`
|
||||||
type VinsRecord struct { // represents part of the response from API vins/get
|
PrefixLen uint64 `json:"prefixlen"`
|
||||||
ID int `json:"id"`
|
Status string `json:"status"`
|
||||||
Name string `json:"name"`
|
TechStatus string `json:"techStatus"`
|
||||||
IPCidr string `json:"network"`
|
}
|
||||||
VxLanID int `json:"vxlanId"`
|
|
||||||
ExternalIP string `json:"externalIP"`
|
type ExtNetList []VINSExtNet
|
||||||
AccountID int `json:"accountId"`
|
|
||||||
AccountName string `json:"accountName"`
|
type IP struct {
|
||||||
RgID int `json:"rgid"`
|
ClientType string `json:"clientType"`
|
||||||
RgName string `json:"rgName"`
|
DomainName string `json:"domainname"`
|
||||||
VNFs map[string]VnfRecord `json:"vnfs"`
|
HostName string `json:"hostname"`
|
||||||
Desc string `json:"desc"`
|
IP string `json:"ip"`
|
||||||
}
|
MAC string `json:"mac"`
|
||||||
|
Type string `json:"type"`
|
||||||
type VinsSearchRecord struct {
|
VMID uint64 `json:"vmId"`
|
||||||
ID int `json:"id"`
|
}
|
||||||
Name string `json:"name"`
|
|
||||||
IPCidr string `json:"network"`
|
type IPList []IP
|
||||||
VxLanID int `json:"vxlanId"`
|
|
||||||
ExternalIP string `json:"externalIP"`
|
type VNFDev struct {
|
||||||
AccountID int `json:"accountId"`
|
CKey string `json:"_ckey"`
|
||||||
AccountName string `json:"accountName"`
|
AccountID uint64 `json:"accountId"`
|
||||||
RgID int `json:"rgId"`
|
Capabilities []string `json:"capabilities"`
|
||||||
RgName string `json:"rgName"`
|
Config VNFConfig `json:"config"`
|
||||||
}
|
ConfigSaved bool `json:"configSaved"`
|
||||||
|
CustomPreConfig bool `json:"customPrecfg"`
|
||||||
|
Description string `json:"desc"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
Interfaces VNFInterfaceList `json:"interfaces"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
VINS []uint64 `json:"vins"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFConfig struct {
|
||||||
|
MGMT VNFConfigMGMT `json:"mgmt"`
|
||||||
|
Resources VNFConfigResources `json:"resources"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFConfigMGMT struct {
|
||||||
|
IPAddr string `json:"ipaddr"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
SSHKey string `json:"sshkey"`
|
||||||
|
User string `json:"user"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFConfigResources struct {
|
||||||
|
CPU uint64 `json:"cpu"`
|
||||||
|
RAM uint64 `json:"ram"`
|
||||||
|
StackID uint64 `json:"stackId"`
|
||||||
|
UUID string `json:"uuid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFInterface struct {
|
||||||
|
ConnID uint64 `json:"connId"`
|
||||||
|
ConnType string `json:"connType"`
|
||||||
|
DefGW string `json:"defGw"`
|
||||||
|
FlipGroupID uint64 `json:"flipgroupId"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
IPAddress string `json:"ipAddress"`
|
||||||
|
ListenSSH bool `json:"listenSsh"`
|
||||||
|
MAC string `json:"mac"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
NetID uint64 `json:"netId"`
|
||||||
|
NetMask uint64 `json:"netMask"`
|
||||||
|
NetType string `json:"netType"`
|
||||||
|
PCISlot uint64 `json:"pciSlot"`
|
||||||
|
QOS QOS `json:"qos"`
|
||||||
|
Target string `json:"target"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
VNFS []uint64 `json:"vnfs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type QOS struct {
|
||||||
|
ERate uint64 `json:"eRate"`
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
InBurst uint64 `json:"inBurst"`
|
||||||
|
InRate uint64 `json:"inRate"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VNFInterfaceList []VNFInterface
|
||||||
|
|
||||||
|
type VINSCompute struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VINSComputeList []VINSCompute
|
||||||
|
|
||||||
|
type VNFS struct {
|
||||||
|
DHCP DHCP `json:"DHCP"`
|
||||||
|
GW GW `json:"GW"`
|
||||||
|
NAT NAT `json:"NAT"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NAT struct {
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
Config NATConfig `json:"config"`
|
||||||
|
Devices Devices `json:"devices"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
OwnerID uint64 `json:"ownerId"`
|
||||||
|
OwnerType string `json:"ownerType"`
|
||||||
|
PureVirtual bool `json:"pureVirtual"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NATConfig struct {
|
||||||
|
NetMask uint64 `json:"netmask"`
|
||||||
|
Network string `json:"network"`
|
||||||
|
Rules ListNATRules `json:"rules"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ItemNATRule struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LocalIP string `json:"localIp"`
|
||||||
|
LocalPort uint64 `json:"localPort"`
|
||||||
|
Protocol string `json:"protocol"`
|
||||||
|
PublicPortEnd uint64 `json:"publicPortEnd"`
|
||||||
|
PublicPortStart uint64 `json:"publicPortStart"`
|
||||||
|
VMID uint64 `json:"vmId"`
|
||||||
|
VMName string `json:"vmName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListNATRules []ItemNATRule
|
||||||
|
|
||||||
|
type GW struct {
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
Config GWConfig `json:"config"`
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
Devices Devices `json:"devices"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
OwnerID uint64 `json:"ownerId"`
|
||||||
|
OwnerType string `json:"ownerType"`
|
||||||
|
PureVirtual bool `json:"pureVirtual"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GWConfig struct {
|
||||||
|
DefaultGW string `json:"default_gw"`
|
||||||
|
ExtNetID uint64 `json:"ext_net_id"`
|
||||||
|
ExtNetIP string `json:"ext_net_ip"`
|
||||||
|
ExtNetMask uint64 `json:"ext_netmask"`
|
||||||
|
QOS QOS `json:"qos"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Devices struct {
|
||||||
|
Primary DevicePrimary `json:"primary"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DevicePrimary struct {
|
||||||
|
DevID uint64 `json:"devId"`
|
||||||
|
IFace01 string `json:"iface01"`
|
||||||
|
IFace02 string `json:"iface02"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DHCP struct {
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
Config DHCPConfig `json:"config"`
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
Devices Devices `json:"devices"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
OwnerID uint64 `json:"ownerId"`
|
||||||
|
OwnerType string `json:"ownerType"`
|
||||||
|
PureVirtual bool `json:"pureVirtual"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TechStatus string `json:"techStatus"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DHCPConfig struct {
|
||||||
|
DefaultGW string `json:"default_gw"`
|
||||||
|
DNS []string `json:"dns"`
|
||||||
|
IPEnd string `json:"ip_end"`
|
||||||
|
IPStart string `json:"ip_start"`
|
||||||
|
Lease uint64 `json:"lease"`
|
||||||
|
Netmask uint64 `json:"netmask"`
|
||||||
|
Network string `json:"network"`
|
||||||
|
Reservations ReservationList `json:"reservations"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VINSDetailed struct {
|
||||||
|
VNFDev VNFDev `json:"VNFDev"`
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
AccountName string `json:"accountName"`
|
||||||
|
Computes VINSComputeList `json:"computes"`
|
||||||
|
DefaultGW string `json:"defaultGW"`
|
||||||
|
DefaultQOS QOS `json:"defaultQos"`
|
||||||
|
Description string `json:"desc"`
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
ManagerID uint64 `json:"managerId"`
|
||||||
|
ManagerType string `json:"managerType"`
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
NetMask uint64 `json:"netMask"`
|
||||||
|
Network string `json:"network"`
|
||||||
|
PreReservaionsNum uint64 `json:"preReservationsNum"`
|
||||||
|
Redundant bool `json:"redundant"`
|
||||||
|
RGID uint64 `json:"rgId"`
|
||||||
|
RGName string `json:"rgName"`
|
||||||
|
SecVNFDevID uint64 `json:"secVnfDevId"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
UserManaged bool `json:"userManaged"`
|
||||||
|
VNFS VNFS `json:"vnfs"`
|
||||||
|
VXLanID uint64 `json:"vxlanId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Reservation struct {
|
||||||
|
ClientType string `json:"clientType"`
|
||||||
|
Description string `json:"desc"`
|
||||||
|
DomainName string `json:"domainname"`
|
||||||
|
HostName string `json:"hostname"`
|
||||||
|
IP string `json:"ip"`
|
||||||
|
MAC string `json:"mac"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
VMID int `json:"vmId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReservationList []Reservation
|
||||||
|
|
||||||
|
type NATRule struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
LocalIP string `json:"localIp"`
|
||||||
|
LocalPort uint64 `json:"localPort"`
|
||||||
|
Protocol string `json:"protocol"`
|
||||||
|
PublicPortEnd uint64 `json:"publicPortEnd"`
|
||||||
|
PublicPortStart uint64 `json:"publicPortStart"`
|
||||||
|
VMID uint64 `json:"vmId"`
|
||||||
|
VMName string `json:"vmName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NATRuleList []NATRule
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -39,6 +40,8 @@ import (
|
|||||||
|
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
"github.com/rudecs/terraform-provider-decort/internal/constants"
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/dc"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/status"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
@@ -46,112 +49,221 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ipcidrDiffSupperss(key, oldVal, newVal string, d *schema.ResourceData) bool {
|
|
||||||
if oldVal == "" && newVal != "" {
|
|
||||||
// if old value for "ipcidr" resource is empty string, it means that we are creating new ViNS
|
|
||||||
// and there is a chance that the user will want specific IP address range for this ViNS -
|
|
||||||
// check if "ipcidr" is explicitly set in TF file to a non-empty string.
|
|
||||||
log.Debugf("ipcidrDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=FALSE", key, oldVal, newVal)
|
|
||||||
return false // there is a difference between stored and new value
|
|
||||||
}
|
|
||||||
log.Debugf("ipcidrDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=TRUE", key, oldVal, newVal)
|
|
||||||
return true // suppress difference
|
|
||||||
}
|
|
||||||
|
|
||||||
func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceVinsCreate: called for ViNS name %s, Account ID %d, RG ID %d",
|
|
||||||
d.Get("name").(string), d.Get("account_id").(int), d.Get("rg_id").(int))
|
|
||||||
|
|
||||||
apiToCall := VinsCreateInAccountAPI
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
urlValues.Add("name", d.Get("name").(string))
|
rgId, rgOk := d.GetOk("rg_id")
|
||||||
|
accountId, accountIdOk := d.GetOk("account_id")
|
||||||
argVal, argSet := d.GetOk("rg_id")
|
if !rgOk && !accountIdOk {
|
||||||
if argSet && argVal.(int) > 0 {
|
return diag.Errorf("resourceVinsCreate: no valid accountId or resource group ID specified")
|
||||||
apiToCall = VinsCreateInRgAPI
|
|
||||||
urlValues.Add("rgId", fmt.Sprintf("%d", argVal.(int)))
|
|
||||||
} else {
|
|
||||||
// RG ID either not set at all or set to 0 - user may want ViNS at account level
|
|
||||||
argVal, argSet = d.GetOk("account_id")
|
|
||||||
if !argSet || argVal.(int) <= 0 {
|
|
||||||
// No valid Account ID (and no RG ID either) - cannot create ViNS
|
|
||||||
return diag.Errorf("resourceVinsCreate: ViNS name %s - no valid account and/or resource group ID specified", d.Id())
|
|
||||||
}
|
|
||||||
urlValues.Add("accountId", fmt.Sprintf("%d", argVal.(int)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
argVal, argSet = d.GetOk("ext_net_id") // NB: even if ext_net_id value is explicitly set to 0, argSet = false anyway
|
if rgOk {
|
||||||
if argSet {
|
urlValues.Add("name", d.Get("name").(string))
|
||||||
if argVal.(int) > 0 {
|
urlValues.Add("rgId", strconv.Itoa(rgId.(int)))
|
||||||
// connect to specific external network
|
if ipcidr, ok := d.GetOk("ipcidr"); ok {
|
||||||
urlValues.Add("extNetId", fmt.Sprintf("%d", argVal.(int)))
|
urlValues.Add("ipcidr", ipcidr.(string))
|
||||||
/*
|
}
|
||||||
Commented out, as we've made "ext_net_ip" parameter non-configurable via Terraform!
|
|
||||||
|
|
||||||
// in case of specific ext net connection user may also want a particular IP address
|
//extnet v1
|
||||||
argVal, argSet = d.GetOk("ext_net_ip")
|
urlValues.Add("extNetId", strconv.Itoa(d.Get("ext_net_id").(int)))
|
||||||
if argSet && argVal.(string) != "" {
|
if extIp, ok := d.GetOk("ext_ip_addr"); ok {
|
||||||
urlValues.Add("extIp", argVal.(string))
|
urlValues.Add("extIp", extIp.(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
//extnet v2
|
||||||
|
if extNetResp, ok := d.GetOk("ext_net"); ok {
|
||||||
|
extNetSl := extNetResp.([]interface{})
|
||||||
|
extNet := extNetSl[0].(map[string]interface{})
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
urlValues.Add("netId", strconv.Itoa(extNet["ext_net_id"].(int)))
|
||||||
|
urlValues.Add("extIp", extNet["ext_net_ip"].(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
if desc, ok := d.GetOk("desc"); ok {
|
||||||
|
urlValues.Add("desc", desc.(string))
|
||||||
|
}
|
||||||
|
urlValues.Add("preReservationsNum", strconv.Itoa(d.Get("pre_reservations_num").(int)))
|
||||||
|
id, err := c.DecortAPICall(ctx, "POST", VinsCreateInRgAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId(id)
|
||||||
|
} else if accountIdOk {
|
||||||
|
urlValues.Add("name", d.Get("name").(string))
|
||||||
|
urlValues.Add("accountId", strconv.Itoa(accountId.(int)))
|
||||||
|
if gid, ok := d.GetOk("gid"); ok {
|
||||||
|
urlValues.Add("gid", strconv.Itoa(gid.(int)))
|
||||||
|
}
|
||||||
|
if ipcidr, ok := d.GetOk("ipcidr"); ok {
|
||||||
|
urlValues.Add("ipcidr", ipcidr.(string))
|
||||||
|
}
|
||||||
|
if desc, ok := d.GetOk("desc"); ok {
|
||||||
|
urlValues.Add("desc", desc.(string))
|
||||||
|
}
|
||||||
|
urlValues.Add("preReservationsNum", strconv.Itoa(d.Get("pre_reservations_num").(int)))
|
||||||
|
id, err := c.DecortAPICall(ctx, "POST", VinsCreateInAccountAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
d.SetId(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
warnings := dc.Warnings{}
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
if ipRes, ok := d.GetOk("ip"); ok {
|
||||||
|
ipsSlice := ipRes.([]interface{})
|
||||||
|
for _, ipInterfase := range ipsSlice {
|
||||||
|
ip := ipInterfase.(map[string]interface{})
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
urlValues.Add("type", ip["type"].(string))
|
||||||
|
if ipAddr, ok := ip["ip_addr"]; ok {
|
||||||
|
urlValues.Add("ipAddr", ipAddr.(string))
|
||||||
|
}
|
||||||
|
if macAddr, ok := ip["mac_addr"]; ok {
|
||||||
|
urlValues.Add("mac", macAddr.(string))
|
||||||
|
}
|
||||||
|
if computeId, ok := ip["compute_id"]; ok {
|
||||||
|
urlValues.Add("computeId", strconv.Itoa(computeId.(int)))
|
||||||
|
}
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsIpReserveAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
if natRule, ok := d.GetOk("nat_rule"); ok {
|
||||||
|
addedNatRules := natRule.([]interface{})
|
||||||
|
if len(addedNatRules) > 0 {
|
||||||
|
for _, natRuleInterface := range addedNatRules {
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
natRule := natRuleInterface.(map[string]interface{})
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
urlValues.Add("intIp", natRule["int_ip"].(string))
|
||||||
|
urlValues.Add("intPort", strconv.Itoa(natRule["int_port"].(int)))
|
||||||
|
urlValues.Add("extPortStart", strconv.Itoa(natRule["ext_port_start"].(int)))
|
||||||
|
urlValues.Add("extPortEnd", strconv.Itoa(natRule["ext_port_end"].(int)))
|
||||||
|
urlValues.Add("proto", natRule["proto"].(string))
|
||||||
|
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsNatRuleAddAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
*/
|
}
|
||||||
} else {
|
|
||||||
// ext_net_id is set to a negative value - connect to default external network
|
|
||||||
// no particular IP address selection in this case
|
|
||||||
urlValues.Add("extNetId", "0")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argVal, argSet = d.GetOk("ipcidr")
|
defer resourceVinsRead(ctx, d, m)
|
||||||
if argSet && argVal.(string) != "" {
|
return warnings.Get()
|
||||||
log.Debugf("resourceVinsCreate: ipcidr is set to %s", argVal.(string))
|
|
||||||
urlValues.Add("ipcidr", argVal.(string))
|
|
||||||
}
|
|
||||||
|
|
||||||
argVal, argSet = d.GetOk("description")
|
|
||||||
if argSet {
|
|
||||||
urlValues.Add("desc", argVal.(string))
|
|
||||||
}
|
|
||||||
|
|
||||||
apiResp, err := c.DecortAPICall(ctx, "POST", apiToCall, urlValues)
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.SetId(apiResp) // update ID of the resource to tell Terraform that the ViNS resource exists
|
|
||||||
vinsId, _ := strconv.Atoi(apiResp)
|
|
||||||
|
|
||||||
log.Debugf("resourceVinsCreate: new ViNS ID / name %d / %s creation sequence complete", vinsId, d.Get("name").(string))
|
|
||||||
|
|
||||||
// We may reuse dataSourceVinsRead here as we maintain similarity
|
|
||||||
// between ViNS resource and ViNS data source schemas
|
|
||||||
// ViNS resource read function will also update resource ID on success, so that Terraform
|
|
||||||
// will know the resource exists (however, we already did it a few lines before)
|
|
||||||
return dataSourceVinsRead(ctx, d, m)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
vinsFacts, err := utilityVinsCheckPresence(ctx, d, m)
|
c := m.(*controller.ControllerCfg)
|
||||||
if vinsFacts == "" {
|
urlValues := &url.Values{}
|
||||||
// if empty string is returned from utilityVinsCheckPresence then there is no
|
warnings := dc.Warnings{}
|
||||||
// such ViNS and err tells so - just return it to the calling party
|
|
||||||
d.SetId("") // ensure ID is empty
|
vins, err := utilityVinsCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return flattenVins(d, vinsFacts)
|
hasChangeState := false
|
||||||
|
if vins.Status == status.Destroyed {
|
||||||
|
d.SetId("")
|
||||||
|
d.Set("vins_id", 0)
|
||||||
|
return resourceVinsCreate(ctx, d, m)
|
||||||
|
} else if vins.Status == status.Deleted {
|
||||||
|
hasChangeState = true
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsRestoreAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
|
||||||
|
isEnabled := d.Get("enable").(bool)
|
||||||
|
if vins.Status == status.Disabled && isEnabled {
|
||||||
|
hasChangeState = true
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsEnableAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
} else if vins.Status == status.Enabled && !isEnabled {
|
||||||
|
hasChangeState = true
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsDisableAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if hasChangeState {
|
||||||
|
vins, err = utilityVinsCheckPresence(ctx, d, m)
|
||||||
|
if err != nil {
|
||||||
|
d.SetId("")
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flattenVins(d, *vins)
|
||||||
|
return warnings.Get()
|
||||||
|
}
|
||||||
|
|
||||||
|
func isContainsIp(els []interface{}, el interface{}) bool {
|
||||||
|
for _, elOld := range els {
|
||||||
|
elOldConv := elOld.(map[string]interface{})
|
||||||
|
elConv := el.(map[string]interface{})
|
||||||
|
if elOldConv["ip_addr"].(string) == elConv["ip_addr"].(string) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func isContinsNatRule(els []interface{}, el interface{}) bool {
|
||||||
|
for _, elOld := range els {
|
||||||
|
elOldConv := elOld.(map[string]interface{})
|
||||||
|
elConv := el.(map[string]interface{})
|
||||||
|
if elOldConv["int_ip"].(string) == elConv["int_ip"].(string) &&
|
||||||
|
elOldConv["int_port"].(int) == elConv["int_port"].(int) &&
|
||||||
|
elOldConv["ext_port_start"].(int) == elConv["ext_port_start"].(int) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
|
|
||||||
log.Debugf("resourceVinsUpdate: called for ViNS ID / name %s / %s, Account ID %d, RG ID %d",
|
|
||||||
d.Id(), d.Get("name").(string), d.Get("account_id").(int), d.Get("rg_id").(int))
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
warnings := dc.Warnings{}
|
||||||
|
|
||||||
// 1. Handle external network connection change
|
enableOld, enableNew := d.GetChange("enable")
|
||||||
|
if enableOld.(bool) && !enableNew.(bool) {
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsDisableAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
} else if !enableOld.(bool) && enableNew.(bool) {
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsEnableAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//extnet v1
|
||||||
oldExtNetId, newExtNedId := d.GetChange("ext_net_id")
|
oldExtNetId, newExtNedId := d.GetChange("ext_net_id")
|
||||||
if oldExtNetId.(int) != newExtNedId.(int) {
|
if oldExtNetId.(int) != newExtNedId.(int) {
|
||||||
log.Debugf("resourceVinsUpdate: changing ViNS ID %s - ext_net_id %d -> %d", d.Id(), oldExtNetId.(int), newExtNedId.(int))
|
log.Debugf("resourceVinsUpdate: changing ViNS ID %s - ext_net_id %d -> %d", d.Id(), oldExtNetId.(int), newExtNedId.(int))
|
||||||
@@ -163,46 +275,178 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
// there was preexisting external net connection - disconnect ViNS
|
// there was preexisting external net connection - disconnect ViNS
|
||||||
_, err := c.DecortAPICall(ctx, "POST", VinsExtNetDisconnectAPI, extnetParams)
|
_, err := c.DecortAPICall(ctx, "POST", VinsExtNetDisconnectAPI, extnetParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if newExtNedId.(int) > 0 {
|
if newExtNedId.(int) > 0 {
|
||||||
// new external network connection requested - connect ViNS
|
// new external network connection requested - connect ViNS
|
||||||
extnetParams.Add("netId", fmt.Sprintf("%d", newExtNedId.(int)))
|
extnetParams.Add("netId", fmt.Sprintf("%d", newExtNedId.(int)))
|
||||||
|
extNetIp, ok := d.GetOk("ext_net_ip")
|
||||||
|
if ok && extNetIp.(string) != "" {
|
||||||
|
urlValues.Add("Ip", extNetIp.(string))
|
||||||
|
}
|
||||||
_, err := c.DecortAPICall(ctx, "POST", VinsExtNetConnectAPI, extnetParams)
|
_, err := c.DecortAPICall(ctx, "POST", VinsExtNetConnectAPI, extnetParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we may reuse dataSourceVinsRead here as we maintain similarity
|
urlValues = &url.Values{}
|
||||||
// between Compute resource and Compute data source schemas
|
if d.HasChange("ip") {
|
||||||
return dataSourceVinsRead(ctx, d, m)
|
deletedIps := make([]interface{}, 0)
|
||||||
|
addedIps := make([]interface{}, 0)
|
||||||
|
|
||||||
|
oldIpInterface, newIpInterface := d.GetChange("ip")
|
||||||
|
oldIpSlice := oldIpInterface.([]interface{})
|
||||||
|
newIpSlice := newIpInterface.([]interface{})
|
||||||
|
|
||||||
|
for _, el := range oldIpSlice {
|
||||||
|
if !isContainsIp(newIpSlice, el) {
|
||||||
|
deletedIps = append(deletedIps, el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, el := range newIpSlice {
|
||||||
|
if !isContainsIp(oldIpSlice, el) {
|
||||||
|
addedIps = append(addedIps, el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(deletedIps) > 0 {
|
||||||
|
for _, ipInterfase := range deletedIps {
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
ip := ipInterfase.(map[string]interface{})
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
if ip["ip_addr"].(string) != "" {
|
||||||
|
urlValues.Add("ipAddr", ip["ip_addr"].(string))
|
||||||
|
}
|
||||||
|
if ip["mac_addr"].(string) != "" {
|
||||||
|
urlValues.Add("mac", ip["mac_addr"].(string))
|
||||||
|
}
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsIpReleaseAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(addedIps) > 0 {
|
||||||
|
for _, ipInterfase := range addedIps {
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
ip := ipInterfase.(map[string]interface{})
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
urlValues.Add("type", ip["type"].(string))
|
||||||
|
if ip["ip_addr"].(string) != "" {
|
||||||
|
urlValues.Add("ipAddr", ip["ip_addr"].(string))
|
||||||
|
}
|
||||||
|
if ip["mac_addr"].(string) != "" {
|
||||||
|
urlValues.Add("mac", ip["mac_addr"].(string))
|
||||||
|
}
|
||||||
|
if ip["compute_id"].(int) != 0 {
|
||||||
|
urlValues.Add("computeId", strconv.Itoa(ip["compute_id"].(int)))
|
||||||
|
}
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsIpReserveAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("nat_rule") {
|
||||||
|
deletedNatRules := make([]interface{}, 0)
|
||||||
|
addedNatRules := make([]interface{}, 0)
|
||||||
|
|
||||||
|
oldNatRulesInterface, newNatRulesInterface := d.GetChange("nat_rule")
|
||||||
|
oldNatRulesSlice := oldNatRulesInterface.([]interface{})
|
||||||
|
newNatRulesSlice := newNatRulesInterface.([]interface{})
|
||||||
|
|
||||||
|
for _, el := range oldNatRulesSlice {
|
||||||
|
if !isContinsNatRule(newNatRulesSlice, el) {
|
||||||
|
deletedNatRules = append(deletedNatRules, el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, el := range newNatRulesSlice {
|
||||||
|
if !isContinsNatRule(oldNatRulesSlice, el) {
|
||||||
|
addedNatRules = append(addedNatRules, el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(deletedNatRules) > 0 {
|
||||||
|
for _, natRuleInterface := range deletedNatRules {
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
natRule := natRuleInterface.(map[string]interface{})
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
urlValues.Add("ruleId", strconv.Itoa(natRule["rule_id"].(int)))
|
||||||
|
log.Debug("NAT_RULE_DEL_WITH: ", urlValues.Encode())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsNatRuleDelAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(addedNatRules) > 0 {
|
||||||
|
for _, natRuleInterface := range addedNatRules {
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
natRule := natRuleInterface.(map[string]interface{})
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
urlValues.Add("intIp", natRule["int_ip"].(string))
|
||||||
|
urlValues.Add("intPort", strconv.Itoa(natRule["int_port"].(int)))
|
||||||
|
urlValues.Add("extPortStart", strconv.Itoa(natRule["ext_port_start"].(int)))
|
||||||
|
if natRule["ext_port_end"].(int) != 0 {
|
||||||
|
urlValues.Add("extPortEnd", strconv.Itoa(natRule["ext_port_end"].(int)))
|
||||||
|
}
|
||||||
|
if natRule["proto"].(string) != "" {
|
||||||
|
urlValues.Add("proto", natRule["proto"].(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug("NAT_RULE_ADD_WITH: ", urlValues.Encode())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsNatRuleAddAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if oldRestart, newRestart := d.GetChange("vnfdev_restart"); oldRestart == false && newRestart == true {
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsVnfdevRestartAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if oldRedeploy, newRedeploy := d.GetChange("vnfdev_redeploy"); oldRedeploy == false && newRedeploy == true {
|
||||||
|
urlValues = &url.Values{}
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsVnfdevRedeployAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
warnings.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resourceVinsRead(ctx, d, m)
|
||||||
|
return warnings.Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceVinsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceVinsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceVinsDelete: called for ViNS ID / name %s / %s, Account ID %d, RG ID %d",
|
urlValues := &url.Values{}
|
||||||
d.Id(), d.Get("name").(string), d.Get("account_id").(int), d.Get("rg_id").(int))
|
|
||||||
|
|
||||||
vinsFacts, err := utilityVinsCheckPresence(ctx, d, m)
|
|
||||||
if vinsFacts == "" {
|
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
// the specified ViNS does not exist - in this case according to Terraform best practice
|
|
||||||
// we exit from Destroy method without error
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
params := &url.Values{}
|
|
||||||
params.Add("vinsId", d.Id())
|
|
||||||
params.Add("force", "1") // disconnect all computes before deleting ViNS
|
|
||||||
params.Add("permanently", "1") // delete ViNS immediately bypassing recycle bin
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
_, err = c.DecortAPICall(ctx, "POST", VinsDeleteAPI, params)
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
urlValues.Add("force", strconv.FormatBool(d.Get("force").(bool)))
|
||||||
|
urlValues.Add("permanently", strconv.FormatBool(d.Get("permanently").(bool)))
|
||||||
|
_, err := c.DecortAPICall(ctx, "POST", VinsDeleteAPI, urlValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@@ -210,73 +454,179 @@ func resourceVinsDelete(ctx context.Context, d *schema.ResourceData, m interface
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceVinsSchemaMake() map[string]*schema.Schema {
|
func extNetSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
return map[string]*schema.Schema{
|
||||||
"name": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
ValidateFunc: validation.StringIsNotEmpty,
|
|
||||||
Description: "Name of the ViNS. Names are case sensitive and unique within the context of an account or resource group.",
|
|
||||||
},
|
|
||||||
|
|
||||||
/* we do not need ViNS ID as an argument because if we already know this ID, it is not practical to call resource provider.
|
|
||||||
Resource Import will work anyway, as it obtains the ID of ViNS to be imported through another mechanism.
|
|
||||||
"vins_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
|
|
||||||
"rg_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Optional: true,
|
|
||||||
ForceNew: true,
|
|
||||||
Default: 0,
|
|
||||||
Description: "ID of the resource group, where this ViNS belongs to. Non-zero for ViNS created at resource group level, 0 otherwise.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"account_id": {
|
|
||||||
Type: schema.TypeInt,
|
|
||||||
Required: true,
|
|
||||||
ForceNew: true,
|
|
||||||
ValidateFunc: validation.IntAtLeast(1),
|
|
||||||
Description: "ID of the account, which this ViNS belongs to. For ViNS created at account level, resource group ID is 0.",
|
|
||||||
},
|
|
||||||
|
|
||||||
"ext_net_id": {
|
"ext_net_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Default: 0,
|
||||||
ValidateFunc: validation.IntAtLeast(0),
|
Optional: true,
|
||||||
Description: "ID of the external network this ViNS is connected to. Pass 0 if no external connection required.",
|
|
||||||
},
|
},
|
||||||
|
"ext_net_ip": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Default: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
"ipcidr": {
|
func ipSchemaMake() map[string]*schema.Schema {
|
||||||
Type: schema.TypeString,
|
return map[string]*schema.Schema{
|
||||||
Optional: true,
|
"type": {
|
||||||
DiffSuppressFunc: ipcidrDiffSupperss,
|
Type: schema.TypeString,
|
||||||
Description: "Network address to use by this ViNS. This parameter is only valid when creating new ViNS.",
|
Required: true,
|
||||||
},
|
},
|
||||||
|
"ip_addr": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
"mac_addr": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
"compute_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
"description": {
|
func natRuleSchemaMake() map[string]*schema.Schema {
|
||||||
Type: schema.TypeString,
|
return map[string]*schema.Schema{
|
||||||
Optional: true,
|
"int_ip": {
|
||||||
Default: "",
|
Type: schema.TypeString,
|
||||||
Description: "Optional user-defined text description of this ViNS.",
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"int_port": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ext_port_start": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ext_port_end": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"proto": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"tcp", "udp"}, false),
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"rule_id": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// the rest of attributes are computed
|
func resourceVinsSchemaMake() map[string]*schema.Schema {
|
||||||
"account_name": {
|
rets := dataSourceVinsSchemaMake()
|
||||||
Type: schema.TypeString,
|
rets["name"] = &schema.Schema{
|
||||||
Computed: true,
|
Type: schema.TypeString,
|
||||||
Description: "Name of the account, which this ViNS belongs to.",
|
Required: true,
|
||||||
|
}
|
||||||
|
rets["rg_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
rets["account_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
}
|
||||||
|
rets["ext_net_id"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Default: -1,
|
||||||
|
}
|
||||||
|
rets["ext_ip_addr"] = &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Default: "",
|
||||||
|
}
|
||||||
|
rets["ipcidr"] = &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
}
|
||||||
|
rets["pre_reservations_num"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Default: 32,
|
||||||
|
}
|
||||||
|
rets["gid"] = &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
}
|
||||||
|
rets["enable"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: true,
|
||||||
|
}
|
||||||
|
rets["permanently"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
}
|
||||||
|
rets["force"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
}
|
||||||
|
rets["ext_net"] = &schema.Schema{
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
MaxItems: 1,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: extNetSchemaMake(),
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
rets["ip"] = &schema.Schema{
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: ipSchemaMake(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
rets["nat_rule"] = &schema.Schema{
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: natRuleSchemaMake(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
rets["desc"] = &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Default: "",
|
||||||
|
Description: "Optional user-defined text description of this ViNS.",
|
||||||
|
}
|
||||||
|
rets["restore"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
}
|
||||||
|
rets["vnfdev_restart"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
}
|
||||||
|
rets["vnfdev_redeploy"] = &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
}
|
||||||
|
|
||||||
"ext_ip_addr": {
|
rets["vins_id"] = &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "IP address of the external connection (valid for ViNS connected to external network, ignored otherwise).",
|
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rets
|
return rets
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -34,120 +35,48 @@ package vins
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
// On success this function returns a string, as returned by API vins/get, which could be unmarshalled
|
func utilityDataVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*VINSDetailed, error) {
|
||||||
// into VinsGetResp structure
|
|
||||||
func utilityVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) {
|
|
||||||
// This function tries to locate ViNS by one of the following algorithms depending
|
|
||||||
// on the parameters passed:
|
|
||||||
// - if resource group ID is specified -> it looks for a ViNS at the RG level
|
|
||||||
// - if account ID is specifeid -> it looks for a ViNS at the account level
|
|
||||||
//
|
|
||||||
// If succeeded, it returns non empty string that contains JSON formatted facts about the
|
|
||||||
// ViNS as returned by vins/get API call.
|
|
||||||
// Otherwise it returns empty string and a meaningful error.
|
|
||||||
//
|
|
||||||
// This function does not modify its ResourceData argument, so it is safe to use it as core
|
|
||||||
// method for the Terraform resource Exists method.
|
|
||||||
//
|
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
|
vins := &VINSDetailed{}
|
||||||
|
|
||||||
// make it possible to use "read" & "check presence" functions with ViNS ID set so
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
// that Import of ViNS resource is possible
|
vinsRaw, err := c.DecortAPICall(ctx, "POST", VinsGetAPI, urlValues)
|
||||||
idSet := false
|
|
||||||
theId, err := strconv.Atoi(d.Id())
|
|
||||||
if err != nil || theId <= 0 {
|
|
||||||
vinsId, argSet := d.GetOk("vins_id") // NB: vins_id is NOT present in vinsResource schema!
|
|
||||||
if argSet {
|
|
||||||
theId = vinsId.(int)
|
|
||||||
idSet = true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
idSet = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if idSet {
|
|
||||||
// ViNS ID is specified, try to get compute instance straight by this ID
|
|
||||||
log.Debugf("utilityVinsCheckPresence: locating ViNS by its ID %d", theId)
|
|
||||||
urlValues.Add("vinsId", fmt.Sprintf("%d", theId))
|
|
||||||
vinsFacts, err := c.DecortAPICall(ctx, "POST", VinsGetAPI, urlValues)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return vinsFacts, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ID was not set in the schema upon entering this function - work through ViNS name
|
|
||||||
// and Account / RG ID
|
|
||||||
|
|
||||||
vinsName, argSet := d.GetOk("name")
|
|
||||||
if !argSet {
|
|
||||||
// if ViNS name is not set. then we cannot locate ViNS
|
|
||||||
return "", fmt.Errorf("Cannot check ViNS presence if ViNS name is empty")
|
|
||||||
}
|
|
||||||
urlValues.Add("name", vinsName.(string))
|
|
||||||
urlValues.Add("show_all", "false")
|
|
||||||
log.Debugf("utilityVinsCheckPresence: preparing to locate ViNS name %s", vinsName.(string))
|
|
||||||
|
|
||||||
rgId, rgSet := d.GetOk("rg_id")
|
|
||||||
if rgSet {
|
|
||||||
log.Debugf("utilityVinsCheckPresence: limiting ViNS search to RG ID %d", rgId.(int))
|
|
||||||
urlValues.Add("rgId", fmt.Sprintf("%d", rgId.(int)))
|
|
||||||
}
|
|
||||||
|
|
||||||
accountId, accountSet := d.GetOk("account_id")
|
|
||||||
if accountSet {
|
|
||||||
log.Debugf("utilityVinsCheckPresence: limiting ViNS search to Account ID %d", accountId.(int))
|
|
||||||
urlValues.Add("accountId", fmt.Sprintf("%d", accountId.(int)))
|
|
||||||
}
|
|
||||||
|
|
||||||
apiResp, err := c.DecortAPICall(ctx, "POST", VinsSearchAPI, urlValues)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.Debugf("%s", apiResp)
|
err = json.Unmarshal([]byte(vinsRaw), vins)
|
||||||
// log.Debugf("utilityResgroupCheckPresence: ready to decode response body from %s", VinsSearchAPI)
|
|
||||||
model := VinsSearchResp{}
|
|
||||||
err = json.Unmarshal([]byte(apiResp), &model)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return vins, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func utilityVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*VINSDetailed, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
vins := &VINSDetailed{}
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", d.Id())
|
||||||
|
vinsRaw, err := c.DecortAPICall(ctx, "POST", VinsGetAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(vinsRaw), vins)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return vins, nil
|
||||||
|
|
||||||
log.Debugf("utilityVinsCheckPresence: traversing decoded Json of length %d", len(model))
|
|
||||||
for index, item := range model {
|
|
||||||
if item.Name == vinsName.(string) {
|
|
||||||
if (accountSet && item.AccountID != accountId.(int)) ||
|
|
||||||
(rgSet && item.RgID != rgId.(int)) {
|
|
||||||
// double check that account ID and Rg ID match, if set in the schema
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("utilityVinsCheckPresence: match ViNS name %s / ID %d, account ID %d, RG ID %d at index %d",
|
|
||||||
item.Name, item.ID, item.AccountID, item.RgID, index)
|
|
||||||
|
|
||||||
// element returned by API vins/search does not contain all information we may need to
|
|
||||||
// manage ViNS, so we have to get detailed info by calling API vins/get
|
|
||||||
rqValues := &url.Values{}
|
|
||||||
rqValues.Add("vinsId", fmt.Sprintf("%d", item.ID))
|
|
||||||
vinsGetResp, err := c.DecortAPICall(ctx, "POST", VinsGetAPI, rqValues)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return vinsGetResp, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "", fmt.Errorf("Cannot find ViNS name %s. Check name and/or RG ID & Account ID and your access rights", vinsName.(string))
|
|
||||||
}
|
}
|
||||||
|
|||||||
61
internal/service/cloudapi/vins/utility_vins_audits.go
Normal file
61
internal/service/cloudapi/vins/utility_vins_audits.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsAuditsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (VINSAuditsList, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
auditsList := VINSAuditsList{}
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
|
auidtsRaw, err := c.DecortAPICall(ctx, "POST", VinsAuditsAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(auidtsRaw), &auditsList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return auditsList, nil
|
||||||
|
}
|
||||||
61
internal/service/cloudapi/vins/utility_vins_ext_net_list.go
Normal file
61
internal/service/cloudapi/vins/utility_vins_ext_net_list.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsExtNetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ExtNetList, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
extNet := ExtNetList{}
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
|
extNetRaw, err := c.DecortAPICall(ctx, "POST", VinsExtNetListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(extNetRaw), &extNet)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return extNet, nil
|
||||||
|
}
|
||||||
61
internal/service/cloudapi/vins/utility_vins_ip_list.go
Normal file
61
internal/service/cloudapi/vins/utility_vins_ip_list.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsIpListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (IPList, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
ips := IPList{}
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
|
auidtsRaw, err := c.DecortAPICall(ctx, "POST", VinsIpListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(auidtsRaw), &ips)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ips, nil
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
|||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -43,8 +44,8 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (VinsList, error) {
|
func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (VINSList, error) {
|
||||||
vinsList := VinsList{}
|
vinsList := VINSList{}
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
urlValues := &url.Values{}
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
|||||||
70
internal/service/cloudapi/vins/utility_vins_list_deleted.go
Normal file
70
internal/service/cloudapi/vins/utility_vins_list_deleted.go
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (VINSList, error) {
|
||||||
|
vinsList := VINSList{}
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
if page, ok := d.GetOk("page"); ok {
|
||||||
|
urlValues.Add("page", strconv.Itoa(page.(int)))
|
||||||
|
}
|
||||||
|
if size, ok := d.GetOk("size"); ok {
|
||||||
|
urlValues.Add("size", strconv.Itoa(size.(int)))
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("utilityVinsListDeletedCheckPresence")
|
||||||
|
vinsListRaw, err := c.DecortAPICall(ctx, "POST", VinsListDeletedAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(vinsListRaw), &vinsList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return vinsList, nil
|
||||||
|
}
|
||||||
61
internal/service/cloudapi/vins/utility_vins_nat_rule_list.go
Normal file
61
internal/service/cloudapi/vins/utility_vins_nat_rule_list.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
|
Authors:
|
||||||
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
|
Source code: https://github.com/rudecs/terraform-provider-decort
|
||||||
|
|
||||||
|
Please see README.md to learn where to place source code so that it
|
||||||
|
builds seamlessly.
|
||||||
|
|
||||||
|
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/rudecs/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func utilityVinsNatRuleListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (NATRuleList, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
natRuleList := NATRuleList{}
|
||||||
|
|
||||||
|
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
|
||||||
|
auidtsRaw, err := c.DecortAPICall(ctx, "POST", VinsNatRuleListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(auidtsRaw), &natRuleList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return natRuleList, nil
|
||||||
|
}
|
||||||
@@ -1,32 +1,141 @@
|
|||||||
|
/*
|
||||||
|
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 status
|
package status
|
||||||
|
|
||||||
type Status = string
|
type Status = string
|
||||||
|
|
||||||
var (
|
var (
|
||||||
//The disk is linked to any Compute
|
// The disk is linked to any Compute
|
||||||
|
// Status available for:
|
||||||
|
// - Disk
|
||||||
Assigned Status = "ASSIGNED"
|
Assigned Status = "ASSIGNED"
|
||||||
|
|
||||||
//An object model has been created in the database
|
// An object enabled for operations
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
// - Disk
|
||||||
|
// - Vins
|
||||||
|
Enabled Status = "ENABLED"
|
||||||
|
|
||||||
|
// Enabling in process
|
||||||
|
// Status available for:
|
||||||
|
// - Disk
|
||||||
|
// - Vins
|
||||||
|
Enabling Status = "ENABLING"
|
||||||
|
|
||||||
|
// An object disabled for operations
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
// - Disk
|
||||||
|
// - Vins
|
||||||
|
Disabled Status = "DISABLED"
|
||||||
|
|
||||||
|
// Disabling in process
|
||||||
|
// Status available for:
|
||||||
|
// - Disk
|
||||||
|
// - Vins
|
||||||
|
Disabling Status = "DISABLING"
|
||||||
|
|
||||||
|
// An object model has been created in the database
|
||||||
|
// Status available for:
|
||||||
|
// - Image
|
||||||
|
// - Disk
|
||||||
|
// - Compute
|
||||||
|
// - Vins
|
||||||
Modeled Status = "MODELED"
|
Modeled Status = "MODELED"
|
||||||
|
|
||||||
//In the process of creation
|
// In the process of creation
|
||||||
|
// Status available for:
|
||||||
|
// - Image
|
||||||
Creating Status = "CREATING"
|
Creating Status = "CREATING"
|
||||||
|
|
||||||
//Creating
|
// An object was created successfully
|
||||||
|
// Status available for:
|
||||||
|
// - Image
|
||||||
|
// - Disk
|
||||||
|
// - Compute
|
||||||
|
// - Vins
|
||||||
Created Status = "CREATED"
|
Created Status = "CREATED"
|
||||||
|
|
||||||
//Physical resources are allocated for the object
|
// Physical resources are allocated for the object
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
Allocated Status = "ALLOCATED"
|
Allocated Status = "ALLOCATED"
|
||||||
|
|
||||||
//The object has released (returned to the platform) the physical resources that it occupied
|
// The object has released (returned to the platform) the physical resources that it occupied
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
Unallocated Status = "UNALLOCATED"
|
Unallocated Status = "UNALLOCATED"
|
||||||
|
|
||||||
//Permanently deleted
|
// Destroying in progress
|
||||||
|
// Status available for:
|
||||||
|
// - Disk
|
||||||
|
// - Compute
|
||||||
|
// - Vins
|
||||||
|
Destroying Status = "DESTROYING"
|
||||||
|
|
||||||
|
// Permanently deleted
|
||||||
|
// Status available for:
|
||||||
|
// - Image
|
||||||
|
// - Disk
|
||||||
|
// - Compute
|
||||||
|
// - Vins
|
||||||
Destroyed Status = "DESTROYED"
|
Destroyed Status = "DESTROYED"
|
||||||
|
|
||||||
//Deleted to Trash
|
// Deleting in progress to Trash
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
// - Vins
|
||||||
|
Deleting Status = "DELETING"
|
||||||
|
|
||||||
|
// Deleted to Trash
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
// - Vins
|
||||||
Deleted Status = "DELETED"
|
Deleted Status = "DELETED"
|
||||||
|
|
||||||
//Deleted from storage
|
// Deleted from storage
|
||||||
|
// Status available for:
|
||||||
|
// - Image
|
||||||
Purged Status = "PURGED"
|
Purged Status = "PURGED"
|
||||||
|
|
||||||
|
// Repeating deploy of the object in progress
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Redeploying Status = "REDEPLOYING"
|
||||||
|
|
||||||
|
// The resource is not bound to vnf device
|
||||||
|
// Status available for:
|
||||||
|
// - vins vnf
|
||||||
|
Stashed Status = "STASHED"
|
||||||
)
|
)
|
||||||
|
|||||||
100
internal/techstatus/techstatus.go
Normal file
100
internal/techstatus/techstatus.go
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
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 techstatus
|
||||||
|
|
||||||
|
type TechStatus = string
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Start in progress - send an execution command
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Starting TechStatus = "STARTING"
|
||||||
|
|
||||||
|
// An object started
|
||||||
|
// Can be stopped
|
||||||
|
// Correctly running
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Started TechStatus = "STARTED"
|
||||||
|
|
||||||
|
// Stop in progress - send an execution command
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Stopping TechStatus = "STOPPING"
|
||||||
|
|
||||||
|
// An object stopped
|
||||||
|
// Can be started
|
||||||
|
// Limited functionality
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Stopped TechStatus = "STOPPED"
|
||||||
|
|
||||||
|
// Pause in progress - send an execution command
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Pausing TechStatus = "PAUSING"
|
||||||
|
|
||||||
|
// An object paused
|
||||||
|
// Can be restarted
|
||||||
|
// Currently running
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Paused TechStatus = "PAUSED"
|
||||||
|
|
||||||
|
// Migrate in progress
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Migrating TechStatus = "MIGRATING"
|
||||||
|
|
||||||
|
// An object failure status
|
||||||
|
// Can be reastarted
|
||||||
|
// Limited functionality
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Down TechStatus = "DOWN"
|
||||||
|
|
||||||
|
// An object configuration process
|
||||||
|
// Status available for:
|
||||||
|
// - Compute
|
||||||
|
Scheduled TechStatus = "SCHEDULED"
|
||||||
|
|
||||||
|
// Physical resources are allocated for the object
|
||||||
|
// Status available for:
|
||||||
|
// - Image
|
||||||
|
Allocated TechStatus = "ALLOCATED"
|
||||||
|
|
||||||
|
// The object has released (returned to the platform) the physical resources that it occupied
|
||||||
|
// Status available for:
|
||||||
|
// - Image
|
||||||
|
Unallocated TechStatus = "UNALLOCATED"
|
||||||
|
)
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
decort = {
|
|
||||||
source = "digitalenergy.online/decort/decort"
|
|
||||||
version = "3.2.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
37
samples/cloudapi/data_k8s/main.tf
Normal file
37
samples/cloudapi/data_k8s/main.tf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение информации о k8s кластере
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_k8s" "k8s" {
|
||||||
|
#id кластера
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
k8s_id = 49304
|
||||||
|
}
|
||||||
|
|
||||||
|
output "output_k8s" {
|
||||||
|
value = data.decort_k8s.k8s
|
||||||
|
}
|
||||||
50
samples/cloudapi/data_k8s_list/main.tf
Normal file
50
samples/cloudapi/data_k8s_list/main.tf
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка доступных кластеров
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_k8s_list" "k8s_list" {
|
||||||
|
#включение удаленных k8s в результат
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - будев тип
|
||||||
|
#если не задан - выводятся все неудаленные данные
|
||||||
|
include_deleted = true
|
||||||
|
|
||||||
|
#номер страницы для отображения
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#если не задан - выводятся все доступные данные
|
||||||
|
page = 1
|
||||||
|
|
||||||
|
#размер страницы
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#если не задан - выводятся все доступные данные
|
||||||
|
size = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
output "output_k8s_list" {
|
||||||
|
value = data.decort_k8s_list.k8s_list
|
||||||
|
}
|
||||||
45
samples/cloudapi/data_k8s_list_deleted/main.tf
Normal file
45
samples/cloudapi/data_k8s_list_deleted/main.tf
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка доступных кластеров включая удаленные
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_k8s_list_deleted" "k8s_list_deleted" {
|
||||||
|
#номер страницы для отображения
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#если не задан - выводятся все доступные данные
|
||||||
|
page = 1
|
||||||
|
|
||||||
|
#размер страницы
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#если не задан - выводятся все доступные данные
|
||||||
|
size = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
output "output_k8s_list_deleted" {
|
||||||
|
value = data.decort_k8s_list_deleted.k8s_list_deleted
|
||||||
|
}
|
||||||
|
|
||||||
42
samples/cloudapi/data_k8s_wg/main.tf
Normal file
42
samples/cloudapi/data_k8s_wg/main.tf
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение информации о k8s кластере
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_k8s_wg" "k8s_wg" {
|
||||||
|
#id кластера
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
k8s_id = 49304
|
||||||
|
|
||||||
|
#id группы воркеров
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
wg_id = 43329
|
||||||
|
}
|
||||||
|
|
||||||
|
output "output_k8s_wg" {
|
||||||
|
value = data.decort_k8s.k8s
|
||||||
|
}
|
||||||
37
samples/cloudapi/data_k8s_wg_list/main.tf
Normal file
37
samples/cloudapi/data_k8s_wg_list/main.tf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка доступных групп воркеров в кластере
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_k8s_wg_list" "k8s_wg_list" {
|
||||||
|
#id кластера
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - число
|
||||||
|
k8s_id = 49304
|
||||||
|
}
|
||||||
|
|
||||||
|
output "output_k8s_wg_list" {
|
||||||
|
value = data.decort_k8s_wg_list.k8s_wg_list
|
||||||
|
}
|
||||||
54
samples/cloudapi/data_kvmvm/main.tf
Normal file
54
samples/cloudapi/data_kvmvm/main.tf
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение данных о compute (виртулаьной машине)
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_kvmvm" "comp" {
|
||||||
|
#Для получения информации о виртуальной машине
|
||||||
|
#можно воспользоваться двумя методами:
|
||||||
|
#1. получение информации по идентификатору машины - compute_id
|
||||||
|
#2. получение информации по имени машины и идентификатору ресурсной группы - name и rg_id
|
||||||
|
|
||||||
|
#id виртуальной машины
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#compute_id = 11346
|
||||||
|
|
||||||
|
#название машины
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - строка
|
||||||
|
#используется вместе с параметром rg_id
|
||||||
|
#name = "test-rg-temp"
|
||||||
|
|
||||||
|
#id ресурсной группы
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - число
|
||||||
|
#используется вместе с параметром name
|
||||||
|
#rg_id = 1825
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_kvmvm.comp
|
||||||
|
}
|
||||||
38
samples/cloudapi/data_vins/main.tf
Normal file
38
samples/cloudapi/data_vins/main.tf
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение данных о vins
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_vins" "vins" {
|
||||||
|
#обязательный параметр
|
||||||
|
#id жедаемого vins
|
||||||
|
#тип - число
|
||||||
|
vins_id = 10101
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_vins.vins
|
||||||
|
}
|
||||||
38
samples/cloudapi/data_vins_audits/main.tf
Normal file
38
samples/cloudapi/data_vins_audits/main.tf
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка vins audits
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_vins_audits" "vins_audits" {
|
||||||
|
#обязательный параметр
|
||||||
|
#id жедаемого vins
|
||||||
|
#тип - число
|
||||||
|
vins_id = 10101
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_vins_audits.vins_audits
|
||||||
|
}
|
||||||
37
samples/cloudapi/data_vins_ext_net_list/main.tf
Normal file
37
samples/cloudapi/data_vins_ext_net_list/main.tf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка vins extnet
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_vins_ext_net_list" "vins_ext_net_list" {
|
||||||
|
#обязательный параметр
|
||||||
|
#id жедаемого vins
|
||||||
|
#тип - число
|
||||||
|
vins_id = 10101
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_vins_ext_net_list.vins_ext_net_list
|
||||||
|
}
|
||||||
39
samples/cloudapi/data_vins_ip_list/main.tf
Normal file
39
samples/cloudapi/data_vins_ip_list/main.tf
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка vins_ip
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_vins_ip_list" "vins_ip_list" {
|
||||||
|
#обязательный параметр
|
||||||
|
#id жедаемого vins
|
||||||
|
#тип - число
|
||||||
|
vins_id = 10101
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_vins_ip_list.vins_ip_list
|
||||||
|
}
|
||||||
|
|
||||||
42
samples/cloudapi/data_vins_list_deleted/main.tf
Normal file
42
samples/cloudapi/data_vins_list_deleted/main.tf
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка удаленных vins
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_vins_list_deleted" "vins_list_deleted" {
|
||||||
|
#кол-во страниц для вывода
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
page = 1
|
||||||
|
|
||||||
|
#размер страницы
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - число
|
||||||
|
size = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_vins_list_deleted.vinslist_deleted
|
||||||
|
}
|
||||||
39
samples/cloudapi/data_vins_nat_rule_list/main.tf
Normal file
39
samples/cloudapi/data_vins_nat_rule_list/main.tf
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Получение списка natRule vins
|
||||||
|
*/
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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://ds1.digitalenergy.online"
|
||||||
|
#oauth2_url = <DECORT_SSO_URL>
|
||||||
|
oauth2_url = "https://sso.digitalenergy.online"
|
||||||
|
allow_unverified_ssl = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data "decort_vins_nat_rule_list" "vins_nat_rule_list" {
|
||||||
|
#обязательный параметр
|
||||||
|
#id жедаемого vins
|
||||||
|
#тип - число
|
||||||
|
vins_id = 10101
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = data.decort_vins_nat_rule_list.vins_nat_rule_list
|
||||||
|
}
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ resource "decort_disk" "acl" {
|
|||||||
restore = true
|
restore = true
|
||||||
permanently = true
|
permanently = true
|
||||||
reason = "delete"
|
reason = "delete"
|
||||||
|
shareable = false
|
||||||
iotune {
|
iotune {
|
||||||
read_bytes_sec = 0
|
read_bytes_sec = 0
|
||||||
read_bytes_sec_max = 0
|
read_bytes_sec_max = 0
|
||||||
|
|||||||
@@ -114,6 +114,99 @@ resource "decort_kvmvm" "comp" {
|
|||||||
#опциональный параметр
|
#опциональный параметр
|
||||||
#тип - bool
|
#тип - bool
|
||||||
permanently = false
|
permanently = false
|
||||||
|
|
||||||
|
#правила affinity
|
||||||
|
#опциональный параметр
|
||||||
|
#может быть один, несколько или ни одного блока
|
||||||
|
#тип - блок
|
||||||
|
#affinity_rules {
|
||||||
|
#тип правила
|
||||||
|
#возможные значения - compute или node
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
#topology = "compute"
|
||||||
|
|
||||||
|
#строгость правила
|
||||||
|
#возможные значения - RECOMMENDED и REQUIRED
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
#policy = "RECOMMENDED"
|
||||||
|
|
||||||
|
#режим проверки
|
||||||
|
#возможные значения - ANY, EQ, NE
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
#mode = "ANY"
|
||||||
|
|
||||||
|
#ключ правила
|
||||||
|
#обязательный параметр
|
||||||
|
#тип строка
|
||||||
|
#key = "testkey"
|
||||||
|
|
||||||
|
#ключ правила
|
||||||
|
#обязательный параметр
|
||||||
|
#тип строка
|
||||||
|
#value = "testvalue"
|
||||||
|
#}
|
||||||
|
|
||||||
|
#правила anti-affinity
|
||||||
|
#опциональный параметр
|
||||||
|
#может быть один, несколько или ни одного блока
|
||||||
|
#тип - блок
|
||||||
|
#anti_affinity_rules {
|
||||||
|
#тип правила
|
||||||
|
#возможные значения - compute или node
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
#topology = "compute"
|
||||||
|
|
||||||
|
#строгость правила
|
||||||
|
#возможные значения - RECOMMENDED и REQUIRED
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
#policy = "RECOMMENDED"
|
||||||
|
|
||||||
|
#режим проверки
|
||||||
|
#возможные значения - ANY, EQ, NE
|
||||||
|
#обязательный параметр
|
||||||
|
#тип - строка
|
||||||
|
#mode = "ANY"
|
||||||
|
|
||||||
|
#ключ правила
|
||||||
|
#обязательный параметр
|
||||||
|
#тип строка
|
||||||
|
#key = "testkey"
|
||||||
|
|
||||||
|
#ключ правила
|
||||||
|
#обязательный параметр
|
||||||
|
#тип строка
|
||||||
|
#value = "testvalue"
|
||||||
|
#}
|
||||||
|
|
||||||
|
#Флаг доступности компьюта для проведения с ним операций
|
||||||
|
#опицональный параметр
|
||||||
|
#тип - bool
|
||||||
|
#enable = true
|
||||||
|
|
||||||
|
#установка метки для вм
|
||||||
|
#опциональный параметр
|
||||||
|
#тип - строка
|
||||||
|
#affinity_label = "test4"
|
||||||
|
|
||||||
|
|
||||||
|
#наименование системы
|
||||||
|
#опциональный параметр
|
||||||
|
#используется при создании вм
|
||||||
|
#по умолчанию - не задан
|
||||||
|
#тип - строка
|
||||||
|
#is=""
|
||||||
|
|
||||||
|
#назначение вм
|
||||||
|
#опциональный параметр
|
||||||
|
#используется при создании вм
|
||||||
|
#по умолчанию - не задан
|
||||||
|
#тип - строка
|
||||||
|
#ipa_type = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
170
samples/cloudapi/resource_vins/main.tf
Normal file
170
samples/cloudapi/resource_vins/main.tf
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
/*
|
||||||
|
Пример использования
|
||||||
|
Ресурса vins
|
||||||
|
Ресурс позволяет:
|
||||||
|
1. Создавать vins
|
||||||
|
2. Удалять vins
|
||||||
|
3. Восстанвливать vins
|
||||||
|
4. Добавлять и убирать подключение к внешней сети
|
||||||
|
5. Резервировать и освобождать ip для vins
|
||||||
|
6. Добавлять и удалять natrule
|
||||||
|
7. Перезапускать и редеплоить vnfdev
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#Расскомментируйте этот код,
|
||||||
|
#и внесите необходимые правки в версию и путь,
|
||||||
|
#чтобы работать с установленным вручную (не через 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_vins" "vins" {
|
||||||
|
#обязательный параметр
|
||||||
|
#имя создаваемого ресурса
|
||||||
|
#тип - строка
|
||||||
|
name = "Test_name"
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#id ресурсной группы для создаения ресруса
|
||||||
|
#тип - число
|
||||||
|
rg_id = 10101
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#id аккаунта для создаения ресруса
|
||||||
|
#тип - число
|
||||||
|
account_id = 2023
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#id внешней сети для подключения к ней ресруса
|
||||||
|
#тип - число
|
||||||
|
ext_net_id = 2222
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#ip внешней сети для подключения к нему ресруса
|
||||||
|
#тип - строка
|
||||||
|
ext_ip_addr = "1.1.1.1"
|
||||||
|
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#private network IP CIDR
|
||||||
|
#тип - строка
|
||||||
|
ipcidr = "192.168.0.1"
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#количество зарезервированных адресов на момент создания
|
||||||
|
#тип - число
|
||||||
|
#значение по умолчанию 32
|
||||||
|
pre_reservations_num = 2
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#grid (platform) ID
|
||||||
|
#тип - число
|
||||||
|
gid = 2002
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#Description
|
||||||
|
#тип - строка
|
||||||
|
desc = "Description"
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#ручное подключение и отключение ресурса
|
||||||
|
#тип - булев тип
|
||||||
|
enable = true
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#удаление навсегда
|
||||||
|
#тип - булев тип
|
||||||
|
permanently = true
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#удаляет за собой все зависимые ресурсы
|
||||||
|
#тип - булев тип
|
||||||
|
force = true
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#блок для резервирования ip
|
||||||
|
#тип - блок
|
||||||
|
ip {
|
||||||
|
#обязательный параметр
|
||||||
|
#тип подключения
|
||||||
|
#тип - строка
|
||||||
|
type = "DHCP"
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#ip который необходимо зарезервировать
|
||||||
|
#тип - строка
|
||||||
|
ip_addr = "192.168.5.5"
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#mac который необходимо зарезервировать
|
||||||
|
#тип - строка
|
||||||
|
mac_addr = "ff:ff:ff:ff:ff:ff"
|
||||||
|
}
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#блок для добавления natRule
|
||||||
|
#тип - блок
|
||||||
|
nat_rule {
|
||||||
|
#опциональный параметр
|
||||||
|
#ip внутренний
|
||||||
|
#тип - строка
|
||||||
|
int_ip = "192.168.0.28"
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#внутренний порт
|
||||||
|
#тип - число
|
||||||
|
int_port = 80
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#начало диапазона внешних портов
|
||||||
|
#тип - число
|
||||||
|
ext_port_start = 8001
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#конец диапазона внешних портов
|
||||||
|
#тип - число
|
||||||
|
ext_port_end = 8001
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#протокол natRule
|
||||||
|
#тип - строка
|
||||||
|
proto = "tcp"
|
||||||
|
}
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#восстановление ресурса
|
||||||
|
#тип - булев тип
|
||||||
|
restore = true
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#перезапуск vnfDev
|
||||||
|
##тип - булев тип
|
||||||
|
vnfdev_restart = true
|
||||||
|
|
||||||
|
#опциональный параметр
|
||||||
|
#редеплой vnfDev
|
||||||
|
#тип - булев тип
|
||||||
|
vnfdev_redeploy = true
|
||||||
|
}
|
||||||
|
|
||||||
|
output "test" {
|
||||||
|
value = decort_vins.vins
|
||||||
|
}
|
||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user