Stop a running machine.
    @param name: Machine to stop
    @type name: str
    @param call: Must be "action"
    @type call: str
430374
def stop(name, call=None):
    
    if call != 'action':
        raise SaltCloudSystemExit(
            'The instance action must be called with -a or --action.'
        )

    log.info("Stopping machine: %s", name)
    vb_stop_vm(name)
    machine = vb_get_machine(name)
    del machine["name"]
    return treat_machine_dict(machine)
1166881
def suspend(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The suspend action must be called with '
            '-a or --action.'
        )

    vm_properties = [
        "name",
        "summary.runtime.powerState"
    ]

    vm_list = salt.utils.vmware.get_mors_with_properties(_get_si(), vim.VirtualMachine, vm_properties)

    for vm in vm_list:
        if vm["name"] == name:
            if vm["summary.runtime.powerState"] == "poweredOff":
                ret = 'cannot suspend in powered off state'
                log.info('VM %s %s', name, ret)
                return ret
            elif vm["summary.runtime.powerState"] == "suspended":
                ret = 'already suspended'
                log.info('VM %s %s', name, ret)
                return ret
            try:
                log.info('Suspending VM %s', name)
                task = vm["object"].Suspend()
                salt.utils.vmware.wait_for_task(task, name, 'suspend')
            except Exception as exc:
                log.error(
                    'Error while suspending VM %s: %s',
                    name, exc,
                    # Show the traceback if the debug logging level is enabled
                    exc_info_on_loglevel=logging.DEBUG
                )
                return 'failed to suspend'

    return 'suspended'
954462
def service_stop(name):
    '''
    
    '''
    cmd = 'stop ' + name

    # Send the command to execute
    out, err = DETAILS['server'].sendline(cmd)

    # "scrape" the output and return the right fields as a dict
    return parse(out)
177373
def stop(self, subname='total'):
        '''
        '''
        assert self._stop is None, (
            'Unable to stop, the timer is already stopped')
        self._stop = time.time()
        return self.send(subname, self._stop - self._start)
1373063
private function stopwatch($action, $name)
    {
        if (isset($this->stopwatch)) {
            $this->stopwatch->$action('ongr_es: '.$name, 'ongr_es');
        }
    }
710919
@Override
   public final void stop() {
      // Trying to stop() from FAILED is valid, but may not work
      boolean failed;

      synchronized (this) {
         try {
            while (state == ComponentStatus.STOPPING) {
               wait();
            }
            if (!state.stopAllowed()) {
               getLog().debugf("Ignoring call to stop() as current state is %s", state);
               return;
            }

            failed = state == ComponentStatus.FAILED;
            state = ComponentStatus.STOPPING;
         } catch (InterruptedException e) {
            throw new CacheException("Interrupted waiting for the component registry to stop");
         }
      }

      preStop();

      try {
         internalStop();

         postStop();
      } catch (Throwable t) {
         if (failed) {
            getLog().failedToCallStopAfterFailure(t);
         } else {
            handleLifecycleTransitionFailure(t);
         }
      } finally {
         synchronized (this) {
            state = ComponentStatus.TERMINATED;
         }
      }
   }
403634
public final void stop()
    {
        m_stopping = true;

        ImmutableMap<URI, AbstractImporter> oldReference;
        boolean success = false;
        do { // onChange also could set m_importers. Use while loop to pick up latest ref
            oldReference = m_importers.get();
            success = m_importers.compareAndSet(oldReference, ImmutableMap.<URI, AbstractImporter> of());
        } while (!success);

        if (!m_starting.get()) return;

        stopImporters(oldReference.values());
        if (!m_factory.isImporterRunEveryWhere()) {
            m_distributer.registerChannels(m_distributerDesignation, Collections.<URI> emptySet());
            m_distributer.unregisterCallback(m_distributerDesignation);
        }

        if (m_executorService == null) {
            return;
        }

        //graceful shutdown to allow importers to properly process post shutdown tasks.
        m_executorService.shutdown();
        try {
            m_executorService.awaitTermination(60, TimeUnit.SECONDS);
            m_executorService = null;
        } catch (InterruptedException ex) {
            //Should never come here.
            s_logger.warn("Unexpected interrupted exception waiting for " + m_factory.getTypeName() + " to shutdown", ex);
        }
    }
