Skip to content

Commit

Permalink
Add "id" for subexpression of group and service
Browse files Browse the repository at this point in the history
Id isn't really needed since we use only a single expression.
Hence value is chosen as "id".
  • Loading branch information
hknutzen committed Nov 7, 2022
1 parent 4a15488 commit 8eb58eb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion go/pkg/pass2/nsx.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func printNSXRules(fd *os.File, rData *routerData) {
}
groupName := "Netspoc-" + g.name
addresses := jsonMap{
"id": "id",
"resource_type": "IPAddressExpression",
"ip_addresses": l,
}
Expand All @@ -190,7 +191,7 @@ func printNSXRules(fd *os.File, rData *routerData) {
pair := protoMap[name]
p := pair.prt
proto := p.protocol
svcEntry := jsonMap{}
svcEntry := jsonMap{"id": "id"}
switch proto {
case "tcp", "udp":
svcEntry["resource_type"] = "L4PortSetServiceEntry"
Expand Down
15 changes: 15 additions & 0 deletions go/testdata/ipv6/nsx_ipv6.t
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ Generated by Netspoc, version devel
{
"expression": [
{
"id": "id",
"ip_addresses": [
"::a01:10a",
"::a01:114"
Expand All @@ -273,6 +274,7 @@ Generated by Netspoc, version devel
{
"expression": [
{
"id": "id",
"ip_addresses": [
"::a01:21e",
"::a01:228"
Expand Down Expand Up @@ -530,6 +532,7 @@ Generated by Netspoc, version devel
"id": "Netspoc-tcp",
"service_entries": [
{
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -542,6 +545,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"22"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -554,6 +558,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"80"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -566,6 +571,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"8080"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -578,6 +584,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"81"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -587,6 +594,7 @@ Generated by Netspoc, version devel
"id": "Netspoc-udp_123:1-65535",
"service_entries": [
{
"id": "id",
"l4_protocol": "UDP",
"resource_type": "L4PortSetServiceEntry",
"source_ports": [
Expand All @@ -602,6 +610,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"123"
],
"id": "id",
"l4_protocol": "UDP",
"resource_type": "L4PortSetServiceEntry",
"source_ports": [
Expand Down Expand Up @@ -648,6 +657,7 @@ service:s1 = {
{
"expression": [
{
"id": "id",
"ip_addresses": [
"::a01:10a",
"::a01:114"
Expand All @@ -660,6 +670,7 @@ service:s1 = {
{
"expression": [
{
"id": "id",
"ip_addresses": [
"::a01:21e",
"::a01:228"
Expand Down Expand Up @@ -743,6 +754,7 @@ service:s1 = {
"destination_ports": [
"80"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand Down Expand Up @@ -958,6 +970,7 @@ service:s1 = {
{
"icmp_code": 0,
"icmp_type": 5,
"id": "id",
"protocol": "ICMPv6",
"resource_type": "IcmpTypeServiceEntry"
}
Expand All @@ -968,6 +981,7 @@ service:s1 = {
"service_entries": [
{
"icmp_type": 8,
"id": "id",
"protocol": "ICMPv6",
"resource_type": "IcmpTypeServiceEntry"
}
Expand All @@ -977,6 +991,7 @@ service:s1 = {
"id": "Netspoc-proto_52",
"service_entries": [
{
"id": "id",
"protocol_number": 52,
"resource_type": "IpProtocolServiceEntry"
}
Expand Down
15 changes: 15 additions & 0 deletions go/testdata/nsx.t
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ Generated by Netspoc, version devel
{
"expression": [
{
"id": "id",
"ip_addresses": [
"10.1.1.10",
"10.1.1.20"
Expand All @@ -263,6 +264,7 @@ Generated by Netspoc, version devel
{
"expression": [
{
"id": "id",
"ip_addresses": [
"10.1.2.30",
"10.1.2.40"
Expand Down Expand Up @@ -520,6 +522,7 @@ Generated by Netspoc, version devel
"id": "Netspoc-tcp",
"service_entries": [
{
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -532,6 +535,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"22"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -544,6 +548,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"80"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -556,6 +561,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"8080"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -568,6 +574,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"81"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand All @@ -577,6 +584,7 @@ Generated by Netspoc, version devel
"id": "Netspoc-udp_123:1-65535",
"service_entries": [
{
"id": "id",
"l4_protocol": "UDP",
"resource_type": "L4PortSetServiceEntry",
"source_ports": [
Expand All @@ -592,6 +600,7 @@ Generated by Netspoc, version devel
"destination_ports": [
"123"
],
"id": "id",
"l4_protocol": "UDP",
"resource_type": "L4PortSetServiceEntry",
"source_ports": [
Expand Down Expand Up @@ -637,6 +646,7 @@ service:s1 = {
{
"expression": [
{
"id": "id",
"ip_addresses": [
"10.1.1.10",
"10.1.1.20"
Expand All @@ -649,6 +659,7 @@ service:s1 = {
{
"expression": [
{
"id": "id",
"ip_addresses": [
"10.1.2.30",
"10.1.2.40"
Expand Down Expand Up @@ -732,6 +743,7 @@ service:s1 = {
"destination_ports": [
"80"
],
"id": "id",
"l4_protocol": "TCP",
"resource_type": "L4PortSetServiceEntry"
}
Expand Down Expand Up @@ -945,6 +957,7 @@ service:s1 = {
{
"icmp_code": 0,
"icmp_type": 5,
"id": "id",
"protocol": "ICMPv4",
"resource_type": "IcmpTypeServiceEntry"
}
Expand All @@ -955,6 +968,7 @@ service:s1 = {
"service_entries": [
{
"icmp_type": 8,
"id": "id",
"protocol": "ICMPv4",
"resource_type": "IcmpTypeServiceEntry"
}
Expand All @@ -964,6 +978,7 @@ service:s1 = {
"id": "Netspoc-proto_52",
"service_entries": [
{
"id": "id",
"protocol_number": 52,
"resource_type": "IpProtocolServiceEntry"
}
Expand Down

0 comments on commit 8eb58eb

Please sign in to comment.