From 8802ff3e0e02a683e567021a870a1456d5cc004f Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Mon, 26 Nov 2018 10:44:23 +0000 Subject: [PATCH] Use only the first 6 characters of the node name in link names Linux interface names can be a maximum of 15 characters. Long node names can exceed this limit, when combined with the patch port prefix, node index and patch port suffix. By default, these are: p---(phy|ovs) This is 7 characters, plus the node name prefix, plus the node index. A 6 character limit on the node name prefix gives a bit of wiggle room if the patch prefix or suffix are changed from the defaults. Change-Id: I672709a2fbf4eec2f7b7ba64404282d7f1e62935 TrivialFix --- ansible/filter_plugins/tenks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ansible/filter_plugins/tenks.py b/ansible/filter_plugins/tenks.py index 47d9ba5..a03b90b 100644 --- a/ansible/filter_plugins/tenks.py +++ b/ansible/filter_plugins/tenks.py @@ -198,7 +198,10 @@ def _parse_size_string(size): def _link_name(context, node, physnet, inventory_hostname=None): prefix = _get_hostvar(context, 'veth_prefix', inventory_hostname=inventory_hostname) - return (prefix + node['name'] + '-' + + # Use up to the first 6 characters of the node name to avoid hitting the + # maximum link name length limit (15). + name = node['name'][:6] + return (prefix + name + '-' + str(physnet_name_to_index(context, physnet, inventory_hostname=inventory_hostname)))