Ensure veths are only 15 characters long

A veth pair on a linux system can only have 15 characters in
its name. This PR ensures that the built veth pair is templated
and string spliced such that it can ONLY be a maximum of 15
characters long.

Change-Id: Ibe78679b9364b41cb68ec42599a906b3f1552e41
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2016-09-12 12:38:16 -05:00
parent 84b73aea3f
commit a717c8bba2
No known key found for this signature in database
GPG Key ID: 69FEFFC5E2D9273F
3 changed files with 4 additions and 2 deletions

View File

@ -102,3 +102,5 @@ lxc_container_download_template_options: >
# Toggle the restart of containers via the handler.
lxc_container_allow_restarts: yes
lxc_container_network_veth_pair: "{{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_{{ item.value.interface }}"

View File

@ -250,7 +250,7 @@
shell: >
/usr/local/bin/lxc-veth-wiring
"{{ inventory_hostname }}"
"{{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_{{ item.value.interface }}"
"{{ lxc_container_network_veth_pair[-15:] }}"
"{{ item.value.interface }}"
"{{ item.value.bridge }}"
register: wiring_script

View File

@ -8,7 +8,7 @@ lxc.network.name = {{ item.value.interface }}
# Name the veth after the container
# NOTE(major): The lxc.network.veth.pair line must appear right after
# lxc.network.name or it will be ignored.
lxc.network.veth.pair = {{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_{{ item.value.interface }}
lxc.network.veth.pair = {{ lxc_container_network_veth_pair[-15:] }}
{% endif %}
# Host link to attach to, this should be a bridge if lxc.network.type = veth
lxc.network.link = {{ item.value.bridge }}