# if no --net option is given, network = [{}], so 1 empty dict in the list
# this results in 1 default interface with a default ip address
for nw in network:
+ # clean up network configuration (e.g. RTNETLINK does not allow ':' in intf names
+ if nw.get("id") is not None:
+ nw["id"] = self._clean_ifname(nw["id"])
# TODO we cannot use TCLink here (see: https://github.com/mpeuster/containernet/issues/3)
self.net.addLink(d, self.switch, params1=nw, cls=Link, intfName1=nw.get('id'))
# do bookkeeping
self.net.rm_registrar.register(self, rm)
LOG.info("Assigned RM: %r to DC: %r" % (rm, self))
+ @staticmethod
+ def _clean_ifname(name):
+ """
+ Cleans up given string to be a
+ RTNETLINK compatible interface name.
+ :param name: string
+ :return: string
+ """
+ if name is None:
+ return "if0"
+ name = name.replace(":", "-")
+ name = name.replace(" ", "-")
+ name = name.replace(".", "-")
+ name = name.replace("_", "-")
+ return name
+