Skip to content

Commit

Permalink
Merge pull request #19 from cisco-open/hh-nat-prop
Browse files Browse the repository at this point in the history
Add support for internal nat rules
  • Loading branch information
hughwphamill authored Jul 10, 2024
2 parents 8ad2e97 + 34ba89f commit 8ddf259
Show file tree
Hide file tree
Showing 216 changed files with 672 additions and 560 deletions.
2 changes: 2 additions & 0 deletions tbclient/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ type IpNatTarget struct {
type IpNatRule struct {
Uid string `json:"uid,omitempty"`
EastWest bool `json:"eastWest"`
Scope *string `json:"scope"`
Target IpNatTarget `json:"target"`
Topology *Topology `json:"topology"`
}
Expand All @@ -410,6 +411,7 @@ type VmNatTarget struct {
type VmNatRule struct {
Uid string `json:"uid,omitempty"`
EastWest bool `json:"eastWest"`
Scope *string `json:"scope"`
Target VmNatTarget `json:"target"`
Topology *Topology `json:"topology"`
}
Expand Down
5 changes: 5 additions & 0 deletions tbclient/natRule.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type natRule struct {
Uid string `json:"uid"`
Topology *Topology `json:"topology"`
EastWest bool `json:"eastWest"`
Scope *string `json:"scope"`
Target struct {
Type string `json:"type"`
VmNic *VmNic `json:"targetItem"`
Expand Down Expand Up @@ -50,6 +51,7 @@ func (c *Client) GetAllIpNatRules(topologyUid string) ([]IpNatRule, error) {
ipNatRule := IpNatRule{
Uid: natRule.Uid,
EastWest: natRule.EastWest,
Scope: natRule.Scope,
Target: IpNatTarget{
IpAddress: natRule.Target.IpAddress,
Name: natRule.Target.Name,
Expand Down Expand Up @@ -80,6 +82,7 @@ func (c *Client) GetIpNatRule(uid string) (*IpNatRule, error) {
return &IpNatRule{
Uid: natRule.Uid,
EastWest: natRule.EastWest,
Scope: natRule.Scope,
Target: IpNatTarget{
IpAddress: natRule.Target.IpAddress,
Name: natRule.Target.Name,
Expand Down Expand Up @@ -130,6 +133,7 @@ func (c *Client) GetAllVmNatRules(topologyUid string) ([]VmNatRule, error) {
vmNatRule := VmNatRule{
Uid: natRule.Uid,
EastWest: natRule.EastWest,
Scope: natRule.Scope,
Target: VmNatTarget{
VmNic: natRule.Target.VmNic,
IpAddress: natRule.Target.IpAddress,
Expand Down Expand Up @@ -161,6 +165,7 @@ func (c *Client) GetVmNatRule(uid string) (*VmNatRule, error) {
return &VmNatRule{
Uid: natRule.Uid,
EastWest: natRule.EastWest,
Scope: natRule.Scope,
Target: VmNatTarget{
VmNic: natRule.Target.VmNic,
IpAddress: natRule.Target.IpAddress,
Expand Down
20 changes: 10 additions & 10 deletions tbclient/tbclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,12 @@ var scenario = Scenario{
Topology: &Topology{Uid: lonTopology.Uid},
}

var publicScope = "PUBLIC"

var ipNatRule = IpNatRule{
Uid: "lonipnatrule1",
EastWest: false,
Scope: &publicScope,
Target: IpNatTarget{
IpAddress: "198.18.131.100",
Name: "Some Device",
Expand All @@ -424,6 +427,7 @@ var ipNatRule = IpNatRule{
var vmNatRule = VmNatRule{
Uid: "lonvmnatrule1",
EastWest: false,
Scope: &publicScope,
Target: VmNatTarget{
VmNic: &VmNic{Uid: "lonvm1natnic"},
IpAddress: "198.18.131.201",
Expand Down Expand Up @@ -1161,10 +1165,10 @@ func (suite *ContractTestSuite) TestCreateInboundProxyRule() {
expectedInboundProxyRule.Uid = "newloninboundproxy"
expectedInboundProxyRule.VmNicTarget = &TrafficVmNicTarget{
Uid: inboundProxyRule.VmNicTarget.Uid,
IpAddress: "192.168.0.6",
IpAddress: "192.168.0.8",
Vm: &Vm{
Uid: "liKK6pJ1Z7rQ0tHI2KSW",
Name: "BRJVLNXVGASIWIRTLRZT",
Uid: "pcVmayo2nx7fQr8V21xO",
Name: "MWRGFTMMILZNATVKXRSM",
},
}
suite.Equal(expectedInboundProxyRule, *actualInboundProxyRule)
Expand Down Expand Up @@ -1229,10 +1233,6 @@ func (suite *ContractTestSuite) TestCreateExternalDnsRecord() {
expectedExternalDnsRecord := externalDnsRecord
expectedExternalDnsRecord.NatRule = &ExternalDnsNatRule{Uid: "lonipnatrule1"}
expectedExternalDnsRecord.SrvRecords = nil
expectedExternalDnsRecord.InventoryDnsAsset = &InventoryDnsAsset{
Id: "3",
Name: "CollabEdge_Swiss",
}

// When
actualExternalDnsRecord, err := suite.tbClient.CreateExternalDnsRecord(expectedExternalDnsRecord)
Expand Down Expand Up @@ -1271,10 +1271,10 @@ func (suite *ContractTestSuite) TestCreateMailServer() {
expectedMailServer := mailServer
expectedMailServer.VmNicTarget = &TrafficVmNicTarget{
Uid: expectedMailServer.VmNicTarget.Uid,
IpAddress: "192.168.0.8",
IpAddress: "192.168.0.3",
Vm: &Vm{
Uid: "jFN4LQ5ghsb8VOd04wzM",
Name: "QRAYMCRXKDADAONQQVCC",
Uid: "LDU9tBp7g5Zd4nZE2aNj",
Name: "HFDJPRCCGOZGHOMYSZGX",
},
}
expectedMailServer.InventoryDnsAsset = &InventoryDnsAsset{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "1cc18a82-9fff-487e-9aea-d676dbe19fa7",
"id" : "2f3379a2-98c1-45a8-961e-87af17617cb5",
"request" : {
"urlPath" : "/datacenters/notfound/inventory-demos",
"method" : "GET",
Expand All @@ -11,11 +11,11 @@
},
"response" : {
"status" : 404,
"body" : "[{\"logref\":\"QIHQTSJNRNDINZQDMHGC\",\"message\":\"The requested Datacenter resource 'notfound' was not found\",\"links\":[]}]",
"body" : "[{\"logref\":\"YJGAWIXFNWUHSQUTJIMT\",\"message\":\"The requested Datacenter resource 'notfound' was not found\",\"links\":[]}]",
"headers" : {
"Content-Type" : "application/vnd.error+json"
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "1cc18a82-9fff-487e-9aea-d676dbe19fa7"
"uuid" : "2f3379a2-98c1-45a8-961e-87af17617cb5"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "8b70ab1c-f7ef-4867-8322-10e70676aca0",
"id" : "5ef182bf-9c37-4375-9417-44149fe53a79",
"request" : {
"urlPath" : "/datacenters/lon/inventory-demos",
"method" : "GET",
Expand All @@ -17,5 +17,5 @@
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "8b70ab1c-f7ef-4867-8322-10e70676aca0"
"uuid" : "5ef182bf-9c37-4375-9417-44149fe53a79"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "31da4a31-8e3d-415b-a2c6-4cb1ba94e785",
"id" : "a352113c-8049-4a0f-877f-75610a3b5288",
"request" : {
"urlPath" : "/datacenters/sng/inventory-demos",
"method" : "GET",
Expand All @@ -11,11 +11,11 @@
},
"response" : {
"status" : 503,
"body" : "[{\"logref\":\"KHRNWQLDSSGGCDDOGHSK\",\"message\":\"Connectivity to the SNG V2 Reader service has not been configured\",\"links\":[]}]",
"body" : "[{\"logref\":\"THIKFDSVDOZNWAEGEAMK\",\"message\":\"Connectivity to the SNG V2 Reader service has not been configured\",\"links\":[]}]",
"headers" : {
"Content-Type" : "application/vnd.error+json"
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "31da4a31-8e3d-415b-a2c6-4cb1ba94e785"
"uuid" : "a352113c-8049-4a0f-877f-75610a3b5288"
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"id" : "f6ee4586-e237-40a1-9959-61f1934c3ece",
"id" : "5292a3c5-2abc-4e5a-af5d-d9910ae7a81f",
"request" : {
"urlPath" : "/datacenters/notfound/templated-topologies",
"method" : "GET"
},
"response" : {
"status" : 404,
"body" : "[{\"logref\":\"JATVWCRFFPBMVECKNSPA\",\"message\":\"The requested Datacenter resource 'notfound' was not found\",\"links\":[]}]",
"body" : "[{\"logref\":\"DDGQKCDNBKNUAHFZVNTH\",\"message\":\"The requested Datacenter resource 'notfound' was not found\",\"links\":[]}]",
"headers" : {
"Content-Type" : "application/vnd.error+json"
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "f6ee4586-e237-40a1-9959-61f1934c3ece"
"uuid" : "5292a3c5-2abc-4e5a-af5d-d9910ae7a81f"
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"id" : "c0d799d5-536f-4b5d-86de-9e01e107245c",
"id" : "e42c5316-26d9-4fcb-8628-fc00a449e375",
"request" : {
"urlPath" : "/datacenters/sng/templated-topologies",
"method" : "GET"
},
"response" : {
"status" : 503,
"body" : "[{\"logref\":\"UQTDRJKQURNUJMXREZRN\",\"message\":\"Connectivity to the Metadata service has not been configured\",\"links\":[]}]",
"body" : "[{\"logref\":\"NKMCHXHOXSWEOBAVYSGN\",\"message\":\"Connectivity to the Metadata service has not been configured\",\"links\":[]}]",
"headers" : {
"Content-Type" : "application/vnd.error+json"
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "c0d799d5-536f-4b5d-86de-9e01e107245c"
"uuid" : "e42c5316-26d9-4fcb-8628-fc00a449e375"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "6ba93818-70d1-494b-8704-45aa2177bc35",
"id" : "65d6e068-4af4-4d60-b3e7-a0a6a4ca3ad4",
"request" : {
"urlPath" : "/datacenters/lon/templated-topologies",
"method" : "GET"
Expand All @@ -12,5 +12,5 @@
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "6ba93818-70d1-494b-8704-45aa2177bc35"
"uuid" : "65d6e068-4af4-4d60-b3e7-a0a6a4ca3ad4"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "061eb9a9-a869-46ac-a407-ac7cadfae694",
"id" : "f85e2e9b-7638-4b70-aa6d-76ac4cd31955",
"request" : {
"urlPath" : "/datacenters/lon/templated-inventory-vms",
"method" : "GET",
Expand All @@ -17,5 +17,5 @@
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "061eb9a9-a869-46ac-a407-ac7cadfae694"
"uuid" : "f85e2e9b-7638-4b70-aa6d-76ac4cd31955"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "3e3608ef-b25d-47de-afa6-5e8acb3b6cd0",
"id" : "142f1215-a35e-421c-ba0a-c63820300d19",
"request" : {
"urlPath" : "/datacenters/notfound/templated-inventory-vms",
"method" : "GET",
Expand All @@ -11,11 +11,11 @@
},
"response" : {
"status" : 404,
"body" : "[{\"logref\":\"YGPUOZNYYDGQJHSXDMPB\",\"message\":\"The requested Datacenter resource 'notfound' was not found\",\"links\":[]}]",
"body" : "[{\"logref\":\"ERPKUNAWVYTLUJVXQUQO\",\"message\":\"The requested Datacenter resource 'notfound' was not found\",\"links\":[]}]",
"headers" : {
"Content-Type" : "application/vnd.error+json"
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "3e3608ef-b25d-47de-afa6-5e8acb3b6cd0"
"uuid" : "142f1215-a35e-421c-ba0a-c63820300d19"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "de51a121-23d5-403d-8d82-75b7919c719f",
"id" : "dcfee7ab-3f0c-4d35-a454-14dddbeadb30",
"request" : {
"urlPath" : "/datacenters/sng/templated-inventory-vms",
"method" : "GET",
Expand All @@ -11,11 +11,11 @@
},
"response" : {
"status" : 503,
"body" : "[{\"logref\":\"KNJEGURJZVBIYJJEPZLB\",\"message\":\"Connectivity to the SNG V2 Reader service has not been configured\",\"links\":[]}]",
"body" : "[{\"logref\":\"VCZQHXFUSSONFANGWOTB\",\"message\":\"Connectivity to the SNG V2 Reader service has not been configured\",\"links\":[]}]",
"headers" : {
"Content-Type" : "application/vnd.error+json"
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "de51a121-23d5-403d-8d82-75b7919c719f"
"uuid" : "dcfee7ab-3f0c-4d35-a454-14dddbeadb30"
}
4 changes: 2 additions & 2 deletions tbclient/test_stubs/mappings/datacenter/getDatacenters.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "40bcec38-3bb8-4126-ae9b-aa1fcb91839e",
"id" : "4699e9b0-307e-4384-b111-ae95006baf3f",
"request" : {
"urlPath" : "/datacenters",
"method" : "GET",
Expand All @@ -17,5 +17,5 @@
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "40bcec38-3bb8-4126-ae9b-aa1fcb91839e"
"uuid" : "4699e9b0-307e-4384-b111-ae95006baf3f"
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"id" : "a3657292-a3fd-4c8c-a957-dece1f71242f",
"id" : "c3b91101-d425-4daf-93cc-9c398e69e508",
"request" : {
"urlPath" : "/datacenters/notfound/inventory-template-topologies",
"method" : "GET"
},
"response" : {
"status" : 404,
"body" : "[{\"logref\":\"LETTFJCPZOXTIAMFBWVW\",\"message\":\"The requested Datacenter resource 'notfound' was not found\",\"links\":[]}]",
"body" : "[{\"logref\":\"JFVHKXIDNSDPSNVPCNGG\",\"message\":\"The requested Datacenter resource 'notfound' was not found\",\"links\":[]}]",
"headers" : {
"Content-Type" : "application/vnd.error+json"
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "a3657292-a3fd-4c8c-a957-dece1f71242f"
"uuid" : "c3b91101-d425-4daf-93cc-9c398e69e508"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "131d3350-7625-43be-9cff-88bcac2b881c",
"id" : "3ea21e98-dc58-4642-a48e-443ded315a0c",
"request" : {
"urlPath" : "/datacenters/lon/inventory-template-topologies",
"method" : "GET"
Expand All @@ -12,5 +12,5 @@
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "131d3350-7625-43be-9cff-88bcac2b881c"
"uuid" : "3ea21e98-dc58-4642-a48e-443ded315a0c"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "423eba26-4629-455a-a688-f18bd89e38bb",
"id" : "4e79db4f-b521-4662-aa22-93714b1c08d8",
"request" : {
"urlPath" : "/datacenters/syd/inventory-template-topologies",
"method" : "GET"
Expand All @@ -12,5 +12,5 @@
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "423eba26-4629-455a-a688-f18bd89e38bb"
"uuid" : "4e79db4f-b521-4662-aa22-93714b1c08d8"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "1c088477-64d2-4fe9-9315-3d2545d39f25",
"id" : "630b272d-d0f9-41a5-bb66-0d383d980ef5",
"request" : {
"urlPath" : "/documentation/lontopology",
"method" : "GET"
Expand All @@ -13,5 +13,5 @@
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "1c088477-64d2-4fe9-9315-3d2545d39f25"
"uuid" : "630b272d-d0f9-41a5-bb66-0d383d980ef5"
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"id" : "faa68c07-b140-4b0b-806a-88a667169be9",
"id" : "cff77d0a-6dc5-4279-a5ed-9368e73c261f",
"request" : {
"urlPath" : "/documentation/notfound",
"method" : "GET"
},
"response" : {
"status" : 404,
"body" : "[{\"logref\":\"PWOBVUWVCCDLUIWMWKUW\",\"message\":\"The requested Documentation resource was not found\",\"links\":[]}]",
"body" : "[{\"logref\":\"BOHPXGTQFPVLTQXVCRTJ\",\"message\":\"The requested Documentation resource was not found\",\"links\":[]}]",
"headers" : {
"Content-Type" : "application/vnd.error+json"
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "faa68c07-b140-4b0b-806a-88a667169be9"
"uuid" : "cff77d0a-6dc5-4279-a5ed-9368e73c261f"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id" : "042f3676-3c61-4b6c-a93d-eab58138c1f9",
"id" : "e5609dbd-0673-4972-9fe4-8d6d9790ca6a",
"request" : {
"urlPath" : "/documentation/lontopology",
"method" : "PUT",
Expand All @@ -19,11 +19,11 @@
},
"response" : {
"status" : 400,
"body" : "[{\"logref\":\"WOMBOSRUIQEXRMZYWFZZ\",\"message\":\"Payload uid does not match the path variable uid\",\"links\":[]}]",
"body" : "[{\"logref\":\"KAOVQFDUTKSLBNHETPOB\",\"message\":\"Payload uid does not match the path variable uid\",\"links\":[]}]",
"headers" : {
"Content-Type" : "application/vnd.error+json"
},
"transformers" : [ "response-template", "spring-cloud-contract" ]
},
"uuid" : "042f3676-3c61-4b6c-a93d-eab58138c1f9"
"uuid" : "e5609dbd-0673-4972-9fe4-8d6d9790ca6a"
}
Loading

0 comments on commit 8ddf259

Please sign in to comment.