def add_file(self, pool_name, dir_path, dirent): filepath = dir_path + "/" + dirent pool = self._pools[pool_name] if os.path.isfile(filepath) and re.search("\.xml$", filepath, re.I): dirname, basename = os.path.split(filepath) m_id = re.sub("\.[xX][mM][lL]$", "", basename) parser = SlaveMachineParser(filepath, self._ctl_config) xml_data = parser.parse() machine_spec = self._process_machine_xml_data(m_id, xml_data) if 'libvirt_domain' in machine_spec['params'] and \ not self._allow_virt: logging.debug("libvirtd not running disabled. "\ "Removing libvirt_domain from "\ "machine '%s'" % m_id) del machine_spec['params']['libvirt_domain'] # Check if there isn't any machine with the same # hostname or libvirt_domain already in the pool for pm_id, m in pool.items(): pm = m["params"] rm = machine_spec["params"] if pm["hostname"] == rm["hostname"]: msg = "You have the same machine listed twice in " \ "your pool ('%s' and '%s')." % (m_id, pm_id) raise PoolManagerError(msg) if "libvirt_domain" in rm and "libvirt_domain" in pm and \ pm["libvirt_domain"] == rm["libvirt_domain"]: msg = "You have the same libvirt_domain listed twice in " \ "your pool ('%s' and '%s')." % (m_id, pm_id) raise PoolManagerError(msg) return (m_id, machine_spec) return (None, None)