From 61f1a6e72e480c006c99fd5e5b9a6e4afda37f70 Mon Sep 17 00:00:00 2001 From: tgoff0 Date: Mon, 9 Mar 2015 15:20:54 +0000 Subject: [PATCH] daemon: Represent object ids in hex when used to generate interface names (to reduce length if possible). --- daemon/core/netns/vnode.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/daemon/core/netns/vnode.py b/daemon/core/netns/vnode.py index b8571ceb..9ec1fd50 100644 --- a/daemon/core/netns/vnode.py +++ b/daemon/core/netns/vnode.py @@ -167,11 +167,17 @@ class SimpleLxcNode(PyCoreNode): if ifname is None: ifname = "eth%d" % ifindex sessionid = self.session.shortsessionid() - name = "veth%s.%sp%s" % (self.objid, ifindex, sessionid) - localname = "veth%s.%s.%s" % (self.objid, ifindex, sessionid) + try: + suffix = '%x.%s.%s' % (self.objid, ifindex, sessionid) + except TypeError: + suffix = '%s.%s.%s' % (self.objid, ifindex, sessionid) + localname = 'veth' + suffix if len(localname) >= 16: - raise ValueError, "interface local name '%s' to long" % \ + raise ValueError, "interface local name '%s' too long" % \ localname + name = localname + 'p' + if len(name) >= 16: + raise ValueError, "interface name '%s' too long" % name ifclass = VEth veth = ifclass(node = self, name = name, localname = localname, mtu = 1500, net = net, start = self.up)