def add_file(self, filepath): 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) xml_data = parser.parse() machine_spec = self._process_machine_xml_data(m_id, xml_data) # Check if there isn't any machine with the same # hostname or libvirt_domain already in the pool for pm_id, m in self._pool.iteritems(): 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 SlaveMachineError(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 SlaveMachineError(msg) if self._pool_checks: available = False hostname = machine_spec["params"]["hostname"] if "rpc_port" in machine_spec["params"]: port = machine_spec["params"]["rpc_port"] else: port = lnst_config.get_option("environment", "rpcport") logging.debug("Querying machine '%s': %s:%s" % (m_id, hostname, port)) if test_tcp_connection(hostname, port): available = True if "libvirt_domain" in machine_spec["params"] and not self._allow_virt: logging.debug("libvirtd not running. Removing " "libvirt_domain from machine '%s'" % m_id) del machine_spec["params"]["libvirt_domain"] if available: self._pool[m_id] = machine_spec return (m_id, available)
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)
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) 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 or allow_virtual "\ "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.iteritems(): 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 SlaveMachineError(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 SlaveMachineError(msg) return (m_id, machine_spec) return (None, None)