Compare commits

..

14 Commits

Author SHA1 Message Date
3a5825ade0 4.4.4 2024-03-25 12:00:45 +03:00
ce4b847596 4.4.3 2023-12-14 18:32:46 +03:00
Nikita Sorokin
2453a32d01 4.4.2 2023-10-18 08:30:37 +03:00
Nikita Sorokin
0602a4b693 4.4.1 2023-10-13 13:28:19 +03:00
Nikita Sorokin
28b60de115 4.4.0-static-route-updated 2023-10-09 13:15:11 +03:00
Nikita Sorokin
b705ce4aab 4.4.0 2023-09-28 19:41:26 +03:00
Nikita Sorokin
83ca627cea 4.4.0 2023-09-28 16:08:15 +03:00
Nikita Sorokin
739289fbb8 4.3.8 2023-09-27 16:17:35 +03:00
Nikita Sorokin
c89574c3e6 4.3.7 2023-09-22 12:49:22 +03:00
Nikita Sorokin
a1e61674c8 4.3.6 2023-09-04 11:15:01 +03:00
Nikita Sorokin
cb9ff26bb0 4.3.5 2023-08-29 16:26:37 +03:00
Nikita Sorokin
6932f9d305 4.3.5 2023-08-28 13:02:41 +03:00
Nikita Sorokin
712f8edf9e 4.3.4 2023-08-23 16:32:48 +03:00
Nikita Sorokin
805ffe1f29 4.3.3 2023-08-22 13:15:17 +03:00
174 changed files with 8572 additions and 1298 deletions

2
.gitignore vendored
View File

@@ -3,3 +3,5 @@ examples/
url_scrapping/
terraform-provider-decort*
.vscode/
.DS_Store

View File

@@ -1,5 +1,20 @@
## Version 4.3.2
## Version 4.4.4
## Bugfixes
- Fixed bootdisk flattens
- Updated golang-decort-sdk version with fixed permamently field in cloudapi/cloudbroker/compute/diskDel
### Bugfix
- Changed field Value in schema resource kvmvm in blocks affinity_rules and anti_affinity_rules from required to optional in cloudapi
- Changed the format ID in resource k8s_wg from wg_id to k8s_id#wg_id
- Fixed scripts intall.bat and intall.sh
- Change logic from disk delete and disk add to disk rename when disk.disk_name field is changed in resource cloudapi/kvmvm
- Fix allowed network plugin value from "weawenet" to "weavenet" for k8ci, k8s resources in cloudbroker and for k8s resource in cloudapi
- Fix bug with deleting decort_bservice resource when setting enable=false in cloudapi/bservice
- Fix panic in data source decort_bservice_snapshot_list in cloudapi/bservice
- Fix panic in data source decort_rg_affinity_groups_list in cloudapi/rg
- Fix duplicate enabling of bservice after create in cloudapi/bservice
- Fix start of bservice after create in cloudapi/b
- Fix permanently field for disks delete, change default value from true to false in decort_kvmvm in cloudapi/kvmvm
### Feature
- Add "permanently" flag in k8s, k8s_cp in cloudapi
- Add RAM validation in cloudapi/[k8s, k8s_cp, k8s_wg, kvmvm, bservice]
- Add RAM validation in cloudbroker/[k8s, k8s_wg, kvmvm]
- Add field restore in cloudapi/disk resource

View File

@@ -7,11 +7,8 @@ ZIPDIR = ./zip
BINARY=${NAME}
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
MAINPATH = ./cmd/decort/
VERSION=4.3.2
VERSION=4.4.4
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
# OS_ARCH=darwin_arm64
# OS_ARCH=windows_amd64
# OS_ARCH=linux_amd64
FILES = ${BINARY}_${VERSION}_darwin_amd64\
${BINARY}_${VERSION}_darwin_arm64\

View File

@@ -6,6 +6,7 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
| Версия DECORT API | Версия провайдера Terraform |
| ------ | ------ |
| 3.8.8 | 4.4.x |
| 3.8.7 | 4.3.x |
| 3.8.6 | 4.0.x, 4.1.x, 4.2.x |
| 3.8.5 | 3.4.x |
@@ -29,6 +30,8 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
- Работа с disks,
- Работа с k8s,
- Работа с image,
- Работа с flipgroups,
- Работа с stacks,
- Работа с reource groups,
- Работа с VINS,
- Работа с pfw,

58
go.mod
View File

