lib/junoser/ruler.rb in junoser-0.5.6 vs lib/junoser/ruler.rb in junoser-0.6.0
- old
+ new
@@ -222,14 +222,12 @@
# Fix .xsd: "class-of-service interfaces xxx unit x"
str.gsub! '"*"', 'arg'
# Fix .xsd: "from-zone" arg is also required
- str.gsub!(/^(\s*)"policy" \(\s*s\(\s*arg,\s*"to-zone-name" arg,\s*c\(\s*"policy" \(\s*policy_type\s*\)\s*\)/) do
- format(['b(s("from-zone", arg, "to-zone", arg),',
- ' b("policy", policy_type',
- ], $1)
+ str.gsub!(/^ "policy" \(\s*s\(\s*arg,\s*"to-zone-name" arg,\s*(.*?)\s*\)\s*^ \),/m) do
+ format(['b(', ' s("from-zone", arg, "to-zone", arg),', " #$1", '),'], ' ')
end
# Fix .xsd: "members" accepts [ foo bar ]
str.gsub! '"members" arg', '"members" any'
@@ -269,18 +267,25 @@
str.gsub! '"ethernet-1', '"1'
# Fix .xsd: support "set policy-options policy-statement xxx from policy [expression]"
str.gsub!(/^rule\(:policy_algebra\) do(\s*)arg\.as\(:arg\)\send/) { "rule(:policy_algebra) do#{$1}any.as(:arg)\nend" }
+ # Fix .xsd: support "set interfaces xxx enable"
+ str.gsub!(/^(rule\(:interfaces_type\) do\s*[^\n]*\s*c\()(\s*)/m) do
+ %[#{$1}#{$2}"enable",#{$2}]
+ end
+
str
end
def format(str, offset = OFFSET)
case str
when String
str.empty? ? '' : offset + str
when Array
str.map { |s| s.empty? ? '' : offset + s.to_s }.join("\n")
+ else
+ ''
end
end
def rule_header
<<-EOS