Skip to content

Commit

Permalink
# 0.1.7 Release
Browse files Browse the repository at this point in the history
## New Features
 - Add NAT support for MCR VXC Connections.
  • Loading branch information
Daniel Barnes committed Feb 22, 2022
1 parent c13da04 commit d435730
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.1.7 Release

## New Features
- Add NAT support for MCR VXC Connections.

# 0.1.6 Release

## New Features
Expand Down
3 changes: 2 additions & 1 deletion service/vxc/aws_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
*********************/

const (
TEST_1_REFERENCE_STRING = `[{"associatedVxcs":[{"productName":"VXC MCR to AWSHC from GO","rateLimit":500,"aEnd":{"vlan":0,"partnerConfig":{"interfaces":[{"ipAddresses":["10.192.0.25/29"],"bfd":{"txInterval":300,"rxInterval":300,"multiplier":3},"bgpConnections":[{"peerAsn":64512,"localIpAddress":"10.192.0.25","peerIpAddress":"10.192.0.26","password":"cnn6eaeaETSjvjvjvjv","shutdown":false,"description":"BGP with MED and BFD enabled","medIn":100,"medOut":100,"bfdEnabled":true}]}]}},"bEnd":{"productUid":"b2e0b6b8-2943-4c44-8a07-9ec13060afb2","partnerConfig":{"connectType":"AWSHC","type":"private","ownerAccount":"684021030471"}}}],"productUid":"mcr-id-here"}]`
TEST_1_REFERENCE_STRING = `[{"associatedVxcs":[{"productName":"VXC MCR to AWSHC from GO","rateLimit":500,"aEnd":{"vlan":0,"partnerConfig":{"interfaces":[{"ipAddresses":["10.192.0.25/29"],"natIpAddresses":["10.192.0.25"],"bfd":{"txInterval":300,"rxInterval":300,"multiplier":3},"bgpConnections":[{"peerAsn":64512,"localIpAddress":"10.192.0.25","peerIpAddress":"10.192.0.26","password":"cnn6eaeaETSjvjvjvjv","shutdown":false,"description":"BGP with MED and BFD enabled","medIn":100,"medOut":100,"bfdEnabled":true}]}]}},"bEnd":{"productUid":"b2e0b6b8-2943-4c44-8a07-9ec13060afb2","partnerConfig":{"connectType":"AWSHC","type":"private","ownerAccount":"684021030471"}}}],"productUid":"mcr-id-here"}]`
)

func SUCCESS_RESPONSE_MOCK(req *http.Request) *http.Response {
Expand Down Expand Up @@ -114,6 +114,7 @@ func Test_VXC_MCR_AWS(t *testing.T) {

partnerConfigInterface := types.PartnerConfigInterface{
IpAddresses: []string{"10.192.0.25/29"},
NatIpAddresses: []string{"10.192.0.25"},
Bfd: types.BfdConfig{
TxInterval: 300,
RxInterval: 300,
Expand Down
32 changes: 28 additions & 4 deletions service/vxc/vxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func (v *VXC) MarshallMcrAEndConfig(d *schema.ResourceData) (types.PartnerConfig

// init config props
ip_addresses_list := []string{}
nat_ip_addresses_list := []string{}
bfd_configuration := types.BfdConfig{}
bgp_connection_list := []types.BgpConnectionConfig{}

Expand All @@ -247,13 +248,24 @@ func (v *VXC) MarshallMcrAEndConfig(d *schema.ResourceData) (types.PartnerConfig
mcrConfig.IpAddresses = ip_addresses_list
}

// extract nat ip addresses list
if nat_ip_addresses, nat_ok := mcr_map["nat_ip_addresses"].([]interface{}); nat_ok {

for _, nat_ip_address := range nat_ip_addresses {
i := nat_ip_address.(string)
nat_ip_addresses_list = append(nat_ip_addresses_list, i)
}

mcrConfig.NatIpAddresses = nat_ip_addresses_list
}

// extract BFD settings
if bfd_config, bfd_ok := mcr_map["bfd_configuration"].(*schema.Set); bfd_ok && len(bfd_config.List()) > 0 {

bfd_config_map := bfd_config.List()[0].(map[string]interface{})
bfd_configuration = types.BfdConfig{
TxInterval: bfd_config_map["tx_internal"].(int),
RxInterval: bfd_config_map["rx_internal"].(int),
TxInterval: bfd_config_map["tx_interval"].(int),
RxInterval: bfd_config_map["rx_interval"].(int),
Multiplier: bfd_config_map["multiplier"].(int),
}

Expand Down Expand Up @@ -330,15 +342,27 @@ func (v *VXC) UnmarshallMcrAEndConfig(vxcDetails types.VXC) (interface{}, error)
v.Log.Info(" - ipAddresses field not present")
}

// add nat ip addresses to configuration
if nat_slice, nat_ok := partner_interface_map["natIpAddresses"].([]interface{}); nat_ok {
if len(nat_slice) > 0 {
v.Log.Info(" - natIpAddresses field present")
partner_configuration["nat_ip_addresses"] = nat_slice
} else {
v.Log.Info(" - natIpAddresses is empty")
}
} else {
v.Log.Info(" - natIpAddresses field not present")
}

// extract bfd settings
bfd_map, bfd_ok := partner_interface_map["bfd"].(map[string]interface{})
if bfd_ok {

v.Log.Info(" - bfd field present")
// add bfd to configuration
partner_configuration["bfd_configuration"] = []interface{}{map[string]interface{}{
"tx_internal": bfd_map["txInterval"],
"rx_internal": bfd_map["rxInterval"],
"tx_interval": bfd_map["txInterval"],
"rx_interval": bfd_map["rxInterval"],
"multiplier": bfd_map["multiplier"],
}}

Expand Down
1 change: 1 addition & 0 deletions service/vxc/vxc_integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ func TestAWSHostedConnectionBuy(t *testing.T) {
Interfaces: []types.PartnerConfigInterface{
types.PartnerConfigInterface{
IpAddresses: []string{"10.0.0.1/30"},
NatIpAddresses: []string{"10.0.0.1"},
Bfd: types.BfdConfig{
TxInterval: 300,
RxInterval: 300,
Expand Down
1 change: 1 addition & 0 deletions types/vxc_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type VXCOrderConfirmation struct {

type PartnerConfigInterface struct {
IpAddresses []string `json:"ipAddresses,omitempty"`
NatIpAddresses []string `json:"natIpAddresses,omitempty"`
Bfd BfdConfig `json:"bfd,omitempty"`
BgpConnections []BgpConnectionConfig `json:"bgpConnections,omitempty"`
}
Expand Down

0 comments on commit d435730

Please sign in to comment.