Files
openstack-ansible/playbooks/roles/lxc_container_create/templates/veth-cleanup.sh.j2
kevin 3a3b076c47 Added post and pre hook script for veth cleanup
The change adds a simple post and pre hook script to clean up all of the
the named veth pairs that are assosiated within a given container.

Change-Id: I563a4be9f5e04c1599a9e4e592970a4ef0dbb38e
Implements: blueprint named-veths
2015-09-03 18:00:42 -05:00

15 lines
858 B
Django/Jinja

#!/usr/bin/env bash
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# LXC eth0 is considered special and not managed by the base container_networks
# data structure. This is being added outside of the loop for this reason.
ip link del {{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_eth0 || true
logger "LXC container {{ inventory_hostname }} removing veth {{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_eth0"
# Veth cleanup for items in the container_networks data structure
{% for key, value in container_networks.items() %}
ip link del {{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_{{ value.interface }} || true
logger "LXC container {{ inventory_hostname }} removing veth {{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_{{ value.interface }}"
{% endfor %}