diff options
7 files changed, 61 insertions, 0 deletions
diff --git a/templates/policy/large-community-list/node.def b/templates/policy/large-community-list/node.def new file mode 100644 index 00000000..61687d47 --- /dev/null +++ b/templates/policy/large-community-list/node.def @@ -0,0 +1,4 @@ +tag: +priority: 470 +type: txt +help: Border Gateway Protocol (BGP) large-community-list filter diff --git a/templates/policy/large-community-list/node.tag/rule/node.def b/templates/policy/large-community-list/node.tag/rule/node.def new file mode 100644 index 00000000..cdea7e30 --- /dev/null +++ b/templates/policy/large-community-list/node.tag/rule/node.def @@ -0,0 +1,20 @@ +tag: +type: u32 +help: create a rule for this BGP large-community list +val_help: u32:1-65535; large-community-list rule number + +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 65535; "rule number must be between 1 and 65535" + +commit:expression: $VAR(./regex/) != ""; "You must specify a regex" +commit:expression: $VAR(./action/) != ""; "You must specify an action" + +end: + # If the rule exists in the running config + if cli-shell-api existsActive policy large-community-list $VAR(../@) rule $VAR(@); then + orig_action=$(cli-shell-api returnActiveValue policy large-community-list $VAR(../@) rule $VAR(@) action) + orig_regex=$(cli-shell-api returnActiveValue policy large-community-list $VAR(../@) rule $VAR(@) regex) + vtysh -c "configure terminal" -c "no ip large-community-list expanded $VAR(../@) $orig_action $VAR(@) regex $orig_regex" + fi + if [[ ${COMMIT_ACTION} != 'DELETE' ]]; then + vtysh -c "configure terminal" -c "ip large-community-list expanded $VAR(../@) $VAR(./action/@) $VAR(@) regex $VAR(./regex/@)" + fi diff --git a/templates/policy/large-community-list/node.tag/rule/node.tag/action/node.def b/templates/policy/large-community-list/node.tag/rule/node.tag/action/node.def new file mode 100644 index 00000000..b965bccf --- /dev/null +++ b/templates/policy/large-community-list/node.tag/rule/node.tag/action/node.def @@ -0,0 +1,5 @@ +type: txt +help: Action to take on communities matching this rule [REQUIRED] +val_help: permit; Permit matching communities +val_help: deny; Deny matching communities +syntax:expression: $VAR(@) in "permit", "deny"; "action must be permit or deny" diff --git a/templates/policy/large-community-list/node.tag/rule/node.tag/description/node.def b/templates/policy/large-community-list/node.tag/rule/node.tag/description/node.def new file mode 100644 index 00000000..b8e3095b --- /dev/null +++ b/templates/policy/large-community-list/node.tag/rule/node.tag/description/node.def @@ -0,0 +1,2 @@ +type: txt +help: Description for this rule diff --git a/templates/policy/large-community-list/node.tag/rule/node.tag/regex/node.def b/templates/policy/large-community-list/node.tag/rule/node.tag/regex/node.def new file mode 100644 index 00000000..2a820bc6 --- /dev/null +++ b/templates/policy/large-community-list/node.tag/rule/node.tag/regex/node.def @@ -0,0 +1,3 @@ +type: txt +help: Regular expression to match against a community list +val_help: Community list regular expression diff --git a/templates/policy/route-map/node.tag/rule/node.tag/match/large-community/large-community-list/node.def b/templates/policy/route-map/node.tag/rule/node.tag/match/large-community/large-community-list/node.def new file mode 100644 index 00000000..5e35214d --- /dev/null +++ b/templates/policy/route-map/node.tag/rule/node.tag/match/large-community/large-community-list/node.def @@ -0,0 +1,5 @@ +type: txt +help: BGP large-community-list to match +allowed: cli-shell-api listNodes policy large-community-list + +commit:expression: exec "cli-shell-api exists policy large-community-list $VAR(./@)"; "Large community list $VAR(./@) does not exist" diff --git a/templates/policy/route-map/node.tag/rule/node.tag/match/large-community/node.def b/templates/policy/route-map/node.tag/rule/node.tag/match/large-community/node.def new file mode 100644 index 00000000..609f8d76 --- /dev/null +++ b/templates/policy/route-map/node.tag/rule/node.tag/match/large-community/node.def @@ -0,0 +1,22 @@ +help: Match BGP large communities +delete: echo route-map $VAR(../../../@) $VAR(../../action/@) $VAR(../../@) >> /tmp/delete-policy-route-map-$VAR(../../../@)-$VAR(../../@)-match-large-community.$PPID +end: if [ -f /tmp/delete-policy-route-map-$VAR(../../../@)-$VAR(../../@)-match-large-community.$PPID ]; then + routemap=`cat /tmp/delete-policy-route-map-$VAR(../../../@)-$VAR(../../@)-match-large-community.$PPID` + rm -f /tmp/delete-policy-route-map-$VAR(../../../@)-$VAR(../../@)-match-large-community.$PPID; + vtysh --noerror -c "configure terminal" -c "$routemap " -c "no match large-community"; + exit 0; + else + if [ -z "$VAR(./large-community-list/@)" ]; then + echo route-map $VAR(../../../@) rule $VAR(../../@) match large-community: you must configure a community-list; + exit 1 ; + fi ; + if [ -z "$VAR(../../action/@)" ]; then + echo route-map $VAR(../../../@) rule $VAR(../../@): you must configure an action; + exit 1 ; + fi ; + routemap='route-map $VAR(../../../@) $VAR(../../action/@) $VAR(../../@)'; + + vtysh --noerror -c "configure terminal" -c "$routemap " -c "no match large-community"; + vtysh -c "configure terminal" -c "$routemap " -c "match large-community $VAR(./large-community-list/@)"; + fi + |