Starts instance if it's stopped, no-op otherwise.
184252
def _maybe_start_instance(instance):
  """"""

  if not instance:
    return

  if instance.state['Name'] == 'stopped':
    instance.start()
    while True:
      print(f"Waiting  for {instance} to start.")
      instance.reload()
      if instance.state['Name'] == 'running':
        break
      time.sleep(10)
358516
def start(self, *args, **kwargs):
        
        self._stop = False

        super(Plant, self).start(*args, **kwargs)
24489
def ensure_started(self):
        
        # server is either starting or stopping (or error)
        if self.state in ['maintenance', 'error']:
            self._wait_for_state_change(['stopped', 'started'])

        if self.state == 'stopped':
            self.start()
            self._wait_for_state_change(['started'])

        if self.state == 'started':
            return True
        else:
            # something went wrong, fail explicitly
            raise Exception('unknown server state: ' + self.state)
738066
private void runSelectTask()
  {
    if (_lifecycle.isActive() || _lifecycle.isAfterStopping()) {
      log.warning(this + " cannot start because an instance is active");
      return;
    }

    initNative(_fd);

    synchronized (_thread) {
      _thread.notify();
    }

    if (! _lifecycle.toActive()) {
      log.warning(this + " invalid starting state");
      return;
    }

    runImpl();
  }
877186
def do_terminateInstance(self,args):
        """"""
        parser = CommandArgumentParser("terminateInstance")
        parser.add_argument(dest='instance',help='instance index or name');
        args = vars(parser.parse_args(args))

        instanceId = args['instance']
        try:
            index = int(instanceId)
            instances = self.scalingGroupDescription['AutoScalingGroups'][0]['Instances']
            instanceId = instances[index]
        except ValueError:
            pass

        client = AwsConnectionFactory.getEc2Client()
        client.terminate_instances(InstanceIds=[instanceId['InstanceId']])
        self.do_printInstances("-r")
992241
def start(self) -> None:
        
        self.stop()  # stop an existing thread
        self._thread = receiverThread(socket=self.sock, callbacks=self._callbacks)
        self._thread.start()
681106
def stop(self, force=False):
        
        rs = self.connection.stop_instances([self.id], force)
        if len(rs) > 0:
            self._update(rs[0])
623638
def start(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with -a or --action.'
        )

    data = query(action='ve', command='{0}/start'.format(name), method='PUT')

    if 'error' in data:
        return data['error']

    return {'Started': '{0} was started.'.format(name)}
822654
def stop_instance(self, instance_id):
        
        if not instance_id:
            log.info("Instance to stop has no instance id")
            return

        gce = self._connect()

        try:
            request = gce.instances().delete(project=self._project_id,
                                        instance=instance_id, zone=self._zone)
            response = self._execute_request(request)
            self._check_response(response)
        except HttpError as e:
            # If the instance does not exist, we get a 404
            if e.resp.status == 404:
                raise InstanceNotFoundError(
                    "Instance `{instance_id}` was not found"
                    .format(instance_id=instance_id))
            else:
                raise InstanceError(
                    "Could not stop instance `{instance_id}`: `{e}`"
                    .format(instance_id=instance_id, e=e))
        except CloudProviderError as e:
            raise InstanceError(
                "Could not stop instance `{instance_id}`: `{e}`"
                .format(instance_id=instance_id, e=e))
639049
def start(self) -> None:
        

        self._shutdown = False

        # Start listening (if server) / Open connection (if client)
        if isinstance(self._protocol, Server):
            self.create_task(self._async_listen)
        elif isinstance(self._protocol, Client):
            self.create_task(self._async_open)
        else:
            raise NotImplementedError
810484
def start(self):
        
        rs = self.connection.start_instances([self.id])
        if len(rs) > 0:
            self._update(rs[0])
381018
def restart(self):
        
        self.initGrid()
        self.win.clear()
        self.current_gen = 1
        self.start
954812
void start( Instance instance, PluginInterface plugin )
	throws IOException {

		String instancePath = InstanceHelpers.computeInstancePath( instance );
		if( instance.getStatus() != InstanceStatus.DEPLOYED_STOPPED
				&& instance.getStatus() != InstanceStatus.WAITING_FOR_ANCESTOR ) {
			this.logger.fine( instancePath + " cannot be started. Prerequisite status: DEPLOYED_STOPPED or WAITING_FOR_ANCESTOR (but was " + instance.getStatus() + ")." );

		} else if( instance.getParent() != null
				&& instance.getParent().getStatus() != InstanceStatus.DEPLOYED_STARTED ) {

			// An element cannot start if its parent is not started.
			// However, if the parent is unresolved (or waiting for its parent to start),
			// then we can mark this instance as ready to start with its parent.
			this.logger.fine( instancePath + " cannot be started because its parent is not started. Parent status: " + instance.getParent().getStatus() + "." );
			if( instance.getParent().getStatus() == InstanceStatus.UNRESOLVED
					|| instance.getParent().getStatus() == InstanceStatus.WAITING_FOR_ANCESTOR ) {

				instance.setStatus( InstanceStatus.WAITING_FOR_ANCESTOR );
				this.logger.fine( instancePath + " will start as soon as its parent starts." );
			}

		} else {
			// Otherwise, start it
			try {
				if( ImportHelpers.hasAllRequiredImports( instance, this.logger )) {
					instance.data.put( FORCE, "whatever" );
					updateStateFromImports( instance, plugin, null, null );

				} else {
					this.logger.fine(
							"Instance " + InstanceHelpers.computeInstancePath( instance )
							+ " cannot be started, dependencies are missing. Requesting exports from other agents." );

					instance.setStatus( InstanceStatus.UNRESOLVED );
					this.messagingClient.sendMessageToTheDm( new MsgNotifInstanceChanged( this.appName, instance ));
					this.messagingClient.requestExportsFromOtherAgents( instance );
				}

			} catch( PluginException e ) {
				this.logger.severe( "An error occured while starting " + InstanceHelpers.computeInstancePath( instance ));
				Utils.logException( this.logger, e );

				instance.setStatus( InstanceStatus.DEPLOYED_STOPPED );
				this.messagingClient.sendMessageToTheDm( new MsgNotifInstanceChanged( this.appName, instance ));
			}
		}
	}
1258169
def restart(self, wait=True, timeout=None, wait_polling_interval=None):
        
        self.stop(timeout=timeout)
        self.start(wait, timeout=timeout, wait_polling_interval=wait_polling_interval)
230534
public final boolean start() {

        if (running || booting || stopping || terminated) {
            // do nothing if this instance is not stopped
            return false;
        } else {
            // mark this instance started
            booting = true;
            running = true;

            onStarted();

            return true;
        }
    }
462898
def __start(self):  # pragma: no cover
        """"""

        assert not self._listener_thread

        self._listener_thread = threading.Thread(target=self.__run_listener,
                                                 name='clearly-listener')
        self._listener_thread.daemon = True
        self._listener_thread.start()
        self._wait_event.wait()
        self._wait_event.clear()
459881
def wait_for_startup(self, timeout=None):
        """"""
        if not self.is_starting():
            # Should not happen
            logger.warning("wait_for_startup() called when not in starting state")

        while not self.check_startup_state_changed():
            with self._cancellable_lock:
                if self._is_cancelled:
                    return None
            if timeout and self.time_in_state() > timeout:
                return None
            time.sleep(1)

        return self.state == 'running'