Skip to content

Commit

Permalink
Reformat openwrt/schema.py (openwisp-qa-format)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanunderwood committed Jul 28, 2020
1 parent e49605e commit 7837ad8
Showing 1 changed file with 76 additions and 94 deletions.
170 changes: 76 additions & 94 deletions netjsonconfig/backends/openwrt/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,29 +115,22 @@
"firewall_policy": {
"type": "string",
"enum": ["ACCEPT", "REJECT", "DROP"],
"options": {
"enum_titles": [
"Accept", "Reject", "Drop"]
},
"default": "REJECT"
"options": {"enum_titles": ["Accept", "Reject", "Drop"]},
"default": "REJECT",
},
"zone_policy": {
"type": "string",
"enum": ["ACCEPT", "REJECT", "DROP"],
"options": {
"enum_titles": [
"Accept", "Reject", "Drop"]
},
"default": "DROP"
"options": {"enum_titles": ["Accept", "Reject", "Drop"]},
"default": "DROP",
},
"rule_policy": {
"type": "string",
"enum": ["ACCEPT", "REJECT", "DROP", "MARK", "NOTRACK"],
"options": {
"enum_titles": [
"Accept", "Reject", "Drop", "Mark", "Notrack"]
"enum_titles": ["Accept", "Reject", "Drop", "Mark", "Notrack"]
},
"default": "DROP"
"default": "DROP",
},
"base_radio_settings": {
"properties": {
Expand Down Expand Up @@ -410,8 +403,8 @@
"interval": {"type": "integer", "propertyOrder": 8},
"message": {"type": "string", "propertyOrder": 9},
"mode": {"type": "string", "propertyOrder": 10},
}
}
},
},
},
"firewall": {
"type": "object",
Expand All @@ -433,7 +426,7 @@
"title": "input",
"description": "policy for the INPUT chain of the filter table",
"propertyOrder": 2,
}
},
]
},
"output": {
Expand All @@ -443,7 +436,7 @@
"title": "output",
"description": "policy for the OUTPUT chain of the filter table",
"propertyOrder": 3,
}
},
]
},
"forward": {
Expand All @@ -453,7 +446,7 @@
"title": "forward",
"description": "policy for the FORWARD chain of the filter table",
"propertyOrder": 4,
}
},
]
},
"forwardings": {
Expand All @@ -464,36 +457,33 @@
"type": "object",
"title": "Forwarding",
"additionalProperties": False,
"required": [
"src",
"dest",
],
"required": ["src", "dest",],
"properties": {
"src": {
"type": "string",
"title": "src",
"description": "specifies the traffic source zone and must "
"refer to one of the defined zone names",
"refer to one of the defined zone names",
"propertyOrder": 1,
},
"dest": {
"type": "string",
"title": "dest",
"description": "specifies the traffic destination zone and must "
"refer to one of the defined zone names",
"refer to one of the defined zone names",
"propertyOrder": 2,
},
"family": {
"type": "string",
"title": "family",
"description": "protocol family (ipv4, ipv6 or any) to generate "
"iptables rules for",
"iptables rules for",
"enum": ["ipv4", "ipv6", "any"],
"default": "any",
"propertyOrder": 3
}
}
}
"propertyOrder": 3,
},
},
},
},
"zones": {
"type": "array",
Expand All @@ -503,16 +493,14 @@
"type": "object",
"title": "Zones",
"additionalProperties": True,
"required": [
"name"
],
"required": ["name"],
"properties": {
"name": {
"type": "string",
"title": "name",
"description": "unique zone name",
"maxLength": 11,
"propertyOrder": 1
"propertyOrder": 1,
},
"network": {
"type": "array",
Expand All @@ -524,17 +512,17 @@
"title": "Network",
"type": "string",
"maxLength": 15,
"pattern": "^[a-zA-z0-9_\\.\\-]*$"
}
"pattern": "^[a-zA-z0-9_\\.\\-]*$",
},
},
"masq": {
"type": "boolean",
"title": "masq",
"description": "specifies wether outgoing zone traffic should be "
"masqueraded",
"masqueraded",
"default": False,
"format": "checkbox",
"propertyOrder": 3
"propertyOrder": 3,
},
"mtu_fix": {
"type": "boolean",
Expand All @@ -551,7 +539,7 @@
"title": "input",
"description": "default policy for incoming zone traffic",
"propertyOrder": 5,
}
},
]
},
"output": {
Expand All @@ -561,7 +549,7 @@
"title": "output",
"description": "default policy for outgoing zone traffic",
"propertyOrder": 6,
}
},
]
},
"forward": {
Expand All @@ -571,11 +559,11 @@
"title": "forward",
"description": "default policy for forwarded zone traffic",
"propertyOrder": 7,
}
},
]
}
}
}
},
},
},
},
"rules": {
"type": "array",
Expand All @@ -585,109 +573,103 @@
"type": "object",
"title": "Rules",
"additionalProperties": True,
"required": [
"src",
"target"
],
"required": ["src", "target"],
"properties": {
"name": {
"type": "string",
"title": "name",
"description": "name of the rule",
"propertyOrder": 1
"propertyOrder": 1,
},
"src": {
"type": "string",
"title": "src",
"description": "specifies the traffic source zone and must "
"refer to one of the defined zone names",
"propertyOrder": 2
"refer to one of the defined zone names",
"propertyOrder": 2,
},
"src_ip": {
"type": "string",
"title": "src_ip",
"description": "match incoming traffic from the specified "
"source ip address",
"propertyOrder": 3
"source ip address",
"propertyOrder": 3,
},
"src_mac": {
"type": "string",
"title": "src_mac",
"description": "match incoming traffic from the specified "
"mac address",
"mac address",
"pattern": "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$",
"minLength": 17,
"maxLength": 17,
"propertyOrder": 4
"propertyOrder": 4,
},
"src_port": {
"type": "string",
"title": "src_port",
"description": "match incoming traffic from the specified "
"source port or port range, if relevant proto "
"is specified. Multiple ports can be specified "
"separated by blanks",
"propertyOrder": 5
"source port or port range, if relevant proto "
"is specified. Multiple ports can be specified "
"separated by blanks",
"propertyOrder": 5,
},
"proto": {
"type": "string",
"title": "proto",
"description": "match incoming traffic using the given protocol. "
"Can be one of tcp, udp, tcpudp, udplite, icmp, esp, "
"ah, sctp, or all or it can be a numeric value, "
"representing one of these protocols or a different one. "
"A protocol name from /etc/protocols is also allowed. "
"The number 0 is equivalent to all",
"Can be one of tcp, udp, tcpudp, udplite, icmp, esp, "
"ah, sctp, or all or it can be a numeric value, "
"representing one of these protocols or a different one. "
"A protocol name from /etc/protocols is also allowed. "
"The number 0 is equivalent to all",
"default": "tcpudp",
"propertyOrder": 6
"propertyOrder": 6,
},
"icmp_type": {
"title": "icmp_type",
"description": "for protocol icmp select specific icmp types to match. "
"Values can be either exact icmp type numbers or type names",
"Values can be either exact icmp type numbers or type names",
"type": "array",
"uniqueItems": True,
"additionalItems": True,
"propertyOrder": 7,
"items": {
"title": "ICMP type",
"type": "string"
}
"items": {"title": "ICMP type", "type": "string"},
},
"dest": {
"type": "string",
"title": "dest",
"description": "specifies the traffic destination zone and must "
"refer to one of the defined zone names, or * for "
"any zone. If specified, the rule applies to forwarded "
"traffic; otherwise, it is treated as input rule",
"propertyOrder": 8
"refer to one of the defined zone names, or * for "
"any zone. If specified, the rule applies to forwarded "
"traffic; otherwise, it is treated as input rule",
"propertyOrder": 8,
},
"dest_ip": {
"type": "string",
"title": "dest_ip",
"description": "match incoming traffic directed to the specified "
"destination ip address. With no dest zone, this "
"is treated as an input rule",
"propertyOrder": 9
"destination ip address. With no dest zone, this "
"is treated as an input rule",
"propertyOrder": 9,
},
"dest_port": {
"type": "string",
"title": "dest_port",
"description": "match incoming traffic directed at the given "
"destination port or port range, if relevant "
"proto is specified. Multiple ports can be specified "
"separated by blanks",
"propertyOrder": 10
"destination port or port range, if relevant "
"proto is specified. Multiple ports can be specified "
"separated by blanks",
"propertyOrder": 10,
},
"target": {
"allOf": [
{"$ref": "#/definitions/rule_policy"},
{
"title": "target",
"description": "firewall action for matched traffic",
"propertyOrder": 11
}
"propertyOrder": 11,
},
]
},
"family": {
Expand All @@ -696,29 +678,29 @@
"description": "protocol family to generate iptables rules for",
"enum": ["ipv4", "ipv6", "any"],
"default": "any",
"propertyOrder": 12
"propertyOrder": 12,
},
"limit": {
"type": "string",
"title": "limit",
"description": "maximum average matching rate; specified as a number, "
"with an optional /second, /minute, /hour or /day suffix",
"propertyOrder": 13
"with an optional /second, /minute, /hour or /day suffix",
"propertyOrder": 13,
},
"enabled": {
"type": "boolean",
"title": "enable rule",
"default": True,
"format": "checkbox",
"propertyOrder": 14
}
}
}
}
}
}
}
}
"propertyOrder": 14,
},
},
},
},
},
},
},
},
)


Expand Down

0 comments on commit 7837ad8

Please sign in to comment.