Esempio n. 1
0
	def __load_ct_config(self):
		logging.info("Loading config file from %s", self.__ct_config())

		self._cfg = {}
		self._veths = []

		veth = None

		ifd = open(self.__ct_config())
		for line in ifd:
			if not ("=" in line):
				continue
			k, v = map(lambda a: a.strip(), line.split("=", 1))
			self._cfg[k] = v

			if k == "lxc.network.type":
				if v != "veth":
					raise Exception("Unsupported network device type: %s", v)
				if veth:
					self._veths.append(veth)
				veth = util.net_dev()
			elif k == "lxc.network.link":
				veth.link = v
			elif k == "lxc.network.name":
				veth.name = v
			elif k == "lxc.network.veth.pair":
				veth.pair = v
		if veth:
			self._veths.append(veth)
		ifd.close()
    def __load_ct_config(self):
        logging.info("Loading config file from %s", self.__ct_config())

        self._cfg = {}
        self._veths = []

        veth = None

        ifd = open(self.__ct_config())
        for line in ifd:
            if not ("=" in line):
                continue
            k, v = map(lambda a: a.strip(), line.split("=", 1))
            self._cfg[k] = v

            if k == "lxc.network.type":
                if v != "veth":
                    raise Exception("Unsupported network device type: %s", v)
                if veth:
                    self._veths.append(veth)
                veth = util.net_dev()
            elif k == "lxc.network.link":
                veth.link = v
            elif k == "lxc.network.name":
                veth.name = v
            elif k == "lxc.network.veth.pair":
                veth.pair = v
        if veth:
            self._veths.append(veth)
        ifd.close()
Esempio n. 3
0
	def __load_ct_config(self, path):
		print "Loading config file from %s" % path
		ifd = open(os.path.join(path, self.__ct_config()))
		for line in ifd:
			self._cfg.append(line)

			if line.startswith("NETIF="):
				#
				# Parse and keep veth pairs, later we will
				# equip restore request with this data and
				# will use it while (un)locking the network
				#
				v_in = None
				v_out = None
				v_bridge = None
				vs = line.strip().split("=", 1)[1].strip("\"")
				for parm in vs.split(","):
					pa = parm.split("=")
					if pa[0] == "ifname":
						v_in = pa[1]
					elif pa[0] == "host_ifname":
						v_out = pa[1]
					elif pa[0] == "bridge":
						v_bridge = pa[1]

				if v_in and v_out:
					print "\tCollect %s -> %s (%s) veth" % (v_in, v_out, v_bridge)
					veth = util.net_dev()
					veth.name = v_in
					veth.pair = v_out
					veth.link = v_bridge
					self._veths.append(veth)

		ifd.close()
Esempio n. 4
0
	def __load_ct_config(self, path):
		print "Loading config file from %s" % path

		with open(os.path.join(path, self.__ct_config())) as ifd:
			self._cfg = ifd.read()

		#
		# Parse and keep veth pairs, later we will
		# equip restore request with this data and
		# will use it while (un)locking the network
		#
		config = parse_vz_config(self._cfg)
		if "NETIF" in config:
			v_in, v_out, v_bridge = None, None, None
			for parm in config["NETIF"].split(","):
				pa = parm.split("=")
				if pa[0] == "ifname":
					v_in = pa[1]
				elif pa[0] == "host_ifname":
					v_out = pa[1]
				elif pa[0] == "bridge":
					v_bridge = pa[1]
			if v_in and v_out:
				print "\tCollect %s -> %s (%s) veth" % (v_in, v_out, v_bridge)
				self._veths.append(util.net_dev(v_in, v_out, v_bridge))
