Provision slave container and wait for it's availability.
160474
private DockerSlave provisionWithWait(DockerSlaveTemplate template, ProvisioningActivity.Id id)
            throws Exception {
        final DockerContainerLifecycle dockerContainerLifecycle = template.getDockerContainerLifecycle();
        final String imageId = dockerContainerLifecycle.getImage();
        final DockerComputerLauncher computerLauncher = template.getLauncher();

        //pull image
        dockerContainerLifecycle.getPullImage().exec(getClient(), imageId, new StreamTaskListener(new NullStream()));

        // set the operating system if it's not already cached
        if (template.getOsType() == null) {
            template.setOsType(determineOsType(imageId));
        }

        LOG.debug("Trying to run container for {}, operating system {}", imageId, template.getOsType());
        final String containerId = runContainer(template);

        InspectContainerResponse ir;
        try {
            ir = getClient().inspectContainerCmd(containerId).exec();
        } catch (ProcessingException ex) {
            LOG.error("Failed to run container for {}, clean-up container", imageId);
            dockerContainerLifecycle.getRemoveContainer().exec(getClient(), containerId);
            throw ex;
        }

        // Build a description up:
        String nodeDescription = "Docker Node [" + imageId + " on ";
        try {
            nodeDescription += getDisplayName();
        } catch (Exception ex) {
            nodeDescription += "???";
        }
        nodeDescription += "]";

        String slaveName = String.format("%s-%s", getDisplayName(), containerId.substring(0, 12));

        if (computerLauncher.waitUp(getDisplayName(), template, ir)) {
            LOG.debug("Container {} is ready for slave connection", containerId);
        } else {
            LOG.error("Container {} is not ready for slave connection.", containerId);
        }

        final DockerComputerLauncher launcher = computerLauncher.getPreparedLauncher(getDisplayName(), template, ir);
        return new DockerSlave(slaveName, nodeDescription, launcher, containerId, template, getDisplayName(), id);
    }
128992
async def wait_until_serving(self) -> None:
        
        await asyncio.gather(
            self._receiving_loop_running.wait(),
            self._internal_loop_running.wait(),
            loop=self.event_loop
        )
239571
def pause(self):
        """"""
        yield from self.manager.query("POST", "containers/{}/pause".format(self._cid))
        self.status = "suspended"
        log.info("Docker container '{name}' [{image}] paused".format(name=self._name, image=self._image))
388713
public synchronized void waitForStart()
	throws ServerException,
	       ClientException,
	       IOException {
	    try {
	        while(!isStarted() && !hasError()) {
		        wait();
	        }
	    } catch(InterruptedException e) {
            // break
	    }
	    checkError();
    }
1315793
def wait(self):
        '''
        
        '''
        @param_to_property(action=["idle", "update"])
        def _wait(action, timeout=1000, package_name=None):
            if timeout / 1000 + 5 > int(os.environ.get("JSONRPC_TIMEOUT", 90)):
                http_timeout = timeout / 1000 + 5
            else:
                http_timeout = int(os.environ.get("JSONRPC_TIMEOUT", 90))
            if action == "idle":
                return self.server.jsonrpc_wrap(timeout=http_timeout).waitForIdle(timeout)
            elif action == "update":
                return self.server.jsonrpc_wrap(timeout=http_timeout).waitForWindowUpdate(package_name, timeout)
        return _wait
1086793
def wait_for_service_endpoint(service_name, timeout_sec=120):
    """"""

    master_count = len(get_all_masters())
    return time_wait(lambda: service_available_predicate(service_name),
                     timeout_seconds=timeout_sec,
                     required_consecutive_success_count=master_count)
624719
def wait_for(self, timeout=None):
        
        from broqer.op import OnEmitFuture  # due circular dependency
        return self | OnEmitFuture(timeout=timeout)
