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-<node name prefix>-<node index>-(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
This commit is contained in:
Mark Goddard 2018-11-26 10:44:23 +00:00
parent 347ee1cc7f
commit 8802ff3e0e
1 changed files with 4 additions and 1 deletions

View File

@ -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)))