diff --git a/go.mod b/go.mod index f116f390e..1652bc5a2 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,11 @@ module github.com/vmware/terraform-provider-nsxt go 1.19 replace ( - github.com/vmware/vsphere-automation-sdk-go/lib => github.com/annakhm/vsphere-automation-sdk-go/lib v0.0.0-20241110024359-e42c5fcc5482 - github.com/vmware/vsphere-automation-sdk-go/runtime => github.com/annakhm/vsphere-automation-sdk-go/runtime v0.0.0-20241110024359-e42c5fcc5482 - github.com/vmware/vsphere-automation-sdk-go/services/nsxt => github.com/annakhm/vsphere-automation-sdk-go/services/nsxt v0.0.0-20241110024359-e42c5fcc5482 - github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm => github.com/annakhm/vsphere-automation-sdk-go/services/nsxt-gm v0.0.0-20241110024359-e42c5fcc5482 - github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp => github.com/annakhm/vsphere-automation-sdk-go/services/nsxt-mp v0.0.0-20241110024359-e42c5fcc5482 + github.com/vmware/vsphere-automation-sdk-go/lib => github.com/vmware/vsphere-automation-sdk-go/lib v0.7.1-0.20241113023437-5938c535c194 + github.com/vmware/vsphere-automation-sdk-go/runtime => github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.1-0.20241113023437-5938c535c194 + github.com/vmware/vsphere-automation-sdk-go/services/nsxt => github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.1-0.20241113023437-5938c535c194 + github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm => github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.1-0.20241113023437-5938c535c194 + github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp => github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.1-0.20241113023437-5938c535c194 ) require ( @@ -30,13 +30,14 @@ require ( github.com/antihax/optional v1.0.0 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beevik/etree v1.1.0 // indirect + github.com/client9/misspell v0.3.4 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.13.0 // indirect github.com/gibson042/canonicaljson-go v1.0.3 // indirect github.com/golang-jwt/jwt/v4 v4.3.0 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -46,7 +47,7 @@ require ( github.com/hashicorp/go-plugin v1.5.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/hc-install v0.6.0 // indirect - github.com/hashicorp/hcl/v2 v2.18.0 // indirect + github.com/hashicorp/hcl/v2 v2.20.1 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.19.0 // indirect github.com/hashicorp/terraform-json v0.17.1 // indirect @@ -55,11 +56,12 @@ require ( github.com/hashicorp/terraform-registry-address v0.2.2 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect + github.com/katbyte/terrafmt v0.5.4 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/mitchellh/go-wordwrap v1.0.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect @@ -67,9 +69,9 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // 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.0 // indirect + github.com/zclconf/go-cty v1.14.3 // indirect golang.org/x/crypto v0.21.0 // indirect - golang.org/x/mod v0.12.0 // indirect + golang.org/x/mod v0.16.0 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.7.0 // indirect golang.org/x/sys v0.18.0 // indirect diff --git a/go.sum b/go.sum index ebe3f9d77..ef07b4c2d 100644 --- a/go.sum +++ b/go.sum @@ -6,16 +6,6 @@ github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjA 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/annakhm/vsphere-automation-sdk-go/lib v0.0.0-20241110024359-e42c5fcc5482 h1:aSqiTMwQQso+tTULhSf/26iAkhTHVfdi9P1Q/X+HpxQ= -github.com/annakhm/vsphere-automation-sdk-go/lib v0.0.0-20241110024359-e42c5fcc5482/go.mod h1:ADkX8BkdnvT1Kc9ZfqHaV4qzaaD+9L8Ok2+pxK4xoD8= -github.com/annakhm/vsphere-automation-sdk-go/runtime v0.0.0-20241110024359-e42c5fcc5482 h1:wWKGPhmqvvpxO0G4mlNtZ27ThzPCuOG/kPXgbu0CR8s= -github.com/annakhm/vsphere-automation-sdk-go/runtime v0.0.0-20241110024359-e42c5fcc5482/go.mod h1:DzLetYAmw1+vj7bqElRWEpuy40WYE/woL3alsymYa/c= -github.com/annakhm/vsphere-automation-sdk-go/services/nsxt v0.0.0-20241110024359-e42c5fcc5482 h1:qDHIIezjQTDqgv9YlFee9R3vBWDlbFJGUZRxvomtkgk= -github.com/annakhm/vsphere-automation-sdk-go/services/nsxt v0.0.0-20241110024359-e42c5fcc5482/go.mod h1:NSjO9WqelbsTEDb3pVxpYYz4zjgX0XPp43dKNT4Y+9k= -github.com/annakhm/vsphere-automation-sdk-go/services/nsxt-gm v0.0.0-20241110024359-e42c5fcc5482 h1:QkLzAnPXPDxqICfRfo8QMVjim0mY1nYfM+ie0r/pyLQ= -github.com/annakhm/vsphere-automation-sdk-go/services/nsxt-gm v0.0.0-20241110024359-e42c5fcc5482/go.mod h1:gcEvyczWPFMZX2gkBiBVpOwvUGSNXSpxU19Sx9aiouY= -github.com/annakhm/vsphere-automation-sdk-go/services/nsxt-mp v0.0.0-20241110024359-e42c5fcc5482 h1:/+pwbYwlKBuZAwJVtZhSQorwtDmIGbo/EqRnFkgE7dk= -github.com/annakhm/vsphere-automation-sdk-go/services/nsxt-mp v0.0.0-20241110024359-e42c5fcc5482/go.mod h1:ugk9I4YM62SSAox57l5NAVBCRIkPQ1RNLb3URxyTADc= github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= @@ -25,6 +15,8 @@ github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= @@ -34,6 +26,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/gibson042/canonicaljson-go v1.0.3 h1:EAyF8L74AWabkyUmrvEFHEt/AGFQeD6RfwbAuf0j1bI= github.com/gibson042/canonicaljson-go v1.0.3/go.mod h1:DsLpJTThXyGNO+KZlI85C1/KDcImpP67k/RKVjcaEqo= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= @@ -53,8 +47,12 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gookit/color v1.5.1 h1:Vjg2VEcdHpwq+oY63s/ksHrgJYCTo0bwWvmmYWdE9fQ= +github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHPaqKM= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= @@ -77,8 +75,12 @@ github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mO github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/hc-install v0.6.0 h1:fDHnU7JNFNSQebVKYhHZ0va1bC6SrPQ8fpebsvNr2w4= github.com/hashicorp/hc-install v0.6.0/go.mod h1:10I912u3nntx9Umo1VAeYPUUuehk0aRQJYpMwbX5wQA= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8= github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/hashicorp/hcl/v2 v2.20.1 h1:M6hgdyz7HYt1UN9e61j+qKJBqR3orTWbI1HKBJEdxtc= +github.com/hashicorp/hcl/v2 v2.20.1/go.mod h1:TZDqQ4kNKCbh1iJp99FdPiUaVDDUPivbqxZulxDYqL4= 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.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM= @@ -97,8 +99,16 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/katbyte/andreyvit-diff v0.0.1 h1:2u6ofZeHrVgJjUzJ6JFlcfb3LeDq0rHxUH+WMHerELo= +github.com/katbyte/andreyvit-diff v0.0.1/go.mod h1:F6SME78YVaEk4agzLHhmsVwdVU+o/CtRnR0Bl9qBfrI= +github.com/katbyte/sergi-go-diff v1.1.1 h1:HelbPXYFHziR633zFq8QzwDY44jQ0Xy7COcLxNEWJtY= +github.com/katbyte/sergi-go-diff v1.1.1/go.mod h1:BxkLLDDB1iVQsnURErqoQMjkyXIlR0DefDKzZCUHNEw= +github.com/katbyte/terrafmt v0.5.4 h1:pL/6Ro/lAxuq4uClAxCFFHSMymdkJoZ+r0BRtktFTdk= +github.com/katbyte/terrafmt v0.5.4/go.mod h1:sgkrsKcZoOxgmoNfFrSYoxXiF+FdBEXcS/ZKfDSvc3o= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -106,6 +116,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= +github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= @@ -118,21 +130,42 @@ github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU= +github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= 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/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +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/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw= +github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= +github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= +github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI= +github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= 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= @@ -142,10 +175,24 @@ github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAh github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/vmware/go-vmware-nsxt v0.0.0-20220328155605-f49a14c1ef5f h1:NbC9yOr5At92seXK+kOr2TzU3mIWzcJOVzZasGSuwoU= github.com/vmware/go-vmware-nsxt v0.0.0-20220328155605-f49a14c1ef5f/go.mod h1:VEqcmf4Sp7gPB7z05QGyKVmn6xWppr7Nz8cVNvyC80o= +github.com/vmware/vsphere-automation-sdk-go/lib v0.7.1-0.20241113023437-5938c535c194 h1:4+nN9YcmXs8uXoKhsQpg0K8ziNTg8zULbdvc3Mu/Dk0= +github.com/vmware/vsphere-automation-sdk-go/lib v0.7.1-0.20241113023437-5938c535c194/go.mod h1:f3+6YVZpNcK2pYyiQ94BoHWmjMj9BnYav0vNFuTiDVM= +github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.1-0.20241113023437-5938c535c194 h1:4NmoWzW501ZhriPGzGULj6mJmr2Dx6QyUO9CmRbuMg0= +github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.1-0.20241113023437-5938c535c194/go.mod h1:qdzEFm2iK3dvlmm99EYYNxs70HbzuiHyENFD24Ps8fQ= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.1-0.20241113023437-5938c535c194 h1:M4/j0HbfW+pFbcpZdbg7wid3WxkIFOZRXuWNi+llXEc= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.1-0.20241113023437-5938c535c194/go.mod h1:M+J1qwzF4o7sAb/2VRu/edl1HLCdC++C4SNUrgiuGlQ= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.1-0.20241113023437-5938c535c194 h1:/+cOYJUazdOQ8sMePBcCoCnnLrQDvIvxjYYDKcdwe4Y= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.1-0.20241113023437-5938c535c194/go.mod h1:gcEvyczWPFMZX2gkBiBVpOwvUGSNXSpxU19Sx9aiouY= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.1-0.20241113023437-5938c535c194 h1:Q2jxex1UrZOMwJVJHSEyZcuWzQjsEeDpzDfc3zrtI1A= +github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.1-0.20241113023437-5938c535c194/go.mod h1:ugk9I4YM62SSAox57l5NAVBCRIkPQ1RNLb3URxyTADc= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc= github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.14.3 h1:1JXy1XroaGrzZuG6X9dt7HL6s9AwbY+l4UNL8o5B6ho= +github.com/zclconf/go-cty v1.14.3/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-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= @@ -158,6 +205,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -213,6 +262,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= 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= @@ -230,6 +281,8 @@ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh 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/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4= +gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/nsxt/data_source_nsxt_vpc_test.go b/nsxt/data_source_nsxt_vpc_test.go index cb0492c76..5731935e9 100644 --- a/nsxt/data_source_nsxt_vpc_test.go +++ b/nsxt/data_source_nsxt_vpc_test.go @@ -103,7 +103,7 @@ func testAccDataSourceNsxtVPCDeleteByName(name string) error { } for _, objInList := range objList.Results { if *objInList.DisplayName == name { - err := client.Delete(defaultOrgID, projID, *objInList.Id) + err := client.Delete(defaultOrgID, projID, *objInList.Id, nil) if err != nil { return handleDeleteError("VPC", *objInList.Id, err) } diff --git a/nsxt/resource_nsxt_vpc.go b/nsxt/resource_nsxt_vpc.go index fb9703902..4ec4a70bd 100644 --- a/nsxt/resource_nsxt_vpc.go +++ b/nsxt/resource_nsxt_vpc.go @@ -275,7 +275,7 @@ func resourceNsxtVpcDelete(d *schema.ResourceData, m interface{}) error { parents := getVpcParentsFromContext(getSessionContext(d, m)) client := clientLayer.NewVpcsClient(connector) - err := client.Delete(parents[0], parents[1], id) + err := client.Delete(parents[0], parents[1], id, nil) if err != nil { return handleDeleteError("Vpc", id, err) diff --git a/nsxt/resource_nsxt_vpc_dhcp_v4_static_binding_config_test.go b/nsxt/resource_nsxt_vpc_dhcp_v4_static_binding_config_test.go index c15e7bab8..66fdf00ae 100644 --- a/nsxt/resource_nsxt_vpc_dhcp_v4_static_binding_config_test.go +++ b/nsxt/resource_nsxt_vpc_dhcp_v4_static_binding_config_test.go @@ -207,9 +207,9 @@ resource "nsxt_vpc_subnet" "test" { ip_addresses = ["192.168.240.0/26"] access_mode = "Isolated" dhcp_config { - enable_dhcp = true - static_pool_config { - ipv4_pool_size = 32 + mode = "DHCP_SERVER" + dhcp_server_additional_config { + reserved_ip_ranges = ["192.168.240.40-192.168.240.60"] } } } diff --git a/nsxt/resource_nsxt_vpc_service_profile.go b/nsxt/resource_nsxt_vpc_service_profile.go index 29b64d47f..c7338263f 100644 --- a/nsxt/resource_nsxt_vpc_service_profile.go +++ b/nsxt/resource_nsxt_vpc_service_profile.go @@ -9,7 +9,6 @@ import ( "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/vmware/vsphere-automation-sdk-go/runtime/protocol/client" "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model" clientLayer "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects" @@ -61,32 +60,13 @@ var vpcServiceProfileSchema = map[string]*metadata.ExtendedSchema{ Required: true, Elem: &metadata.ExtendedResource{ Schema: map[string]*metadata.ExtendedSchema{ - "ntp_servers": { - Schema: schema.Schema{ - Type: schema.TypeList, - Elem: &metadata.ExtendedSchema{ - Schema: schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validateSingleIPOrHostName(), - }, - Metadata: metadata.Metadata{ - SchemaType: "string", - }, - }, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "list", - SdkFieldName: "NtpServers", - }, - }, - "dns_client_config": { + "dhcp_relay_config": { Schema: schema.Schema{ Type: schema.TypeList, MaxItems: 1, Elem: &metadata.ExtendedResource{ Schema: map[string]*metadata.ExtendedSchema{ - "dns_server_ips": { + "server_addresses": { Schema: schema.Schema{ Type: schema.TypeList, Elem: &metadata.ExtendedSchema{ @@ -101,7 +81,7 @@ var vpcServiceProfileSchema = map[string]*metadata.ExtendedSchema{ }, Metadata: metadata.Metadata{ SchemaType: "list", - SdkFieldName: "DnsServerIps", + SdkFieldName: "ServerAddresses", }, }, }, @@ -110,73 +90,68 @@ var vpcServiceProfileSchema = map[string]*metadata.ExtendedSchema{ }, Metadata: metadata.Metadata{ SchemaType: "struct", - SdkFieldName: "DnsClientConfig", - ReflectType: reflect.TypeOf(model.DnsClientConfig{}), - }, - }, - "lease_time": { - Schema: schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Default: 86400, - }, - Metadata: metadata.Metadata{ - SchemaType: "int", - SdkFieldName: "LeaseTime", - }, - }, - "mode": { - Schema: schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringInSlice(vpcServiceProfileModeValues, false), - Optional: true, - Default: model.VpcProfileDhcpConfig_MODE_SERVER, - }, - Metadata: metadata.Metadata{ - SchemaType: "string", - SdkFieldName: "Mode", + SdkFieldName: "DhcpRelayConfig", + ReflectType: reflect.TypeOf(model.VpcDhcpRelayConfig{}), }, }, - "advanced_config": { + "dhcp_server_config": { Schema: schema.Schema{ Type: schema.TypeList, MaxItems: 1, Elem: &metadata.ExtendedResource{ Schema: map[string]*metadata.ExtendedSchema{ - "is_distributed_dhcp": { + "dns_client_config": { Schema: schema.Schema{ - Type: schema.TypeBool, + Type: schema.TypeList, + MaxItems: 1, + Elem: &metadata.ExtendedResource{ + Schema: map[string]*metadata.ExtendedSchema{ + "dns_server_ips": { + Schema: schema.Schema{ + Type: schema.TypeList, + Elem: &metadata.ExtendedSchema{ + Schema: schema.Schema{ + Type: schema.TypeString, + }, + Metadata: metadata.Metadata{ + SchemaType: "string", + }, + }, + Optional: true, + }, + Metadata: metadata.Metadata{ + SchemaType: "list", + SdkFieldName: "DnsServerIps", + }, + }, + }, + }, Optional: true, - Default: true, }, Metadata: metadata.Metadata{ - SchemaType: "bool", - SdkFieldName: "IsDistributedDhcp", + SchemaType: "struct", + SdkFieldName: "DnsClientConfig", + ReflectType: reflect.TypeOf(model.DnsClientConfig{}), }, }, - }, - }, - Optional: true, - Computed: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "struct", - SdkFieldName: "AdvancedConfig", - ReflectType: reflect.TypeOf(model.VpcDhcpAdvancedConfig{}), - }, - }, - "dhcp_relay_config": { - Schema: schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Elem: &metadata.ExtendedResource{ - Schema: map[string]*metadata.ExtendedSchema{ - "server_addresses": { + "lease_time": { + Schema: schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Default: 86400, + }, + Metadata: metadata.Metadata{ + SchemaType: "int", + SdkFieldName: "LeaseTime", + }, + }, + "ntp_servers": { Schema: schema.Schema{ Type: schema.TypeList, Elem: &metadata.ExtendedSchema{ Schema: schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + ValidateFunc: validateSingleIPOrHostName(), }, Metadata: metadata.Metadata{ SchemaType: "string", @@ -186,7 +161,35 @@ var vpcServiceProfileSchema = map[string]*metadata.ExtendedSchema{ }, Metadata: metadata.Metadata{ SchemaType: "list", - SdkFieldName: "ServerAddresses", + SdkFieldName: "NtpServers", + }, + }, + "advanced_config": { + Schema: schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Elem: &metadata.ExtendedResource{ + Schema: map[string]*metadata.ExtendedSchema{ + "is_distributed_dhcp": { + Schema: schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, + Metadata: metadata.Metadata{ + SchemaType: "bool", + SdkFieldName: "IsDistributedDhcp", + }, + }, + }, + }, + Optional: true, + Computed: true, + }, + Metadata: metadata.Metadata{ + SchemaType: "struct", + SdkFieldName: "AdvancedConfig", + ReflectType: reflect.TypeOf(model.VpcDhcpAdvancedConfig{}), }, }, }, @@ -195,8 +198,8 @@ var vpcServiceProfileSchema = map[string]*metadata.ExtendedSchema{ }, Metadata: metadata.Metadata{ SchemaType: "struct", - SdkFieldName: "DhcpRelayConfig", - ReflectType: reflect.TypeOf(model.VpcDhcpRelayConfig{}), + SdkFieldName: "DhcpServerConfig", + ReflectType: reflect.TypeOf(model.VpcDhcpServerConfig{}), }, }, }, @@ -299,6 +302,11 @@ func resourceNsxtVpcServiceProfileCreate(d *schema.ResourceData, m interface{}) return err } + if obj.DhcpConfig == nil { + // NSX requires to send this struct even if empty + obj.DhcpConfig = &model.VpcProfileDhcpConfig{} + } + log.Printf("[INFO] Creating VpcServiceProfile with ID %s", id) client := clientLayer.NewVpcServiceProfilesClient(connector) @@ -368,6 +376,12 @@ func resourceNsxtVpcServiceProfileUpdate(d *schema.ResourceData, m interface{}) if err := metadata.SchemaToStruct(elem, d, vpcServiceProfileSchema, "", nil); err != nil { return err } + + if obj.DhcpConfig == nil { + // NSX requires to send this struct even if empty + obj.DhcpConfig = &model.VpcProfileDhcpConfig{} + } + client := clientLayer.NewVpcServiceProfilesClient(connector) _, err := client.Update(parents[0], parents[1], id, obj) if err != nil { diff --git a/nsxt/resource_nsxt_vpc_service_profile_test.go b/nsxt/resource_nsxt_vpc_service_profile_test.go index e4b679e70..9cdb16268 100644 --- a/nsxt/resource_nsxt_vpc_service_profile_test.go +++ b/nsxt/resource_nsxt_vpc_service_profile_test.go @@ -16,7 +16,6 @@ var accTestPolicyVpcServiceProfileCreateAttributes = map[string]string{ "description": "terraform created", "ntp_servers": "5.5.5.5", "lease_time": "50840", - "mode": "DHCP_SERVER", "dns_server_ips": "7.7.7.7", "server_addresses": "11.11.11.11", } @@ -26,7 +25,6 @@ var accTestPolicyVpcServiceProfileUpdateAttributes = map[string]string{ "description": "terraform updated", "ntp_servers": "5.5.5.7", "lease_time": "148000", - "mode": "DHCP_SERVER", "dns_server_ips": "7.7.7.2", "server_addresses": "11.11.11.111", } @@ -50,12 +48,13 @@ func TestAccResourceNsxtVpcServiceProfile_basic(t *testing.T) { resource.TestCheckResourceAttrSet(testDataSourceName, "description"), resource.TestCheckResourceAttr(testResourceName, "display_name", accTestPolicyVpcServiceProfileCreateAttributes["display_name"]), resource.TestCheckResourceAttr(testResourceName, "description", accTestPolicyVpcServiceProfileCreateAttributes["description"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.ntp_servers.0", accTestPolicyVpcServiceProfileCreateAttributes["ntp_servers"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dns_client_config.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.lease_time", accTestPolicyVpcServiceProfileCreateAttributes["lease_time"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.mode", accTestPolicyVpcServiceProfileCreateAttributes["mode"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_relay_config.#", "0"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dns_client_config.0.dns_server_ips.0", accTestPolicyVpcServiceProfileCreateAttributes["dns_server_ips"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.ntp_servers.0", accTestPolicyVpcServiceProfileCreateAttributes["ntp_servers"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.lease_time", accTestPolicyVpcServiceProfileCreateAttributes["lease_time"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.dns_client_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.dns_client_config.0.dns_server_ips.0", accTestPolicyVpcServiceProfileCreateAttributes["dns_server_ips"]), resource.TestCheckResourceAttrSet(testResourceName, "nsx_id"), resource.TestCheckResourceAttrSet(testResourceName, "path"), @@ -72,13 +71,13 @@ func TestAccResourceNsxtVpcServiceProfile_basic(t *testing.T) { resource.TestCheckResourceAttrSet(testDataSourceName, "description"), resource.TestCheckResourceAttr(testResourceName, "display_name", accTestPolicyVpcServiceProfileCreateAttributes["display_name"]), resource.TestCheckResourceAttr(testResourceName, "description", accTestPolicyVpcServiceProfileCreateAttributes["description"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.ntp_servers.0", accTestPolicyVpcServiceProfileCreateAttributes["ntp_servers"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dns_client_config.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.lease_time", accTestPolicyVpcServiceProfileCreateAttributes["lease_time"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.mode", accTestPolicyVpcServiceProfileCreateAttributes["mode"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_relay_config.#", "0"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dns_client_config.0.dns_server_ips.0", accTestPolicyVpcServiceProfileCreateAttributes["dns_server_ips"]), - + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.ntp_servers.0", accTestPolicyVpcServiceProfileCreateAttributes["ntp_servers"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.lease_time", accTestPolicyVpcServiceProfileCreateAttributes["lease_time"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.dns_client_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.dns_client_config.0.dns_server_ips.0", accTestPolicyVpcServiceProfileCreateAttributes["dns_server_ips"]), resource.TestCheckResourceAttrSet(testResourceName, "qos_profile"), resource.TestCheckResourceAttrSet(testResourceName, "spoof_guard_profile"), resource.TestCheckResourceAttrSet(testResourceName, "ip_discovery_profile"), @@ -91,18 +90,19 @@ func TestAccResourceNsxtVpcServiceProfile_basic(t *testing.T) { ), }, { + // update values, no profiles Config: testAccNsxtVpcServiceProfileTemplate(false, false), Check: resource.ComposeTestCheckFunc( testAccNsxtVpcServiceProfileExists(accTestPolicyVpcServiceProfileUpdateAttributes["display_name"], testResourceName), resource.TestCheckResourceAttr(testResourceName, "display_name", accTestPolicyVpcServiceProfileUpdateAttributes["display_name"]), resource.TestCheckResourceAttr(testResourceName, "description", accTestPolicyVpcServiceProfileUpdateAttributes["description"]), resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.ntp_servers.0", accTestPolicyVpcServiceProfileUpdateAttributes["ntp_servers"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dns_client_config.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.lease_time", accTestPolicyVpcServiceProfileUpdateAttributes["lease_time"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.mode", accTestPolicyVpcServiceProfileUpdateAttributes["mode"]), resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_relay_config.#", "0"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dns_client_config.0.dns_server_ips.0", accTestPolicyVpcServiceProfileUpdateAttributes["dns_server_ips"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.ntp_servers.0", accTestPolicyVpcServiceProfileUpdateAttributes["ntp_servers"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.lease_time", accTestPolicyVpcServiceProfileUpdateAttributes["lease_time"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.dns_client_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_config.0.dns_client_config.0.dns_server_ips.0", accTestPolicyVpcServiceProfileUpdateAttributes["dns_server_ips"]), resource.TestCheckResourceAttr(testResourceName, "qos_profile", ""), resource.TestCheckResourceAttr(testResourceName, "spoof_guard_profile", ""), @@ -115,6 +115,20 @@ func TestAccResourceNsxtVpcServiceProfile_basic(t *testing.T) { resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"), ), }, + { + Config: testAccNsxtVpcServiceProfileDhcpRelay(), + Check: resource.ComposeTestCheckFunc( + testAccNsxtVpcServiceProfileExists(accTestPolicyVpcServiceProfileCreateAttributes["display_name"], testResourceName), + resource.TestCheckResourceAttr(testResourceName, "description", ""), + resource.TestCheckResourceAttrSet(testResourceName, "nsx_id"), + resource.TestCheckResourceAttrSet(testResourceName, "path"), + resource.TestCheckResourceAttrSet(testResourceName, "revision"), + resource.TestCheckResourceAttr(testResourceName, "tag.#", "0"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_relay_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_relay_config.0.server_addresses.#", "1"), + ), + }, { Config: testAccNsxtVpcServiceProfileMinimalistic(), Check: resource.ComposeTestCheckFunc( @@ -124,6 +138,7 @@ func TestAccResourceNsxtVpcServiceProfile_basic(t *testing.T) { resource.TestCheckResourceAttrSet(testResourceName, "path"), resource.TestCheckResourceAttrSet(testResourceName, "revision"), resource.TestCheckResourceAttr(testResourceName, "tag.#", "0"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), ), }, }, @@ -256,13 +271,13 @@ resource "nsxt_vpc_service_profile" "test" { description = "%s" dhcp_config { - ntp_servers = ["%s"] - - lease_time = %s - mode = "%s" + dhcp_server_config { + ntp_servers = ["%s"] + lease_time = %s - dns_client_config { - dns_server_ips = ["%s"] + dns_client_config { + dns_server_ips = ["%s"] + } } } @@ -277,17 +292,30 @@ data "nsxt_vpc_service_profile" "test" { display_name = "%s" depends_on = [nsxt_vpc_service_profile.test] -}`, testAccNsxtProjectContext(), profileAssignment, attrMap["display_name"], attrMap["description"], attrMap["ntp_servers"], attrMap["lease_time"], attrMap["mode"], attrMap["dns_server_ips"], testAccNsxtProjectContext(), attrMap["display_name"]) +}`, testAccNsxtProjectContext(), profileAssignment, attrMap["display_name"], attrMap["description"], attrMap["ntp_servers"], attrMap["lease_time"], attrMap["dns_server_ips"], testAccNsxtProjectContext(), attrMap["display_name"]) } -func testAccNsxtVpcServiceProfileMinimalistic() string { +func testAccNsxtVpcServiceProfileDhcpRelay() string { return fmt.Sprintf(` resource "nsxt_vpc_service_profile" "test" { %s display_name = "%s" + dhcp_config { + dhcp_relay_config { + server_addresses = ["%s"] + } + } +}`, testAccNsxtProjectContext(), accTestPolicyVpcServiceProfileUpdateAttributes["display_name"], accTestPolicyVpcServiceProfileUpdateAttributes["server_addresses"]) +} + +func testAccNsxtVpcServiceProfileMinimalistic() string { + return fmt.Sprintf(` +resource "nsxt_vpc_service_profile" "test" { + %s + display_name = "%s" dhcp_config { - mode = "%s" } -}`, testAccNsxtProjectContext(), accTestPolicyVpcServiceProfileUpdateAttributes["display_name"], accTestPolicyVpcServiceProfileUpdateAttributes["mode"]) + +}`, testAccNsxtProjectContext(), accTestPolicyVpcServiceProfileUpdateAttributes["display_name"]) } diff --git a/nsxt/resource_nsxt_vpc_subnet.go b/nsxt/resource_nsxt_vpc_subnet.go index 9516f1d8a..631d24f57 100644 --- a/nsxt/resource_nsxt_vpc_subnet.go +++ b/nsxt/resource_nsxt_vpc_subnet.go @@ -33,6 +33,12 @@ var vpcSubnetConnectivityStateValues = []string{ model.SubnetAdvancedConfig_CONNECTIVITY_STATE_DISCONNECTED, } +var vpcSubnetModeValues = []string{ + model.SubnetDhcpConfig_MODE_SERVER, + model.SubnetDhcpConfig_MODE_RELAY, + model.SubnetDhcpConfig_MODE_DEACTIVATED, +} + var vpcSubnetSchema = map[string]*metadata.ExtendedSchema{ "nsx_id": metadata.GetExtendedSchema(getNsxIDSchema()), "path": metadata.GetExtendedSchema(getPathSchema()), @@ -233,6 +239,7 @@ var vpcSubnetSchema = map[string]*metadata.ExtendedSchema{ }, Optional: true, Computed: true, + ForceNew: true, }, Metadata: metadata.Metadata{ SchemaType: "list", @@ -259,209 +266,114 @@ var vpcSubnetSchema = map[string]*metadata.ExtendedSchema{ Computed: true, Elem: &metadata.ExtendedResource{ Schema: map[string]*metadata.ExtendedSchema{ - "ntp_servers": { - Schema: schema.Schema{ - Type: schema.TypeList, - Elem: &metadata.ExtendedSchema{ - Schema: schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validateSingleIPOrHostName(), - }, - Metadata: metadata.Metadata{ - SchemaType: "string", - }, - }, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "list", - SdkFieldName: "NtpServers", - }, - }, - "lease_time": { - Schema: schema.Schema{ - Type: schema.TypeInt, - Optional: true, - Default: 86400, - }, - Metadata: metadata.Metadata{ - SchemaType: "int", - SdkFieldName: "LeaseTime", - }, - }, - "dhcp_relay_config_path": { + "mode": { Schema: schema.Schema{ Type: schema.TypeString, - ValidateFunc: validatePolicyPath(), + ValidateFunc: validation.StringInSlice(vpcSubnetModeValues, false), Optional: true, + Default: model.SubnetDhcpConfig_MODE_DEACTIVATED, }, Metadata: metadata.Metadata{ SchemaType: "string", - SdkFieldName: "DhcpRelayConfigPath", - OmitIfEmpty: true, - }, - }, - "excluded_ips": { - Schema: schema.Schema{ - Type: schema.TypeList, - Elem: &metadata.ExtendedSchema{ - Schema: schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validateSingleIP(), - }, - Metadata: metadata.Metadata{ - SchemaType: "string", - }, - }, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "list", - SdkFieldName: "ExcludedIps", - }, - }, - "dns_client_config": { - Schema: schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Elem: &metadata.ExtendedResource{ - Schema: map[string]*metadata.ExtendedSchema{ - "dns_server_ips": { - Schema: schema.Schema{ - Type: schema.TypeList, - Elem: &metadata.ExtendedSchema{ - Schema: schema.Schema{ - Type: schema.TypeString, - }, - Metadata: metadata.Metadata{ - SchemaType: "string", - }, - }, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "list", - SdkFieldName: "DnsServerIps", - }, - }, - }, - }, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "struct", - SdkFieldName: "DnsClientConfig", - ReflectType: reflect.TypeOf(model.DnsClientConfig{}), - }, - }, - "enable_dhcp": { - Schema: schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Computed: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "bool", - SdkFieldName: "EnableDhcp", - }, - }, - "static_pool_config": { - Schema: schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Elem: &metadata.ExtendedResource{ - Schema: map[string]*metadata.ExtendedSchema{ - "ipv4_pool_size": { - Schema: schema.Schema{ - Type: schema.TypeInt, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "int", - SdkFieldName: "Ipv4PoolSize", - }, - }, - }, - }, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "struct", - SdkFieldName: "StaticPoolConfig", - ReflectType: reflect.TypeOf(model.StaticPoolConfig{}), + SdkFieldName: "Mode", }, }, - "dhcp_relay_config": { + "dhcp_server_additional_config": { Schema: schema.Schema{ Type: schema.TypeList, MaxItems: 1, Elem: &metadata.ExtendedResource{ Schema: map[string]*metadata.ExtendedSchema{ - "server_addresses": { - Schema: schema.Schema{ - Type: schema.TypeList, - Elem: &metadata.ExtendedSchema{ - Schema: schema.Schema{ - Type: schema.TypeString, - }, - Metadata: metadata.Metadata{ - SchemaType: "string", - }, - }, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "list", - SdkFieldName: "ServerAddresses", - }, - }, - }, - }, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "struct", - SdkFieldName: "DhcpRelayConfig", - ReflectType: reflect.TypeOf(model.VpcDhcpRelayConfig{}), - }, - }, - "options": { - Schema: schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Elem: &metadata.ExtendedResource{ - Schema: map[string]*metadata.ExtendedSchema{ - "option121": { + "options": { Schema: schema.Schema{ Type: schema.TypeList, MaxItems: 1, Elem: &metadata.ExtendedResource{ Schema: map[string]*metadata.ExtendedSchema{ - "static_route": { + "option121": { + Schema: schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Elem: &metadata.ExtendedResource{ + Schema: map[string]*metadata.ExtendedSchema{ + "static_route": { + Schema: schema.Schema{ + Type: schema.TypeList, + Elem: &metadata.ExtendedResource{ + Schema: map[string]*metadata.ExtendedSchema{ + "next_hop": { + Schema: schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validateSingleIP(), + Optional: true, + }, + Metadata: metadata.Metadata{ + SchemaType: "string", + SdkFieldName: "NextHop", + }, + }, + "network": { + Schema: schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validateCidrOrIPOrRange(), + Optional: true, + }, + Metadata: metadata.Metadata{ + SchemaType: "string", + SdkFieldName: "Network", + }, + }, + }, + }, + Optional: true, + }, + Metadata: metadata.Metadata{ + SchemaType: "list", + SdkFieldName: "StaticRoutes", + ReflectType: reflect.TypeOf(model.ClasslessStaticRoute{}), + }, + }, + }, + }, + Optional: true, + }, + Metadata: metadata.Metadata{ + SchemaType: "struct", + SdkFieldName: "Option121", + ReflectType: reflect.TypeOf(model.DhcpOption121{}), + }, + }, + "other": { Schema: schema.Schema{ Type: schema.TypeList, Elem: &metadata.ExtendedResource{ Schema: map[string]*metadata.ExtendedSchema{ - "next_hop": { + "code": { Schema: schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validateSingleIP(), - Optional: true, + Type: schema.TypeInt, + Optional: true, }, Metadata: metadata.Metadata{ - SchemaType: "string", - SdkFieldName: "NextHop", + SchemaType: "int", + SdkFieldName: "Code", }, }, - "network": { + "values": { Schema: schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validateCidrOrIPOrRange(), - Optional: true, + Type: schema.TypeList, + Elem: &metadata.ExtendedSchema{ + Schema: schema.Schema{ + Type: schema.TypeString, + }, + Metadata: metadata.Metadata{ + SchemaType: "string", + }, + }, + Optional: true, }, Metadata: metadata.Metadata{ - SchemaType: "string", - SdkFieldName: "Network", + SchemaType: "list", + SdkFieldName: "Values", }, }, }, @@ -470,8 +382,8 @@ var vpcSubnetSchema = map[string]*metadata.ExtendedSchema{ }, Metadata: metadata.Metadata{ SchemaType: "list", - SdkFieldName: "StaticRoutes", - ReflectType: reflect.TypeOf(model.ClasslessStaticRoute{}), + SdkFieldName: "Others", + ReflectType: reflect.TypeOf(model.GenericDhcpOption{}), }, }, }, @@ -480,61 +392,37 @@ var vpcSubnetSchema = map[string]*metadata.ExtendedSchema{ }, Metadata: metadata.Metadata{ SchemaType: "struct", - SdkFieldName: "Option121", - ReflectType: reflect.TypeOf(model.DhcpOption121{}), + SdkFieldName: "Options", + ReflectType: reflect.TypeOf(model.DhcpV4Options{}), }, }, - "other": { + "reserved_ip_ranges": { Schema: schema.Schema{ Type: schema.TypeList, - Elem: &metadata.ExtendedResource{ - Schema: map[string]*metadata.ExtendedSchema{ - "code": { - Schema: schema.Schema{ - Type: schema.TypeInt, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "int", - SdkFieldName: "Code", - }, - }, - "values": { - Schema: schema.Schema{ - Type: schema.TypeList, - Elem: &metadata.ExtendedSchema{ - Schema: schema.Schema{ - Type: schema.TypeString, - }, - Metadata: metadata.Metadata{ - SchemaType: "string", - }, - }, - Optional: true, - }, - Metadata: metadata.Metadata{ - SchemaType: "list", - SdkFieldName: "Values", - }, - }, + Elem: &metadata.ExtendedSchema{ + Schema: schema.Schema{ + Type: schema.TypeString, + }, + Metadata: metadata.Metadata{ + SchemaType: "string", }, }, Optional: true, }, Metadata: metadata.Metadata{ SchemaType: "list", - SdkFieldName: "Others", - ReflectType: reflect.TypeOf(model.GenericDhcpOption{}), + SdkFieldName: "ReservedIpRanges", }, }, }, }, Optional: true, + Computed: true, }, Metadata: metadata.Metadata{ SchemaType: "struct", - SdkFieldName: "Options", - ReflectType: reflect.TypeOf(model.DhcpV4Options{}), + SdkFieldName: "DhcpServerAdditionalConfig", + ReflectType: reflect.TypeOf(model.DhcpServerAdditionalConfig{}), }, }, }, @@ -543,8 +431,10 @@ var vpcSubnetSchema = map[string]*metadata.ExtendedSchema{ }, Metadata: metadata.Metadata{ SchemaType: "struct", - SdkFieldName: "DhcpConfig", - ReflectType: reflect.TypeOf(model.VpcSubnetDhcpConfig{}), + // Note that SubnetDhcpConfig is populated here (rather than the alernative VpcSubnetDhcpConfig) + // This is the recommended way to configure DHCP + SdkFieldName: "SubnetDhcpConfig", + ReflectType: reflect.TypeOf(model.SubnetDhcpConfig{}), }, }, } @@ -586,6 +476,10 @@ func resourceNsxtVpcSubnetCreate(d *schema.ResourceData, m interface{}) error { return err } + if err = validateDhcpConfig(d); err != nil { + return err + } + parents := getVpcParentsFromContext(getSessionContext(d, m)) displayName := d.Get("display_name").(string) description := d.Get("description").(string) @@ -615,6 +509,31 @@ func resourceNsxtVpcSubnetCreate(d *schema.ResourceData, m interface{}) error { return resourceNsxtVpcSubnetRead(d, m) } +func validateDhcpConfig(d *schema.ResourceData) error { + dhcpConfig, ok := d.GetOk("dhcp_config") + if !ok { + return nil + } + + configList := dhcpConfig.([]interface{}) + if len(configList) == 0 { + return nil + } + + config := configList[0].(map[string]interface{}) + + if config["mode"].(string) == model.SubnetDhcpConfig_MODE_RELAY { + if ac, ok := config["dhcp_server_additional_config"]; ok { + advancedConfig := ac.([]interface{}) + if len(advancedConfig) > 0 { + return fmt.Errorf("dhcp_server_additional_config can not be specified with DHCP_RELAY mode") + } + } + } + + return nil +} + func resourceNsxtVpcSubnetRead(d *schema.ResourceData, m interface{}) error { connector := getPolicyConnector(m) @@ -653,6 +572,10 @@ func resourceNsxtVpcSubnetUpdate(d *schema.ResourceData, m interface{}) error { return fmt.Errorf("Error obtaining VpcSubnet ID") } + if err := validateDhcpConfig(d); err != nil { + return err + } + parents := getVpcParentsFromContext(getSessionContext(d, m)) description := d.Get("description").(string) displayName := d.Get("display_name").(string) @@ -671,6 +594,14 @@ func resourceNsxtVpcSubnetUpdate(d *schema.ResourceData, m interface{}) error { if err := metadata.SchemaToStruct(elem, d, vpcSubnetSchema, "", nil); err != nil { return err } + + // Since dhcp block is Computed (sent back by NSX even if not specified), we need to + // explicitly clear out additional DHCP config in case of DHCP RELAY mode, otherwise + // NSX throws an error + if (obj.SubnetDhcpConfig != nil) && (obj.SubnetDhcpConfig.Mode != nil && *obj.SubnetDhcpConfig.Mode == model.SubnetDhcpConfig_MODE_RELAY) { + obj.SubnetDhcpConfig.DhcpServerAdditionalConfig = nil + } + client := clientLayer.NewSubnetsClient(connector) _, err := client.Update(parents[0], parents[1], parents[2], id, obj) if err != nil { diff --git a/nsxt/resource_nsxt_vpc_subnet_test.go b/nsxt/resource_nsxt_vpc_subnet_test.go index e8f266600..2f5795341 100644 --- a/nsxt/resource_nsxt_vpc_subnet_test.go +++ b/nsxt/resource_nsxt_vpc_subnet_test.go @@ -11,31 +11,24 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -// TODO - change lease_time to non-default value when platform bug is fixed var accTestVpcSubnetCreateAttributes = map[string]string{ - "display_name": getAccTestResourceName(), - "description": "terraform created", - "access_mode": "Isolated", - "enabled": "true", - "enable_dhcp": "true", - "ipv4_subnet_size": "32", - "ip_addresses": "192.168.240.0/26", - "ntp_servers": "192.168.4.14", - "lease_time": "86400", - "excluded_ips": "2.2.2.2", + "display_name": getAccTestResourceName(), + "description": "terraform created", + "access_mode": "Isolated", + "enabled": "true", + "ipv4_subnet_size": "32", + "ip_addresses": "192.168.240.0/26", + "reserved_ip_ranges": "11.11.50.7", } var accTestVpcSubnetUpdateAttributes = map[string]string{ - "display_name": getAccTestResourceName(), - "description": "terraform updated", - "access_mode": "Isolated", - "enabled": "true", - "enable_dhcp": "true", - "ipv4_subnet_size": "32", - "ip_addresses": "192.168.240.0/26", - "ntp_servers": "192.168.4.15", - "lease_time": "86400", - "excluded_ips": "2.2.2.3", + "display_name": getAccTestResourceName(), + "description": "terraform updated", + "access_mode": "Isolated", + "enabled": "true", + "ipv4_subnet_size": "32", + "ip_addresses": "192.168.240.0/26", + "reserved_ip_ranges": "11.11.50.4-11.11.50.6", } func TestAccResourceNsxtVpcSubnet_basic(t *testing.T) { @@ -60,7 +53,7 @@ func TestAccResourceNsxtVpcSubnet_basic(t *testing.T) { resource.TestCheckResourceAttr(testResourceName, "ip_addresses.0", accTestVpcSubnetCreateAttributes["ip_addresses"]), resource.TestCheckResourceAttr(testResourceName, "access_mode", accTestVpcSubnetCreateAttributes["access_mode"]), resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.enable_dhcp", accTestVpcSubnetCreateAttributes["enable_dhcp"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.mode", "DHCP_DEACTIVATED"), resource.TestCheckResourceAttrSet(testResourceName, "nsx_id"), resource.TestCheckResourceAttrSet(testResourceName, "path"), @@ -74,10 +67,10 @@ func TestAccResourceNsxtVpcSubnet_basic(t *testing.T) { testAccNsxtVpcSubnetExists(accTestVpcSubnetUpdateAttributes["display_name"], testResourceName), resource.TestCheckResourceAttr(testResourceName, "display_name", accTestVpcSubnetUpdateAttributes["display_name"]), resource.TestCheckResourceAttr(testResourceName, "description", accTestVpcSubnetUpdateAttributes["description"]), - resource.TestCheckResourceAttr(testResourceName, "ip_addresses.0", accTestVpcSubnetCreateAttributes["ip_addresses"]), + resource.TestCheckResourceAttr(testResourceName, "ip_addresses.0", accTestVpcSubnetUpdateAttributes["ip_addresses"]), resource.TestCheckResourceAttr(testResourceName, "access_mode", accTestVpcSubnetUpdateAttributes["access_mode"]), resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.enable_dhcp", accTestVpcSubnetUpdateAttributes["enable_dhcp"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.mode", "DHCP_DEACTIVATED"), resource.TestCheckResourceAttrSet(testResourceName, "nsx_id"), resource.TestCheckResourceAttrSet(testResourceName, "path"), @@ -86,7 +79,7 @@ func TestAccResourceNsxtVpcSubnet_basic(t *testing.T) { ), }, { - Config: testAccNsxtVpcSubnetMinimalistic(), + Config: testAccNsxtVpcSubnetMinimalisticIsolated(), Check: resource.ComposeTestCheckFunc( testAccNsxtVpcSubnetExists(accTestVpcSubnetCreateAttributes["display_name"], testResourceName), resource.TestCheckResourceAttr(testResourceName, "description", ""), @@ -122,15 +115,12 @@ func TestAccResourceNsxtVpcSubnet_subnetSize(t *testing.T) { resource.TestCheckResourceAttr(testResourceName, "ipv4_subnet_size", accTestVpcSubnetCreateAttributes["ipv4_subnet_size"]), resource.TestCheckResourceAttr(testResourceName, "ip_addresses.#", "1"), resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.enable_dhcp", "true"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.ntp_servers.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.ntp_servers.0", accTestVpcSubnetCreateAttributes["ntp_servers"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.lease_time", accTestVpcSubnetCreateAttributes["lease_time"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.excluded_ips.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.excluded_ips.0", accTestVpcSubnetCreateAttributes["excluded_ips"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.options.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.options.0.option121.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.options.0.other.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.reserved_ip_ranges.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.reserved_ip_ranges.0", accTestVpcSubnetCreateAttributes["reserved_ip_ranges"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.options.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.options.0.option121.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.options.0.other.#", "1"), resource.TestCheckResourceAttrSet(testResourceName, "nsx_id"), resource.TestCheckResourceAttrSet(testResourceName, "path"), @@ -147,15 +137,12 @@ func TestAccResourceNsxtVpcSubnet_subnetSize(t *testing.T) { resource.TestCheckResourceAttr(testResourceName, "ip_addresses.#", "1"), resource.TestCheckResourceAttr(testResourceName, "ipv4_subnet_size", accTestVpcSubnetCreateAttributes["ipv4_subnet_size"]), resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.enable_dhcp", "true"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.ntp_servers.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.ntp_servers.0", accTestVpcSubnetUpdateAttributes["ntp_servers"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.lease_time", accTestVpcSubnetUpdateAttributes["lease_time"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.excluded_ips.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.excluded_ips.0", accTestVpcSubnetUpdateAttributes["excluded_ips"]), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.options.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.options.0.option121.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.options.0.other.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.reserved_ip_ranges.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.reserved_ip_ranges.0", accTestVpcSubnetUpdateAttributes["reserved_ip_ranges"]), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.options.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.options.0.option121.#", "1"), + resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.dhcp_server_additional_config.0.options.0.other.#", "1"), resource.TestCheckResourceAttrSet(testResourceName, "nsx_id"), resource.TestCheckResourceAttrSet(testResourceName, "path"), @@ -164,7 +151,7 @@ func TestAccResourceNsxtVpcSubnet_subnetSize(t *testing.T) { ), }, { - Config: testAccNsxtVpcSubnetMinimalistic(), + Config: testAccNsxtVpcSubnetMinimalisticPublic(), Check: resource.ComposeTestCheckFunc( testAccNsxtVpcSubnetExists(accTestVpcSubnetCreateAttributes["display_name"], testResourceName), resource.TestCheckResourceAttr(testResourceName, "description", ""), @@ -173,7 +160,6 @@ func TestAccResourceNsxtVpcSubnet_subnetSize(t *testing.T) { resource.TestCheckResourceAttrSet(testResourceName, "revision"), resource.TestCheckResourceAttr(testResourceName, "tag.#", "0"), resource.TestCheckResourceAttr(testResourceName, "dhcp_config.#", "1"), - resource.TestCheckResourceAttr(testResourceName, "dhcp_config.0.options.#", "0"), ), }, }, @@ -195,7 +181,7 @@ func TestAccResourceNsxtVpcSubnet_importBasic(t *testing.T) { }, Steps: []resource.TestStep{ { - Config: testAccNsxtVpcSubnetMinimalistic(), + Config: testAccNsxtVpcSubnetMinimalisticIsolated(), }, { ResourceName: testResourceName, @@ -272,14 +258,14 @@ resource "nsxt_vpc_subnet" "test" { ip_addresses = ["%s"] access_mode = "%s" dhcp_config { - enable_dhcp = %s + mode = "DHCP_DEACTIVATED" } tag { scope = "scope1" tag = "tag1" } -}`, testAccNsxtPolicyMultitenancyContext(), attrMap["display_name"], attrMap["description"], attrMap["ip_addresses"], attrMap["access_mode"], attrMap["enable_dhcp"]) +}`, testAccNsxtPolicyMultitenancyContext(), attrMap["display_name"], attrMap["description"], attrMap["ip_addresses"], attrMap["access_mode"]) } func testAccNsxtVpcSubnetSizeTemplate(createFlow bool) string { @@ -300,31 +286,42 @@ resource "nsxt_vpc_subnet" "test" { access_mode = "Public" dhcp_config { - enable_dhcp = true - ntp_servers = ["%s"] - lease_time = %s - excluded_ips = ["%s"] - - options { - option121 { - static_route { - network = "2.1.1.0/24" - next_hop = "2.3.1.3" + mode = "DHCP_SERVER" + + dhcp_server_additional_config { + options { + option121 { + static_route { + network = "2.1.1.0/24" + next_hop = "2.3.1.3" + } + } + other { + code = "119" + values = ["abc", "def"] } } - other { - code = "119" - values = ["abc", "def"] - } + reserved_ip_ranges = ["%s"] } } -}`, testAccNsxtPolicyMultitenancyContext(), attrMap["display_name"], attrMap["description"], attrMap["ipv4_subnet_size"], attrMap["ntp_servers"], attrMap["lease_time"], attrMap["excluded_ips"]) +}`, testAccNsxtPolicyMultitenancyContext(), attrMap["display_name"], attrMap["description"], attrMap["ipv4_subnet_size"], attrMap["reserved_ip_ranges"]) +} + +func testAccNsxtVpcSubnetMinimalisticIsolated() string { + return fmt.Sprintf(` +resource "nsxt_vpc_subnet" "test" { +%s + display_name = "%s" + ip_addresses = ["%s"] + access_mode = "Isolated" +}`, testAccNsxtPolicyMultitenancyContext(), accTestVpcSubnetUpdateAttributes["display_name"], accTestVpcSubnetUpdateAttributes["ip_addresses"]) } -func testAccNsxtVpcSubnetMinimalistic() string { +func testAccNsxtVpcSubnetMinimalisticPublic() string { return fmt.Sprintf(` resource "nsxt_vpc_subnet" "test" { %s display_name = "%s" + access_mode = "Public" }`, testAccNsxtPolicyMultitenancyContext(), accTestVpcSubnetUpdateAttributes["display_name"]) } diff --git a/nsxt/resource_nsxt_vpc_test.go b/nsxt/resource_nsxt_vpc_test.go index b954bd515..45c4aa52f 100644 --- a/nsxt/resource_nsxt_vpc_test.go +++ b/nsxt/resource_nsxt_vpc_test.go @@ -196,7 +196,9 @@ resource "nsxt_vpc_service_profile" "test" { %s display_name = "%s" dhcp_config { - mode = "DHCP_SERVER" + dhcp_server_config { + lease_time = 15600 + } } } diff --git a/website/docs/r/vpc_service_profile.html.markdown b/website/docs/r/vpc_service_profile.html.markdown index 929b7303a..9d4e75f1b 100644 --- a/website/docs/r/vpc_service_profile.html.markdown +++ b/website/docs/r/vpc_service_profile.html.markdown @@ -32,17 +32,17 @@ resource "nsxt_vpc_service_profile" "vpc1_service_profile" { qos_profile = nsxt_policy_qos_profile.for_vpc1.path dhcp_config { - ntp_servers = ["20.2.60.5"] + dhcp_server_config { + ntp_servers = ["20.2.60.5"] + lease_time = 50840 - lease_time = 50840 - mode = "DHCP_SERVER" + dns_client_config { + dns_server_ips = ["10.204.2.20"] + } - dns_client_config { - dns_server_ips = ["10.204.2.20"] - } - - advanced_config { - is_distributed_dhcp = false + advanced_config { + is_distributed_dhcp = false + } } } } @@ -64,18 +64,17 @@ The following arguments are supported: * `security_profile` - (Optional) Policy path for Security Profile * `qos_profile` - (Optional) Policy path for QoS profile * `dhcp_config` - (Required) DHCP configuration for this profile - * `ntp_servers` - (Optional) List of NTP servers - * `dns_client_config` - (Optional) DNS Client configuration - * `dns_server_ips` - (Optional) List of IP addresses of the DNS servers which need to be configured on the workload VMs - * `lease_time` - (Optional) DHCP lease time in seconds. - * `mode` - (Optional) DHCP mode of the VPC Profile DHCP Config. Possible values are `DHCP_SERVER`, `DHCP_RELAY`, `DHCP_DEACTIVATED`. Default is `DHCP_SERVER`. + * `dhcp_server_config` - (Optionl) DHCP server configuration for this profile + * `ntp_servers` - (Optional) List of NTP servers + * `dns_client_config` - (Optional) DNS Client configuration + * `dns_server_ips` - (Optional) List of IP addresses of the DNS servers which need to be configured on the workload VMs + * `lease_time` - (Optional) DHCP lease time in seconds. + * `advanced_config` - (Optional) VPC DHCP advanced configuration + * `is_distributed_dhcp` - DHCP server's IP allocation model based on workloads subnet port id. Can be `false` only when Edge cluster is available, in + which case edge cluster in VPC connectivity profile must be configured. This is the traditional DHCP server that dynamically allocates IP per VM's MAC. + If value is `true`, edge cluster will not be required. This is a DHCP server that dynamically assigns IP per VM port. * `dhcp_relay_config` - (Optional) DHCP Relay configuration * `server_addresses` - (Optional) List of DHCP server IP addresses for DHCP relay configuration. Both IPv4 and IPv6 addresses are supported. - * `advanced_config` - (Optional) VPC DHCP advanced configuration - * `is_distributed_dhcp` - DHCP server's IP allocation model based on workloads subnet port id. It is applicable when DHCP mode is DHCP_SERVER. - Value of this field can be False only when Edge cluster is available. If value is False, edge cluster in VPC connectivity profile must be - configured for this mode. This is the traditional DHCP server that dynamically allocates IP per VM's MAC. - If value is True, edge cluster will not be required for this mode. This is a DHCP server that dynamically assigns IP per VM port." ## Attributes Reference diff --git a/website/docs/r/vpc_subnet.html.markdown b/website/docs/r/vpc_subnet.html.markdown index 6a4d7ecb9..14cdc764e 100644 --- a/website/docs/r/vpc_subnet.html.markdown +++ b/website/docs/r/vpc_subnet.html.markdown @@ -40,6 +40,9 @@ resource "nsxt_vpc_subnet" "test" { } ``` +~> **NOTE:** In some cases, subnet creation will depend on VPC attachment. If both resources are being created within same apply, + explicit `depends_on` meta argument needs to be added to enforce this dependency. + ## Argument Reference The following arguments are supported: @@ -65,24 +68,19 @@ The following arguments are supported: * `key` - (Required) key for vendor-specific configuration * `value` - (Required) value for vendor-specific configuration * `dhcp_config` - (Optional) DHCP configuration block - * `ntp_servers` - (Optional) List of NTP server IP addresses - * `dhcp_relay_config_path` - (Optional) Policy path of DHCP-relay-config. If configured then all the subnets will be - configured with the DHCP relay server. - If not specified, then the local DHCP server will be configured for all connected subnets. - * `dns_client_config` - (Optional) DHCP Client configuration block - * `dns_server_ips` - (Optional) IPs of the DNS servers which need to be configured on the workload VMs - * `enable_dhcp` - (Optional) If activated, the DHCP server will be configured based on IP address type. - * `static_pool_config` - (Optional) Static pool configuration block - * `ipv4_pool_size` - (Optional) Number of IPs to be reserved in static ip pool. - * `excluded_ips` - (Optional) List of excluded IP addresses - * `options` - (Optional) DHCPv4 options block - * `option121` - (Optional) Specification for DHCP option 121 - * `static_route` - (Optional) Static route - * `network` - (Optional) Destination network in CIDR format - * `next_hop` - (Optional) IP Address for next hop of the route - * `other` - (Optional) DHCP option in generic format - * `code` - (Optional) Code of DHCP option - * `values` - (Optional) List of values in string format + * `mode` - (Optional) The operational mode of DHCP within the subnet, can be one of `DHCP_SERVER`, `DHCP_RELAY`, `DHCP_DEACTIVATED`. + Default is `DHCP_DEACTIVATED` + * `dhcp_server_additional_config` - (Optional) Additional DHCP server config + * `options` - (Optional) DHCPv4 options block + * `option121` - (Optional) Specification for DHCP option 121 + * `static_route` - (Optional) Static route + * `network` - (Optional) Destination network in CIDR format + * `next_hop` - (Optional) IP Address for next hop of the route + * `other` - (Optional) DHCP option in generic format + * `code` - (Optional) Code of DHCP option + * `values` - (Optional) List of values in string format + * `reserved_ip_ranges` - (Optional) Specifies IP ranges that are reserved and excluded from being assigned by the DHCP server to clients. + This is a list of IP ranges or IP addresses. * `ip_blocks` - (Optional) List of IP block path for subnet IP allocation ## Attributes Reference