597963
def stop_agent(agent_name)
      res = false
      if (pid_file = AgentConfig.pid_file(agent_name))
        name = human_readable_name(agent_name, pid_file.identity)
        if (pid = pid_file.read_pid[:pid])
          begin
            Process.kill('TERM', pid)
            res = true
            puts "#{name} stopped"
          rescue Errno::ESRCH
            puts "#{name} not running"
          end
        elsif File.file?(pid_file.to_s)
          puts "Invalid pid file '#{pid_file.to_s}' content: #{IO.read(pid_file.to_s)}"
        else
          puts "#{name} not running"
        end
      else
        puts "Non-existent pid file for #{agent_name}"
      end
      res
    end
723998
def halt(self, vm_name=None, force=False):
        '''
        
        '''
        force_opt = '--force' if force else None
        self._call_vagrant_command(['halt', vm_name, force_opt])
        self._cached_conf[vm_name] = None
404701
public static void shutdownExecutor(ExecutorService executor, final String name)
    {
        executor.shutdown();
        try {
            log.info("Waiting for %s to shutdown", name);
            if (!executor.awaitTermination(5, TimeUnit.SECONDS)) {
                log.warn("%s did not shutdown properly", name);
            }
        }
        catch (InterruptedException e) {
            log.warn("Interrupted while waiting for %s to shutdown", name);
            Thread.currentThread().interrupt();
        }
    }
654469
public long stopTimer(String name) {
        StopWatch sw = getStopWatch(name);
        sw.stop();
        STOP_WATCHES.remove(name);
        return sw.getTime();
    }
1327122
@Override
	public void terminateMachine( TargetHandlerParameters parameters, String machineId ) throws TargetException {

		try {
			cancelMachineConfigurator( machineId );

			final ServiceInstance vmwareServiceInstance = getServiceInstance( parameters.getTargetProperties());
			VirtualMachine vm = getVirtualMachine( vmwareServiceInstance, machineId );
			if (vm == null)
				throw new TargetException( "Error vm: " + machineId + " was not found");

			Task task = vm.powerOffVM_Task();
			try {
				if(!(task.waitForTask()).equals(Task.SUCCESS))
					throw new TargetException( "Error while trying to stop vm: " + machineId);

			} catch (InterruptedException ignore) { /*ignore*/ }

			task = vm.destroy_Task();
			try {
				if(!(task.waitForTask()).equals(Task.SUCCESS))
					throw new TargetException( "Error while trying to remove vm: " + machineId);

			} catch (InterruptedException ignore) { /*ignore*/ }

		} catch( Exception e ) {
			throw new TargetException(e);
		}
	}
679741
public static xen stop(nitro_service client, xen resource) throws Exception
	{
		return ((xen[]) resource.perform_operation(client, "stop"))[0];
	}
30356
def stop(name):
    '''
    
    '''
    if not exists(name):
        raise ContainerNotExists("The container (%s) does not exist!" % name)
    cmd = ['lxc-stop', '-n', name]
    subprocess.check_call(cmd)
1050383
public static void stop(String name) {
        Long start = PENDING.remove(name);
        if (start == null) {
            return;
        }
        long duration = System.currentTimeMillis() - start;
        Counter sum = CUMULATED.computeIfAbsent(name, k -> new Counter(k, "ms"));
        sum.increment(duration);
    }
529880
@Override
	public void terminateMachine( TargetHandlerParameters parameters, String machineId ) throws TargetException {

		this.logger.fine( "Terminating an in-memory agent." );
		Map<String,String> targetProperties = preventNull( parameters.getTargetProperties());

		// If we executed real recipes, undeploy everything first.
		// That's because we do not really terminate the agent's machine, we just kill the agent.
		// So, it is important to stop and undeploy properly.
		if( ! simulatePlugins( targetProperties )) {
			this.logger.fine( "Stopping instances correctly (real recipes are used)." );
			Map.Entry<String,String> ctx = parseMachineId( machineId );
			ManagedApplication ma = this.manager.applicationMngr().findManagedApplicationByName( ctx.getValue());

			// We do not want to undeploy the scoped instances, but its children.
			try {
				Instance scopedInstance = InstanceHelpers.findInstanceByPath( ma.getApplication(), ctx.getKey());
				for( Instance childrenInstance : scopedInstance.getChildren())
					this.manager.instancesMngr().changeInstanceState( ma, childrenInstance, InstanceStatus.NOT_DEPLOYED );

			} catch( IOException e ) {
				throw new TargetException( e );
			}
		}

		// Destroy the IPojo
		Factory factory = findIPojoFactory( parameters );
		deleteIPojo( factory, machineId );
	}
90825
def stop(self, handle, reason=None):
        """"""
        params = self._get_params(reason=reason)
        self._transport.stop(handle, params)