Пример #1
0
    def connect_host(self, hostname, timeout=60, port=None, machine_id=None,
                     security=None):
        ctl_config = self._controller._config
        msg_dispatcher = self._controller._msg_dispatcher

        if security is None:
            security = {"auth_type": "none"}

        if machine_id is None:
            machine_id = hostname

        m = Machine(machine_id, hostname, msg_dispatcher,
                    ctl_config, None, port, security)

        def condition():
            try:
                m.init_connection(timeout=1)
                return True
            except:
                log_exc_traceback()
                return False

        msg_dispatcher.wait_for_condition(condition, timeout)

        host = Host(m)
        self._controller._prepare_machine(m)
        m.start_recipe(self._recipe)
        return host
Пример #2
0
    def _map_match(self, match, requested, recipe):
        self._machines = {}
        self._hosts = Hosts()
        pool = self._pools.get_machine_pool(match["pool_name"])
        for m_id, m in list(match["machines"].items()):
            machine = self._machines[m_id] = pool[m["target"]]

            setattr(self._hosts, m_id, Host(machine))
            host = getattr(self._hosts, m_id)

            machine.set_id(m_id)
            machine.set_mapped(True)
            self._prepare_machine(machine)

            for if_id, i in list(m["interfaces"].items()):
                host.map_device(if_id, i)

            if match["virtual"]:
                req_host = getattr(requested, m_id)
                for name, dev in req_host:
                    new_virt_dev = VirtualDevice(
                        network=dev.label,
                        driver=getattr(dev.params, "driver", None),
                        hwaddr=getattr(dev.params, "hwaddr", None))
                    setattr(host, name, new_virt_dev)
                    new_virt_dev._enable()

            machine.start_recipe(recipe)
Пример #3
0
    def _map_match(self, match, requested):
        self._machines = {}
        self._hosts = Hosts()
        pool = self._pools.get_machine_pool(match["pool_name"])
        for m_id, m in match["machines"].items():
            machine = self._machines[m_id] = pool[m["target"]]

            machine.set_id(m_id)
            self._prepare_machine(machine)

            setattr(self._hosts, m_id, Host(machine))
            host = getattr(self._hosts, m_id)
            for if_id, i in m["interfaces"].items():
                host._map_device(if_id, i)

            if match["virtual"]:
                req_host = getattr(requested, m_id)
                for name, dev in req_host:
                    new_virt_dev = VirtualDevice(network=dev.label,
                                                 driver=dev.params.driver,
                                                 hwaddr=dev.params.hwaddr)
                    setattr(host, name, new_virt_dev)