From 1d43615b6eb48ad9d966f86a327871004662c9bf Mon Sep 17 00:00:00 2001 From: ajay-malhotra1 Date: Mon, 11 Oct 2021 19:57:12 -0700 Subject: [PATCH 1/3] feat: implement the changes to enable/update the BFD config for the Directlink gateways * allow the user to add bfd_interval and bfd_multiplier for BFD configuration * show the status, interval, multiplier and bfd status updated at for Directlink Gateways --- go.mod | 2 +- go.sum | 15 +- ibm/data_source_ibm_dl_gateway.go | 39 ++++++ ibm/data_source_ibm_dl_gateways.go | 40 ++++++ ibm/resource_ibm_dl_gateway.go | 169 ++++++++++++++++++----- website/docs/d/dl_gateway.html.markdown | 4 + website/docs/d/dl_gateways.html.markdown | 4 + website/docs/r/dl_gateway.html.markdown | 2 + 8 files changed, 230 insertions(+), 45 deletions(-) diff --git a/go.mod b/go.mod index ef52a65b94..45b1c07f09 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/IBM/ibm-cos-sdk-go-config v1.2.0 github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20210723145459-a232c3f3ac91 github.com/IBM/keyprotect-go-client v0.7.0 - github.com/IBM/networking-go-sdk v0.20.0 + github.com/IBM/networking-go-sdk v0.23.0 github.com/IBM/platform-services-go-sdk v0.19.3 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk v1.2.0 diff --git a/go.sum b/go.sum index 1c891526a8..36c39a8d29 100644 --- a/go.sum +++ b/go.sum @@ -67,7 +67,6 @@ github.com/IBM/go-sdk-core/v5 v5.0.0/go.mod h1:vyNdbFujJtdTj9HbihtvKwwS3k/GKSKpO github.com/IBM/go-sdk-core/v5 v5.0.3/go.mod h1:vyNdbFujJtdTj9HbihtvKwwS3k/GKSKpOx9ZIQ6MWDY= github.com/IBM/go-sdk-core/v5 v5.1.0/go.mod h1:vyNdbFujJtdTj9HbihtvKwwS3k/GKSKpOx9ZIQ6MWDY= github.com/IBM/go-sdk-core/v5 v5.4.5/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723y8GsfLV8e0= -github.com/IBM/go-sdk-core/v5 v5.5.1 h1:Hb4xB1BL8L6uCnskIqSCxF9wLfOmj4+sVzM5vFtuhs4= github.com/IBM/go-sdk-core/v5 v5.5.1/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723y8GsfLV8e0= github.com/IBM/go-sdk-core/v5 v5.6.3 h1:xj44tzfBnjGJXKthMeaIn9wcYH+z4dXTuhntsBp+NdQ= github.com/IBM/go-sdk-core/v5 v5.6.3/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3btdruJaoUeek= @@ -80,8 +79,8 @@ github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20210723145459-a232c3f3ac91 h1:8ICDvg7YM+ github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20210723145459-a232c3f3ac91/go.mod h1:M2JyuyeWHPtgGNeezr6YqVRuaav2MpY8Ha4QrEYvMoI= github.com/IBM/keyprotect-go-client v0.7.0 h1:JstSHD14Lp6ihwQseyPuGcs1AjOBjAmcisP0dTBA6A0= github.com/IBM/keyprotect-go-client v0.7.0/go.mod h1:SVr2ylV/fhSQPDiUjWirN9fsyWFCNNbt8GIT8hPJVjE= -github.com/IBM/networking-go-sdk v0.20.0 h1:DSqjcNNyWSOiett7aM0sTbPhNgcnLgC8cc+VQ5ZJFXA= -github.com/IBM/networking-go-sdk v0.20.0/go.mod h1:nViqUm1Bv+ke8dyOhjQ6e+2U1XeqZX2y4bQbR8Od3Hc= +github.com/IBM/networking-go-sdk v0.23.0 h1:11ud+f0P6SMRuZ/JprGl1H+TqCwDvjpciQVS6xNU77o= +github.com/IBM/networking-go-sdk v0.23.0/go.mod h1:nViqUm1Bv+ke8dyOhjQ6e+2U1XeqZX2y4bQbR8Od3Hc= github.com/IBM/platform-services-go-sdk v0.19.3 h1:lB8Xsnhwt82z2i2AI4GBb2Tdxn3TuveAsjwk7p6R/sY= github.com/IBM/platform-services-go-sdk v0.19.3/go.mod h1:E9HQN/MKeVqo3IRmfcCMw9/yq/QHmRvb/4FzxXQsfOk= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4= @@ -125,7 +124,6 @@ github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/apache/openwhisk-client-go v0.0.0-20200201143223-a804fb82d105 h1:k1wP1gZMrNJeXTz6a+3010NKC/ZvSffk07BzrLmYrmc= github.com/apache/openwhisk-client-go v0.0.0-20200201143223-a804fb82d105/go.mod h1:jLLKYP7+1+LFlIJW1n9U1gqeveLM1HIwa4ZHNOFxjPw= @@ -141,7 +139,6 @@ github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJE 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/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= @@ -193,11 +190,9 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/form3tech-oss/jwt-go v3.2.1+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c= github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= @@ -208,7 +203,6 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= @@ -217,7 +211,6 @@ github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4u 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 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8= 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= @@ -418,9 +411,7 @@ github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= @@ -555,7 +546,6 @@ github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= -github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= 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.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= @@ -594,7 +584,6 @@ github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/nicksnyder/go-i18n v1.10.0 h1:5AzlPKvXBH4qBzmZ09Ua9Gipyruv6uApMcrNZdo96+Q= github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q= diff --git a/ibm/data_source_ibm_dl_gateway.go b/ibm/data_source_ibm_dl_gateway.go index c5d8a0acc1..c31ab59455 100644 --- a/ibm/data_source_ibm_dl_gateway.go +++ b/ibm/data_source_ibm_dl_gateway.go @@ -78,6 +78,26 @@ func dataSourceIBMDLGateway() *schema.Resource { Computed: true, Description: "BGP MD5 authentication key", }, + dlBfdInterval: { + Type: schema.TypeInt, + Computed: true, + Description: "BFD Interval", + }, + dlBfdMultiplier: { + Type: schema.TypeInt, + Computed: true, + Description: "BFD Multiplier", + }, + dlBfdStatus: { + Type: schema.TypeString, + Computed: true, + Description: "BFD Status", + }, + dlBfdStatusUpdatedAt: { + Type: schema.TypeString, + Computed: true, + Description: "BFD Status", + }, dlBgpAsn: { Type: schema.TypeInt, Computed: true, @@ -405,6 +425,25 @@ func dataSourceIBMDLGatewayRead(d *schema.ResourceData, meta interface{}) error if instance.CreatedAt != nil { d.Set(dlCreatedAt, instance.CreatedAt.String()) } + + //Show the BFD Config parameters if set + if instance.BfdConfig != nil { + if instance.BfdConfig.Interval != nil { + d.Set(dlBfdInterval, *instance.BfdConfig.Interval) + } + + if instance.BfdConfig.Multiplier != nil { + d.Set(dlBfdMultiplier, *instance.BfdConfig.Multiplier) + } + + if instance.BfdConfig.BfdStatus != nil { + d.Set(dlBfdStatus, *instance.BfdConfig.BfdStatus) + } + + if instance.BfdConfig.BfdStatusUpdatedAt != nil { + d.Set(dlBfdStatusUpdatedAt, instance.BfdConfig.BfdStatusUpdatedAt.String()) + } + } dtype := *instance.Type if dtype == "dedicated" { if instance.MacsecConfig != nil { diff --git a/ibm/data_source_ibm_dl_gateways.go b/ibm/data_source_ibm_dl_gateways.go index c455597b55..896db3cc02 100644 --- a/ibm/data_source_ibm_dl_gateways.go +++ b/ibm/data_source_ibm_dl_gateways.go @@ -36,6 +36,26 @@ func dataSourceIBMDLGateways() *schema.Resource { Computed: true, Description: "BGP MD5 authentication key", }, + dlBfdInterval: { + Type: schema.TypeInt, + Computed: true, + Description: "BFD Interval", + }, + dlBfdMultiplier: { + Type: schema.TypeInt, + Computed: true, + Description: "BFD Multiplier", + }, + dlBfdStatus: { + Type: schema.TypeString, + Computed: true, + Description: "BFD Status", + }, + dlBfdStatusUpdatedAt: { + Type: schema.TypeString, + Computed: true, + Description: "BFD Status", + }, dlBgpAsn: { Type: schema.TypeInt, Computed: true, @@ -322,6 +342,26 @@ func dataSourceIBMDLGatewaysRead(d *schema.ResourceData, meta interface{}) error rg := instance.ResourceGroup gateway[dlResourceGroup] = *rg.ID } + + //Show the BFD Config parameters if set + if instance.BfdConfig != nil { + if instance.BfdConfig.Interval != nil { + gateway[dlBfdInterval] = *instance.BfdConfig.Interval + } + + if instance.BfdConfig.Multiplier != nil { + gateway[dlBfdMultiplier] = *instance.BfdConfig.Multiplier + } + + if instance.BfdConfig.BfdStatus != nil { + gateway[dlBfdStatus] = *instance.BfdConfig.BfdStatus + } + + if instance.BfdConfig.BfdStatusUpdatedAt != nil { + gateway[dlBfdStatusUpdatedAt] = instance.BfdConfig.BfdStatusUpdatedAt.String() + } + } + dtype := *instance.Type if dtype == "dedicated" { if instance.MacsecConfig != nil { diff --git a/ibm/resource_ibm_dl_gateway.go b/ibm/resource_ibm_dl_gateway.go index 137e800c70..68a36b24a6 100644 --- a/ibm/resource_ibm_dl_gateway.go +++ b/ibm/resource_ibm_dl_gateway.go @@ -8,6 +8,7 @@ import ( "fmt" "log" "os" + "reflect" "strings" "time" @@ -18,50 +19,54 @@ import ( ) const ( - dlLoaRejectReason = "loa_reject_reason" - dlCustomerName = "customer_name" - dlCarrierName = "carrier_name" - dlResourceGroup = "resource_group" + dlActive = "active" + dlAuthenticationKey = "authentication_key" + dlBfdInterval = "bfd_interval" + dlBfdMultiplier = "bfd_multiplier" + dlBfdStatus = "bfd_status" + dlBfdStatusUpdatedAt = "bfd_status_updated_at" dlBgpAsn = "bgp_asn" dlBgpBaseCidr = "bgp_base_cidr" dlBgpCerCidr = "bgp_cer_cidr" + dlBgpIbmAsn = "bgp_ibm_asn" dlBgpIbmCidr = "bgp_ibm_cidr" + dlBgpStatus = "bgp_status" + dlCarrierName = "carrier_name" + dlChangeRequest = "change_request" + dlCipherSuite = "cipher_suite" + dlCompletionNoticeRejectReason = "completion_notice_reject_reason" + dlConfidentialityOffset = "confidentiality_offset" + dlGatewayProvisioning = "configuring" + dlConnectionMode = "connection_mode" + dlCreatedAt = "created_at" + dlGatewayProvisioningRejected = "create_rejected" dlCrossConnectRouter = "cross_connect_router" + dlCrn = "crn" + dlCryptographicAlgorithm = "cryptographic_algorithm" + dlCustomerName = "customer_name" + dlFallbackCak = "fallback_cak" dlGlobal = "global" + dlKeyServerPriority = "key_server_priority" + dlLoaRejectReason = "loa_reject_reason" + dlLocationDisplayName = "location_display_name" dlLocationName = "location_name" - dlName = "name" - dlSpeedMbps = "speed_mbps" - dlOperationalStatus = "operational_status" - dlBgpStatus = "bgp_status" dlLinkStatus = "link_status" - dlType = "type" - dlCrn = "crn" - dlCreatedAt = "created_at" + dlMacSecConfig = "macsec_config" dlMetered = "metered" - dlLocationDisplayName = "location_display_name" - dlBgpIbmAsn = "bgp_ibm_asn" - dlCompletionNoticeRejectReason = "completion_notice_reject_reason" + dlName = "name" + dlOperationalStatus = "operational_status" dlPort = "port" - dlProviderAPIManaged = "provider_api_managed" - dlVlan = "vlan" - dlTags = "tags" - dlActive = "active" - dlFallbackCak = "fallback_cak" dlPrimaryCak = "primary_cak" + dlProviderAPIManaged = "provider_api_managed" + dlGatewayProvisioningDone = "provisioned" + dlResourceGroup = "resource_group" dlSakExpiryTime = "sak_expiry_time" - dlWindowSize = "window_size" - dlMacSecConfig = "macsec_config" - dlCipherSuite = "cipher_suite" - dlConfidentialityOffset = "confidentiality_offset" - dlCryptographicAlgorithm = "cryptographic_algorithm" - dlKeyServerPriority = "key_server_priority" + dlSpeedMbps = "speed_mbps" dlMacSecConfigStatus = "status" - dlChangeRequest = "change_request" - dlGatewayProvisioning = "configuring" - dlGatewayProvisioningDone = "provisioned" - dlGatewayProvisioningRejected = "create_rejected" - dlAuthenticationKey = "authentication_key" - dlConnectionMode = "connection_mode" + dlTags = "tags" + dlType = "type" + dlVlan = "vlan" + dlWindowSize = "window_size" ) func resourceIBMDLGateway() *schema.Resource { @@ -92,6 +97,32 @@ func resourceIBMDLGateway() *schema.Resource { ForceNew: false, Description: "BGP MD5 authentication key", }, + dlBfdInterval: { + Type: schema.TypeInt, + Optional: true, + ForceNew: false, + Description: "BFD Interval", + ValidateFunc: InvokeValidator("ibm_dl_gateway", dlBfdInterval), + }, + dlBfdMultiplier: { + Type: schema.TypeInt, + Optional: true, + ForceNew: false, + Description: "BFD Multiplier", + ValidateFunc: InvokeValidator("ibm_dl_gateway", dlBfdMultiplier), + }, + dlBfdStatus: { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Gateway BFD status", + }, + dlBfdStatusUpdatedAt: { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Date and time BFD status was updated", + }, dlBgpAsn: { Type: schema.TypeInt, Required: true, @@ -423,6 +454,22 @@ func resourceIBMDLGatewayValidator() *ResourceValidator { Type: TypeString, Required: true, AllowedValues: dlConnectionModeAllowedValues}) + validateSchema = append(validateSchema, + ValidateSchema{ + Identifier: dlBfdInterval, + ValidateFunctionIdentifier: IntBetween, + Type: TypeInt, + Required: true, + MinValue: "300", + MaxValue: "255000"}) + validateSchema = append(validateSchema, + ValidateSchema{ + Identifier: dlBfdMultiplier, + ValidateFunctionIdentifier: IntBetween, + Type: TypeInt, + Required: true, + MinValue: "1", + MaxValue: "255"}) ibmISDLGatewayResourceValidator := ResourceValidator{ResourceName: "ibm_dl_gateway", Schema: validateSchema} return &ibmISDLGatewayResourceValidator @@ -446,6 +493,24 @@ func resourceIBMdlGatewayCreate(d *schema.ResourceData, meta interface{}) error bgpAsn := int64(d.Get(dlBgpAsn).(int)) metered := d.Get(dlMetered).(bool) + var bfdConfig directlinkv1.GatewayBfdConfigTemplate + isBfdInterval := false + + if bfdInterval, ok := d.GetOk(dlBfdInterval); ok { + isBfdInterval = true + interval := int64(bfdInterval.(int)) + bfdConfig.Interval = &interval + } + + if bfdMultiplier, ok := d.GetOk(dlBfdMultiplier); ok { + multiplier := int64(bfdMultiplier.(int)) + bfdConfig.Multiplier = &multiplier + } else if isBfdInterval { + // Set the default value for multiplier if interval is set + multiplier := int64(3) + bfdConfig.Multiplier = &multiplier + } + if dtype == "dedicated" { var crossConnectRouter, carrierName, locationName, customerName string if _, ok := d.GetOk(dlCarrierName); ok { @@ -537,6 +602,10 @@ func resourceIBMdlGatewayCreate(d *schema.ResourceData, meta interface{}) error gatewayDedicatedTemplateModel.ConnectionMode = &connectionModeStr } + if !reflect.DeepEqual(bfdConfig, directlinkv1.GatewayBfdConfigTemplate{}) { + gatewayDedicatedTemplateModel.BfdConfig = &bfdConfig + } + createGatewayOptionsModel.GatewayTemplate = gatewayDedicatedTemplateModel } else if dtype == "connect" { @@ -578,6 +647,10 @@ func resourceIBMdlGatewayCreate(d *schema.ResourceData, meta interface{}) error gatewayConnectTemplateModel.ConnectionMode = &connectionModeStr } + if !reflect.DeepEqual(bfdConfig, directlinkv1.GatewayBfdConfigTemplate{}) { + gatewayConnectTemplateModel.BfdConfig = &bfdConfig + } + createGatewayOptionsModel.GatewayTemplate = gatewayConnectTemplateModel } else { @@ -792,6 +865,25 @@ func resourceIBMdlGatewayRead(d *schema.ResourceData, meta interface{}) error { d.Set(ResourceGroupName, *rg.ID) } + //Show the BFD Config parameters if set + if instance.BfdConfig != nil { + if instance.BfdConfig.Interval != nil { + d.Set(dlBfdInterval, *instance.BfdConfig.Interval) + } + + if instance.BfdConfig.Multiplier != nil { + d.Set(dlBfdMultiplier, *instance.BfdConfig.Multiplier) + } + + if instance.BfdConfig.BfdStatus != nil { + d.Set(dlBfdStatus, *instance.BfdConfig.BfdStatus) + } + + if instance.BfdConfig.BfdStatusUpdatedAt != nil { + d.Set(dlBfdStatusUpdatedAt, instance.BfdConfig.BfdStatusUpdatedAt.String()) + } + } + return nil } func isWaitForDirectLinkAvailable(client *directlinkv1.DirectLinkV1, id string, timeout time.Duration) (interface{}, error) { @@ -898,6 +990,21 @@ func resourceIBMdlGatewayUpdate(d *schema.ResourceData, meta interface{}) error updateGatewayOptionsModel.ConnectionMode = &updatedConnectionMode } + var updatedBfdConfig directlinkv1.GatewayBfdPatchTemplate + if bfdInterval, ok := d.GetOk(dlBfdInterval); ok && d.HasChange(dlBfdInterval) { + updatedBfdInterval := bfdInterval.(int64) + updatedBfdConfig.Interval = &updatedBfdInterval + } + + if bfdMultiplier, ok := d.GetOk(dlBfdMultiplier); ok && d.HasChange(dlBfdMultiplier) { + updatedbfdMultiplier := bfdMultiplier.(int64) + updatedBfdConfig.Multiplier = &updatedbfdMultiplier + } + + if !reflect.DeepEqual(updatedBfdConfig, directlinkv1.GatewayBfdPatchTemplate{}) { + updateGatewayOptionsModel.BfdConfig = &updatedBfdConfig + } + if dtype == "dedicated" { if d.HasChange(dlMacSecConfig) && !d.IsNewResource() { // Construct an instance of the GatewayMacsecConfigTemplate model diff --git a/website/docs/d/dl_gateway.html.markdown b/website/docs/d/dl_gateway.html.markdown index 1219a0779a..11e73562a8 100644 --- a/website/docs/d/dl_gateway.html.markdown +++ b/website/docs/d/dl_gateway.html.markdown @@ -30,6 +30,10 @@ Review the argument reference that you can specify for your resource. In addition to the argument reference list, you can access the following attribute references after your data source is created. - `authentication_key` - (String) BGP MD5 authentication key. +- `bfd_interval` - (String) Minimum interval in milliseconds at which the local routing device transmits hello packets and then expects to receive a reply from a neighbor with which it has established a BFD session. +- `bfd_multiplier` - (String) The number of hello packets not received by a neighbor that causes the originating interface to be declared down. +- `bfd_status` - (String) Gateway BFD status. +- `bfd_status_updated_at` - (String) Date and time bfd status was updated. - `bgp_asn` - (String) Customer BGP ASN. - `bgp_base_cidr` - (String) The BGP base CIDR. - `bgp_cer_cidr` - (String) The BGP customer edge router CIDR. diff --git a/website/docs/d/dl_gateways.html.markdown b/website/docs/d/dl_gateways.html.markdown index 55c32608cf..ad7a481d11 100644 --- a/website/docs/d/dl_gateways.html.markdown +++ b/website/docs/d/dl_gateways.html.markdown @@ -30,6 +30,10 @@ You can access the following attribute references after your data source is crea Nested scheme for `gateways`: - `authentication_key` - (String) BGP MD5 authentication key. + - `bfd_interval` - (String) Minimum interval in milliseconds at which the local routing device transmits hello packets and then expects to receive a reply from a neighbor with which it has established a BFD session. + - `bfd_multiplier` - (String) The number of hello packets not received by a neighbor that causes the originating interface to be declared down. + - `bfd_status` - (String) Gateway BFD status. + - `bfd_status_updated_at` - (String) Date and time bfd status was updated. - `bgp_asn` - (String) Customer BGP ASN. - `bgp_base_cidr` - (String) The BGP base CIDR. - `bgp_cer_cidr` - (String) The BGP customer edge router CIDR. diff --git a/website/docs/r/dl_gateway.html.markdown b/website/docs/r/dl_gateway.html.markdown index 49a2d333d1..d979f4cdd4 100644 --- a/website/docs/r/dl_gateway.html.markdown +++ b/website/docs/r/dl_gateway.html.markdown @@ -59,6 +59,8 @@ resource "ibm_dl_gateway" "test_dl_connect" { Review the argument reference that you can specify for your resource. - `authentication_key` - (Optional, String) BGP MD5 authentication key. +- `bfd_interval` - (String) Minimum interval in milliseconds at which the local routing device transmits hello packets and then expects to receive a reply from a neighbor with which it has established a BFD session. +- `bfd_multiplier` - (String) The number of hello packets not received by a neighbor that causes the originating interface to be declared down. - `bgp_asn`- (Required, Forces new resource, Integer) The BGP ASN of the gateway to be created. For example, `64999`. - `bgp_base_cidr` - (Optional, String) (Deprecated) The BGP base CIDR of the gateway to be created. See `bgp_ibm_cidr` and `bgp_cer_cidr` for details on how to create a gateway by using automatic or explicit IP assignment. Any `bgp_base_cidr` value set will be ignored. - `bgp_cer_cidr` - (Optional, Forces new resource, String) The BGP customer edge router CIDR. Specify a value within `bgp_base_cidr`. For auto IP assignment, omit `bgp_cer_cidr` and `bgp_ibm_cidr`. IBM will automatically select values for `bgp_cer_cidr` and `bgp_ibm_cidr`. From 7a1fb37762c515d1e53e456c36f627789ee013c6 Mon Sep 17 00:00:00 2001 From: ajay-malhotra1 Date: Wed, 13 Oct 2021 17:26:02 -0700 Subject: [PATCH 2/3] chore: updated the go sum file --- go.sum | 3 --- 1 file changed, 3 deletions(-) diff --git a/go.sum b/go.sum index 94e3b5300f..f8d9e1b441 100644 --- a/go.sum +++ b/go.sum @@ -70,7 +70,6 @@ github.com/IBM/go-sdk-core/v5 v5.0.3/go.mod h1:vyNdbFujJtdTj9HbihtvKwwS3k/GKSKpO github.com/IBM/go-sdk-core/v5 v5.1.0/go.mod h1:vyNdbFujJtdTj9HbihtvKwwS3k/GKSKpOx9ZIQ6MWDY= github.com/IBM/go-sdk-core/v5 v5.4.5/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723y8GsfLV8e0= github.com/IBM/go-sdk-core/v5 v5.5.1/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723y8GsfLV8e0= -github.com/IBM/go-sdk-core/v5 v5.6.3 h1:xj44tzfBnjGJXKthMeaIn9wcYH+z4dXTuhntsBp+NdQ= github.com/IBM/go-sdk-core/v5 v5.6.3/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3btdruJaoUeek= github.com/IBM/go-sdk-core/v5 v5.6.5 h1:zXlt5x/udqZTD617SKUQzPDON4x5y0+22vNxsdCGYpg= github.com/IBM/go-sdk-core/v5 v5.6.5/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3btdruJaoUeek= @@ -95,8 +94,6 @@ github.com/IBM/schematics-go-sdk v0.0.2 h1:IFdM73VL3xwf/KaTh1IY99hkiTfFRYg5F1JNj github.com/IBM/schematics-go-sdk v0.0.2/go.mod h1:ymN1+3uEaWNT0RthwHzExxMiN0AnTh6W3piSY8canjs= github.com/IBM/secrets-manager-go-sdk v0.1.19 h1:0GPs5EoTaWNsjo4QPj64GNxlWfN8VHJy4RDFLqddSe8= github.com/IBM/secrets-manager-go-sdk v0.1.19/go.mod h1:eO3dBhzPrHkkt+yPex/jB2xD6qHZxBko+Aw+0tfqHeA= -github.com/IBM/vpc-go-sdk v0.10.0 h1:QAUN6hziV9+dbtsHrk8KuSr/kIW8qGBNlCsZ/ghgBZ4= -github.com/IBM/vpc-go-sdk v0.10.0/go.mod h1:Y1oXX7o+UJIKzMnTt1t74e2weUzVqb2XZ1/INV/D/fs= github.com/IBM/vpc-go-sdk v0.12.0 h1:tOuEveEJOEjNhLcRxTOG/w5mf0e59fqJVwSysq2oSx8= github.com/IBM/vpc-go-sdk v0.12.0/go.mod h1:B3Pgkwb0tQqTeIojR1MFLp96qW7cKnWyJ74jbAJgdbk= github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0= From e5d10baeac24c99d59b0846cbb29a6c4f97aded9 Mon Sep 17 00:00:00 2001 From: ajay-malhotra1 Date: Mon, 25 Oct 2021 11:46:54 -0700 Subject: [PATCH 3/3] doc: updated the BFD status and BFD status updated at has been added to attributes --- website/docs/r/dl_gateway.html.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/docs/r/dl_gateway.html.markdown b/website/docs/r/dl_gateway.html.markdown index 23470c8c2c..ef372cf622 100644 --- a/website/docs/r/dl_gateway.html.markdown +++ b/website/docs/r/dl_gateway.html.markdown @@ -80,7 +80,8 @@ Review the argument reference that you can specify for your resource. ## Attribute reference In addition to all argument references list, you can access the following attribute references after your resource is created. - +- `bfd_status` - (String) Gateway BFD status +- `bfd_status_updated_at` - (String) Date and time BFD status was updated at - `bgp_asn` - (String) The IBM BGP ASN. - `bgp_status` - (String) The gateway BGP status. - `completion_notice_reject_reason` - (String) The reason for completion notice rejection.