177539
def wait_for_instance(
        vm_=None,
        data=None,
        ip_address=None,
        display_ssh_output=True,
        call=None,
    ):
    '''
    
    '''
    if call == 'function':
        # Technically this function may be called other ways too, but it
        # definitely cannot be called with --function.
        raise SaltCloudSystemExit(
            'The wait_for_instance action must be called with -a or --action.'
        )

    if vm_ is None:
        vm_ = {}

    if data is None:
        data = {}

    ssh_gateway_config = vm_.get(
        'gateway', get_ssh_gateway_config(vm_)
    )

    __utils__['cloud.fire_event'](
        'event',
        'waiting for ssh',
        'salt/cloud/{0}/waiting_for_ssh'.format(vm_['name']),
        args={'ip_address': ip_address},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    ssh_connect_timeout = config.get_cloud_config_value(
        'ssh_connect_timeout', vm_, __opts__, 900   # 15 minutes
    )
    ssh_port = config.get_cloud_config_value(
        'ssh_port', vm_, __opts__, 22
    )

    if config.get_cloud_config_value('win_installer', vm_, __opts__):
        username = config.get_cloud_config_value(
            'win_username', vm_, __opts__, default='Administrator'
        )
        win_passwd = config.get_cloud_config_value(
            'win_password', vm_, __opts__, default=''
        )
        win_deploy_auth_retries = config.get_cloud_config_value(
            'win_deploy_auth_retries', vm_, __opts__, default=10
        )
        win_deploy_auth_retry_delay = config.get_cloud_config_value(
            'win_deploy_auth_retry_delay', vm_, __opts__, default=1
        )
        use_winrm = config.get_cloud_config_value(
            'use_winrm', vm_, __opts__, default=False
        )
        winrm_verify_ssl = config.get_cloud_config_value(
            'winrm_verify_ssl', vm_, __opts__, default=True
        )

        if win_passwd and win_passwd == 'auto':
            log.debug('Waiting for auto-generated Windows EC2 password')
            while True:
                password_data = get_password_data(
                    name=vm_['name'],
                    kwargs={
                        'key_file': vm_['private_key'],
                    },
                    call='action',
                )
                win_passwd = password_data.get('password', None)
                if win_passwd is None:
                    log.debug(password_data)
                    # This wait is so high, because the password is unlikely to
                    # be generated for at least 4 minutes
                    time.sleep(60)
                else:
                    logging_data = password_data

                    logging_data['password'] = 'XXX-REDACTED-XXX'
                    logging_data['passwordData'] = 'XXX-REDACTED-XXX'
                    log.debug(logging_data)

                    vm_['win_password'] = win_passwd
                    break

        # SMB used whether psexec or winrm
        if not salt.utils.cloud.wait_for_port(ip_address,
                                              port=445,
                                              timeout=ssh_connect_timeout):
            raise SaltCloudSystemExit(
                'Failed to connect to remote windows host'
            )

        # If not using winrm keep same psexec behavior
        if not use_winrm:

            log.debug('Trying to authenticate via SMB using psexec')

            if not salt.utils.cloud.validate_windows_cred(ip_address,
                                                          username,
                                                          win_passwd,
                                                          retries=win_deploy_auth_retries,
                                                          retry_delay=win_deploy_auth_retry_delay):
                raise SaltCloudSystemExit(
                    'Failed to authenticate against remote windows host (smb)'
                )

        # If using winrm
        else:

            # Default HTTPS port can be changed in cloud configuration
            winrm_port = config.get_cloud_config_value(
                'winrm_port', vm_, __opts__, default=5986
            )

            # Wait for winrm port to be available
            if not salt.utils.cloud.wait_for_port(ip_address,
                                                  port=winrm_port,
                                                  timeout=ssh_connect_timeout):
                raise SaltCloudSystemExit(
                    'Failed to connect to remote windows host (winrm)'
                )

            log.debug('Trying to authenticate via Winrm using pywinrm')

            if not salt.utils.cloud.wait_for_winrm(ip_address,
                                                          winrm_port,
                                                          username,
                                                          win_passwd,
                                                          timeout=ssh_connect_timeout,
                                                          verify=winrm_verify_ssl):
                raise SaltCloudSystemExit(
                    'Failed to authenticate against remote windows host'
                )

    elif salt.utils.cloud.wait_for_port(ip_address,
                                        port=ssh_port,
                                        timeout=ssh_connect_timeout,
                                        gateway=ssh_gateway_config
                                        ):
        # If a known_hosts_file is configured, this instance will not be
        # accessible until it has a host key. Since this is provided on
        # supported instances by cloud-init, and viewable to us only from the
        # console output (which may take several minutes to become available,
        # we have some more waiting to do here.
        known_hosts_file = config.get_cloud_config_value(
            'known_hosts_file', vm_, __opts__, default=None
        )
        if known_hosts_file:
            console = {}
            while 'output_decoded' not in console:
                console = get_console_output(
                    instance_id=vm_['instance_id'],
                    call='action',
                    location=get_location(vm_)
                )
                pprint.pprint(console)
                time.sleep(5)
            output = salt.utils.stringutils.to_unicode(console['output_decoded'])
            comps = output.split('-----BEGIN SSH HOST KEY KEYS-----')
            if len(comps) < 2:
                # Fail; there are no host keys
                return False

            comps = comps[1].split('-----END SSH HOST KEY KEYS-----')
            keys = ''
            for line in comps[0].splitlines():
                if not line:
                    continue
                keys += '\n{0} {1}'.format(ip_address, line)

            with salt.utils.files.fopen(known_hosts_file, 'a') as fp_:
                fp_.write(salt.utils.stringutils.to_str(keys))
            fp_.close()

        for user in vm_['usernames']:
            if salt.utils.cloud.wait_for_passwd(
                host=ip_address,
                port=ssh_port,
                username=user,
                ssh_timeout=config.get_cloud_config_value(
                    'wait_for_passwd_timeout', vm_, __opts__, default=1 * 60
                ),
                key_filename=vm_['key_filename'],
                display_ssh_output=display_ssh_output,
                gateway=ssh_gateway_config,
                maxtries=config.get_cloud_config_value(
                    'wait_for_passwd_maxtries', vm_, __opts__, default=15
                ),
                known_hosts_file=config.get_cloud_config_value(
                    'known_hosts_file', vm_, __opts__,
                    default='/dev/null'
                ),
            ):
                __opts__['ssh_username'] = user
                vm_['ssh_username'] = user
                break
        else:
            raise SaltCloudSystemExit(
                'Failed to authenticate against remote ssh'
            )
    else:
        raise SaltCloudSystemExit(
            'Failed to connect to remote ssh'
        )

    if 'reactor' in vm_ and vm_['reactor'] is True:
        __utils__['cloud.fire_event'](
            'event',
            'ssh is available',
            'salt/cloud/{0}/ssh_ready_reactor'.format(vm_['name']),
            args={'ip_address': ip_address},
            sock_dir=__opts__['sock_dir'],
            transport=__opts__['transport']
        )

    return vm_
563981
def waitStarted(self):
        """"""
        ns = None
        while not ns:
            try:
                time.sleep(3)
                ns = Pyro.naming.NameServerLocator(
                    identification=self.identification).getNS()
            except Pyro.errors.NamingError as er:
                pass
1322335
public void waitForExit() throws InterruptedException {
        try {
            dockerClient.waitContainer(container.id());
        } catch (DockerException e) {
            throw new IllegalStateException(e);
        }
    }
619897
def wait(self):
        """"""
        logging.info("waiting for {} jobs to complete".format(len(self.submissions)))
        while not self.shutdown:
            time.sleep(1)
1080071
public void waitForApproval(boolean isWorkspaceInitialized)
   {

      if (disabled)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("The RepositoryCreationSynchronizer has been disabled so no need to make it wait.");
         }
         return;
      }
      if (rpcService == null)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("No RPCService has been defined so we assume that we are in"
               + " a non cluster environment so no need to make it wait.");
         }
         return;
      }

      // The RPC Service has been defined so we assume that we are in a cluster environment
      if (!isWorkspaceInitialized)
      {
         // Set locally the value
         needToInitWorkspace();
         // A workspace has not been initialized, we need to notify everybody
         if (LOG.isDebugEnabled())
         {
            LOG.debug("Notify all the nodes that there is at least one workspace to initialize.");
         }
         try
         {
            rpcService.executeCommandOnAllNodes(needToInitWorkspaceCommand, false);
         }
         catch (Exception e)
         {
            LOG.warn("Could not notify all the nodes that there is at least one workspace to initialize.", e);
         }
      }
      if (lock.getCount() <= 0)
      {
         // We already have been released so no need to wait
         if (LOG.isTraceEnabled())
         {
            LOG.trace("We already have been released so no need to make it wait.");
         }
         return;
      }
      try
      {
         if (!needToInitWorkspace && isWorkspaceInitialized)
         {
            // Asking the coordinator if we have to wait since the workspace could be currently
            // initialized by the coordinator
            if (LOG.isDebugEnabled())
            {
               LOG.debug("Ask the coordinator if the local node needs to wait.");
            }
            Object result = rpcService.executeCommandOnCoordinator(shouldIWaitCommand, 0);
            if (LOG.isDebugEnabled())
            {
               LOG.debug("The response from the coordinator was " + result);
            }
            if (result instanceof Boolean && (Boolean)result)
            {
               // We wait to be release by the coordinator
               waitForCoordinator();
            }
         }
         else
         {
            // We wait to be release by the coordinator
            waitForCoordinator();
         }
      }
      catch (RPCException e)
      {
         LOG.warn("An error occured while executing the method waitForApproval()", e);
      }
   }
