Ejemplo n.º 1
0
    def first_pass(self):
        dom_init = XmlDomTreeInit()
        rp = self._rp
        self._xml_dom = dom_init.parse_string(rp.to_str(), rp.abs_path())

        first_pass = FirstPass(self)
        first_pass.parse(self._xml_dom)
Ejemplo n.º 2
0
    def first_pass(self):
        dom_init = XmlDomTreeInit()
        rp = self._rp
        self._xml_dom = dom_init.parse_string(rp.to_str(), rp.abs_path())

        first_pass = FirstPass(self)
        first_pass.parse(self._xml_dom)
Ejemplo n.º 3
0
    def add_file(self, filepath):
        if os.path.isfile(filepath) and re.search("\.xml$", filepath, re.I):
            dom_init = XmlDomTreeInit()
            dom = dom_init.parse_file(filepath)

            dirname, basename = os.path.split(filepath)

            parser = SlaveMachineParse()
            parser.set_include_root(dirname)
            parser.disable_events()

            machine = {"params": {}, "interfaces": {}}
            m_id = re.sub("\.[xX][mM][lL]$", "", basename)
            parser.set_machine(m_id, machine)

            slavemachine = dom.getElementsByTagName("slavemachine")[0]

            parser.parse(slavemachine)

            if self._pool_checks:
                hostname = machine["params"]["hostname"]
                if "rpcport" in machine:
                    port = machine["params"]["rpcport"]
                else:
                    port = lnst_config.get_option('environment', 'rpcport')

                logging.info("Querying slave machine %s." % m_id)
                if not test_tcp_connection(hostname, port):
                    msg = "Machine '%s' not responding. Skipping." % m_id
                    logging.warning(msg)
                    return

                if 'libvirt_domain' in machine['params'] and \
                   not self._allow_virt:
                    msg = "libvird not running. Skipping machine '%s'." % m_id
                    logging.warning(msg)

            logging.info("Adding slave machine %s to slave pool." % m_id)
            self._pool[m_id] = machine
Ejemplo n.º 4
0
    def add_file(self, filepath):
        if os.path.isfile(filepath) and re.search("\.xml$", filepath, re.I):
            dom_init = XmlDomTreeInit()
            dom = dom_init.parse_file(filepath)

            dirname, basename = os.path.split(filepath)

            parser = SlaveMachineParse()
            parser.set_include_root(dirname)
            parser.disable_events()

            machine = {"params": {}, "interfaces": {}}
            m_id = re.sub("\.[xX][mM][lL]$", "", basename)
            parser.set_machine(m_id, machine)

            slavemachine = dom.getElementsByTagName("slavemachine")[0]

            parser.parse(slavemachine)

            if self._pool_checks:
                hostname = machine["params"]["hostname"]
                if "rpcport" in machine:
                    port = machine["params"]["rpcport"]
                else:
                    port = lnst_config.get_option("environment", "rpcport")

                logging.info("Querying slave machine %s." % m_id)
                if not test_tcp_connection(hostname, port):
                    msg = "Machine '%s' not responding. Skipping." % m_id
                    logging.warning(msg)
                    return

                if "libvirt_domain" in machine["params"] and not self._allow_virt:
                    msg = "libvird not running. Skipping machine '%s'." % m_id
                    logging.warning(msg)

            logging.info("Adding slave machine %s to slave pool." % m_id)
            self._pool[m_id] = machine