コード例 #1
0
    def pop(self, n=None):
        if self._popped:
            assert n is None
            return []
        self._popped = True

        remotes = []
        for i in range(self.available_n):
            if self.vnc_addresses is not None:
                vnc_address = self.vnc_addresses[i]
            else:
                vnc_address = None

            if self.rewarder_addresses is not None:
                rewarder_address = self.rewarder_addresses[i]
            else:
                rewarder_address = None

            name = self._handles[i]
            env = remote.Remote(
                handle=self._handles[i],
                vnc_address=vnc_address,
                vnc_password=self.vnc_password,
                rewarder_address=rewarder_address,
                rewarder_password=self.rewarder_password,
            )
            remotes.append(env)
        return remotes
コード例 #2
0
    def _handle_allocation(self, allocation, pop=False):
        ready = []
        not_ready = []
        for alloc_env in allocation['env_n']:
            if alloc_env['status'] != 'allocated':
                not_ready.append(alloc_env)
                continue
            if pop:
                self.pending.pop(alloc_env['name'])
            env = remote.Remote(
                name=alloc_env['name'],
                handle=alloc_env['handle'],
                vnc_address=alloc_env['vnc_address'],
                vnc_password=alloc_env['vnc_password'],
                rewarder_address=alloc_env['rewarder_address'],
                rewarder_password=alloc_env['rewarder_password'],
            )
            ready.append(env)

        if len(ready) > 0:
            extra_logger.info(
                '[%s] The following envs now have IPs, but still may take time to boot: %s',
                self.label, ready)
            self.ready.put(ready)

        return ready, not_ready
コード例 #3
0
    def pop(self, n=None):
        """Call from main thread. Returns the list of newly-available (handle, env) pairs."""
        if self._popped:
            assert n is None
            return []
        self._popped = True

        envs = []
        for i, instance in enumerate(self.instances):
            env = remote.Remote(
                handle=self._handles[i],
                vnc_address='{}:{}'.format(instance.host, instance.vnc_port),
                vnc_password='******',
                rewarder_address='{}:{}'.format(instance.host, instance.rewarder_port),
                rewarder_password='******',
            )
            envs.append(env)
        return envs