901878
def wait(state)
      if !LXC::Shell.valid_state?(status.state)
        raise ArgumentError, "Invalid container state: #{state}"
      end

      run("wait", "-s", state)
    end
1352474
def wait(self, timeout=None, raise_error=True):
        
        return self.get(timeout=timeout, raise_error=raise_error)
1020850
def wait_for_running(self):
        """"""
        self.server_attrs = self.consul.find_running(
                self.server_attrs,
                self.launch_timeout_s,
                )
1362324
public void waitForDeployments(@Observes(precedence = -100) AfterStart event, OpenShiftAdapter client,
        CEEnvironmentProcessor.TemplateDetails details, TestClass testClass, CubeOpenShiftConfiguration configuration, OpenShiftClient openshiftClient)
        throws Exception {
        if (testClass == null) {
            // nothing to do, since we're not in ClassScoped context
            return;
        }
        if (details == null) {
            log.warning(String.format("No environment for %s", testClass.getName()));
            return;
        }
        log.info(String.format("Waiting for environment for %s", testClass.getName()));
        try {
            delay(client, details.getResources());
        } catch (Throwable t) {
            throw new IllegalArgumentException("Error waiting for template resources to deploy: " + testClass.getName(), t);
        }
    }
1280191
public boolean waitUp(String cloudId, DockerSlaveTemplate dockerSlaveTemplate,
                          InspectContainerResponse containerInspect) {
        if (isFalse(containerInspect.getState().getRunning())) {
            throw new IllegalStateException("Container '" + containerInspect.getId() + "' is not running!");
        }

        return true;
    }