daemon: Represent object ids in hex when used to generate interface

names (to reduce length if possible).
This commit is contained in:
tgoff0 2015-03-09 15:20:54 +00:00
parent 62adc0f1c9
commit 61f1a6e72e

View file

@ -167,11 +167,17 @@ class SimpleLxcNode(PyCoreNode):
if ifname is None: if ifname is None:
ifname = "eth%d" % ifindex ifname = "eth%d" % ifindex
sessionid = self.session.shortsessionid() sessionid = self.session.shortsessionid()
name = "veth%s.%sp%s" % (self.objid, ifindex, sessionid) try:
localname = "veth%s.%s.%s" % (self.objid, ifindex, sessionid) 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: if len(localname) >= 16:
raise ValueError, "interface local name '%s' to long" % \ raise ValueError, "interface local name '%s' too long" % \
localname localname
name = localname + 'p'
if len(name) >= 16:
raise ValueError, "interface name '%s' too long" % name
ifclass = VEth ifclass = VEth
veth = ifclass(node = self, name = name, localname = localname, veth = ifclass(node = self, name = name, localname = localname,
mtu = 1500, net = net, start = self.up) mtu = 1500, net = net, start = self.up)