Esempio n. 5
0
    def __load_ct_config(self, path):
        print "Loading config file from %s" % path
        ifd = open(os.path.join(path, self.__ct_config()))
        for line in ifd:
            self._cfg.append(line)

            if line.startswith("NETIF="):
                #
                # Parse and keep veth pairs, later we will
                # equip restore request with this data and
                # will use it while (un)locking the network
                #
                v_in = None
                v_out = None
                v_bridge = None
                vs = line.strip().split("=", 1)[1].strip("\"")
                for parm in vs.split(","):
                    pa = parm.split("=")
                    if pa[0] == "ifname":
                        v_in = pa[1]
                    elif pa[0] == "host_ifname":
                        v_out = pa[1]
                    elif pa[0] == "bridge":
                        v_bridge = pa[1]

                if v_in and v_out:
                    print "\tCollect %s -> %s (%s) veth" % (v_in, v_out,
                                                            v_bridge)
                    veth = util.net_dev()
                    veth.name = v_in
                    veth.pair = v_out
                    veth.link = v_bridge
                    self._veths.append(veth)

        ifd.close()
Esempio n. 6
0
    def __load_ct_config(self, path):
        logging.info("Loading config file from %s", path)

        # Read container config
        with open(os.path.join(path, self.__ct_config())) as ifd:
            self._cfg = ifd.read()
        config = parse_vz_config(self._cfg)

        # Read global config
        with open(vz_global_conf) as ifd:
            global_config = parse_vz_config(ifd.read())

        # Extract veth pairs, later we will equip restore request with this
        # data and will use it while (un)locking the network
        if "NETIF" in config:
            v_in, v_out, v_bridge = None, None, None
            for parm in config["NETIF"].split(","):
                pa = parm.split("=")
                if pa[0] == "ifname":
                    v_in = pa[1]
                elif pa[0] == "host_ifname":
                    v_out = pa[1]
                elif pa[0] == "bridge":
                    v_bridge = pa[1]
            if v_in and v_out:
                logging.info("\tCollect %s -> %s (%s) veth", v_in, v_out,
                             v_bridge)
                self._veths.append(util.net_dev(v_in, v_out, v_bridge))

        # Extract private path from config
        if "VE_PRIVATE" in config:
            self._ct_priv = expand_veid_var(config["VE_PRIVATE"], self._ctid)
        else:
            self._ct_priv = expand_veid_var(global_config["VE_PRIVATE"],
                                            self._ctid)

        # Extract root path from config
        if "VE_ROOT" in config:
            self._ct_root = expand_veid_var(config["VE_ROOT"], self._ctid)
        else:
            self._ct_root = expand_veid_var(global_config["VE_ROOT"],
                                            self._ctid)
Esempio n. 7
0
	def __load_ct_config(self, path):
		logging.info("Loading config file from %s", path)

		# Read container config
		with open(os.path.join(path, self.__ct_config())) as ifd:
			self._cfg = ifd.read()
		config = parse_vz_config(self._cfg)

		# Read global config
		with open(vz_global_conf) as ifd:
			global_config = parse_vz_config(ifd.read())

		# Extract veth pairs, later we will equip restore request with this
		# data and will use it while (un)locking the network
		if "NETIF" in config:
			v_in, v_out, v_bridge = None, None, None
			for parm in config["NETIF"].split(","):
				pa = parm.split("=")
				if pa[0] == "ifname":
					v_in = pa[1]
				elif pa[0] == "host_ifname":
					v_out = pa[1]
				elif pa[0] == "bridge":
					v_bridge = pa[1]
			if v_in and v_out:
				logging.info("\tCollect %s -> %s (%s) veth", v_in, v_out, v_bridge)
				self._veths.append(util.net_dev(v_in, v_out, v_bridge))

		# Extract private path from config
		if "VE_PRIVATE" in config:
			self._ct_priv = expand_veid_var(config["VE_PRIVATE"], self._ctid)
		else:
			self._ct_priv = expand_veid_var(global_config["VE_PRIVATE"],
				self._ctid)

		# Extract root path from config
		if "VE_ROOT" in config:
			self._ct_root = expand_veid_var(config["VE_ROOT"], self._ctid)
		else:
			self._ct_root = expand_veid_var(global_config["VE_ROOT"],
				self._ctid)