summaryrefslogtreecommitdiff
path: root/templates/interfaces/vxlan/node.def
diff options
context:
space:
mode:
Diffstat (limited to 'templates/interfaces/vxlan/node.def')
-rw-r--r--templates/interfaces/vxlan/node.def48
1 files changed, 48 insertions, 0 deletions
diff --git a/templates/interfaces/vxlan/node.def b/templates/interfaces/vxlan/node.def
new file mode 100644
index 00000000..f5f99af7
--- /dev/null
+++ b/templates/interfaces/vxlan/node.def
@@ -0,0 +1,48 @@
+tag:
+priority: 460
+type: txt
+help: Virtual eXtensible LAN interface
+val_help: <vxlanN>; VXLAN interface name
+syntax:expression: pattern $VAR(@) "vxlan[0-9]+$"
+
+commit:expression: $VAR(./group/) != ""; \
+ "Must configure vxlan group for $VAR(@)"
+commit:expression: $VAR(./vni/) != ""; \
+ "Must configure vxlan vni for $VAR(@)"
+
+begin:
+ [ -d /sys/module/vxlan ] || sudo modprobe vxlan
+
+
+create:
+ if [ -e /sys/class/net/$VAR(@) ]; then
+ echo "VXLAN interface \"$VAR(@)\" already exists."
+ fi
+
+ VXLAN_VNI="id $VAR(./vni/@)"
+ VXLAN_GROUP="group $VAR(./group/@)"
+ VXLAN_TTL="ttl 16"
+
+ if [ ! $VAR(./dev/) == "" ]; then
+ VXLAN_DEV="dev $VAR(./dev/@)"
+ fi
+
+ ip link add name $VAR(@) type vxlan \
+ $VXLAN_VNI $VXLAN_GROUP $VXLAN_TTL $VXLAN_DEV
+ ip link set $VAR(@) up
+
+ touch /tmp/vxlan-$VAR(@)-create
+
+
+delete:
+ if [ ! -e /sys/class/net/$VAR(@) ]; then
+ echo "VXLAN interface \"$VAR(@)\" does not exist."
+ fi
+
+ ip link del dev $VAR(@)
+
+
+end:
+ if [ -e /tmp/vxlan-$VAR(@)-create ]; then
+ rm /tmp/vxlan-$VAR(@)-create
+ fi