@@ -3,52 +3,53 @@ module repository.basistech.ru/BASIS/terraform-provider-decort
go 1.18
require (
github.com/golang-jwt/jwt/v4 v4.4.3
github.com/google/uuid v1.3.0
github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
github.com/sirupsen/logrus v1.9.0
golang.org/x/net v0.12.0
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.3
golang.org/x/net v0.17.0
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.14
)
require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/go-playground/validator/v10 v10.15.4 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-querystring 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-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.4.0 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.8 // indirect
github.com/hashicorp/go-plugin v1.5.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.4.0 // indirect
github.com/hashicorp/hcl/v2 v2.15.0 // indirect
github.com/hashicorp/hc-install v0.6.1 // indirect
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.17.3 // indirect
github.com/hashicorp/terraform-json v0.14.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.14.2 // indirect
github.com/hashicorp/terraform-plugin-log v0.7.0 // 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-exec v0.19.0 // indirect
github.com/hashicorp/terraform-json v0.17.1 // indirect
github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.2 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
@@ -64,15 +65,16 @@ require (
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
google.golang.org/grpc v1.57.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

238
go.sum
View File

@@ -1,4 +1,4 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
@@ -7,73 +7,57 @@ github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYr
github.com/Masterminds/sprig/v3 v3.2.1/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.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ=
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
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/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
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/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
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/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34=
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k=
github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-playground/validator/v10 v10.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs=
github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
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/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
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/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@@ -86,47 +70,44 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs=
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-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c=
github.com/hashicorp/go-hclog v1.5.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.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
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-plugin v1.5.1 h1:oGm7cWBaYIp3lJpx1RUEfLWophprE2EV/KUeqBYo+6k=
github.com/hashicorp/go-plugin v1.5.1/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4=
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/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH92oYYk=
github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI=
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/hc-install v0.6.1 h1:IGxShH7AVhPaSuSJpKtVi/EFORNjO+OYVJJrAtGG2mY=
github.com/hashicorp/hc-install v0.6.1/go.mod h1:0fW3jpg+wraYSnFDJ6Rlie3RvLf1bIqVIkzoon4KoVE=
github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI=
github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
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/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/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM=
github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM=
github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg=
github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA=
github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o=
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-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.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.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.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/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
github.com/hashicorp/terraform-plugin-go v0.19.0 h1:BuZx/6Cp+lkmiG0cOBk6Zps0Cb2tmqQpDM3iAtnhDQU=
github.com/hashicorp/terraform-plugin-go v0.19.0/go.mod h1:EhRSkEPNoylLQntYsk5KrDHTZJh9HQoumZXbOGOXmec=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 h1:X7vB6vn5tON2b49ILa4W7mFAsndeqJ7bZFOGbVO+0Cc=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0/go.mod h1:ydFcxbdj6klCqYEPkPvdvFKiNGKZLUs+896ODUXCyao=
github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno=
github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
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=
@@ -135,28 +116,19 @@ github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq
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.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
@@ -172,8 +144,6 @@ github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2c
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/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
@@ -183,11 +153,9 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
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.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
@@ -196,24 +164,20 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -226,64 +190,46 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
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/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
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.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
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=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA=
github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
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-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.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
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-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
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-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-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
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.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/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-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/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=
@@ -293,51 +239,51 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
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.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
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.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
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/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
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=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.5/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-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.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U=
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
google.golang.org/grpc v1.57.1 h1:upNTNqv0ES+2ZOOqACwVtS3Il8M12/+Hz41RCPzAjQg=
google.golang.org/grpc v1.57.1/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/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 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
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-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.3 h1:Rt5tE4EZcUr4ONK9u/XYe2mG1CC37xLUnNuCLYKDwYs=
repository.basistech.ru/BASIS/decort-golang-sdk v1.5.3/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.14 h1:FSu4kPKHsrmZpYIUKlX0s4v53CGmmT2Ne2uWuiRh6pM=
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.14/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=

View File

@@ -37,3 +37,6 @@ const MaxCpusPerCompute = 128
// MinRamPerCompute sets minimum amount of RAM per compute in MB
const MinRamPerCompute = 128
// RAMDivisibility sets divisibility of RAM value
const RAMDivisibility = 128

View File

@@ -21,7 +21,6 @@ limitations under the License.
package controller
import (
"bytes"
"crypto/tls"
"fmt"
"io/ioutil"
@@ -39,8 +38,6 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
jwt "github.com/golang-jwt/jwt/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
@@ -170,27 +167,27 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
case MODE_OAUTH2:
// on success getOAuth2JWT will set config.jwt to the obtained JWT, so there is no
// need to set it once again here
_, err := ret_config.getOAuth2JWT()
if err != nil {
return nil, err
}
// we are not verifying the JWT when parsing because actual verification is done on the
// OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user")
// and JWT issuer name (claim "iss")
parser := jwt.Parser{}
token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{})
if err != nil {
return nil, err
}
if claims, ok := token.Claims.(jwt.MapClaims); ok {
var tbuf bytes.Buffer
tbuf.WriteString(claims["username"].(string))
tbuf.WriteString("@")
tbuf.WriteString(claims["iss"].(string))
ret_config.decort_username = tbuf.String()
} else {
return nil, fmt.Errorf("Failed to extract user and iss fields from JWT token in oauth2 mode.")
}
// _, err := ret_config.getOAuth2JWT()
// if err != nil {
// return nil, err
// }
// // we are not verifying the JWT when parsing because actual verification is done on the
// // OVC controller side. Here we do parsing solely to extract Oauth2 user name (claim "user")
// // and JWT issuer name (claim "iss")
// parser := jwt.Parser{}
// token, _, err := parser.ParseUnverified(ret_config.jwt, jwt.MapClaims{})
// if err != nil {
// return nil, err
// }
// if claims, ok := token.Claims.(jwt.MapClaims); ok {
// var tbuf bytes.Buffer
// tbuf.WriteString(claims["username"].(string))
// tbuf.WriteString("@")
// tbuf.WriteString(claims["iss"].(string))
// ret_config.decort_username = tbuf.String()
// } else {
// return nil, fmt.Errorf("Failed to extract user and iss fields from JWT token in oauth2 mode.")
// }
sdkConf := config.Config{
AppID: ret_config.app_id,
@@ -212,57 +209,57 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
return ret_config, nil
}
func (config *ControllerCfg) GetDecortUsername() string {
return config.decort_username
}
// func (config *ControllerCfg) GetDecortUsername() string {
// return config.decort_username
// }
func (config *ControllerCfg) getOAuth2JWT() (string, error) {
// Obtain JWT from the Oauth2 provider using application ID and application secret provided in config.
if config.auth_mode_code == MODE_UNDEF {
return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode.")
}
if config.auth_mode_code != MODE_OAUTH2 {
return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q.", config.auth_mode_txt)
}
// func (config *ControllerCfg) getOAuth2JWT() (string, error) {
// // Obtain JWT from the Oauth2 provider using application ID and application secret provided in config.
// if config.auth_mode_code == MODE_UNDEF {
// return "", fmt.Errorf("getOAuth2JWT method called for undefined authorization mode.")
// }
// if config.auth_mode_code != MODE_OAUTH2 {
// return "", fmt.Errorf("getOAuth2JWT method called for incompatible authorization mode %q.", config.auth_mode_txt)
// }
params := url.Values{}
params.Add("grant_type", "client_credentials")
params.Add("client_id", config.app_id)
params.Add("client_secret", config.app_secret)
params.Add("response_type", "id_token")
params.Add("validity", "3600")
params_str := params.Encode()
// params := url.Values{}
// params.Add("grant_type", "client_credentials")
// params.Add("client_id", config.app_id)
// params.Add("client_secret", config.app_secret)
// params.Add("response_type", "id_token")
// params.Add("validity", "3600")
// params_str := params.Encode()
req, err := http.NewRequest("POST", config.oauth2_url+"/v1/oauth/access_token", strings.NewReader(params_str))
if err != nil {
return "", err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Content-Length", strconv.Itoa(len(params_str)))
// req, err := http.NewRequest("POST", config.oauth2_url+"/v1/oauth/access_token", strings.NewReader(params_str))
// if err != nil {
// return "", err
// }
// req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// req.Header.Set("Content-Length", strconv.Itoa(len(params_str)))
resp, err := config.cc_client.Do(req)
if err != nil {
return "", err
}
if resp.StatusCode != http.StatusOK {
// fmt.Println("response Status:", resp.Status)
// fmt.Println("response Headers:", resp.Header)
// fmt.Println("response Headers:", req.URL)
return "", fmt.Errorf("getOauth2JWT: unexpected status code %d when obtaining JWT from %q for APP_ID %q, request Body %q",
resp.StatusCode, req.URL, config.app_id, params_str)
}
defer resp.Body.Close()
// resp, err := config.cc_client.Do(req)
// if err != nil {
// return "", err
// }
// if resp.StatusCode != http.StatusOK {
// // fmt.Println("response Status:", resp.Status)
// // fmt.Println("response Headers:", resp.Header)
// // fmt.Println("response Headers:", req.URL)
// return "", fmt.Errorf("getOauth2JWT: unexpected status code %d when obtaining JWT from %q for APP_ID %q, request Body %q",
// resp.StatusCode, req.URL, config.app_id, params_str)
// }
// defer resp.Body.Close()
responseData, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
// responseData, err := ioutil.ReadAll(resp.Body)
// if err != nil {
// return "", err
// }
// validation successful - store JWT in the corresponding field of the ControllerCfg structure
config.jwt = strings.TrimSpace(string(responseData))
// // validation successful - store JWT in the corresponding field of the ControllerCfg structure
// config.jwt = strings.TrimSpace(string(responseData))
return config.jwt, nil
}
// return config.jwt, nil
// }
func (config *ControllerCfg) validateJWT(jwt string) (bool, error) {
/*

View File

@@ -34,6 +34,7 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/locations"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/snapshot"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/stack"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/vins"
cb_account "repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/account"
@@ -49,81 +50,93 @@ import (
func newDataSourcesMap() map[string]*schema.Resource {
return map[string]*schema.Resource{
"decort_account": account.DataSourceAccount(),
"decort_resgroup": rg.DataSourceResgroup(),
"decort_kvmvm": kvmvm.DataSourceCompute(),
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
"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_k8s_computes": k8s.DataSourceK8sComputes(),
"decort_k8ci_list": k8s.DataSourceK8CIList(),
"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_disk": disks.DataSourceDisk(),
"decort_disk_list": disks.DataSourceDiskList(),
"decort_rg_list": rg.DataSourceRgList(),
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
"decort_rg_audits": rg.DataSourceRgAudits(),
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
"decort_rg_list_lb": rg.DataSourceRgListLb(),
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
"decort_rg_list_vins": rg.DataSourceRgListVins(),
"decort_rg_usage": rg.DataSourceRgUsage(),
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
"decort_account_list": account.DataSourceAccountList(),
"decort_account_computes_list": account.DataSourceAccountComputesList(),
"decort_account_disks_list": account.DataSourceAccountDisksList(),
"decort_account_vins_list": account.DataSourceAccountVinsList(),
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
"decort_account_rg_list": account.DataSourceAccountRGList(),
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
"decort_bservice": bservice.DataSourceBasicService(),
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
"decort_extnet_list": extnet.DataSourceExtnetList(),
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
"decort_extnet": extnet.DataSourceExtnet(),
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
"decort_locations_list": locations.DataSourceLocationsList(),
"decort_location_url": locations.DataSourceLocationUrl(),
"decort_image_list": image.DataSourceImageList(),
"decort_image": image.DataSourceImage(),
"decort_lb": lb.DataSourceLB(),
"decort_lb_list": lb.DataSourceLBList(),
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
"decort_account": account.DataSourceAccount(),
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
"decort_resgroup": rg.DataSourceResgroup(),
"decort_kvmvm": kvmvm.DataSourceCompute(),
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
"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_k8s_computes": k8s.DataSourceK8sComputes(),
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
"decort_k8ci_list": k8s.DataSourceK8CIList(),
"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_vins_static_route_list": vins.DataSourceStaticRouteList(),
"decort_vins_static_route": vins.DataSourceStaticRoute(),
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
"decort_disk": disks.DataSourceDisk(),
"decort_disk_list": disks.DataSourceDiskList(),
"decort_rg_list": rg.DataSourceRgList(),
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
"decort_rg_audits": rg.DataSourceRgAudits(),
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
"decort_rg_list_lb": rg.DataSourceRgListLb(),
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
"decort_rg_list_vins": rg.DataSourceRgListVins(),
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
"decort_rg_usage": rg.DataSourceRgUsage(),
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
"decort_account_list": account.DataSourceAccountList(),
"decort_account_computes_list": account.DataSourceAccountComputesList(),
"decort_account_disks_list": account.DataSourceAccountDisksList(),
"decort_account_vins_list": account.DataSourceAccountVinsList(),
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
"decort_account_rg_list": account.DataSourceAccountRGList(),
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
"decort_bservice": bservice.DataSourceBasicService(),
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
"decort_extnet_list": extnet.DataSourceExtnetList(),
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
"decort_extnet": extnet.DataSourceExtnet(),
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
"decort_locations_list": locations.DataSourceLocationsList(),
"decort_location_url": locations.DataSourceLocationUrl(),
"decort_image_list": image.DataSourceImageList(),
"decort_image": image.DataSourceImage(),
"decort_lb": lb.DataSourceLB(),
"decort_lb_list": lb.DataSourceLBList(),
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
"decort_stack": stack.DataSourceStack(),
"decort_stack_list": stack.DataSourceStackList(),
"decort_cb_account": cb_account.DataSourceAccount(),
"decort_cb_account_list": cb_account.DataSourceAccountList(),

View File

@@ -72,6 +72,7 @@ func newResourcesMap() map[string]*schema.Resource {
"decort_lb_frontend": lb.ResourceLBFrontend(),
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
"decort_vins_static_route": vins.ResourceStaticRoute(),
"decort_cb_account": cb_account.ResourceAccount(),
"decort_cb_extnet": cb_extnet.ResourceExtnetCB(),

View File

@@ -0,0 +1,136 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceAccountResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountResourceConsumptionRec, err := utilityAccountResourceConsumptionGetCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
flattenResourceConsumption(d, accountResourceConsumptionRec)
return nil
}
func dataSourceAccountResourceConsumptionGetSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Required: true,
},
"consumed": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceAccResourceSchemaMake(),
},
},
"reserved": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceAccResourceSchemaMake(),
},
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceResourceLimitsSchemaMake(),
},
},
}
return res
}
func dataSourceResourceLimitsSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"cu_c": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_d": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_dm": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_i": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_m": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_np": {
Type: schema.TypeFloat,
Computed: true,
},
"gpu_units": {
Type: schema.TypeFloat,
Computed: true,
},
}
return res
}
func DataSourceAccountResourceConsumptionGet() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountResourceConsumptionGetRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountResourceConsumptionGetSchemaMake(),
}
}

View File

@@ -0,0 +1,169 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceAccountResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountResourceConsumptionList, err := utilityAccountResourceConsumptionListCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenAccResourceConsumption(accountResourceConsumptionList))
d.Set("entry_count", accountResourceConsumptionList.EntryCount)
return nil
}
func dataSourceAccountResourceConsumptionListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"consumed": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceAccResourceSchemaMake(),
},
},
"reserved": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceAccResourceSchemaMake(),
},
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func dataSourceSepsSchemaMake() map[string]*schema.Schema {
res := 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.TypeFloat,
Computed: true,
},
}
return res
}
func dataSourceAccResourceSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"cpu": {
Type: schema.TypeInt,
Computed: true,
},
"disk_size": {
Type: schema.TypeFloat,
Computed: true,
},
"disk_size_max": {
Type: schema.TypeFloat,
Computed: true,
},
"ext_ips": {
Type: schema.TypeInt,
Computed: true,
},
"ext_traffic": {
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: dataSourceSepsSchemaMake(),
},
},
}
return res
}
func DataSourceAccountResourceConsumptionList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountResourceConsumptionListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountResourceConsumptionListSchemaMake(),
}
}

View File

@@ -43,7 +43,7 @@ import (
)
func flattenAccountTemplatesList(atl *account.ListTemplates) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(atl.Data))
for _, at := range atl.Data {
temp := map[string]interface{}{
"unc_path": at.UNCPath,
@@ -72,7 +72,7 @@ func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceD
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
d.Set("entry_count", accountTemplatesList.EntryCount)
return nil
}
@@ -87,6 +87,31 @@ func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Optional: true,
},
"image_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by image id",
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by name",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by type",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -136,6 +161,10 @@ func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}

View File

@@ -21,7 +21,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
d.Set("guid", acc.GUID)
d.Set("account_id", acc.ID)
d.Set("account_name", acc.Name)
d.Set("resource_limits", flattenRgResourceLimits(acc.ResourceLimits))
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
d.Set("send_access_emails", acc.SendAccessEmails)
d.Set("status", acc.Status)
d.Set("updated_time", acc.UpdatedTime)
@@ -79,11 +79,19 @@ func flattenAccAcl(acls []account.RecordACL) []map[string]interface{} {
return res
}
func flattenRgResourceLimits(rl account.ResourceLimits) []map[string]interface{} {
func flattenResourceConsumption(d *schema.ResourceData, acc *account.RecordResourceConsumption) {
d.Set("account_id", acc.AccountID)
d.Set("consumed", flattenAccResource(acc.Consumed))
d.Set("reserved", flattenAccResource(acc.Reserved))
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
}
func flattenAccResourceLimits(rl account.ResourceLimits) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"cu_c": rl.CUC,
"cu_d": rl.CUD,
"cu_dm": rl.CUDM,
"cu_i": rl.CUI,
"cu_m": rl.CUM,
"cu_np": rl.CUNP,
@@ -124,14 +132,28 @@ func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[stri
func flattenAccResource(r account.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),
"cpu": r.CPU,
"disk_size": r.DiskSize,
"disk_size_max": r.DiskSizeMax,
"ext_ips": r.ExtIPs,
"ext_traffic": r.ExtTraffic,
"gpu": r.GPU,
"ram": r.RAM,
"seps": flattenAccountSeps(r.SEPs),
}
res = append(res, temp)
return res
}
func flattenAccResourceConsumption(lrc *account.ListResourceConsumption) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lrc.Data))
for _, rc := range lrc.Data {
temp := map[string]interface{}{
"consumed": flattenAccResource(rc.Consumed),
"reserved": flattenAccResource(rc.Reserved),
"account_id": rc.AccountID,
}
res = append(res, temp)
}
return res
}

View File

@@ -54,7 +54,7 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interf
func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceAccountRead: called for account with ID: %v", d.Id())
c := m.(*controller.ControllerCfg)
// c := m.(*controller.ControllerCfg)
acc, err := utilityAccountCheckPresence(ctx, d, m)
if err != nil {
@@ -67,22 +67,23 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interfac
switch acc.Status {
case status.Destroyed:
d.SetId("")
return resourceAccountCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceAccountCreate(ctx, d, m)
case status.Destroying:
return diag.Errorf("The account is in progress with status: %s", acc.Status)
case status.Deleted:
id, _ := strconv.ParseUint(d.Id(), 10, 64)
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
req := account.RestoreRequest{
AccountID: id,
}
// req := account.RestoreRequest{
// AccountID: id,
// }
_, err := c.CloudAPI().Account().Restore(ctx, req)
if err != nil {
return diag.FromErr(err)
}
// _, err := c.CloudAPI().Account().Restore(ctx, req)
// if err != nil {
// return diag.FromErr(err)
// }
hasChanged = true
// hasChanged = true
case status.Disabled:
log.Debugf("The account is in status: %s, troubles may occur with update. Please, enable account first.", acc.Status)
case status.Confirmed:
@@ -142,7 +143,8 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
switch acc.Status {
case status.Destroyed:
d.SetId("")
return resourceAccountCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceAccountCreate(ctx, d, m)
case status.Destroying:
return diag.Errorf("The account is in progress with status: %s", acc.Status)
case status.Deleted:

View 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://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountResourceConsumptionGetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.RecordResourceConsumption, error) {
c := m.(*controller.ControllerCfg)
id := uint64(d.Get("account_id").(int))
req:= account.GetResourceConsumptionRequest {
AccountID: id,
}
log.Debugf("utilityAccountResourceConsumptionGetCheckPresence: load")
accountResourceConsumptionRec, err := c.CloudAPI().Account().GetResourceConsumption(ctx, req)
if err != nil {
return nil, err
}
return accountResourceConsumptionRec, nil
}

View File

@@ -0,0 +1,55 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountResourceConsumptionListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListResourceConsumption, error) {
c := m.(*controller.ControllerCfg)
log.Debugf("utilityAccountResourceConsumptionListCheckPresence: load")
accountResourceConsumptionList, err := c.CloudAPI().Account().ListResourceConsumption(ctx)
if err != nil {
return nil, err
}
return accountResourceConsumptionList, nil
}

View File

@@ -44,9 +44,8 @@ import (
func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListTemplates, error) {
c := m.(*controller.ControllerCfg)
var id uint64
id = uint64(d.Get("account_id").(int))
id := uint64(d.Get("account_id").(int))
req := account.ListTemplatesRequest{
AccountID: id,
@@ -55,6 +54,21 @@ func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.Res
if include_deleted, ok := d.GetOk("include_deleted"); ok {
req.IncludeDeleted = include_deleted.(bool)
}
if imageId, ok := d.GetOk("image_id"); ok {
req.ImageID = uint64(imageId.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if typeTemplates, ok := d.GetOk("type"); ok {
req.Type = typeTemplates.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)

View File

@@ -146,7 +146,7 @@ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"disk_total": {
Type: schema.TypeString,
Type: schema.TypeInt,
Computed: true,
},
"gid": {
@@ -185,13 +185,13 @@ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
},
},
},
"groups_name": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
// "groups_name": {
// Type: schema.TypeList,
// Computed: true,
// Elem: &schema.Schema{
// Type: schema.TypeString,
// },
// },
"guid": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -1,105 +1,105 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package bservice
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenBasicServiceSnapshots(basicServiceSnapshotList))
return nil
}
func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"service_id": {
Type: schema.TypeInt,
Required: true,
Description: "ID of the BasicService instance",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"guid": {
Type: schema.TypeString,
Computed: true,
},
"label": {
Type: schema.TypeString,
Computed: true,
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
},
"valid": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
}
return res
}
func DataSourceBasicServiceSnapshotList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceBasicServiceSnapshotListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceSnapshotListSchemaMake(),
}
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package bservice
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenBasicServiceSnapshots(basicServiceSnapshotList.Data))
return nil
}
func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"service_id": {
Type: schema.TypeInt,
Required: true,
Description: "ID of the BasicService instance",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"guid": {
Type: schema.TypeString,
Computed: true,
},
"label": {
Type: schema.TypeString,
Computed: true,
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
},
"valid": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},
}
return res
}
func DataSourceBasicServiceSnapshotList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceBasicServiceSnapshotListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceSnapshotListSchemaMake(),
}
}

View File

@@ -30,6 +30,7 @@ func flattenResourceBasicServiceGroup(d *schema.ResourceData, bsg *bservice.Reco
d.Set("rg_name", bsg.RGName)
d.Set("role", bsg.Role)
d.Set("sep_id", bsg.SEPID)
d.Set("sep_pool", bsg.PoolName)
d.Set("seq_no", bsg.SeqNo)
d.Set("status", bsg.Status)
d.Set("tech_status", bsg.TechStatus)

View File

@@ -34,14 +34,17 @@ package bservice
import (
"context"
"errors"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
)
@@ -77,13 +80,50 @@ func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m i
d.SetId(strconv.FormatUint(serviceId, 10))
d.Set("service_id", serviceId)
return resourceBasicServiceRead(ctx, d, m)
service, err := utilityBasicServiceCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
warnings := dc.Warnings{}
if d.Get("enable").(bool) && (service.Status == status.Disabled || service.Status == status.Created) {
log.Debugf("trying to enable bservice %v", serviceId)
_, err := c.CloudAPI().BService().Enable(ctx, bservice.EnableRequest{
ServiceID: serviceId,
})
if err != nil {
warnings.Add(err)
}
}
if d.Get("start").(bool) {
log.Debugf("trying to start bservice %v", serviceId)
if !d.Get("enable").(bool) {
warnings.Add(errors.New("can not start bservice that is not enabled. Set enable = true and start = true to enable and start bservice"))
}
if d.Get("enable").(bool) {
_, err := c.CloudAPI().BService().Start(ctx, bservice.StartRequest{
ServiceID: serviceId,
})
if err != nil {
warnings.Add(err)
}
}
}
return append(warnings.Get(), resourceBasicServiceRead(ctx, d, m)...)
}
func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceRead")
c := m.(*controller.ControllerCfg)
// c := m.(*controller.ControllerCfg)
bs, err := utilityBasicServiceCheckPresence(ctx, d, m)
if err != nil {
@@ -104,29 +144,30 @@ func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m int
case status.Disabling:
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
case status.Deleted:
id, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := bservice.RestoreRequest{
ServiceID: id,
}
enableReq := bservice.EnableRequest{
ServiceID: id,
}
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
// restoreReq := bservice.RestoreRequest{
// ServiceID: id,
// }
// enableReq := bservice.EnableRequest{
// ServiceID: id,
// }
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
if err != nil {
return diag.FromErr(err)
}
// _, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
// if err != nil {
// return diag.FromErr(err)
// }
_, err = c.CloudAPI().BService().Enable(ctx, enableReq)
if err != nil {
return diag.FromErr(err)
}
// _, err = c.CloudAPI().BService().Enable(ctx, enableReq)
// if err != nil {
// return diag.FromErr(err)
// }
hasChanged = true
// hasChanged = true
case status.Deleting:
case status.Destroyed:
d.SetId("")
return resourceBasicServiceCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceBasicServiceCreate(ctx, d, m)
case status.Destroying:
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
case status.Restoring:
@@ -202,29 +243,44 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
case status.Disabling:
log.Debugf("The basic service is in status: %s, troubles can occur with the update.", bs.Status)
case status.Deleted:
id, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := bservice.RestoreRequest{
ServiceID: id,
}
enableReq := bservice.EnableRequest{
ServiceID: id,
}
if d.Get("restore").(bool) {
id, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := bservice.RestoreRequest{
ServiceID: id,
}
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
if err != nil {
return diag.FromErr(err)
}
_, err := c.CloudAPI().BService().Restore(ctx, restoreReq)
if err != nil {
return diag.FromErr(err)
}
_, err = c.CloudAPI().BService().Enable(ctx, enableReq)
if err != nil {
return diag.FromErr(err)
}
hasChanged = true
hasChanged = true
if d.Get("enable").(bool) {
_, err := c.CloudAPI().BService().Enable(ctx, bservice.EnableRequest{
ServiceID: id,
})
if err != nil {
return diag.FromErr(err)
}
}
if d.Get("start").(bool) {
_, err := c.CloudAPI().BService().Start(ctx, bservice.StartRequest{
ServiceID: id,
})
if err != nil {
return diag.FromErr(err)
}
}
}
case status.Deleting:
case status.Destroyed:
d.SetId("")
return resourceBasicServiceCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceBasicServiceCreate(ctx, d, m)
case status.Destroying:
return diag.Errorf("The basic service is in progress with status: %s", bs.Status)
case status.Restoring:
@@ -262,19 +318,6 @@ func resourceBasicServiceUpdate(ctx context.Context, d *schema.ResourceData, m i
}
}
if d.HasChange("restore") {
restore := d.Get("restore").(bool)
if restore {
req := bservice.RestoreRequest{
ServiceID: uint64(d.Get("service_id").(int)),
}
_, err := c.CloudAPI().BService().Restore(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
}
if d.HasChange("start") {
start := d.Get("start").(bool)
if start {
@@ -533,7 +576,7 @@ func resourceBasicServiceSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"disk_total": {
Type: schema.TypeString,
Type: schema.TypeInt,
Computed: true,
},
"gid": {

View File

@@ -43,6 +43,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/validators"
)
func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
@@ -68,6 +69,20 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData
req.TimeoutStart = uint64(timeoutStart.(int))
}
///4.4.0
if sepId, ok := d.GetOk("sep_id"); ok {
req.SEPID = uint64(sepId.(int))
}
if sepPool, ok := d.GetOk("sep_pool"); ok {
req.SEPPool = sepPool.(string)
}
if cloudInit, ok := d.GetOk("cloud_init"); ok {
req.UserData = cloudInit.(string)
}
///
if vinses, ok := d.GetOk("vinses"); ok {
res := []uint64{}
for _, vins := range vinses.([]interface{}) {
@@ -93,6 +108,20 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData
d.SetId(strconv.FormatUint(compgroupId, 10))
d.Set("compgroup_id", compgroupId)
serviceId := uint64(d.Get("service_id").(int))
if d.Get("start").(bool) {
log.Debugf("trying to start bservice group %v", compgroupId)
_, err := c.CloudAPI().BService().GroupStart(ctx, bservice.GroupStartRequest{
ServiceID: serviceId,
CompGroupID: compgroupId,
})
if err != nil {
return diag.FromErr(err)
}
}
return resourceBasicServiceGroupRead(ctx, d, m)
}
@@ -343,8 +372,12 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
Description: "compute CPU number. All computes in the group have the same CPU count",
},
"ram": {
Type: schema.TypeInt,
Required: true,
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.All(
validation.IntAtLeast(constants.MinRamPerCompute),
validators.DivisibleBy(constants.RAMDivisibility),
),
Description: "compute RAM volume in MB. All computes in the group have the same RAM volume",
},
"disk": {
@@ -362,6 +395,25 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "compute driver like a KVM_X86, KVM_PPC, etc.",
},
///4.4.0
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
"sep_pool": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "pool to use if sepId is set, can be also empty if needed to be chosen by system",
},
"cloud_init": {
Type: schema.TypeString,
Optional: true,
Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.",
},
///
"role": {
Type: schema.TypeString,
Optional: true,
@@ -524,10 +576,6 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"sep_id": {
Type: schema.TypeInt,
Computed: true,
},
"seq_no": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -1,64 +1,64 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package bservice
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityBasicServiceSnapshotListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (bservice.ListSnapshots, error) {
c := m.(*controller.ControllerCfg)
var id uint64
if serviceId, ok := d.GetOk("service_id"); ok {
id = uint64(serviceId.(int))
}
req := bservice.SnapshotListRequest{
ServiceID: id,
}
log.Debugf("utilityBasicServiceSnapshotListCheckPresence")
basicServiceSnapshotList, err := c.CloudAPI().BService().SnapshotList(ctx, req)
if err != nil {
return nil, err
}
return basicServiceSnapshotList, nil
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package bservice
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityBasicServiceSnapshotListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*bservice.ListInfoSnapshots, error) {
c := m.(*controller.ControllerCfg)
var id uint64
if serviceId, ok := d.GetOk("service_id"); ok {
id = uint64(serviceId.(int))
}
req := bservice.SnapshotListRequest{
ServiceID: id,
}
log.Debugf("utilityBasicServiceSnapshotListCheckPresence")
basicServiceSnapshotList, err := c.CloudAPI().BService().SnapshotList(ctx, req)
if err != nil {
return nil, err
}
return basicServiceSnapshotList, nil
}

View File

@@ -97,6 +97,16 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "type of the disks",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Description: "find by sep ID",
},
"pool_name": {
Type: schema.TypeString,
Optional: true,
Description: "find by pool name",
},
"page": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -49,12 +49,23 @@ func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m
id := uuid.New()
d.SetId(id.String())
d.Set("types", listTypes)
d.Set("types", listTypes.Data)
d.Set("entry_count", listTypes.EntryCount)
return nil
}
func dataSourceDiskListTypesSchemaMake() 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",
},
"types": {
Type: schema.TypeList,
Computed: true,
@@ -63,6 +74,10 @@ func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
},
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}

View File

@@ -49,6 +49,7 @@ func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{}
temp := map[string]interface{}{
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
"sep_id": toMap["sepId"].(float64),
"sep_name": toMap["sepName"].(string),
}
res = append(res, temp)
}
@@ -61,6 +62,7 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
toMap := pool.(map[string]interface{})
temp := map[string]interface{}{
"name": toMap["name"].(string),
"system": toMap["system"].(string),
"types": toMap["types"].([]interface{}),
}
res = append(res, temp)
@@ -78,11 +80,22 @@ func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.Resource
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed))
d.Set("entry_count", listTypesDetailed.EntryCount)
return nil
}
func dataSourceDiskListTypesDetailedSchemaMake() 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,
@@ -98,6 +111,10 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Pool name",
},
"system": {
Type: schema.TypeString,
Computed: true,
},
"types": {
Type: schema.TypeList,
Computed: true,
@@ -114,9 +131,17 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Storage endpoint provider ID to create disk",
},
"sep_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}

View File

@@ -97,6 +97,16 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "ID of the account the disks belong to",
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Description: "find by sep ID",
},
"pool_name": {
Type: schema.TypeString,
Optional: true,
Description: "find by pool name",
},
"type": {
Type: schema.TypeString,
Optional: true,

View File

@@ -17,7 +17,7 @@ func flattenDiskSnapshot(d *schema.ResourceData, snapshot disks.ItemSnapshot) {
}
func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(ul.Data))
for _, unattachedDisk := range ul.Data {
unattachedDiskAcl, _ := json.Marshal(unattachedDisk.ACL)
tmp := map[string]interface{}{
@@ -120,7 +120,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
}
func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
res := make([]interface{}, 0)
res := make([]interface{}, 0, len(sl))
for _, snapshot := range sl {
temp := map[string]interface{}{
"guid": snapshot.GUID,
@@ -137,7 +137,7 @@ func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
}
func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(dl.Data))
for _, disk := range dl.Data {
diskAcl, _ := json.Marshal(disk.ACL)
temp := map[string]interface{}{

View File

@@ -142,7 +142,7 @@ func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface
}
func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*controller.ControllerCfg)
// c := m.(*controller.ControllerCfg)
warnings := dc.Warnings{}
disk, err := utilityDiskCheckPresence(ctx, d, m)
@@ -157,23 +157,24 @@ func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}
case status.Destroyed, status.Purged:
d.Set("disk_id", 0)
d.SetId("")
return resourceDiskCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceDiskCreate(ctx, d, m)
case status.Deleted:
hasChangeState = true
req := disks.RestoreRequest{
DiskID: disk.ID,
}
// hasChangeState = true
// req := disks.RestoreRequest{
// DiskID: disk.ID,
// }
if reason, ok := d.GetOk("reason"); ok {
req.Reason = reason.(string)
} else {
req.Reason = "Terraform automatic restore"
}
// if reason, ok := d.GetOk("reason"); ok {
// req.Reason = reason.(string)
// } else {
// req.Reason = "Terraform automatic restore"
// }
_, err := c.CloudAPI().Disks().Restore(ctx, req)
if err != nil {
warnings.Add(err)
}
// _, err := c.CloudAPI().Disks().Restore(ctx, req)
// if err != nil {
// warnings.Add(err)
// }
case status.Assigned:
case status.Modeled:
return diag.Errorf("The disk is in status: %s, please, contact support for more information", disk.Status)
@@ -227,22 +228,26 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
case status.Destroyed, status.Purged:
d.Set("disk_id", 0)
d.SetId("")
return resourceDiskCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceDiskCreate(ctx, d, m)
case status.Deleted:
hasChangeState = true
req := disks.RestoreRequest{
DiskID: disk.ID,
}
if restore, ok:= d.GetOk("restore"); ok && restore.(bool) {
hasChangeState = true
req := disks.RestoreRequest{
DiskID: disk.ID,
}
if reason, ok := d.GetOk("reason"); ok {
req.Reason = reason.(string)
} else {
req.Reason = "Terraform automatic restore"
}
_, err := c.CloudAPI().Disks().Restore(ctx, req)
if err != nil {
warnings.Add(err)
}
if reason, ok := d.GetOk("reason"); ok {
req.Reason = reason.(string)
} else {
req.Reason = "Terraform automatic restore"
}
_, err := c.CloudAPI().Disks().Restore(ctx, req)
if err != nil {
warnings.Add(err)
}
case status.Assigned:
case status.Modeled:
@@ -271,7 +276,7 @@ func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface
Size: uint64(newSize.(int)),
}
_, err := c.CloudAPI().Disks().Resize(ctx, req)
_, err := c.CloudAPI().Disks().Resize2(ctx, req)
if err != nil {
return diag.FromErr(err)
}
@@ -355,10 +360,18 @@ func resourceDiskDelete(ctx context.Context, d *schema.ResourceData, m interface
}
req := disks.DeleteRequest{
DiskID: disk.ID,
Detach: d.Get("detach").(bool),
Permanently: d.Get("permanently").(bool),
Reason: d.Get("reason").(string),
DiskID: disk.ID,
}
if detach, ok := d.GetOk("detach"); ok {
req.Detach = detach.(bool)
}
if permanently, ok := d.GetOk("permanently"); ok {
req.Permanently = permanently.(bool)
}
if reason, ok := d.GetOk("reason"); ok {
req.Reason = reason.(string)
}
c := m.(*controller.ControllerCfg)
@@ -444,6 +457,11 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Optional: true,
Computed: true,
},
"restore": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"iotune": {
Type: schema.TypeList,
Optional: true,

View File

@@ -47,18 +47,6 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
c := m.(*controller.ControllerCfg)
req := disks.ListRequest{}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = strings.ToUpper(diskType.(string))
}
if accountId, ok := d.GetOk("accountId"); ok {
req.AccountID = uint64(accountId.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
@@ -77,6 +65,24 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
if shared, ok := d.GetOk("shared"); ok {
req.Shared = shared.(bool)
}
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = strings.ToUpper(diskType.(string))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.AccountID = uint64(sepId.(int))
}
if pool_name, ok := d.GetOk("pool_name"); ok {
req.Pool = pool_name.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListCheckPresence: load disk list")
diskList, err := c.CloudAPI().Disks().List(ctx, req)

View File

@@ -13,15 +13,6 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou
c := m.(*controller.ControllerCfg)
req := disks.ListUnattachedRequest{}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if accountId, ok := d.GetOk("accountId"); ok {
req.AccountID = uint64(accountId.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
@@ -34,6 +25,24 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if diskType, ok := d.GetOk("type"); ok {
req.Type = diskType.(string)
}
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.AccountID = uint64(sepId.(int))
}
if pool_name, ok := d.GetOk("pool_name"); ok {
req.Pool = pool_name.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req)

View File

@@ -46,6 +46,13 @@ func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.Re
req := disks.ListTypesRequest{
Detailed: true,
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed")
listTypesDetailed, err := c.CloudAPI().Disks().ListTypes(ctx, req)

View File

@@ -47,6 +47,13 @@ func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceDa
Detailed: false,
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
typesList, err := c.CloudAPI().Disks().ListTypes(ctx, req)
if err != nil {

View File

@@ -50,7 +50,7 @@ func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceDat
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenExtnetComputesList(extnetComputesList))
d.Set("entry_count", extnetComputesList.EntryCount)
return nil
}
@@ -61,6 +61,26 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "filter by account ID",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by RG ID",
},
"compute_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by compute ID",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -117,6 +137,10 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}

View File

@@ -35,7 +35,7 @@ func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
}
func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(ex))
for _, item := range ex {
temp := map[string]interface{}{
"client_type": item.ClientType,
@@ -51,7 +51,7 @@ func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
}
func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(ers))
for _, er := range ers {
temp := map[string]interface{}{
"client_type": er.ClientType,
@@ -92,7 +92,7 @@ func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
}
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len (ecs))
for _, ec := range ecs {
temp := map[string]interface{}{
"net_id": ec.ID,
@@ -106,7 +106,7 @@ func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface
}
func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(ecl.Data))
for _, ec := range ecl.Data {
temp := map[string]interface{}{
"account_id": ec.AccountID,
@@ -123,7 +123,7 @@ func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]inte
}
func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(el.Data))
for _, e := range el.Data {
temp := map[string]interface{}{
"net_id": e.ID,

View File

@@ -48,6 +48,20 @@ func utilityExtnetComputesListCheckPresence(ctx context.Context, d *schema.Resou
AccountID: uint64(d.Get("account_id").(int)),
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if compute_id, ok := d.GetOk("compute_id"); ok {
req.ComputeID = uint64(compute_id.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityExtnetComputesListCheckPresence")
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
if err != nil {

View File

@@ -144,7 +144,8 @@ func resourceImageRead(ctx context.Context, d *schema.ResourceData, m interface{
case status.Created:
case status.Destroyed, status.Purged:
d.SetId("")
return resourceImageCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceImageCreate(ctx, d, m)
}
flattenImage(d, img)
@@ -233,7 +234,8 @@ func resourceImageUpdate(ctx context.Context, d *schema.ResourceData, m interfac
case status.Created:
case status.Destroyed, status.Purged:
d.SetId("")
return resourceImageCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceImageCreate(ctx, d, m)
}
if d.HasChange("name") {

View File

@@ -50,7 +50,7 @@ func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m i
c := m.(*controller.ControllerCfg)
req := image.CreateVirtualRequest{
Name: d.Get("name").(string),
TargetID: uint64(d.Get("target_id").(int)),
TargetID: uint64(d.Get("link_to").(int)),
}
imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req)

View File

@@ -80,10 +80,6 @@ func computesSchemaMake() map[string]*schema.Schema {
}
}
func workerComputesSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{}
}
func dataSourceK8sComputesSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"k8s_id": {

View File

@@ -58,6 +58,7 @@ func dataSourceK8sListDeletedRead(ctx context.Context, d *schema.ResourceData, m
func dataSourceK8sListDeletedSchemaMake() map[string]*schema.Schema {
k8sListDeleted := createK8sListSchema()
delete(k8sListDeleted, "includedeleted")
delete(k8sListDeleted, "status")
return k8sListDeleted
}

View File

@@ -0,0 +1,93 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package k8s
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceK8sWgCloudInitRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("dataSourceK8sWgCloudInitRead: called with k8s id %d and wg id %d", d.Get("k8s_id").(int), d.Get("wg_id").(int))
metaData, err := utilityK8sWgCloudInitCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("cloud_init", metaData)
return nil
}
func dataSourceK8sWgCloudInitSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"k8s_id": {
Type: schema.TypeInt,
Required: true,
Description: "Kubernetes cluster ID",
},
"wg_id": {
Type: schema.TypeInt,
Required: true,
Description: "ID of the workers compute group",
},
"cloud_init": {
Type: schema.TypeString,
Computed: true,
Description: "Worker group Cloud init",
},
}
}
func DataSourceK8sWgCloudInit() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceK8sWgCloudInitRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceK8sWgCloudInitSchemaMake(),
}
}

View File

@@ -42,7 +42,7 @@ import (
)
func flattenK8CIItems(list *k8ci.ListK8CI) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(list.Data))
for _, item := range list.Data {
temp := map[string]interface{}{
"k8ci_id": item.ID,
@@ -72,7 +72,7 @@ func flattenK8sDataComputes(d *schema.ResourceData, cluster *k8s.RecordK8S) {
}
func flattenMasterComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(cluster.K8SGroups.Masters.DetailedInfo))
for _, comp := range cluster.K8SGroups.Masters.DetailedInfo {
temp := map[string]interface{}{
"id": comp.ID,
@@ -88,7 +88,7 @@ func flattenMasterComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
}
func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(cluster.K8SGroups.Workers))
for _, wg := range cluster.K8SGroups.Workers {
for _, comp := range wg.DetailedInfo {
temp := map[string]interface{}{
@@ -106,7 +106,7 @@ func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
}
func flattenAclList(aclList k8s.ListACL) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len (aclList))
for _, acl := range aclList {
temp := map[string]interface{}{
"explicit": acl.Explicit,
@@ -134,7 +134,7 @@ func flattenAcl(acl k8s.RecordACL) []map[string]interface{} {
}
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len (interfaces))
for _, interfaceCompute := range interfaces {
temp := map[string]interface{}{
"def_gw": interfaceCompute.DefGW,
@@ -147,7 +147,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
}
func flattenDetailedInfo(detailedInfoList k8s.ListDetailedInfo, computes []compute.RecordCompute) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len (detailedInfoList))
if computes != nil {
for i, detailedInfo := range detailedInfoList {
temp := map[string]interface{}{
@@ -193,7 +193,7 @@ func flattenMasterGroup(mastersGroup k8s.MasterGroup, masters []compute.RecordCo
}
func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCompute) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(k8SGroupList))
for _, k8sGroup := range k8SGroupList {
labels := make([]string, 0)
for _, label := range k8sGroup.Labels {
@@ -222,15 +222,15 @@ func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCom
return res
}
func flattenK8sGroups(k8sGroups k8s.RecordK8SGroups, masters []compute.RecordCompute, workers []compute.RecordCompute) []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 flattenK8sGroups(k8sGroups k8s.RecordK8SGroups, masters []compute.RecordCompute, workers []compute.RecordCompute) []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, cluster k8s.RecordK8S, masters []compute.RecordCompute, workers []compute.RecordCompute) {
d.Set("acl", flattenAcl(cluster.ACL))
@@ -267,7 +267,7 @@ func flattenServiceAccount(serviceAccount k8s.RecordServiceAccount) []map[string
}
func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len (workersGroups))
for _, worker := range workersGroups {
temp := map[string]interface{}{
"annotations": worker.Annotations,
@@ -288,7 +288,7 @@ func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface
}
func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len (k8sItems.Data))
for _, item := range k8sItems.Data {
temp := map[string]interface{}{
"account_id": item.AccountID,
@@ -396,7 +396,7 @@ func flattenResourceK8s(d *schema.ResourceData, k8s k8s.RecordK8S, masters []com
}
func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.RecordCompute) {
labels := make([]string, 0)
labels := make([]string, 0, len(wg.Labels))
for _, label := range wg.Labels {
if strings.HasPrefix(label, "workersGroupName") {
continue
@@ -418,7 +418,7 @@ func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.R
}
func flattenWgList(wgList k8s.ListK8SGroups, computesMap map[uint64][]compute.RecordCompute) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(wgList))
for _, wg := range wgList {
computes := computesMap[wg.ID]
temp := map[string]interface{}{

View File

@@ -35,6 +35,8 @@ package k8s
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/validators"
)
func nodeMasterDefault() K8sNodeRecord {
@@ -85,21 +87,25 @@ func mastersSchemaMake() map[string]*schema.Schema {
Optional: true,
}
masters["cpu"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
Description: "Node CPU count.",
}
masters["ram"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
ValidateFunc: validation.All(
validation.IntAtLeast(constants.MinRamPerCompute),
validators.DivisibleBy(constants.RAMDivisibility),
),
Description: "Node RAM in MB.",
}
masters["disk"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Type: schema.TypeInt,
Required: true,
//ForceNew: true,
Description: "Node boot disk size in GB.",
}
@@ -117,7 +123,11 @@ func workersSchemaMake() map[string]*schema.Schema {
Required: true,
},
"ram": {
Type: schema.TypeInt,
Type: schema.TypeInt,
ValidateFunc: validation.All(
validation.IntAtLeast(constants.MinRamPerCompute),
validators.DivisibleBy(constants.RAMDivisibility),
),
Required: true,
},
"cpu": {

View File

@@ -145,6 +145,54 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
createReq.WithLB = d.Get("with_lb").(bool)
///4.4.0
createReq.HighlyAvailable = d.Get("ha_mode").(bool)
if additionalSans, ok := d.GetOk("additional_sans"); ok {
addSans := additionalSans.([]interface{})
resSans := make([]string, 0)
for _, san := range addSans {
resSans = append(resSans, san.(string))
}
createReq.AdditionalSANs = resSans
}
if clusterConfig, ok := d.GetOk("cluster_config"); ok {
createReq.ClusterConfiguration = clusterConfig.(string)
}
if kubeletConfig, ok := d.GetOk("kubelet_config"); ok {
createReq.KubeletConfiguration = kubeletConfig.(string)
}
if kubeProxyConfig, ok := d.GetOk("kube_proxy_config"); ok {
createReq.KubeProxyConfiguration = kubeProxyConfig.(string)
}
if joinConfig, ok := d.GetOk("join_config"); ok {
createReq.JoinConfiguration = joinConfig.(string)
}
if cloudInit, ok := d.GetOk("cloud_init"); ok {
createReq.UserData = cloudInit.(string)
}
if initConfig, ok := d.GetOk("init_config"); ok {
createReq.InitConfiguration = initConfig.(string)
}
if lbSysctlParams, ok := d.GetOk("lb_sysctl_params"); ok {
createReq.LbSysctlParams = lbSysctlParams.(string)
}
if oidcCertificate, ok := d.GetOk("oidc_cert"); ok {
createReq.OidcCertificate = oidcCertificate.(string)
}
///
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
if extNet, ok := d.GetOk("extnet_id"); ok {
createReq.ExtNetID = uint64(extNet.(int))
} else {
@@ -181,7 +229,7 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
break
}
time.Sleep(time.Second * 10)
time.Sleep(time.Second * 20)
}
return resourceK8sRead(ctx, d, m)
@@ -205,31 +253,32 @@ func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{})
case status.Created:
case status.Deleting:
case status.Deleted:
id, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := k8s.RestoreRequest{
K8SID: id,
}
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
// restoreReq := k8s.RestoreRequest{
// K8SID: id,
// }
_, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
if err != nil {
return diag.FromErr(err)
}
// _, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
// if err != nil {
// return diag.FromErr(err)
// }
enableReq := k8s.DisableEnableRequest{
K8SID: id,
}
// enableReq := k8s.DisableEnableRequest{
// K8SID: id,
// }
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
if err != nil {
return diag.FromErr(err)
}
// _, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
// if err != nil {
// return diag.FromErr(err)
// }
hasChanged = true
// hasChanged = true
case status.Destroying:
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
case status.Destroyed:
d.SetId("")
return resourceK8sCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceK8sCreate(ctx, d, m)
case status.Enabling:
case status.Enabled:
case status.Disabling:
@@ -388,7 +437,8 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
case status.Destroyed:
d.SetId("")
return resourceK8sCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceK8sCreate(ctx, d, m)
case status.Enabling:
case status.Enabled:
case status.Disabling:
@@ -463,6 +513,7 @@ func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{
}
func resourceK8sDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sDelete: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
cluster, err := utilityK8sCheckPresence(ctx, d, m)
@@ -470,12 +521,14 @@ func resourceK8sDelete(ctx context.Context, d *schema.ResourceData, m interface{
return diag.FromErr(err)
}
c := m.(*controller.ControllerCfg)
req := k8s.DeleteRequest{
K8SID: cluster.ID,
Permanently: true,
req := k8s.DeleteRequest{K8SID: cluster.ID}
if val, ok := d.GetOk("permanently"); ok {
req.Permanently = val.(bool)
}
c := m.(*controller.ControllerCfg)
_, err = c.CloudAPI().K8S().Delete(ctx, req)
if err != nil {
return diag.FromErr(err)
@@ -561,6 +614,12 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
Default: true,
Description: "Create k8s with load balancer if true.",
},
"extnet_only": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Use only selected ExtNet for infrastructure connections",
},
"extnet_id": {
Type: schema.TypeInt,
Optional: true,
@@ -568,6 +627,61 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
ForceNew: true,
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
},
///4.4.0
"cloud_init": {
Type: schema.TypeString,
Optional: true,
Description: "Meta data for working group computes, format YAML 'user_data': 1111",
},
"join_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to configure the behavior and settings for joining a node to a cluster. It includes parameters such as the cluster's control plane endpoint, token, and certificate key. insert a valid JSON string with all levels of nesting.",
},
"kube_proxy_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to configure the behavior and settings of the Kube-proxy, which is responsible for network proxying and load balancing within the cluster. It includes parameters such as proxy mode, cluster IP ranges, and other Kube-proxy specific configurations. insert a valid JSON string with all levels of nesting.",
},
"kubelet_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to configure the behavior and settings of the Kubelet, which is the primary node agent that runs on each node in the cluster. It includes parameters such as node IP address, resource allocation, pod eviction policies, and other Kubelet-specific configurations. insert a valid JSON string with all levels of nesting.",
},
"cluster_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to define global settings and configurations for the entire cluster. It includes parameters such as cluster name, DNS settings, authentication methods, and other cluster-wide configurations. insert a valid JSON string with all levels of nesting.",
},
"init_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to define settings and actions that should be performed before any other component in the cluster starts. It allows you to configure things like node registration, network setup, and other initialization tasks. insert a valid JSON string with all levels of nesting.",
},
"additional_sans": {
Type: schema.TypeList,
Optional: true,
Description: "Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"ha_mode": {
Type: schema.TypeBool,
Optional: true,
Description: "Use Highly Available schema for LB deploy",
},
"lb_sysctl_params": {
Type: schema.TypeString,
Optional: true,
Description: "Custom sysctl values for Load Balancer instance. Applied on boot.",
},
"oidc_cert": {
Type: schema.TypeString,
Optional: true,
Description: "insert ssl certificate in x509 pem format",
},
"desc": {
Type: schema.TypeString,
Optional: true,
@@ -628,6 +742,13 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "IP address of default load balancer.",
},
"permanently": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Determines if cluster should be destroyed",
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
@@ -660,6 +781,7 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
},
"vins_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "ID of default vins for this instace.",
},

View File

@@ -52,6 +52,7 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/validators"
)
func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
@@ -129,6 +130,56 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
createReq.WithLB = d.Get("with_lb").(bool)
///4.4.0
createReq.HighlyAvailable = d.Get("ha_mode").(bool)
if additionalSans, ok := d.GetOk("additional_sans"); ok {
addSans := additionalSans.([]interface{})
resSans := make([]string, 0)
for _, san := range addSans {
resSans = append(resSans, san.(string))
}
createReq.AdditionalSANs = resSans
}
if clusterConfig, ok := d.GetOk("cluster_config"); ok {
createReq.ClusterConfiguration = clusterConfig.(string)
}
if kubeletConfig, ok := d.GetOk("kubelet_config"); ok {
createReq.KubeletConfiguration = kubeletConfig.(string)
}
if kubeProxyConfig, ok := d.GetOk("kube_proxy_config"); ok {
createReq.KubeProxyConfiguration = kubeProxyConfig.(string)
}
if joinConfig, ok := d.GetOk("join_config"); ok {
createReq.JoinConfiguration = joinConfig.(string)
}
if cloudInit, ok := d.GetOk("cloud_init"); ok {
createReq.UserData = cloudInit.(string)
}
if initConfig, ok := d.GetOk("init_config"); ok {
createReq.InitConfiguration = initConfig.(string)
}
if lbSysctlParams, ok := d.GetOk("lb_sysctl_params"); ok {
createReq.LbSysctlParams = lbSysctlParams.(string)
}
if oidcCertificate, ok := d.GetOk("oidc_cert"); ok {
createReq.OidcCertificate = oidcCertificate.(string)
log.Debug(createReq.OidcCertificate)
}
///
createReq.ExtNetOnly = d.Get("extnet_only").(bool)
if extNet, ok := d.GetOk("extnet_id"); ok {
createReq.ExtNetID = uint64(extNet.(int))
} else {
@@ -165,7 +216,7 @@ func resourceK8sCPCreate(ctx context.Context, d *schema.ResourceData, m interfac
break
}
time.Sleep(time.Second * 10)
time.Sleep(time.Second * 20)
}
cluster, err := utilityK8sCheckPresence(ctx, d, m)
@@ -204,31 +255,32 @@ func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{
case status.Created:
case status.Deleting:
case status.Deleted:
id, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := k8s.RestoreRequest{
K8SID: id,
}
// id, _ := strconv.ParseUint(d.Id(), 10, 64)
// restoreReq := k8s.RestoreRequest{
// K8SID: id,
// }
_, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
if err != nil {
return diag.FromErr(err)
}
// _, err := c.CloudAPI().K8S().Restore(ctx, restoreReq)
// if err != nil {
// return diag.FromErr(err)
// }
enableReq := k8s.DisableEnableRequest{
K8SID: id,
}
// enableReq := k8s.DisableEnableRequest{
// K8SID: id,
// }
_, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
if err != nil {
return diag.FromErr(err)
}
// _, err = c.CloudAPI().K8S().Enable(ctx, enableReq)
// if err != nil {
// return diag.FromErr(err)
// }
hasChanged = true
// hasChanged = true
case status.Destroying:
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
case status.Destroyed:
d.SetId("")
return resourceK8sCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceK8sCreate(ctx, d, m)
case status.Enabling:
case status.Enabled:
case status.Disabling:
@@ -291,7 +343,7 @@ func resourceK8sCPRead(ctx context.Context, d *schema.ResourceData, m interface{
if _, ok := d.GetOk("k8s_id"); !ok {
for _, worker := range cluster.K8SGroups.Workers {
err := fmt.Errorf("Found worker-group with ID %d. Make sure to import it to decort_k8s_wg resource if you wish to manage it", worker.ID)
err := fmt.Errorf("found worker-group with ID %d. Make sure to import it to decort_k8s_wg resource if you wish to manage it", worker.ID)
warnings.Add(err)
}
}
@@ -387,7 +439,8 @@ func resourceK8sCPUpdate(ctx context.Context, d *schema.ResourceData, m interfac
return diag.Errorf("The k8s cluster is in progress with status: %s", cluster.Status)
case status.Destroyed:
d.SetId("")
return resourceK8sCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceK8sCreate(ctx, d, m)
case status.Enabling:
case status.Enabled:
case status.Disabling:
@@ -478,25 +531,29 @@ func resourceK8sCPUpdate(ctx context.Context, d *schema.ResourceData, m interfac
}
func resourceK8sCPDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sControlPlaneDelete: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
log.Debugf("resourceK8sDelete: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
cluster, err := utilityK8sCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
c := m.(*controller.ControllerCfg)
req := k8s.DeleteRequest{
K8SID: cluster.ID,
Permanently: true,
req := k8s.DeleteRequest{K8SID: cluster.ID}
if val, ok := d.GetOk("permanently"); ok {
req.Permanently = val.(bool)
}
c := m.(*controller.ControllerCfg)
_, err = c.CloudAPI().K8S().Delete(ctx, req)
if err != nil {
return diag.FromErr(err)
}
return nil
}
func resourceK8sCPSchemaMake() map[string]*schema.Schema {
@@ -538,9 +595,13 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
Description: "Node CPU count.",
},
"ram": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.All(
validation.IntAtLeast(constants.MinRamPerCompute),
validators.DivisibleBy(constants.RAMDivisibility),
),
Description: "Node RAM in MB.",
},
"disk": {
@@ -567,6 +628,74 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
Default: true,
Description: "Create k8s with load balancer if true.",
},
"extnet_only": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Use only selected ExtNet for infrastructure connections",
},
///4.4.0
"cloud_init": {
Type: schema.TypeString,
Optional: true,
Description: "Meta data for working group computes, format YAML 'user_data': 1111",
},
"join_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to configure the behavior and settings for joining a node to a cluster. It includes parameters such as the cluster's control plane endpoint, token, and certificate key. insert a valid JSON string with all levels of nesting.",
},
"kube_proxy_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to configure the behavior and settings of the Kube-proxy, which is responsible for network proxying and load balancing within the cluster. It includes parameters such as proxy mode, cluster IP ranges, and other Kube-proxy specific configurations. insert a valid JSON string with all levels of nesting.",
},
"kubelet_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to configure the behavior and settings of the Kubelet, which is the primary node agent that runs on each node in the cluster. It includes parameters such as node IP address, resource allocation, pod eviction policies, and other Kubelet-specific configurations. insert a valid JSON string with all levels of nesting.",
},
"cluster_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to define global settings and configurations for the entire cluster. It includes parameters such as cluster name, DNS settings, authentication methods, and other cluster-wide configurations. insert a valid JSON string with all levels of nesting.",
},
"init_config": {
Type: schema.TypeString,
Optional: true,
Description: "is used to define settings and actions that should be performed before any other component in the cluster starts. It allows you to configure things like node registration, network setup, and other initialization tasks. insert a valid JSON string with all levels of nesting.",
},
"additional_sans": {
Type: schema.TypeList,
Optional: true,
Description: "Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"ha_mode": {
Type: schema.TypeBool,
Optional: true,
Description: "Use Highly Available schema for LB deploy",
},
"lb_sysctl_params": {
Type: schema.TypeString,
Optional: true,
Description: "Custom sysctl values for Load Balancer instance. Applied on boot.",
},
"oidc_cert": {
Type: schema.TypeString,
Optional: true,
Description: "insert ssl certificate in x509 pem format",
},
"permanently": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Determines if cluster should be destroyed",
},
////
"extnet_id": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -34,16 +34,19 @@ package k8s
import (
"context"
"fmt"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/validators"
)
func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
@@ -92,12 +95,16 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
req.WorkerDisk = uint64(d.Get("disk").(int))
}
if cloudInit, ok := d.GetOk("cloud_init"); ok {
req.UserData = cloudInit.(string)
}
resp, err := c.CloudAPI().K8S().WorkersGroupAdd(ctx, req)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(resp, 10))
d.SetId(fmt.Sprintf("%d#%d", d.Get("k8s_id").(int), resp))
return resourceK8sWgRead(ctx, d, m)
}
@@ -110,7 +117,7 @@ func resourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interface{
return diag.FromErr(err)
}
workersComputeList := make([]compute.RecordCompute, 0, 0)
workersComputeList := make([]compute.RecordCompute, 0)
for _, info := range wg.DetailedInfo {
compute, err := utilityComputeCheckPresence(ctx, d, m, info.ID)
if err != nil {
@@ -121,7 +128,7 @@ func resourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interface{
d.Set("wg_id", wg.ID)
if strings.Contains(d.Id(), "#") {
k8sId, err := strconv.Atoi(strings.Split(d.Id(), "#")[1])
k8sId, err := strconv.Atoi(strings.Split(d.Id(), "#")[0])
if err != nil {
return diag.FromErr(err)
}
@@ -130,8 +137,7 @@ func resourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interface{
} else {
d.Set("k8s_id", d.Get("k8s_id"))
}
d.SetId(strings.Split(d.Id(), "#")[0])
d.SetId(fmt.Sprintf("%d#%d", d.Get("k8s_id").(int), wg.ID))
flattenWg(d, *wg, workersComputeList)
@@ -157,11 +163,10 @@ func resourceK8sWgUpdate(ctx context.Context, d *schema.ResourceData, m interfac
return diag.FromErr(err)
}
wgId, _ := strconv.ParseUint(d.Id(), 10, 64)
if newNum := d.Get("num").(int); uint64(newNum) > wg.Num {
req := k8s.WorkerAddRequest{
K8SID: uint64(d.Get("k8s_id").(int)),
WorkersGroupID: wgId,
WorkersGroupID: wg.ID,
Num: uint64(newNum) - wg.Num,
}
@@ -173,7 +178,7 @@ func resourceK8sWgUpdate(ctx context.Context, d *schema.ResourceData, m interfac
for i := int(wg.Num) - 1; i >= newNum; i-- {
req := k8s.DeleteWorkerFromGroupRequest{
K8SID: uint64(d.Get("k8s_id").(int)),
WorkersGroupID: wgId,
WorkersGroupID: wg.ID,
WorkerID: wg.DetailedInfo[i].ID,
}
@@ -184,6 +189,19 @@ func resourceK8sWgUpdate(ctx context.Context, d *schema.ResourceData, m interfac
}
}
if d.HasChange("cloud_init") {
req := k8s.UpdateWorkerNodesMetaDataRequest{
K8SID: uint64(d.Get("k8s_id").(int)),
WorkersGroupID: wg.ID,
UserData: d.Get("cloud_init").(string),
}
_, err := c.CloudAPI().K8S().UpdateWorkerNodesMetaData(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
return nil
}
@@ -212,16 +230,16 @@ func resourceK8sWgDelete(ctx context.Context, d *schema.ResourceData, m interfac
func resourceK8sWgSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"k8s_id": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Type: schema.TypeInt,
Required: true,
// ForceNew: true,
Description: "ID of k8s instance.",
},
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Type: schema.TypeString,
Required: true,
// ForceNew: true,
Description: "Name of the worker group.",
},
@@ -233,18 +251,22 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
},
"cpu": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Type: schema.TypeInt,
Optional: true,
// ForceNew: true,
Default: 1,
Description: "Worker node CPU count.",
},
"ram": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Default: 1024,
Type: schema.TypeInt,
Optional: true,
//ForceNew: true,
Default: 1024,
ValidateFunc: validation.All(
validation.IntAtLeast(constants.MinRamPerCompute),
validators.DivisibleBy(constants.RAMDivisibility),
),
Description: "Worker node RAM in MB.",
},
@@ -286,6 +308,11 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Optional: true,
},
"cloud_init": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: cloudInitDiffSupperss,
},
"wg_id": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -261,6 +261,19 @@ func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m
req.TechStatus = tech_status.(string)
}
if includedeleted, ok := d.GetOk("includedeleted"); ok {
req.IncludeDeleted = includedeleted.(bool)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
k8sList, err := c.CloudAPI().K8S().List(ctx, req)
if err != nil {
return nil, err
@@ -297,14 +310,18 @@ func utilityK8sListDeletedCheckPresence(ctx context.Context, d *schema.ResourceD
req.BasicServiceID = uint64(bservice_id.(int))
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if tech_status, ok := d.GetOk("tech_status"); ok {
req.TechStatus = tech_status.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
k8sList, err := c.CloudAPI().K8S().ListDeleted(ctx, req)
if err != nil {
return nil, err

View File

@@ -39,6 +39,7 @@ import (
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
@@ -70,7 +71,7 @@ func utilityDataK8sWgCheckPresence(ctx context.Context, d *schema.ResourceData,
return nil, nil, fmt.Errorf("WG with id %v in k8s cluster %v not found", wgId, k8sId)
}
workersComputeList := make([]compute.RecordCompute, 0, 0)
workersComputeList := make([]compute.RecordCompute, 0)
for _, info := range curWg.DetailedInfo {
compute, err := utilityComputeCheckPresence(ctx, d, m, info.ID)
if err != nil {
@@ -90,11 +91,11 @@ func utilityK8sWgCheckPresence(ctx context.Context, d *schema.ResourceData, m in
var err error
if strings.Contains(d.Id(), "#") {
wgId, err = strconv.Atoi(strings.Split(d.Id(), "#")[0])
wgId, err = strconv.Atoi(strings.Split(d.Id(), "#")[1])
if err != nil {
return nil, err
}
k8sId, err = strconv.Atoi(strings.Split(d.Id(), "#")[1])
k8sId, err = strconv.Atoi(strings.Split(d.Id(), "#")[0])
if err != nil {
return nil, err
}
@@ -121,7 +122,7 @@ func utilityK8sWgCheckPresence(ctx context.Context, d *schema.ResourceData, m in
}
}
return nil, fmt.Errorf("Not found wg with id: %v in k8s cluster: %v", wgId, cluster.ID)
return nil, fmt.Errorf("not found wg with id: %v in k8s cluster: %v", wgId, cluster.ID)
}
func utilityK8sWgListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (k8s.ListK8SGroups, error) {
@@ -137,3 +138,27 @@ func utilityK8sWgListCheckPresence(ctx context.Context, d *schema.ResourceData,
return cluster.K8SGroups.Workers, nil
}
func utilityK8sWgCloudInitCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) {
c := m.(*controller.ControllerCfg)
req := k8s.GetWorkerNodesMetaDataRequest{
K8SID: uint64(d.Get("k8s_id").(int)),
WorkersGroupID: uint64(d.Get("wg_id").(int)),
}
cloudInit, err := c.CloudAPI().K8S().GetWorkerNodesMetaData(ctx, req)
if err != nil {
return "", err
}
return cloudInit, nil
}
func cloudInitDiffSupperss(key, oldVal, newVal string, d *schema.ResourceData) bool {
if newVal != "" && newVal != oldVal {
log.Debugf("networkSubresIPAddreDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=FALSE", key, oldVal, newVal)
return false
}
log.Debugf("networkSubresIPAddreDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=TRUE", key, oldVal, newVal)
return true // suppress difference
}

View File

@@ -637,10 +637,10 @@ func dataSourceComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
// "custom_fields": {
// Type: schema.TypeString,
// Computed: true,
// },
"custom_fields": {
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,

View File

@@ -154,10 +154,10 @@ func itemComputeSchemaMake() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
// "custom_fields": { //NEED
// Type: schema.TypeString,
// Computed: true,
// },
"custom_fields": { //NEED
Type: schema.TypeString,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,

View File

@@ -0,0 +1,153 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package kvmvm
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceComputeListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
computeList, err := utilityDataComputeListDeletedCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
result := computeList
if d.Get("ignore_k8s").(bool) {
// matches automatically generated names like "s234-g2134-c1" etc
result = matchComputes(computeList)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenComputeList(result))
d.Set("entry_count", computeList.EntryCount)
return nil
}
func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"by_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by ID",
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Find by name",
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by AccountID",
},
"rg_name": {
Type: schema.TypeString,
Optional: true,
Description: "Find by resgroup name",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by RGID",
},
"tech_status": {
Type: schema.TypeString,
Optional: true,
Description: "Find by tech status",
},
"ip_address": {
Type: schema.TypeString,
Optional: true,
Description: "Find by IP address",
},
"extnet_name": {
Type: schema.TypeString,
Optional: true,
Description: "Find by Extnet name",
},
"extnet_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by Extnet ID",
},
"page": {
Type: schema.TypeInt,
Optional: true,
},
"size": {
Type: schema.TypeInt,
Optional: true,
},
"ignore_k8s": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If set to true, ignores any VMs associated with any k8s cluster",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: itemComputeSchemaMake(),
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceComputeListDeleted() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceComputeListDeletedRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceComputeListDeletedSchemaMake(),
}
}

View File

@@ -0,0 +1,119 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package kvmvm
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceComputePCIDeviceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
computePCIDeviceList, err := utilityComputePCIDeviceListCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenPCIDevice(computePCIDeviceList.Data))
d.Set("entry_count", computePCIDeviceList.EntryCount)
return nil
}
func dataSourceComputePCIDeviceListSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeInt,
Required: true,
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by RG id",
},
"device_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by device id",
},
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Find by name",
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: "Find by status",
},
"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.Schema{
Type: schema.TypeString,
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
}
func DataSourceComputePCIDeviceList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceComputePCIDeviceListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceComputePCIDeviceListSchemaMake(),
}
}

View File

@@ -49,6 +49,7 @@ func dataSourceComputePfwListRead(ctx context.Context, d *schema.ResourceData, m
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenPfwList(computePfwList))
d.Set("entry_count", computePfwList.EntryCount)
return nil
}
@@ -94,6 +95,10 @@ func dataSourceComputePfwListSchemaMake() map[string]*schema.Schema {
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
}

View File

@@ -0,0 +1,120 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package kvmvm
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceComputeVGPUListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
computeVGPUList, err := utilityComputeVGPUListCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenVGPU(computeVGPUList.Data))
d.Set("entry_count", computeVGPUList.EntryCount)
return nil
}
func dataSourceComputeVGPUListSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeInt,
Required: true,
},
"gpu_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by GPU id",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "Find by type",
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: "Find by status",
},
"includedeleted": {
Type: schema.TypeBool,
Optional: true,
Description: "Include deleted computes. If using field 'status', then includedeleted will be ignored",
},
"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.Schema{
Type: schema.TypeString,
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
}
func DataSourceComputeVGPUList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceComputeVGPUListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceComputeVGPUListSchemaMake(),
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
@@ -33,10 +33,10 @@ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/w
package kvmvm
import (
"context"
"encoding/json"
"sort"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
@@ -67,7 +67,7 @@ func flattenQOS(qos compute.QOS) []map[string]interface{} {
return res
}
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(interfaces))
for _, interfaceItem := range interfaces {
temp := map[string]interface{}{
"conn_id": interfaceItem.ConnID,
@@ -93,7 +93,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
return res
}
func flattenSnapSets(snapSets compute.ListSnapSets) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(snapSets))
for _, snapSet := range snapSets {
temp := map[string]interface{}{
"disks": snapSet.Disks,
@@ -106,7 +106,7 @@ func flattenSnapSets(snapSets compute.ListSnapSets) []map[string]interface{} {
return res
}
func flattenTags(tags map[string]string) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(tags))
for key, val := range tags {
temp := map[string]interface{}{
"key": key,
@@ -118,7 +118,7 @@ func flattenTags(tags map[string]string) []map[string]interface{} {
}
func flattenListRules(listRules compute.ListRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(listRules))
for _, rule := range listRules {
temp := map[string]interface{}{
"guid": rule.GUID,
@@ -133,7 +133,7 @@ func flattenListRules(listRules compute.ListRules) []map[string]interface{} {
return res
}
func flattenListACL(listAcl compute.ListACL) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(listAcl))
for _, acl := range listAcl {
temp := map[string]interface{}{
"explicit": acl.Explicit,
@@ -149,9 +149,9 @@ func flattenListACL(listAcl compute.ListACL) []map[string]interface{} {
}
func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(computes.Data))
for _, compute := range computes.Data {
// customFields, _ := json.Marshal(compute.CustomFields)
customFields, _ := json.Marshal(compute.CustomFields)
devices, _ := json.Marshal(compute.Devices)
temp := map[string]interface{}{
"acl": flattenListACL(compute.ACL),
@@ -170,44 +170,44 @@ func flattenComputeList(computes *compute.ListComputes) []map[string]interface{}
"cpus": compute.CPU,
"created_by": compute.CreatedBy,
"created_time": compute.CreatedTime,
// "custom_fields": string(customFields),
"deleted_by": compute.DeletedBy,
"deleted_time": compute.DeletedTime,
"desc": compute.Description,
"devices": string(devices),
"disks": flattenDisks(compute.Disks),
"driver": compute.Driver,
"gid": compute.GID,
"guid": compute.GUID,
"compute_id": compute.ID,
"image_id": compute.ImageID,
"interfaces": flattenInterfaces(compute.Interfaces),
"lock_status": compute.LockStatus,
"manager_id": compute.ManagerID,
"manager_type": compute.ManagerType,
"migrationjob": compute.MigrationJob,
"milestones": compute.Milestones,
"name": compute.Name,
"pinned": compute.Pinned,
"ram": compute.RAM,
"reference_id": compute.ReferenceID,
"registered": compute.Registered,
"res_name": compute.ResName,
"rg_id": compute.RGID,
"rg_name": compute.RGName,
"snap_sets": flattenSnapSets(compute.SnapSets),
"stateless_sep_id": compute.StatelessSepID,
"stateless_sep_type": compute.StatelessSepType,
"status": compute.Status,
"tags": flattenTags(compute.Tags),
"tech_status": compute.TechStatus,
"total_disk_size": compute.TotalDiskSize,
"updated_by": compute.UpdatedBy,
"updated_time": compute.UpdatedTime,
"user_managed": compute.UserManaged,
"vgpus": compute.VGPUs,
"vins_connected": compute.VINSConnected,
"virtual_image_id": compute.VirtualImageID,
"custom_fields": string(customFields),
"deleted_by": compute.DeletedBy,
"deleted_time": compute.DeletedTime,
"desc": compute.Description,
"devices": string(devices),
"disks": flattenDisks(compute.Disks),
"driver": compute.Driver,
"gid": compute.GID,
"guid": compute.GUID,
"compute_id": compute.ID,
"image_id": compute.ImageID,
"interfaces": flattenInterfaces(compute.Interfaces),
"lock_status": compute.LockStatus,
"manager_id": compute.ManagerID,
"manager_type": compute.ManagerType,
"migrationjob": compute.MigrationJob,
"milestones": compute.Milestones,
"name": compute.Name,
"pinned": compute.Pinned,
"ram": compute.RAM,
"reference_id": compute.ReferenceID,
"registered": compute.Registered,
"res_name": compute.ResName,
"rg_id": compute.RGID,
"rg_name": compute.RGName,
"snap_sets": flattenSnapSets(compute.SnapSets),
"stateless_sep_id": compute.StatelessSepID,
"stateless_sep_type": compute.StatelessSepType,
"status": compute.Status,
"tags": flattenTags(compute.Tags),
"tech_status": compute.TechStatus,
"total_disk_size": compute.TotalDiskSize,
"updated_by": compute.UpdatedBy,
"updated_time": compute.UpdatedTime,
"user_managed": compute.UserManaged,
"vgpus": compute.VGPUs,
"vins_connected": compute.VINSConnected,
"virtual_image_id": compute.VirtualImageID,
}
res = append(res, temp)
}
@@ -237,33 +237,57 @@ func flattenBootDisk(bootDisk *compute.ItemComputeDisk) []map[string]interface{}
return res
}
func flattenComputeDisksDemo(disksList compute.ListComputeDisks, extraDisks []interface{}) []map[string]interface{} {
func flattenComputeDisksDemo(ctx context.Context, d *schema.ResourceData, disksList compute.ListComputeDisks, extraDisks []interface{}, bootDiskId uint64) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(disksList))
for _, disk := range disksList {
if strings.Contains(disk.Name, "bootdisk") || findInExtraDisks(uint(disk.ID), extraDisks) { //skip main bootdisk and extraDisks
if disk.ID == bootDiskId || findInExtraDisks(uint(disk.ID), extraDisks) { //skip main bootdisk and extraDisks
continue
}
permanently, ok := ctx.Value(DiskKey(strconv.Itoa(int(disk.ID)))).(bool) // get permamently from Create or Update context
if !ok {
permanently = getPermanentlyByDiskID(d, disk.ID) // get permanently from state when Read is not after Create/Update
}
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.Description,
"image_id": disk.ImageID,
"size": disk.SizeMax,
"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.Description,
"image_id": disk.ImageID,
"size": disk.SizeMax,
"permanently": permanently,
}
res = append(res, temp)
}
sort.Slice(res, func(i, j int) bool {
return res[i]["disk_id"].(uint64) < res[j]["disk_id"].(uint64)
})
return res
}
// getPermanentlyByDiskID gets permanently value of specific disk (by diskId) from disks current state
func getPermanentlyByDiskID(d *schema.ResourceData, diskId uint64) bool {
disks := d.Get("disks").([]interface{})
for _, diskItem := range disks {
disk := diskItem.(map[string]interface{})
if uint64(disk["disk_id"].(int)) == diskId {
return disk["permanently"].(bool)
}
}
log.Infof("getPermanentlyByDiskID: disk with id %d not found in state", diskId)
return false
}
func flattenNetwork(interfaces compute.ListInterfaces) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(interfaces))
@@ -281,14 +305,14 @@ func flattenNetwork(interfaces compute.ListInterfaces) []map[string]interface{}
func findBootDisk(disks compute.ListComputeDisks) *compute.ItemComputeDisk {
for _, disk := range disks {
if strings.Contains(disk.Name, "bootdisk") {
if disk.Type == "B" {
return &disk
}
}
return nil
}
func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) error {
func flattenCompute(ctx context.Context, d *schema.ResourceData, computeRec compute.RecordCompute) error {
// This function expects that compFacts string contains response from API compute/get,
// i.e. detailed information about compute instance.
//
@@ -301,7 +325,7 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) er
//check extraDisks, ipa_type, is,
d.SetId(strconv.FormatUint(computeRec.ID, 10))
d.Set("acl", flattenACL(computeRec.ACL))
// d.Set("acl", flattenACL(computeRec.ACL))
d.Set("account_id", computeRec.AccountID)
d.Set("account_name", computeRec.AccountName)
d.Set("affinity_weight", computeRec.AffinityWeight)
@@ -317,11 +341,12 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) er
d.Set("computeci_id", computeRec.ComputeCIID)
d.Set("created_by", computeRec.CreatedBy)
d.Set("created_time", computeRec.CreatedTime)
// d.Set("custom_fields", flattenCustomFields(computeRec.CustomFields))
d.Set("deleted_by", computeRec.DeletedBy)
d.Set("deleted_time", computeRec.DeletedTime)
d.Set("description", computeRec.Description)
d.Set("devices", string(devices))
err := d.Set("disks", flattenComputeDisksDemo(computeRec.Disks, d.Get("extra_disks").(*schema.Set).List()))
err := d.Set("disks", flattenComputeDisksDemo(ctx, d, computeRec.Disks, d.Get("extra_disks").(*schema.Set).List(), bootDisk.ID))
if err != nil {
return err
}
@@ -397,7 +422,7 @@ func flattenACL(acl compute.RecordACL) []map[string]interface{} {
}
func flattenAffinityRules(affinityRules compute.ListRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(affinityRules))
for _, affinityRule := range affinityRules {
temp := map[string]interface{}{
"guid": affinityRule.GUID,
@@ -436,7 +461,7 @@ func flattenIotune(iotune compute.IOTune) []map[string]interface{} {
}
func flattenSnapshots(snapshots compute.SnapshotExtendList) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(snapshots))
for _, snapshot := range snapshots {
temp := map[string]interface{}{
"guid": snapshot.GUID,
@@ -454,7 +479,7 @@ func flattenSnapshots(snapshots compute.SnapshotExtendList) []map[string]interfa
}
func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(disks))
for _, disk := range disks {
acl, _ := json.Marshal(disk.ACL)
temp := map[string]interface{}{
@@ -510,7 +535,7 @@ func flattenCustomFields(customFields map[string]interface{}) string {
}
func flattenOsUsers(osUsers compute.ListOSUser) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(osUsers))
for _, user := range osUsers {
temp := map[string]interface{}{
"guid": user.GUID,
@@ -542,7 +567,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
d.Set("cpus", computeRec.CPU)
d.Set("created_by", computeRec.CreatedBy)
d.Set("created_time", computeRec.CreatedTime)
// d.Set("custom_fields", flattenCustomFields(computeRec.CustomFields))
d.Set("custom_fields", flattenCustomFields(computeRec.CustomFields))
d.Set("deleted_by", computeRec.DeletedBy)
d.Set("deleted_time", computeRec.DeletedTime)
d.Set("desc", computeRec.Description)
@@ -589,7 +614,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
}
func flattenComputeAudits(computeAudits compute.ListAudits) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(computeAudits))
for _, computeAudit := range computeAudits {
temp := map[string]interface{}{
"call": computeAudit.Call,
@@ -604,7 +629,7 @@ func flattenComputeAudits(computeAudits compute.ListAudits) []map[string]interfa
}
func flattenPfwList(computePfws *compute.ListPFWs) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(computePfws.Data))
for _, computePfw := range computePfws.Data {
temp := map[string]interface{}{
"pfw_id": computePfw.ID,
@@ -627,7 +652,7 @@ func flattenUserList(d *schema.ResourceData, userList *compute.ListUsers) {
}
func flattenComputeGetAudits(computeAudits compute.ListShortAudits) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(computeAudits))
for _, computeAudit := range computeAudits {
temp := map[string]interface{}{
"epoch": computeAudit.Epoch,
@@ -639,7 +664,7 @@ func flattenComputeGetAudits(computeAudits compute.ListShortAudits) []map[string
}
func flattenSnapshotUsage(computeSnapshotUsages compute.ListUsageSnapshots) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(computeSnapshotUsages))
for _, computeUsage := range computeSnapshotUsages {
temp := map[string]interface{}{
"count": computeUsage.Count,
@@ -651,3 +676,55 @@ func flattenSnapshotUsage(computeSnapshotUsages compute.ListUsageSnapshots) []ma
}
return res
}
func flattenSnapshotList(computeSnapshotUsages *compute.ListSnapShots) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(computeSnapshotUsages.Data))
for _, computeUsage := range computeSnapshotUsages.Data {
temp := map[string]interface{}{
"disks": computeUsage.Disks,
"guid": computeUsage.GUID,
"label": computeUsage.Label,
"timestamp": computeUsage.Timestamp,
}
res = append(res, temp)
}
return res
}
func flattenVGPU(m []interface{}) []string {
output := []string{}
for _, item := range m {
switch d := item.(type) {
case string:
output = append(output, d)
case int:
output = append(output, strconv.Itoa(d))
case int64:
output = append(output, strconv.FormatInt(d, 10))
case float64:
output = append(output, strconv.FormatInt(int64(d), 10))
default:
output = append(output, "")
}
}
return output
}
func flattenPCIDevice(m []interface{}) []string {
output := []string{}
for _, item := range m {
switch d := item.(type) {
case string:
output = append(output, d)
case int:
output = append(output, strconv.Itoa(d))
case int64:
output = append(output, strconv.FormatInt(d, 10))
case float64:
output = append(output, strconv.FormatInt(int64(d), 10))
default:
output = append(output, "")
}
}
return output
}

File diff suppressed because it is too large Load Diff

View File

@@ -63,14 +63,16 @@ func existRgID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
func existImageId(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
c := m.(*controller.ControllerCfg)
imageId := uint64(d.Get("image_id").(int))
req := image.ListRequest{}
req := image.ListRequest{
ByID: imageId,
}
imageList, err := c.CloudAPI().Image().List(ctx, req)
if err != nil {
return false, err
}
return len(imageList.FilterByID(imageId).Data) != 0, nil
return len(imageList.Data) != 0, nil
}
func existVinsIdInList(vinsId uint64, vinsList *vins.ListVINS) bool {

View File

@@ -40,6 +40,7 @@ import (
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmppc"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmx86"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
@@ -47,12 +48,16 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/validators"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
// DiskKey is custom string type to set up context Key for Disk ID
type DiskKey string
func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceComputeCreate: called for Compute name %q, RG ID %d", d.Get("name").(string), d.Get("rg_id").(int))
c := m.(*controller.ControllerCfg)
@@ -129,9 +134,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
createReqX86.IS = IS.(string)
}
if !d.Get("with_default_vins").(bool) {
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
}
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
if networks, ok := d.GetOk("network"); ok {
if networks.(*schema.Set).Len() > 0 {
@@ -192,6 +195,16 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
createReqX86.Driver = driver
if custom_fields, ok := d.GetOk("custom_fields"); ok {
val := custom_fields.(string)
val = strings.ReplaceAll(val, "\\", "")
val = strings.ReplaceAll(val, "\n", "")
val = strings.ReplaceAll(val, "\t", "")
val = strings.TrimSpace(val)
createReqX86.CustomFields = val
}
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
apiResp, err := c.CloudAPI().KVMX86().Create(ctx, createReqX86)
if err != nil {
@@ -226,7 +239,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
argVal, ok = d.GetOk("extra_disks")
if ok && argVal.(*schema.Set).Len() > 0 {
log.Debugf("resourceComputeCreate: calling utilityComputeExtraDisksConfigure to attach %d extra disk(s)", argVal.(*schema.Set).Len())
err = utilityComputeExtraDisksConfigure(ctx, d, m, false)
err = utilityComputeExtraDisksConfigure(ctx, d, m, false, nil)
if err != nil {
log.Errorf("resourceComputeCreate: error when attaching extra disk(s) to a new Compute ID %d: %v", computeId, err)
cleanup = true
@@ -247,13 +260,13 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
if enabled, ok := d.GetOk("enabled"); ok {
if enabled.(bool) {
req := compute.EnableRequest{ComputeID: computeId}
log.Debugf("resourceComputeCreate: enable=%t Compute ID %d after completing its resource configuration", computeId, enabled)
log.Debugf("resourceComputeCreate: enable=%t Compute ID %d after completing its resource configuration", enabled, computeId)
if _, err := c.CloudAPI().Compute().Enable(ctx, req); err != nil {
warnings.Add(err)
}
} else {
req := compute.DisableRequest{ComputeID: computeId}
log.Debugf("resourceComputeCreate: enable=%t Compute ID %d after completing its resource configuration", computeId, enabled)
log.Debugf("resourceComputeCreate: enable=%t Compute ID %d after completing its resource configuration", enabled, computeId)
if _, err := c.CloudAPI().Compute().Disable(ctx, req); err != nil {
warnings.Add(err)
}
@@ -299,11 +312,13 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
req.ImageID = uint64(diskConv["image_id"].(int))
}
_, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
diskId, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
if err != nil {
cleanup = true
return diag.FromErr(err)
}
ctx = context.WithValue(ctx, DiskKey(strconv.Itoa(int(diskId))), diskConv["permanently"].(bool))
}
}
}
@@ -486,7 +501,7 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
log.Debugf("resourceComputeRead: called for Compute name %s, RG ID %d",
d.Get("name").(string), d.Get("rg_id").(int))
c := m.(*controller.ControllerCfg)
// c := m.(*controller.ControllerCfg)
computeRec, err := utilityComputeCheckPresence(ctx, d, m)
if err != nil {
@@ -497,23 +512,24 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
switch computeRec.Status {
case status.Deleted:
restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID}
enableReq := compute.EnableRequest{ComputeID: computeRec.ID}
// restoreReq := compute.RestoreRequest{ComputeID: computeRec.ID}
// enableReq := compute.EnableRequest{ComputeID: computeRec.ID}
_, err := c.CloudAPI().Compute().Restore(ctx, restoreReq)
if err != nil {
return diag.FromErr(err)
}
// _, err := c.CloudAPI().Compute().Restore(ctx, restoreReq)
// if err != nil {
// return diag.FromErr(err)
// }
_, err = c.CloudAPI().Compute().Enable(ctx, enableReq)
if err != nil {
return diag.FromErr(err)
}
// _, err = c.CloudAPI().Compute().Enable(ctx, enableReq)
// if err != nil {
// return diag.FromErr(err)
// }
hasChanged = true
// hasChanged = true
case status.Destroyed:
d.SetId("")
return resourceComputeCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceComputeCreate(ctx, d, m)
case status.Disabled:
log.Debugf("The compute is in status: %s, troubles may occur with update. Please, enable compute first.", computeRec.Status)
case status.Redeploying:
@@ -532,7 +548,7 @@ func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interfac
}
}
if err = flattenCompute(d, computeRec); err != nil {
if err = flattenCompute(ctx, d, computeRec); err != nil {
return diag.FromErr(err)
}
@@ -574,11 +590,11 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
switch networkData["net_type"].(string) {
case "VINS":
if vinsId, ok := existVinsId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't create compute because vins ID %d is not allowed or does not exist", vinsId)
return diag.Errorf("resourceComputeCreate: can't update compute because vins ID %d is not allowed or does not exist", vinsId)
}
case "EXTNET":
if extNetId, ok := existExtNetId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't create compute because extnet ID %d is not allowed or does not exist", extNetId)
return diag.Errorf("resourceComputeCreate: can't update compute because extnet ID %d is not allowed or does not exist", extNetId)
}
default:
@@ -632,7 +648,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
case status.Destroyed:
d.SetId("")
return resourceComputeCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// 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.", computeRec.Status)
case status.Redeploying:
@@ -706,7 +723,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
if d.HasChange("extra_disks") {
err := utilityComputeExtraDisksConfigure(ctx, d, m, true) // pass do_delta = true to apply changes, if any
err := utilityComputeExtraDisksConfigure(ctx, d, m, true, computeRec.Disks) // pass do_delta = true to apply changes, if any
if err != nil {
return diag.FromErr(err)
}
@@ -725,7 +742,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
Name: d.Get("name").(string),
}
if desc, ok := d.GetOk("desc"); ok {
if desc, ok := d.GetOk("description"); ok {
req.Description = desc.(string)
}
@@ -737,25 +754,52 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if d.HasChange("disks") {
deletedDisks := make([]interface{}, 0)
addedDisks := make([]interface{}, 0)
updatedDisks := make([]interface{}, 0)
resizedDisks := make([]interface{}, 0)
renamedDisks := make([]interface{}, 0)
// save permanently in disks based on disk_id to context
for _, diskItemInterface := range d.Get("disks").([]interface{}) {
diskItem := diskItemInterface.(map[string]interface{})
diskId := diskItem["disk_id"].(int)
permanently := diskItem["permanently"].(bool)
ctx = context.WithValue(ctx, DiskKey(strconv.Itoa(diskId)), permanently)
}
oldDisks, newDisks := d.GetChange("disks")
oldConv := oldDisks.([]interface{})
newConv := newDisks.([]interface{})
for _, el := range oldConv {
if !isContainsDisk(newConv, el) {
deletedDisks = append(deletedDisks, el)
if !isContainsDisk(newConv, el) && !isRenameDisk(newConv, el) && !isResizeDisk(newConv, el) {
flag := false
extraDisks := d.Get("extra_disks").(*schema.Set).List()
delDisk := el.(map[string]interface{})
delDiskId := delDisk["disk_id"].(int)
for _, extraDiskId := range extraDisks {
if extraDiskId.(int) == delDiskId {
flag = true
break
}
}
if !flag {
deletedDisks = append(deletedDisks, el)
} else {
log.Debugf("disk %d will not be deleted because it is present in the extra_disks block", delDiskId)
}
}
}
for _, el := range newConv {
if !isContainsDisk(oldConv, el) {
addedDisks = append(addedDisks, el)
} else {
if isChangeDisk(oldConv, el) {
updatedDisks = append(updatedDisks, el)
}
}
if isResizeDisk(oldConv, el) {
resizedDisks = append(resizedDisks, el)
}
if isRenameDisk(oldConv, el) {
renamedDisks = append(renamedDisks, el)
}
}
@@ -772,7 +816,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
for _, disk := range deletedDisks {
diskConv := disk.(map[string]interface{})
if strings.Contains(diskConv["disk_name"].(string), "bootdisk") {
if diskConv["disk_type"].(string) == "B" {
continue
}
@@ -782,6 +826,8 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
Permanently: diskConv["permanently"].(bool),
}
log.Debugf("trying to delete disk %d", req.DiskID)
_, err := c.CloudAPI().Compute().DiskDel(ctx, req)
if err != nil {
return diag.FromErr(err)
@@ -800,7 +846,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if len(addedDisks) > 0 {
for _, disk := range addedDisks {
diskConv := disk.(map[string]interface{})
if strings.Contains(diskConv["disk_name"].(string), "bootdisk") {
if diskConv["disk_type"].(string) == "B" {
continue
}
req := compute.DiskAddRequest{
@@ -822,17 +868,19 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
if diskConv["image_id"].(int) != 0 {
req.ImageID = uint64(diskConv["image_id"].(int))
}
_, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
diskId, err := c.CloudAPI().Compute().DiskAdd(ctx, req)
if err != nil {
return diag.FromErr(err)
}
ctx = context.WithValue(ctx, DiskKey(strconv.Itoa(int(diskId))), diskConv["permanently"].(bool))
}
}
if len(updatedDisks) > 0 {
for _, disk := range updatedDisks {
if len(resizedDisks) > 0 {
for _, disk := range resizedDisks {
diskConv := disk.(map[string]interface{})
if strings.Contains(diskConv["disk_name"].(string), "bootdisk") {
if diskConv["disk_type"].(string) == "B" {
continue
}
req := compute.DiskResizeRequest{
@@ -847,6 +895,22 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
}
if len(renamedDisks) > 0 {
for _, disk := range renamedDisks {
diskConv := disk.(map[string]interface{})
req := disks.RenameRequest{
DiskID: uint64(diskConv["disk_id"].(int)),
Name: diskConv["disk_name"].(string),
}
_, err := c.CloudAPI().Disks().Rename(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
}
}
if d.HasChange("started") {
@@ -1335,13 +1399,42 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if d.HasChange("custom_fields") {
val := d.Get("custom_fields").(string)
val = strings.ReplaceAll(val, "\\", "")
val = strings.ReplaceAll(val, "\n", "")
val = strings.ReplaceAll(val, "\t", "")
val = strings.TrimSpace(val)
if len(val) > 0 {
req := compute.SetCustomFieldsRequest{
ComputeID: computeRec.ID,
CustomFields: val,
}
_, err := c.CloudAPI().Compute().SetCustomFields(ctx, req)
if err != nil {
return diag.FromErr(err)
}
} else {
req := compute.DeleteCustomFieldsRequest{
ComputeID: computeRec.ID,
}
_, err := c.CloudAPI().Compute().DeleteCustomFields(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
}
// we may reuse dataSourceComputeRead here as we maintain similarity
// between Compute resource and Compute data source schemas
defer resourceComputeRead(ctx, d, m)
return warnings.Get()
}
func isChangeDisk(els []interface{}, el interface{}) bool {
func isResizeDisk(els []interface{}, el interface{}) bool {
for _, elOld := range els {
elOldConv := elOld.(map[string]interface{})
elConv := el.(map[string]interface{})
@@ -1353,11 +1446,23 @@ func isChangeDisk(els []interface{}, el interface{}) bool {
return false
}
func isRenameDisk(els []interface{}, el interface{}) bool {
for _, elOld := range els {
elOldConv := elOld.(map[string]interface{})
elConv := el.(map[string]interface{})
if elOldConv["disk_id"].(int) == elConv["disk_id"].(int) &&
elOldConv["disk_name"].(string) != elConv["disk_name"].(string) {
return true
}
}
return false
}
func isContainsDisk(els []interface{}, el interface{}) bool {
for _, elOld := range els {
elOldConv := elOld.(map[string]interface{})
elConv := el.(map[string]interface{})
if elOldConv["disk_name"].(string) == elConv["disk_name"].(string) {
if elOldConv["disk_id"].(int) == elConv["disk_id"].(int) {
return true
}
}
@@ -1447,8 +1552,8 @@ func disksSubresourceSchemaMake() map[string]*schema.Schema {
},
"permanently": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
Default: false,
Description: "Disk deletion status",
},
"disk_id": {
@@ -1556,16 +1661,16 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Description: "Name of this compute. Compute names are case sensitive and must be unique in the resource group.",
},
"rg_id": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Type: schema.TypeInt,
Required: true,
// ForceNew: true,
ValidateFunc: validation.IntAtLeast(1),
Description: "ID of the resource group where this compute should be deployed.",
},
"driver": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Type: schema.TypeString,
Required: true,
// ForceNew: true,
StateFunc: statefuncs.StateFuncToUpper,
ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86", "KVM_PPC"}, false), // observe case while validating
Description: "Hardware architecture of this compute instance.",
@@ -1577,10 +1682,13 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Description: "Number of CPUs to allocate to this compute instance.",
},
"ram": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(constants.MinRamPerCompute),
Description: "Amount of RAM in MB to allocate to this compute instance.",
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.All(
validation.IntAtLeast(constants.MinRamPerCompute),
validators.DivisibleBy(constants.RAMDivisibility),
),
Description: "Amount of RAM in MB to allocate to this compute instance.",
},
"image_id": {
Type: schema.TypeInt,
@@ -1629,7 +1737,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
},
"value": {
Type: schema.TypeString,
Required: true,
Optional: true,
Description: "value that must match the key to be taken into account when analyzing this rule",
},
},
@@ -1665,7 +1773,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
},
"value": {
Type: schema.TypeString,
Required: true,
Optional: true,
Description: "value that must match the key to be taken into account when analyzing this rule",
},
},
@@ -1678,18 +1786,17 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
Schema: disksSubresourceSchemaMake(),
},
},
"custom_fields": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"stateless": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Compute will be stateless (SVA_KVM_X86) if set to True",
},
"with_default_vins": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Create compute with default resgroup ViNS (true) or without any interfaces (false). This parameter is ignored if network block is specified",
},
"boot_disk": {
Type: schema.TypeSet,
Computed: true,
@@ -1698,23 +1805,24 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
},
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
Type: schema.TypeInt,
Optional: true,
Computed: true,
// ForceNew: true,
Description: "ID of SEP to create bootDisk on. Uses image's sepId if not set.",
},
"pool": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
// ForceNew: true,
Description: "Pool to use if sepId is set, can be also empty if needed to be chosen by system.",
},
"extra_disks": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
MaxItems: constants.MaxExtraDisksPerCompute,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -2075,7 +2183,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
func ResourceCompute() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
SchemaVersion: 3,
CreateContext: resourceComputeCreate,
ReadContext: resourceComputeRead,
@@ -2095,5 +2203,17 @@ func ResourceCompute() *schema.Resource {
},
Schema: ResourceComputeSchemaMake(),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceComputeResourceV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourceCompueteStateUpgradeV1,
Version: 1,
},
{
Type: resourceComputeResourceV2().CoreConfigSchema().ImpliedType(),
Upgrade: resourceComputeStateUpgradeV2,
Version: 2,
},
},
}
}

View File

@@ -0,0 +1,41 @@
package kvmvm
import (
"context"
"fmt"
"strings"
log "github.com/sirupsen/logrus"
)
func resourceCompueteStateUpgradeV1(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
log.Debug("resourceCompueteStateUpgradeV1: upgrading state")
customFields, ok := rawState["custom_fields"]
if !ok || customFields == nil {
rawState["custom_fields"] = "{}"
return rawState, nil
}
b := &strings.Builder{}
b.WriteString("{")
oldCustomFieldsSlice := customFields.([]interface{})
for i := range oldCustomFieldsSlice {
oldCustomFields := oldCustomFieldsSlice[i].(map[string]interface{})
b.WriteString(fmt.Sprintf(`"%s":"%s"`, oldCustomFields["key"], oldCustomFields["val"]))
if i < len(oldCustomFieldsSlice)-1 {
b.WriteString(",")
}
}
b.WriteString("}")
rawState["custom_fields"] = b.String()
return rawState, nil
}
func resourceComputeStateUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
log.Debug("resourceComputeStateUpgradeV2: upgrading state")
delete(rawState, "with_default_vins")
return rawState, nil
}

View File

@@ -54,7 +54,7 @@ func matchComputes(computeList *compute.ListComputes) *compute.ListComputes {
return &result
}
func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceData, m interface{}, do_delta bool) error {
func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceData, m interface{}, do_delta bool, disks compute.ListComputeDisks) error {
c := m.(*controller.ControllerCfg)
log.Debugf("utilityComputeExtraDisksConfigure: called for Compute ID %s with do_delta = %t", d.Id(), do_delta)
@@ -138,6 +138,22 @@ func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceDa
DiskID: uint64(diskId.(int)),
}
log.Debug("before attach HERE0")
flag := false
// check if there is an extra disk in the disks from the platform, so as not to attach it if it is already attached
for _, elem := range disks {
if elem.ID == uint64(diskId.(int)) {
flag = true
break
}
}
if flag {
continue
}
_, err := c.CloudAPI().Compute().DiskAttach(ctx, req)
if err != nil {
log.Errorf("utilityComputeExtraDisksConfigure: failed to attach disk ID %d to Compute ID %s: %s", diskId.(int), d.Id(), err)
@@ -165,6 +181,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
Force: true,
}
log.Debugf("utilityComputeNetworksConfigure: stopping compute %d", computeID)
_, err := c.CloudAPI().Compute().Stop(ctx, req)
if err != nil {
return err
@@ -255,6 +272,7 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
startReq := compute.StartRequest{ComputeID: computeID}
log.Debugf("utilityComputeNetworksConfigure: starting compute %d", computeID)
_, err = c.CloudAPI().Compute().Start(ctx, startReq)
if err != nil {
apiErrCount++
@@ -279,7 +297,7 @@ func utilityComputeCheckPresence(ctx context.Context, d *schema.ResourceData, m
computeRecord, err := c.CloudAPI().Compute().Get(ctx, req)
if err != nil {
return *computeRecord, err
return compute.RecordCompute{}, err
}
return *computeRecord, nil

View File

@@ -0,0 +1,87 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package kvmvm
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityDataComputeListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListComputes, error) {
c := m.(*controller.ControllerCfg)
req := compute.ListDeletedRequest{}
if byId, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(byId.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if rgName, ok := d.GetOk("rg_name"); ok {
req.RGName = rgName.(string)
}
if rgId, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rgId.(int))
}
if techStatus, ok := d.GetOk("tech_status"); ok {
req.TechStatus = techStatus.(string)
}
if ipAddress, ok := d.GetOk("ip_address"); ok {
req.IPAddress = ipAddress.(string)
}
if extNetName, ok := d.GetOk("extnet_name"); ok {
req.ExtNetName = extNetName.(string)
}
if extnetId, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extnetId.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
listComputes, err := c.CloudAPI().Compute().ListDeleted(ctx, req)
if err != nil {
return nil, err
}
return listComputes, nil
}

View File

@@ -0,0 +1,74 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package kvmvm
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityComputePCIDeviceListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListPCIDevices, error) {
c := m.(*controller.ControllerCfg)
req := compute.ListPCIDeviceRequest{
ComputeID: uint64(d.Get("compute_id").(int)),
}
if rgId, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rgId.(int))
}
if devId, ok := d.GetOk("device_id"); ok {
req.DevID = uint64(devId.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
listPCIDevice, err := c.CloudAPI().Compute().ListPCIDevice(ctx, req)
if err != nil {
return nil, err
}
return listPCIDevice, err
}

View File

@@ -0,0 +1,74 @@
/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package kvmvm
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityComputeVGPUListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListVGPUs, error) {
c := m.(*controller.ControllerCfg)
req := compute.ListVGPURequest{
ComputeID: uint64(d.Get("compute_id").(int)),
}
if GPUID, ok := d.GetOk("gpu_id"); ok {
req.GPUID = uint64(GPUID.(int))
}
if typeVGPU, ok := d.GetOk("type"); ok {
req.Type = typeVGPU.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if includeDeleted, ok := d.GetOk("includedeleted"); ok {
req.IncludeDeleted = includeDeleted.(bool)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
listVGPU, err := c.CloudAPI().Compute().ListVGPU(ctx, req)
if err != nil {
return nil, err
}
return listVGPU, err
}

View File

@@ -91,6 +91,7 @@ func flattenResourceLBBackend(d *schema.ResourceData, b *lb.ItemBackend, lbId in
func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
d.Set("backends", flattenLBBackends(lb.Backends))
d.Set("created_by", lb.CreatedBy)
d.Set("created_time", lb.CreatedTime)
@@ -99,6 +100,7 @@ func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("desc", lb.Description)
d.Set("dp_api_user", lb.DPAPIUser)
d.Set("extnet_id", lb.ExtNetID)
d.Set("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
@@ -106,6 +108,7 @@ func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
d.Set("primary_node", flattenNode(lb.PrimaryNode))
d.Set("rg_id", lb.RGID)
d.Set("rg_name", lb.RGName)
@@ -120,6 +123,7 @@ func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) {
func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
d.Set("backends", flattenLBBackends(lb.Backends))
d.Set("created_by", lb.CreatedBy)
d.Set("created_time", lb.CreatedTime)
@@ -128,12 +132,14 @@ func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("desc", lb.Description)
d.Set("dp_api_user", lb.DPAPIUser)
d.Set("extnet_id", lb.ExtNetID)
d.Set("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
d.Set("primary_node", flattenNode(lb.PrimaryNode))
d.Set("rg_id", lb.RGID)
d.Set("rg_name", lb.RGName)
@@ -246,6 +252,7 @@ func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
for _, lb := range lbl.Data {
temp := map[string]interface{}{
"ha_mode": lb.HAMode,
"backend_haip": lb.BackendHAIP,
"backends": flattenLBBackends(lb.Backends),
"created_by": lb.CreatedBy,
"created_time": lb.CreatedTime,
@@ -255,6 +262,7 @@ func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
"dp_api_user": lb.DPAPIUser,
"dp_api_password": lb.DPAPIPassword,
"extnet_id": lb.ExtNetID,
"frontend_haip": lb.FrontendHAIP,
"frontends": flattenFrontends(lb.Frontends),
"gid": lb.GID,
"guid": lb.GUID,

View File

@@ -181,5 +181,6 @@ func dsLBItemSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
}
delete(sch, "part_k8s")
return sch
}

View File

@@ -47,12 +47,12 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
sch["extnet_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
Optional: true,
}
sch["vins_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
Optional: true,
}
sch["start"] = &schema.Schema{
Type: schema.TypeBool,
@@ -83,7 +83,18 @@ func lbResourceSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Optional: true,
}
///4.4.0
sch["ha_mode"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["lb_sysctl_params"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
}
///
sch["permanently"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,

View File

@@ -40,6 +40,10 @@ func createLBSchema() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"backend_haip": {
Type: schema.TypeString,
Computed: true,
},
"backends": {
Type: schema.TypeList,
Computed: true,
@@ -204,6 +208,10 @@ func createLBSchema() map[string]*schema.Schema {
Type: schema.TypeInt,
Computed: true,
},
"frontend_haip": {
Type: schema.TypeString,
Computed: true,
},
"frontends": {
Type: schema.TypeList,
Computed: true,
@@ -272,6 +280,10 @@ func createLBSchema() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"part_k8s": {
Type: schema.TypeBool,
Computed: true,
},
"primary_node": {
Type: schema.TypeList,
Computed: true,

View File

@@ -43,6 +43,11 @@ func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (
c := m.(*controller.ControllerCfg)
extNetID := uint64(d.Get("extnet_id").(int))
// this code is needed in order to be able to pass 0
if extNetID == 0 {
return true, nil
}
req := extnet.ListRequest{}
extNetList, err := c.CloudAPI().ExtNet().List(ctx, req)
@@ -57,6 +62,11 @@ func existViNSID(ctx context.Context, d *schema.ResourceData, m interface{}) (bo
c := m.(*controller.ControllerCfg)
vinsID := uint64(d.Get("vins_id").(int))
// this code is needed in order to be able to pass 0
if vinsID == 0 {
return true, nil
}
req := vins.ListRequest{}
vinsList, err := c.CloudAPI().VINS().List(ctx, req)

View File

@@ -88,15 +88,19 @@ func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}
req.Description = desc.(string)
}
if haMode, ok := d.GetOk("ha_mode"); ok {
req.HighlyAvailable = haMode.(bool)
}
lbId, err := c.CloudAPI().LB().Create(ctx, req)
if err != nil {
return diag.FromErr(err)
}
lbIdParsed, _ := strconv.ParseInt(lbId, 10, 64)
lbIdParsed := strconv.Itoa(int(lbId))
d.SetId(lbId)
d.Set("lb_id", lbIdParsed)
d.SetId(lbIdParsed)
d.Set("lb_id", lbId)
_, err = utilityLBCheckPresence(ctx, d, m)
if err != nil {
@@ -128,7 +132,7 @@ func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBRead")
c := m.(*controller.ControllerCfg)
// c := m.(*controller.ControllerCfg)
lbRec, err := utilityLBCheckPresence(ctx, d, m)
if lbRec == nil {
@@ -145,25 +149,26 @@ func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{})
case status.Created:
case status.Deleting:
case status.Deleted:
lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
restoreReq := lb.RestoreRequest{LBID: lbId}
enableReq := lb.DisableEnableRequest{LBID: lbId}
// lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
// restoreReq := lb.RestoreRequest{LBID: lbId}
// enableReq := lb.DisableEnableRequest{LBID: lbId}
_, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
if err != nil {
return diag.FromErr(err)
}
_, err = c.CloudAPI().LB().Enable(ctx, enableReq)
if err != nil {
return diag.FromErr(err)
}
// _, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
// if err != nil {
// return diag.FromErr(err)
// }
// _, err = c.CloudAPI().LB().Enable(ctx, enableReq)
// if err != nil {
// return diag.FromErr(err)
// }
hasChanged = true
// hasChanged = true
case status.Destroying:
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
case status.Destroyed:
d.SetId("")
return resourceLBCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceLBCreate(ctx, d, m)
case status.Enabled:
case status.Enabling:
case status.Disabling:
@@ -276,7 +281,8 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
case status.Destroyed:
d.SetId("")
return resourceLBCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceLBCreate(ctx, d, m)
case status.Enabled:
case status.Enabling:
case status.Disabling:
@@ -286,13 +292,26 @@ func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}
}
if hasChanged {
lbRec, err = utilityLBCheckPresence(ctx, d, m)
_, err = utilityLBCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
}
if d.HasChange("ha_mode") {
hamode := d.Get("ha_mode").(bool)
if hamode {
req:= lb.HighlyAvailableRequest {
LBID: uint64(d.Get("lb_id").(int)),
}
_, err := c.CloudAPI().LB().HighlyAvailable(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
}
if d.HasChange("enable") {
enable := d.Get("enable").(bool)
req := lb.DisableEnableRequest{

View File

@@ -34,6 +34,7 @@ package pfw
import (
"context"
"fmt"
"strconv"
"strings"
@@ -65,5 +66,5 @@ func utilityPfwCheckPresence(ctx context.Context, d *schema.ResourceData, m inte
}
}
return nil, nil
return nil, fmt.Errorf("PFW not found")
}

View File

@@ -49,6 +49,7 @@ func dataSourceRgAffinityGroupsListRead(ctx context.Context, d *schema.ResourceD
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
d.Set("affinity_groups", flattenRgListGroups(list))
d.Set("entry_count", list.EntryCount)
return nil
}
@@ -59,6 +60,16 @@ func dataSourceRgAffinityGroupsListSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "ID of the RG",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"affinity_groups": {
Type: schema.TypeList,
Computed: true,
@@ -71,13 +82,26 @@ func dataSourceRgAffinityGroupsListSchemaMake() map[string]*schema.Schema {
"ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeInt,
Computed: true,
},
"node_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res

View File

@@ -0,0 +1,101 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package rg
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceRGResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
RGResourceConsumptionRec, err := utilityRGResourceConsumptionGetCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
flattenRGResourceConsumption(d, RGResourceConsumptionRec)
return nil
}
func dataSourceRGResourceConsumptionGetSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"rg_id": {
Type: schema.TypeInt,
Required: true,
},
"consumed": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceRGResourceSchemaMake(),
},
},
"reserved": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceRGResourceSchemaMake(),
},
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceResourceLimitsSchemaMake(),
},
},
}
return res
}
func DataSourceRGResourceConsumptionGet() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRGResourceConsumptionGetRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRGResourceConsumptionGetSchemaMake(),
}
}

View File

@@ -78,17 +78,17 @@ func dataSourceRgListVinsSchemaMake() map[string]*schema.Schema {
},
"vins_id": {
Type: schema.TypeInt,
Required: true,
Optional: true,
Description: "Filter by ViNS ID",
},
"page": {
Type: schema.TypeInt,
Required: true,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Required: true,
Optional: true,
Description: "Page size",
},
"items": {

View File

@@ -0,0 +1,211 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package rg
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceRGResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
rgResourceConsumptionList, err := utilityRGResourceConsumptionListCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenRGResourceConsumptionList(rgResourceConsumptionList))
d.Set("entry_count", rgResourceConsumptionList.EntryCount)
return nil
}
func dataSourceRGResourceConsumptionListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"consumed": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceRGResourceSchemaMake(),
},
},
"reserved": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceRGResourceSchemaMake(),
},
},
"resource_limits": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dataSourceResourceLimitsSchemaMake(),
},
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func dataSourceSepsSchemaMake() map[string]*schema.Schema {
res := 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.TypeFloat,
Computed: true,
},
}
return res
}
func dataSourceRGResourceSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"cpu": {
Type: schema.TypeInt,
Computed: true,
},
"disk_size": {
Type: schema.TypeFloat,
Computed: true,
},
"disk_size_max": {
Type: schema.TypeFloat,
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: dataSourceSepsSchemaMake(),
},
},
}
return res
}
func dataSourceResourceLimitsSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"cu_c": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_d": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_dm": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_i": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_m": {
Type: schema.TypeFloat,
Computed: true,
},
"cu_np": {
Type: schema.TypeFloat,
Computed: true,
},
"gpu_units": {
Type: schema.TypeFloat,
Computed: true,
},
}
return res
}
func DataSourceRGResourceConsumptionList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRGResourceConsumptionListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRGResourceConsumptionListSchemaMake(),
}
}

View File

@@ -40,7 +40,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
)
func flattenAccountSeps(seps map[string]map[string]DiskUsage) []map[string]interface{} {
func flattenRGSeps(seps map[string]map[string]rg.DiskUsage) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for sepKey, sepVal := range seps {
for dataKey, dataVal := range sepVal {
@@ -57,31 +57,31 @@ func flattenAccountSeps(seps map[string]map[string]DiskUsage) []map[string]inter
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)
// 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": flattenRgSeps(r.SEPs),
// }
// res = append(res, temp)
return res
}
// 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 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 flattenResgroup(d *schema.ResourceData, details rg.RecordResourceGroup) error {
log.Debugf("flattenResgroup: decoded RG name %q / ID %d, account ID %d",
@@ -122,7 +122,7 @@ func flattenResgroup(d *schema.ResourceData, details rg.RecordResourceGroup) err
}
func flattenRgSeps(seps map[string]map[string]rg.DiskUsage) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(seps))
for sepKey, sepVal := range seps {
SepMap := map[string]interface{}{}
for dataKey, dataVal := range sepVal {
@@ -140,7 +140,6 @@ func flattenRgSeps(seps map[string]map[string]rg.DiskUsage) []map[string]interfa
func flattenResource(resource rg.Resource) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"cpu": resource.CPU,
"disk_size": resource.DiskSize,
@@ -149,7 +148,7 @@ func flattenResource(resource rg.Resource) []map[string]interface{} {
"exttraffic": resource.ExtTraffic,
"gpu": resource.GPU,
"ram": resource.RAM,
"seps": flattenRgSeps(resource.SEPs),
"seps": flattenRGSeps(resource.SEPs),
}
res = append(res, temp)
@@ -191,7 +190,7 @@ func flattenRg(d *schema.ResourceData, itemRg rg.RecordResourceGroup) {
}
func flattenRgAudits(rgAudits rg.ListAudits) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(rgAudits))
for _, rgAudit := range rgAudits {
temp := map[string]interface{}{
"call": rgAudit.Call,
@@ -208,7 +207,7 @@ func flattenRgAudits(rgAudits rg.ListAudits) []map[string]interface{} {
}
func flattenRgList(rgl *rg.ListResourceGroups) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(rgl.Data))
for _, rg := range rgl.Data {
temp := map[string]interface{}{
"account_acl": flattenRgAcl(rg.ACL),
@@ -249,7 +248,7 @@ func flattenRgList(rgl *rg.ListResourceGroups) []map[string]interface{} {
}
func flattenRgAcl(rgAcls rg.ListACL) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(rgAcls))
for _, rgAcl := range rgAcls {
temp := map[string]interface{}{
"explicit": rgAcl.Explicit,
@@ -281,7 +280,7 @@ func flattenRgResourceLimits(rl rg.ResourceLimits) []map[string]interface{} {
}
func flattenRules(list rg.ListRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(list))
for _, rule := range list {
temp := map[string]interface{}{
"guid": rule.GUID,
@@ -299,7 +298,7 @@ func flattenRules(list rg.ListRules) []map[string]interface{} {
}
func flattenRgListComputes(lc *rg.ListComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(lc.Data))
for _, compute := range lc.Data {
temp := map[string]interface{}{
"account_id": compute.AccountID,
@@ -351,7 +350,7 @@ func flattenServerSettings(settings rg.RecordServerSettings) []map[string]interf
}
func flattenListServers(list rg.ListServers) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(list))
for _, serv := range list {
temp := map[string]interface{}{
"address": serv.Address,
@@ -368,7 +367,7 @@ func flattenListServers(list rg.ListServers) []map[string]interface{} {
}
func flattenBackends(b rg.ListBackends) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(b))
for _, item := range b {
temp := map[string]interface{}{
"algorithm": item.Algorithm,
@@ -383,7 +382,7 @@ func flattenBackends(b rg.ListBackends) []map[string]interface{} {
}
func flattenBindings(list rg.ListBindings) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(list))
for _, bind := range list {
temp := map[string]interface{}{
"address": bind.Address,
@@ -398,7 +397,7 @@ func flattenBindings(list rg.ListBindings) []map[string]interface{} {
}
func flattenFrontends(list rg.ListFrontends) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(list))
for _, front := range list {
temp := map[string]interface{}{
"backend": front.Backend,
@@ -427,7 +426,7 @@ func flattenNode(node rg.RecordNode) []map[string]interface{} {
}
func flattenRgListLb(listLb *rg.ListLB) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(listLb.Data))
for _, lb := range listLb.Data {
temp := map[string]interface{}{
"ha_mode": lb.HAMode,
@@ -462,7 +461,7 @@ func flattenRgListLb(listLb *rg.ListLB) []map[string]interface{} {
}
func flattenRgListPfw(listPfw *rg.ListPortForwards) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(listPfw.Data))
for _, pfw := range listPfw.Data {
temp := map[string]interface{}{
"public_port_end": pfw.PublicPortEnd,
@@ -481,7 +480,7 @@ func flattenRgListPfw(listPfw *rg.ListPortForwards) []map[string]interface{} {
}
func flattenRgListVins(lv *rg.ListVINS) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(lv.Data))
for _, vins := range lv.Data {
temp := map[string]interface{}{
"account_id": vins.AccountID,
@@ -509,7 +508,7 @@ func flattenRgListVins(lv *rg.ListVINS) []map[string]interface{} {
}
func flattenRgAffinityGroupComputes(list rg.ListAffinityGroupsComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(list))
for _, item := range list {
temp := map[string]interface{}{
@@ -527,22 +526,37 @@ func flattenRgAffinityGroupComputes(list rg.ListAffinityGroupsComputes) []map[st
return res
}
func flattenRgAffinityGroupsGet(list []uint64) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"items": list,
// func flattenRgAffinityGroupsGet(list []uint64) []map[string]interface{} {
// res := make([]map[string]interface{}, 0)
// temp := map[string]interface{}{
// "items": list,
// }
// res = append(res, temp)
// return res
// }
func flattenRgListGroups(list *rg.ListAffinityGroups) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(list.Data))
for _, groupVal := range list.Data {
for label, ag := range groupVal {
temp := map[string]interface{}{
"label": label,
"ids": flattenRgAffinityListGroup(ag),
}
res = append(res, temp)
}
}
res = append(res, temp)
return res
}
func flattenRgListGroups(list *rg.ListAffinityGroups) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for groupKey, groupVal := range list.Data {
func flattenRgAffinityListGroup(list rg.ListAffinityGroup) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(list))
for _, ag := range list {
temp := map[string]interface{}{
"label": groupKey,
"ids": groupVal,
"id": ag.ID,
"node_id": ag.NodeID,
}
res = append(res, temp)
}
@@ -560,3 +574,24 @@ func flattenRgUsageResource(d *schema.ResourceData, usage rg.RecordResourceUsage
d.Set("ram", usage.RAM)
d.Set("seps", flattenRgSeps(usage.SEPs))
}
func flattenRGResourceConsumptionList(rg *rg.ListResourceConsumption) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(rg.Data))
for _, rc := range rg.Data {
temp := map[string]interface{}{
"consumed": flattenResource(rc.Consumed),
"reserved": flattenResource(rc.Reserved),
"resource_limits": flattenRgResourceLimits(rc.ResourceLimits),
"rg_id": rc.RGID,
}
res = append(res, temp)
}
return res
}
func flattenRGResourceConsumption(d *schema.ResourceData, rg *rg.ItemResourceConsumption) {
d.Set("consumed", flattenResource(rg.Consumed))
d.Set("reserved", flattenResource(rg.Reserved))
d.Set("resource_limits", flattenRgResourceLimits(rg.ResourceLimits))
d.Set("rg_id", rg.RGID)
}

View File

@@ -97,14 +97,13 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
setQuota = true
}
log.Debugf("resourceResgroupCreate: called by user %q for RG name %s, account ID %d",
c.GetDecortUsername(),
log.Debugf("resourceResgroupCreate: called for RG name %s, account ID %d",
// c.GetDecortUsername(),
rgName.(string), d.Get("account_id").(int))
req.AccountID = uint64(d.Get("account_id").(int))
req.Name = rgName.(string)
req.GID = uint64(location.DefaultGridID)
req.Owner = c.GetDecortUsername()
if setQuota {
req.MaxCPUCapacity = int64(quotaRecord.Cpu)
@@ -121,6 +120,11 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
d.Set("def_net_type", "PRIVATE")
}
owner, ok := d.GetOk("owner")
if ok {
req.Owner = owner.(string)
}
ipcidr, ok := d.GetOk("ipcidr")
if ok {
req.IPCIDR = ipcidr.(string)
@@ -256,7 +260,7 @@ func resourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interfa
log.Debugf("resourceResgroupRead: called for RG name %s, account ID %d",
d.Get("name").(string), d.Get("account_id").(int))
c := m.(*controller.ControllerCfg)
// c := m.(*controller.ControllerCfg)
rgData, err := utilityResgroupCheckPresence(ctx, d, m)
if err != nil {
@@ -272,24 +276,25 @@ func resourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interfa
case status.Created:
case status.Enabled:
case status.Deleted:
restoreReq := rg.RestoreRequest{RGID: rgData.ID}
enableReq := rg.EnableRequest{RGID: rgData.ID}
// restoreReq := rg.RestoreRequest{RGID: rgData.ID}
// enableReq := rg.EnableRequest{RGID: rgData.ID}
_, err := c.CloudAPI().RG().Restore(ctx, restoreReq)
if err != nil {
return diag.FromErr(err)
}
// _, err := c.CloudAPI().RG().Restore(ctx, restoreReq)
// if err != nil {
// return diag.FromErr(err)
// }
_, err = c.CloudAPI().RG().Enable(ctx, enableReq)
if err != nil {
return diag.FromErr(err)
}
// _, err = c.CloudAPI().RG().Enable(ctx, enableReq)
// if err != nil {
// return diag.FromErr(err)
// }
hasChanged = true
// hasChanged = true
case status.Deleting:
case status.Destroyed:
d.SetId("")
return resourceResgroupCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceResgroupCreate(ctx, d, m)
case status.Destroying:
case status.Disabled:
case status.Disabling:
@@ -369,7 +374,8 @@ func resourceResgroupUpdate(ctx context.Context, d *schema.ResourceData, m inter
case status.Deleting:
case status.Destroyed:
d.SetId("")
return resourceResgroupCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceResgroupCreate(ctx, d, m)
case status.Destroying:
case status.Disabled:
case status.Disabling:
@@ -656,6 +662,11 @@ func ResourceRgSchemaMake() map[string]*schema.Schema {
Description: "Address of the netowrk inside the private network segment (aka ViNS) if def_net_type=PRIVATE",
},
"owner": {
Type: schema.TypeString,
Optional: true,
},
"ext_net_id": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -46,6 +46,14 @@ func utilityRgAffinityGroupsListCheckPresence(ctx context.Context, d *schema.Res
RGID: uint64(d.Get("rg_id").(int)),
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
groups, err := c.CloudAPI().RG().AffinityGroupsList(ctx, req)
if err != nil {
return nil, err

View 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://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package rg
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityRGResourceConsumptionGetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.ItemResourceConsumption, error) {
c := m.(*controller.ControllerCfg)
id := uint64(d.Get("rg_id").(int))
req := rg.GetResourceConsumptionRequest{
RGID: id,
}
log.Debugf("utilityRGResourceConsumptionGetCheckPresence: load")
accountResourceConsumptionRec, err := c.CloudAPI().RG().GetResourceConsumption(ctx, req)
if err != nil {
return nil, err
}
return accountResourceConsumptionRec, nil
}

View File

@@ -0,0 +1,55 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package rg
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityRGResourceConsumptionListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.ListResourceConsumption, error) {
c := m.(*controller.ControllerCfg)
log.Debugf("utilityRGResourceConsumptionListCheckPresence: load")
rgResourceConsumptionList, err := c.CloudAPI().RG().ListResourceConsumption(ctx)
if err != nil {
return nil, err
}
return rgResourceConsumptionList, nil
}

View File

@@ -49,7 +49,7 @@ func dataSourceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m i
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenSnapshotList(snapshotList))
d.Set("entry_count", snapshotList.EntryCount)
return nil
}
@@ -69,6 +69,10 @@ func dataSourceSnapshotListSchemaMake() map[string]*schema.Schema {
Schema: dataSourceSnapshotSchemaMake(),
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets

View File

@@ -6,7 +6,7 @@ import (
)
func flattenSnapshotList(gl *compute.ListSnapShots) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(gl.Data))
for _, item := range gl.Data {
temp := map[string]interface{}{
"label": item.Label,

View 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://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package stack
import (
"context"
"strconv"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceStackSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"stack_id": {
Type: schema.TypeInt,
Required: true,
},
"cpu_allocation_ratio": {
Type: schema.TypeInt,
Computed: true,
},
"descr": {
Type: schema.TypeString,
Computed: true,
},
"drivers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"mem_allocation_ratio": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
}
return res
}
func dataSourceStackRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
stack, err := utilityStackCheckPresence(ctx, d, m)
if err != nil {
d.SetId("") // ensure ID is empty in this case
return diag.FromErr(err)
}
d.SetId(strconv.Itoa(d.Get("stack_id").(int)))
flattenStack(d, *stack)
return nil
}
func DataSourceStack() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceStackRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceStackSchemaMake(),
}
}

View File

@@ -0,0 +1,136 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package stack
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceStackListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
stackList, err := utilityStackListCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenStackList(stackList))
d.Set("entry_count", stackList.EntryCount)
return nil
}
func dataSourceStackListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"by_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Find by ID",
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Find by name",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "Find by type",
},
"status": {
Type: schema.TypeString,
Optional: true,
Description: "Find by status",
},
"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{
"stack_id": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceStackList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceStackListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceStackListSchemaMake(),
}
}

View File

@@ -0,0 +1,69 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package stack
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
)
func flattenStackList(stackl *stack.ListStacks) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, stack := range stackl.Data {
temp := map[string]interface{}{
"stack_id": stack.ID,
"name": stack.Name,
"status": stack.Status,
"type": stack.Type,
}
res = append(res, temp)
}
return res
}
func flattenStack(d *schema.ResourceData, details stack.InfoStack) error {
log.Debugf("flattenStack: decoded Stack name %q / ID %d",
details.Name, details.ID)
d.Set("stack_id", details.ID)
d.Set("cpu_allocation_ratio", details.CPUAllocationRatio)
d.Set("name", details.Name)
d.Set("descr", details.Descr)
d.Set("mem_allocation_ratio", details.MemAllocationRatio)
d.Set("status", details.Status)
d.Set("type", details.Type)
d.Set("drivers", details.Drivers)
return nil
}

View File

@@ -0,0 +1,62 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package stack
import (
"context"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityStackCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*stack.InfoStack, error) {
c := m.(*controller.ControllerCfg)
req := stack.GetRequest{}
if d.Id() != "" {
stackId, _ := strconv.ParseUint(d.Id(), 10, 64)
req.StackId = stackId
} else {
req.StackId = uint64(d.Get("stack_id").(int))
}
stackData, err := c.CloudAPI().Stack().Get(ctx, req)
if err != nil {
return nil, err
}
return stackData, nil
}

View File

@@ -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://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package stack
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityStackListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*stack.ListStacks, error) {
c := m.(*controller.ControllerCfg)
req := stack.ListRequest{}
if byId, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(byId.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if stackType, ok := d.GetOk("type"); ok {
req.Type = stackType.(string)
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
log.Debugf("utilityStackListCheckPresence: load stack list")
stackList, err := c.CloudAPI().Stack().List(ctx, req)
if err != nil {
return nil, err
}
return stackList, nil
}

View File

@@ -0,0 +1,107 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package vins
import (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
staticRoute, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(staticRoute.ID, 10))
flattenStaticRouteData(d, staticRoute)
return nil
}
func dataSourceStaticRouteSchemaMake() map[string]*schema.Schema {
rets := map[string]*schema.Schema{
"vins_id": {
Type: schema.TypeInt,
Required: true,
Description: "Unique ID of the ViNS",
},
"route_id": {
Type: schema.TypeInt,
Required: true,
Description: "Unique ID of the static route",
},
"compute_ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"destination": {
Type: schema.TypeString,
Computed: true,
},
"gateway": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"netmask": {
Type: schema.TypeString,
Computed: true,
},
}
return rets
}
func DataSourceStaticRoute() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceStaticRouteRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceStaticRouteSchemaMake(),
}
}

View File

@@ -0,0 +1,121 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package vins
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
)
func dataSourceStaticRouteListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
staticRouteList, err := utilityStaticRouteListCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenStaticRouteList(staticRouteList))
d.Set("entry_count", staticRouteList.EntryCount)
return nil
}
func dataSourceStaticRouteListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"vins_id": {
Type: schema.TypeInt,
Required: true,
Description: "ID of VINS",
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"compute_ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"destination": {
Type: schema.TypeString,
Computed: true,
},
"gateway": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"netmask": {
Type: schema.TypeString,
Computed: true,
},
"route_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}
func DataSourceStaticRouteList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceStaticRouteListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceStaticRouteListSchemaMake(),
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
@@ -34,8 +34,8 @@ package vins
import (
"context"
"strconv"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
@@ -47,8 +47,9 @@ func dataSourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(vins.ID, 10))
flattenVinsData(d, *vins)
id := uuid.New()
d.SetId(id.String())
flattenVinsData(d, vins)
return nil
}
@@ -640,7 +641,7 @@ func rulesSchemaMake() map[string]*schema.Schema {
}
}
func configSchrmaMake() map[string]*schema.Schema {
func natConfigSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"net_mask": {
Type: schema.TypeInt,
@@ -678,7 +679,7 @@ func natSchemaMake() map[string]*schema.Schema {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: configSchrmaMake(),
Schema: natConfigSchemaMake(),
},
},
"devices": {
@@ -768,7 +769,6 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
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,
@@ -776,10 +776,6 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Schema: vnfDevSchemaMake(),
},
},
"_ckey": {
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeInt,
Computed: true,
@@ -797,6 +793,14 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Schema: vinsComputeSchemaMake(),
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"default_gw": {
Type: schema.TypeString,
Computed: true,
@@ -808,6 +812,14 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Schema: qosSchemaMake(),
},
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
@@ -874,6 +886,14 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
"user_managed": {
Type: schema.TypeBool,
Computed: true,

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
@@ -49,7 +49,7 @@ func dataSourceVinsExtNetListRead(ctx context.Context, d *schema.ResourceData, m
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenVinsExtNetList(extNetList))
d.Set("entry_count", extNetList.EntryCount)
return nil
}
@@ -92,6 +92,10 @@ func DataSourceVinsExtNetListchemaMake() map[string]*schema.Schema {
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
@@ -49,7 +49,7 @@ func dataSourceVinsIpListRead(ctx context.Context, d *schema.ResourceData, m int
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenVinsIpList(ips))
d.Set("entry_count", ips.EntryCount)
return nil
}
@@ -96,6 +96,10 @@ func DataSourceVinsIpListSchemaMake() map[string]*schema.Schema {
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
@@ -49,6 +49,8 @@ func dataSourceVinsNatRuleListRead(ctx context.Context, d *schema.ResourceData,
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenVinsNatRuleList(natRules))
d.Set("entry_count", natRules.EntryCount)
return nil
}
@@ -99,6 +101,10 @@ func DataSourceVinsNatRuleListSchemaMake() map[string]*schema.Schema {
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return rets
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
@@ -49,7 +49,7 @@ func flattenMGMT(mgmt vins.RecordMGMT) []map[string]interface{} {
return res
}
func flattenResources(resources *vins.RecordResources) []map[string]interface{} {
func flattenResources(resources vins.RecordResources) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"cpu": resources.CPU,
@@ -65,7 +65,7 @@ func flattenConfig(config vins.RecordVNFConfig) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"mgmt": flattenMGMT(config.MGMT),
"resources": flattenResources(&config.Resources),
"resources": flattenResources(config.Resources),
}
res = append(res, temp)
return res
@@ -84,8 +84,7 @@ func flattenQOS(qos vins.QOS) []map[string]interface{} {
}
func flattenInterfaces(interfaces []vins.ItemVNFInterface) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(interfaces))
for _, vnfInterface := range interfaces {
temp := map[string]interface{}{
"conn_id": vnfInterface.ConnID,
@@ -141,7 +140,7 @@ func flattenVNFDev(vnfDev vins.RecordVNFDev) []map[string]interface{} {
}
func flattenComputes(computes vins.ListVINSComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(computes))
for _, compute := range computes {
temp := map[string]interface{}{
"compute_id": compute.ID,
@@ -154,7 +153,7 @@ func flattenComputes(computes vins.ListVINSComputes) []map[string]interface{} {
}
func flattenReservations(reservations vins.ListReservations) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(reservations))
for _, reservation := range reservations {
temp := map[string]interface{}{
"client_type": reservation.ClientType,
@@ -275,9 +274,9 @@ func flattenGW(gw vins.RecordGW) []map[string]interface{} {
return res
}
func flattenRules(rules vins.ListNATRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, rule := range rules.Data {
func flattenRules(rules vins.ListNATRulesConfig) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(rules))
for _, rule := range rules {
tmp := map[string]interface{}{
"rule_id": rule.ID,
"local_ip": rule.LocalIP,
@@ -343,9 +342,9 @@ func flattenVNFS(vnfs vins.RecordVNFs) []map[string]interface{} {
return res
}
func flattenRuleBlock(rules vins.ListNATRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, rule := range rules.Data {
func flattenRuleBlock(rules vins.ListNATRulesConfig) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(rules))
for _, rule := range rules {
tmp := map[string]interface{}{
"int_ip": rule.LocalIP,
"int_port": rule.LocalPort,
@@ -359,15 +358,18 @@ func flattenRuleBlock(rules vins.ListNATRules) []map[string]interface{} {
return res
}
func flattenVins(d *schema.ResourceData, vins vins.RecordVINS) {
func flattenVins(d *schema.ResourceData, vins *vins.RecordVINS) {
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("created_by", vins.CreatedBy)
d.Set("created_time", vins.CreatedTime)
d.Set("default_gw", vins.DefaultGW)
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
d.Set("deleted_by", vins.DeletedBy)
d.Set("deleted_time", vins.DeletedTime)
d.Set("desc", vins.Description)
d.Set("gid", vins.GID)
d.Set("guid", vins.GUID)
@@ -384,21 +386,26 @@ func flattenVins(d *schema.ResourceData, vins vins.RecordVINS) {
d.Set("rg_name", vins.RGName)
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
d.Set("status", vins.Status)
d.Set("updated_by", vins.UpdatedBy)
d.Set("updated_time", vins.UpdatedTime)
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 vins.RecordVINS) {
func flattenVinsData(d *schema.ResourceData, vins *vins.RecordVINS) {
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("created_by", vins.CreatedBy)
d.Set("created_time", vins.CreatedTime)
d.Set("default_gw", vins.DefaultGW)
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
d.Set("deleted_by", vins.DeletedBy)
d.Set("deleted_time", vins.DeletedTime)
d.Set("desc", vins.Description)
d.Set("gid", vins.GID)
d.Set("guid", vins.GUID)
@@ -415,14 +422,16 @@ func flattenVinsData(d *schema.ResourceData, vins vins.RecordVINS) {
d.Set("rg_name", vins.RGName)
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
d.Set("status", vins.Status)
d.Set("updated_by", vins.UpdatedBy)
d.Set("updated_time", vins.UpdatedTime)
d.Set("user_managed", vins.UserManaged)
d.Set("vnfs", flattenVNFS(vins.VNFs))
d.Set("vxlan_id", vins.VXLANID)
}
func flattenVinsAudits(auidts vins.ListAudits) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, audit := range auidts {
func flattenVinsAudits(audits vins.ListAudits) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(audits))
for _, audit := range audits {
temp := map[string]interface{}{
"call": audit.Call,
"response_time": audit.ResponseTime,
@@ -437,7 +446,7 @@ func flattenVinsAudits(auidts vins.ListAudits) []map[string]interface{} {
}
func flattenVinsExtNetList(extNetList *vins.ListExtNets) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(extNetList.Data))
for _, extNet := range extNetList.Data {
temp := map[string]interface{}{
"default_gw": extNet.DefaultGW,
@@ -454,7 +463,7 @@ func flattenVinsExtNetList(extNetList *vins.ListExtNets) []map[string]interface{
}
func flattenVinsIpList(ips *vins.ListIPs) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(ips.Data))
for _, ip := range ips.Data {
temp := map[string]interface{}{
"client_type": ip.ClientType,
@@ -472,7 +481,7 @@ func flattenVinsIpList(ips *vins.ListIPs) []map[string]interface{} {
}
func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(vl.Data))
for _, v := range vl.Data {
temp := map[string]interface{}{
"account_id": v.AccountID,
@@ -497,8 +506,37 @@ func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
return res
}
func flattenVinsNatRuleList(natRules *vins.ListNATRules) []map[string]interface{} {
// /4.4.0
func flattenStaticRouteList(sr *vins.ListStaticRoutes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, staticRoute := range sr.Data {
temp := map[string]interface{}{
"route_id": staticRoute.ID,
"destination": staticRoute.Destination,
"gateway": staticRoute.Gateway,
"guid": staticRoute.GUID,
"netmask": staticRoute.Netmask,
"compute_ids": staticRoute.ComputeIds,
}
res = append(res, temp)
}
return res
}
func flattenStaticRouteData(d *schema.ResourceData, route *vins.ItemRoutes) {
d.Set("destination", route.Destination)
d.Set("gateway", route.Gateway)
d.Set("guid", route.GUID)
d.Set("netmask", route.Netmask)
d.Set("compute_ids", route.ComputeIds)
d.Set("route_id", route.ID)
}
///
func flattenVinsNatRuleList(natRules *vins.ListNATRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(natRules.Data))
for _, natRule := range natRules.Data {
temp := map[string]interface{}{
"id": natRule.ID,

View File

@@ -8,6 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
@@ -68,3 +69,16 @@ func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool,
return len(locationList.FilterByGID(gid).Data) != 0, nil
}
func existVinsID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
c := m.(*controller.ControllerCfg)
vinsID := uint64(d.Get("vins_id").(int))
req := vins.ListRequest{}
vinsList, err := c.CloudAPI().VINS().List(ctx, req)
if err != nil {
return false, err
}
return len(vinsList.FilterByID(vinsID).Data) != 0, nil
}

View File

@@ -0,0 +1,276 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package vins
import (
"context"
"fmt"
"strconv"
"strings"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func resourceStaticRouteCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*controller.ControllerCfg)
if _, ok := d.GetOk("vins_id"); ok {
haveVinsID, err := existVinsID(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !haveVinsID {
return diag.Errorf("resourceStaticRouteCreate: can't create Static Route because Vins ID %d is not allowed or does not exist", d.Get("vins_id").(int))
}
}
req := vins.StaticRouteAddRequest{
VINSID: uint64(d.Get("vins_id").(int)),
Destination: d.Get("destination").(string),
Netmask: d.Get("netmask").(string),
Gateway: d.Get("gateway").(string),
}
if computesIDS, ok := d.GetOk("compute_ids"); ok {
ids := computesIDS.([]interface{})
res := make([]uint64, 10)
for _, id := range ids {
computeId := uint64(id.(int))
res = append(res, computeId)
}
req.ComputeIds = res
}
_, err := c.CloudAPI().VINS().StaticRouteAdd(ctx, req)
if err != nil {
return diag.FromErr(err)
}
staticRouteData, err := getStaticRouteData(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
d.SetId(fmt.Sprintf("%d#%d", req.VINSID, staticRouteData.ID))
return resourceStaticRouteRead(ctx, d, m)
}
func resourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
warnings := dc.Warnings{}
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
flattenStaticRouteData(d, staticRouteData)
return warnings.Get()
}
func resourceStaticRouteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*controller.ControllerCfg)
warnings := dc.Warnings{}
if _, ok := d.GetOk("vins_id"); ok {
haveVinsID, err := existVinsID(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
if !haveVinsID {
return diag.Errorf("resourceVinsUpdate: can't update Static Route because VinsID %d is not allowed or does not exist", d.Get("vins_id").(int))
}
}
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
if d.HasChange("compute_ids") {
deletedIds := make([]uint64, 0)
addedIds := make([]uint64, 0)
oldComputeIds, newComputeIds := d.GetChange("compute_ids")
oldComputeIdsSlice := oldComputeIds.([]interface{})
newComputeIdsSlice := newComputeIds.([]interface{})
for _, el := range oldComputeIdsSlice {
if !isContainsIds(newComputeIdsSlice, el) {
convertedEl := uint64(el.(int))
deletedIds = append(deletedIds, convertedEl)
}
}
for _, el := range newComputeIdsSlice {
if !isContainsIds(oldComputeIdsSlice, el) {
convertedEl := uint64(el.(int))
addedIds = append(addedIds, convertedEl)
}
}
if len(deletedIds) > 0 {
req := vins.StaticRouteAccessRevokeRequest{
VINSID: uint64(d.Get("vins_id").(int)),
RouteId: staticRouteData.ID,
ComputeIds: deletedIds,
}
_, err := c.CloudAPI().VINS().StaticRouteAccessRevoke(ctx, req)
if err != nil {
warnings.Add(err)
}
}
if len(addedIds) > 0 {
req := vins.StaticRouteAccessGrantRequest{
VINSID: uint64(d.Get("vins_id").(int)),
RouteId: staticRouteData.ID,
ComputeIds: addedIds,
}
_, err := c.CloudAPI().VINS().StaticRouteAccessGrant(ctx, req)
if err != nil {
warnings.Add(err)
}
}
}
return append(warnings.Get(), resourceStaticRouteRead(ctx, d, m)...)
}
func resourceStaticRouteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*controller.ControllerCfg)
arr := strings.Split(d.Id(), "#")
if len(arr) != 2 {
return diag.FromErr(fmt.Errorf("broken state id"))
}
vinsId, _ := strconv.ParseUint(arr[0], 10, 64)
routeId, _ := strconv.ParseUint(arr[1], 10, 64)
req := vins.StaticRouteDelRequest{
VINSID: vinsId,
RouteId: routeId,
}
_, err := c.CloudAPI().VINS().StaticRouteDel(ctx, req)
if err != nil {
return diag.FromErr(err)
}
d.SetId("")
return nil
}
func resourceStaticRouteSchemaMake() map[string]*schema.Schema {
rets := dataSourceStaticRouteSchemaMake()
rets["route_id"] = &schema.Schema{
Type: schema.TypeInt,
Computed: true,
Optional: true,
}
rets["compute_ids"] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
}
rets["destination"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
}
rets["gateway"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
}
rets["netmask"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
}
return rets
}
func isContainsIds(els []interface{}, el interface{}) bool {
convEl := el.(int)
for _, elOld := range els {
if convEl == elOld.(int) {
return true
}
}
return false
}
func ResourceStaticRoute() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
CreateContext: resourceStaticRouteCreate,
ReadContext: resourceStaticRouteRead,
UpdateContext: resourceStaticRouteUpdate,
DeleteContext: resourceStaticRouteDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout20m,
Read: &constants.Timeout600s,
Update: &constants.Timeout20m,
Delete: &constants.Timeout600s,
Default: &constants.Timeout600s,
},
Schema: resourceStaticRouteSchemaMake(),
}
}

View File

@@ -129,8 +129,10 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
if desc, ok := d.GetOk("desc"); ok {
req.Description = desc.(string)
}
req.PreReservationsNum = uint(d.Get("pre_reservations_num").(int))
if preReservationsNum, ok := d.GetOk("pre_reservations_num"); ok {
req.PreReservationsNum = uint64(preReservationsNum.(int))
}
id, err := c.CloudAPI().VINS().CreateInRG(ctx, req)
if err != nil {
return diag.FromErr(err)
@@ -141,7 +143,6 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
req := vins.CreateInAccountRequest{
Name: d.Get("name").(string),
AccountID: uint64(accountId.(int)),
PreReservationsNum: uint64(d.Get("pre_reservations_num").(int)),
}
if gid, ok := d.GetOk("gid"); ok {
@@ -153,7 +154,10 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
if desc, ok := d.GetOk("desc"); ok {
req.Description = desc.(string)
}
if preReservationsNum, ok := d.GetOk("pre_reservations_num"); ok {
req.PreReservationsNum = uint64(preReservationsNum.(int))
}
id, err := c.CloudAPI().VINS().CreateInAccount(ctx, req)
if err != nil {
return diag.FromErr(err)
@@ -214,21 +218,21 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
}
}
defer resourceVinsRead(ctx, d, m)
return warnings.Get()
return append(warnings.Get(), resourceVinsRead(ctx, d, m)...)
}
func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*controller.ControllerCfg)
// c := m.(*controller.ControllerCfg)
warnings := dc.Warnings{}
vinsData, err := utilityVinsCheckPresence(ctx, d, m)
vinsData, err := utilityDataVinsCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
isEnabled := d.Get("enable").(bool)
// isEnabled := d.Get("enable").(bool)
hasChangeState := false
@@ -236,60 +240,61 @@ func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}
case status.Destroyed:
d.Set("vins_id", 0)
d.SetId("")
return resourceVinsCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceVinsCreate(ctx, d, m)
case status.Deleted:
hasChangeState = true
// hasChangeState = true
req := vins.RestoreRequest{
VINSID: vinsData.ID,
}
// req := vins.RestoreRequest{
// VINSID: vinsData.ID,
// }
_, err := c.CloudAPI().VINS().Restore(ctx, req)
if err != nil {
warnings.Add(err)
}
// _, err := c.CloudAPI().VINS().Restore(ctx, req)
// if err != nil {
// warnings.Add(err)
// }
case status.Modeled:
return diag.Errorf("ViNS are in status: %s, please, contact support for more information", vinsData.Status)
case status.Created:
case status.Enabled:
if !isEnabled {
hasChangeState = true
req := vins.DisableEnableRequest{
VINSID: vinsData.ID,
}
// if !isEnabled {
// hasChangeState = true
// req := vins.DisableEnableRequest{
// VINSID: vinsData.ID,
// }
_, err := c.CloudAPI().VINS().Disable(ctx, req)
if err != nil {
warnings.Add(err)
}
}
// _, err := c.CloudAPI().VINS().Disable(ctx, req)
// if err != nil {
// warnings.Add(err)
// }
// }
case status.Enabling:
case status.Disabled:
if isEnabled {
hasChangeState = true
req := vins.DisableEnableRequest{
VINSID: vinsData.ID,
}
// if isEnabled {
// hasChangeState = true
// req := vins.DisableEnableRequest{
// VINSID: vinsData.ID,
// }
_, err := c.CloudAPI().VINS().Enable(ctx, req)
if err != nil {
warnings.Add(err)
}
}
// _, err := c.CloudAPI().VINS().Enable(ctx, req)
// if err != nil {
// warnings.Add(err)
// }
// }
case status.Disabling:
case status.Deleting:
return diag.Errorf("ViNS are in progress with status: %s", vinsData.Status)
}
if hasChangeState {
vinsData, err = utilityVinsCheckPresence(ctx, d, m)
vinsData, err = utilityDataVinsCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
}
flattenVins(d, *vinsData)
flattenVins(d, vinsData)
return warnings.Get()
}
@@ -366,7 +371,7 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
}
}
vinsData, err := utilityVinsCheckPresence(ctx, d, m)
vinsData, err := utilityDataVinsCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
@@ -379,7 +384,8 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
switch vinsData.Status {
case status.Destroyed:
d.SetId("")
return resourceVinsCreate(ctx, d, m)
return diag.Errorf("The resource cannot be updated because it has been destroyed")
// return resourceVinsCreate(ctx, d, m)
case status.Deleted:
hasChangeState = true
@@ -425,7 +431,7 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
}
if hasChangeState {
vinsData, err = utilityVinsCheckPresence(ctx, d, m)
vinsData, err = utilityDataVinsCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
@@ -631,8 +637,7 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
}
}
defer resourceVinsRead(ctx, d, m)
return warnings.Get()
return append (warnings.Get(), resourceVinsRead(ctx, d, m)...)
}
func resourceVinsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
@@ -658,7 +663,7 @@ func extNetSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"ext_net_id": {
Type: schema.TypeInt,
Default: 0,
Default: -1,
Optional: true,
},
"ext_net_ip": {
@@ -674,6 +679,7 @@ func ipSchemaMake() map[string]*schema.Schema {
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string {"DHCP", "VIP", "EXCLUDE"}, false),
},
"ip_addr": {
Type: schema.TypeString,
@@ -823,7 +829,6 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
Optional: true,
Default: false,
}
rets["vins_id"] = &schema.Schema{
Type: schema.TypeInt,
Computed: true,

Some files were not shown because too many files have changed in this diff Show More