Set Windows to use a list of NTP servers

    CLI Example:

    .. code-block:: bash

        salt '*' ntp.set_servers 'pool.ntp.org' 'us.pool.ntp.org'
963673
def set_servers(*servers):
    '''
    
    '''
    service_name = 'w32time'
    if not __salt__['service.status'](service_name):
        if not __salt__['service.start'](service_name):
            return False

    server_cmd = ['W32tm', '/config', '/syncfromflags:manual',
                  '/manualpeerlist:{0}'.format(' '.join(servers))]
    reliable_cmd = ['W32tm', '/config', '/reliable:yes']
    update_cmd = ['W32tm', '/config', '/update']

    for cmd in server_cmd, reliable_cmd, update_cmd:
        __salt__['cmd.run'](cmd, python_shell=False)

    if not sorted(list(servers)) == get_servers():
        return False

    __salt__['service.restart'](service_name)
    return True
410475
def set_settings(self, releases=None, default_release=None):
        """"""
        super(ReplicaSets, self).set_settings(releases, default_release)
        Servers().set_settings(releases, default_release)
1311421
def __bind(self):
        '''
        
        '''
        if self.log_queue is not None:
            salt.log.setup.set_multiprocessing_logging_queue(self.log_queue)
        if self.log_queue_level is not None:
            salt.log.setup.set_multiprocessing_logging_level(self.log_queue_level)
        salt.log.setup.setup_multiprocessing_logging(self.log_queue)
        if self.secrets is not None:
            SMaster.secrets = self.secrets

        dfn = os.path.join(self.opts['cachedir'], '.dfn')
        if os.path.isfile(dfn):
            try:
                if salt.utils.platform.is_windows() and not os.access(dfn, os.W_OK):
                    # Cannot delete read-only files on Windows.
                    os.chmod(dfn, stat.S_IRUSR | stat.S_IWUSR)
                os.remove(dfn)
            except os.error:
                pass

        # Wait for kill should be less then parent's ProcessManager.
        self.process_manager = salt.utils.process.ProcessManager(name='ReqServer_ProcessManager',
                                                                 wait_for_kill=1)

        req_channels = []
        tcp_only = True
        for transport, opts in iter_transport_opts(self.opts):
            chan = salt.transport.server.ReqServerChannel.factory(opts)
            chan.pre_fork(self.process_manager)
            req_channels.append(chan)
            if transport != 'tcp':
                tcp_only = False

        kwargs = {}
        if salt.utils.platform.is_windows():
            kwargs['log_queue'] = self.log_queue
            kwargs['log_queue_level'] = self.log_queue_level
            # Use one worker thread if only the TCP transport is set up on
            # Windows and we are using Python 2. There is load balancer
            # support on Windows for the TCP transport when using Python 3.
            if tcp_only and six.PY2 and int(self.opts['worker_threads']) != 1:
                log.warning('TCP transport supports only 1 worker on Windows '
                            'when using Python 2.')
                self.opts['worker_threads'] = 1

        # Reset signals to default ones before adding processes to the process
        # manager. We don't want the processes being started to inherit those
        # signal handlers
        with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):
            for ind in range(int(self.opts['worker_threads'])):
                name = 'MWorker-{0}'.format(ind)
                self.process_manager.add_process(MWorker,
                                                 args=(self.opts,
                                                       self.master_key,
                                                       self.key,
                                                       req_channels,
                                                       name),
                                                 kwargs=kwargs,
                                                 name=name)
        self.process_manager.run()
1317449
def init_command_set(self, scrapyd_url):
        

        if scrapyd_url[-1:] != '/':
            scrapyd_url = scrapyd_url + '/'
        self['daemonstatus'] = [scrapyd_url + 'daemonstatus.json', http_utils.METHOD_GET]
        self['addversion'] = [scrapyd_url + 'addversion.json', http_utils.METHOD_POST]
        self['schedule'] = [scrapyd_url + 'schedule.json', http_utils.METHOD_POST]
        self['cancel'] = [scrapyd_url + 'cancel.json', http_utils.METHOD_POST]
        self['listprojects'] = [scrapyd_url + 'listprojects.json', http_utils.METHOD_GET]
        self['listversions'] = [scrapyd_url + 'listversions.json', http_utils.METHOD_GET]
        self['listspiders'] = [scrapyd_url + 'listspiders.json', http_utils.METHOD_GET]
        self['listjobs'] = [scrapyd_url + 'listjobs.json', http_utils.METHOD_GET]
        self['delversion'] = [scrapyd_url + 'delversion.json', http_utils.METHOD_POST]
        self['delproject'] = [scrapyd_url + 'delproject.json', http_utils.METHOD_POST]
        self['logs'] = [scrapyd_url + 'logs/', http_utils.METHOD_GET]
80700
def list_networks(conn=None, call=None):
    '''
    

    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_networks function must be called with '
            '-f or --function'
        )
    if conn is None:
        conn = get_conn()
    return conn.list_networks()
128738
def freeze(session):
    
    sconf = {'session_name': session['session_name'], 'windows': []}

    for w in session.windows:
        wconf = {
            'options': w.show_window_options(),
            'window_name': w.name,
            'layout': w.layout,
            'panes': [],
        }
        if w.get('window_active', '0') == '1':
            wconf['focus'] = 'true'

        # If all panes have same path, set 'start_directory' instead
        # of using 'cd' shell commands.
        def pane_has_same_path(p):
            return w.panes[0].current_path == p.current_path

        if all(pane_has_same_path(p) for p in w.panes):
            wconf['start_directory'] = w.panes[0].current_path

        for p in w.panes:
            pconf = {'shell_command': []}

            if 'start_directory' not in wconf:
                pconf['shell_command'].append('cd ' + p.current_path)

            if p.get('pane_active', '0') == '1':
                pconf['focus'] = 'true'

            current_cmd = p.current_command

            def filter_interpretters_and_shells():
                return current_cmd.startswith('-') or any(
                    current_cmd.endswith(cmd) for cmd in ['python', 'ruby', 'node']
                )

            if filter_interpretters_and_shells():
                current_cmd = None

            if current_cmd:
                pconf['shell_command'].append(current_cmd)
            else:
                if not len(pconf['shell_command']):
                    pconf = 'pane'

            wconf['panes'].append(pconf)

        sconf['windows'].append(wconf)

    return sconf
872922
def set_server(self, pos, key, value):
        """"""
        self._web_list[pos][key] = value
394135
def set_source_interface(self, name):
        
        cmd = self.command_builder('ntp source', value=name)
        return self.configure(cmd)
339305
def _set_conf_sockets():
    
    if conf.use_bpf and not BSD:
        Interceptor.set_from_hook(conf, "use_bpf", False)
        raise ScapyInvalidPlatformException("BSD-like (OSX, *BSD...) only !")
    if conf.use_winpcapy and not WINDOWS:
        Interceptor.set_from_hook(conf, "use_winpcapy", False)
        raise ScapyInvalidPlatformException("Windows only !")
    # we are already in an Interceptor hook, use Interceptor.set_from_hook
    if conf.use_pcap or conf.use_dnet or conf.use_winpcapy:
        try:
            from scapy.arch.pcapdnet import L2pcapListenSocket, L2pcapSocket, \
                L3pcapSocket
        except ImportError:
            warning("No pcap provider available ! pcap won't be used")
            Interceptor.set_from_hook(conf, "use_winpcapy", False)
            Interceptor.set_from_hook(conf, "use_pcap", False)
        else:
            conf.L3socket = L3pcapSocket
            conf.L3socket6 = functools.partial(L3pcapSocket, filter="ip6")
            conf.L2socket = L2pcapSocket
            conf.L2listen = L2pcapListenSocket
            return
    if conf.use_bpf:
        from scapy.arch.bpf.supersocket import L2bpfListenSocket, \
            L2bpfSocket, L3bpfSocket
        conf.L3socket = L3bpfSocket
        conf.L3socket6 = functools.partial(L3bpfSocket, filter="ip6")
        conf.L2socket = L2bpfSocket
        conf.L2listen = L2bpfListenSocket
        return
    if LINUX:
        from scapy.arch.linux import L3PacketSocket, L2Socket, L2ListenSocket
        conf.L3socket = L3PacketSocket
        conf.L3socket6 = functools.partial(L3PacketSocket, filter="ip6")
        conf.L2socket = L2Socket
        conf.L2listen = L2ListenSocket
        return
    if WINDOWS:
        from scapy.arch.windows import _NotAvailableSocket
        from scapy.arch.windows.native import L3WinSocket, L3WinSocket6
        conf.L3socket = L3WinSocket
        conf.L3socket6 = L3WinSocket6
        conf.L2socket = _NotAvailableSocket
        conf.L2listen = _NotAvailableSocket
        return
    from scapy.supersocket import L3RawSocket
    from scapy.layers.inet6 import L3RawSocket6
    conf.L3socket = L3RawSocket
    conf.L3socket6 = L3RawSocket6
984499
def _connect_setns(spec, kind=None):
    
    return {
        'method': 'setns',
        'kwargs': {
            'container': spec.remote_addr(),
            'username': spec.remote_user(),
            'python_path': spec.python_path(),
            'kind': kind or spec.mitogen_kind(),
            'docker_path': spec.mitogen_docker_path(),
            'lxc_path': spec.mitogen_lxc_path(),
            'lxc_info_path': spec.mitogen_lxc_info_path(),
            'machinectl_path': spec.mitogen_machinectl_path(),
        }
    }
383147
def _set_up_pool_config(self):
    '''
    
    '''
    self._max_conns = self.settings_dict['OPTIONS'].get('MAX_CONNS', pool_config_defaults['MAX_CONNS'])
    self._min_conns = self.settings_dict['OPTIONS'].get('MIN_CONNS', self._max_conns)
                
    self._test_on_borrow = self.settings_dict["OPTIONS"].get('TEST_ON_BORROW', 
                                                             pool_config_defaults['TEST_ON_BORROW'])
    if self._test_on_borrow:
        self._test_on_borrow_query = self.settings_dict["OPTIONS"].get('TEST_ON_BORROW_QUERY', 
                                                                       pool_config_defaults['TEST_ON_BORROW_QUERY'])
    else: 
        self._test_on_borrow_query = None
756338
def host_list(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'This function must be called with -f, --function argument.'
        )
    ret = {}
    session = _get_session()
    hosts = session.xenapi.host.get_all()
    for host in hosts:
        host_record = session.xenapi.host.get_record(host)
        ret[host_record['name_label']] = host_record
    return ret
408424
def setsebools(pairs, persist=False):
    '''
    
    '''
    if not isinstance(pairs, dict):
        return {}
    if persist:
        cmd = 'setsebool -P '
    else:
        cmd = 'setsebool '
    for boolean, value in six.iteritems(pairs):
        cmd = '{0} {1}={2}'.format(cmd, boolean, value)
    return not __salt__['cmd.retcode'](cmd, python_shell=False)
1091941
public void setDirectoryServers(List<String> servers){
        if(servers == null || servers.size() == 0){
            return;
        }
        directoryServers = new DirectoryServers(servers);
        connection.setDirectoryServers(directoryServers.getNextDirectoryServer());
    }
773435
def set_user_tags(name, tags, runas=None):
    '''
    '''
    if runas is None and not salt.utils.platform.is_windows():
        runas = salt.utils.user.get_user()

    if not isinstance(tags, (list, tuple)):
        tags = [tags]

    res = __salt__['cmd.run_all'](
        [RABBITMQCTL, 'set_user_tags', name] + list(tags),
        reset_system_locale=False,
        runas=runas,
        python_shell=False)
    msg = "Tag(s) set"
    return _format_response(res, msg)
1303433
def floating_ip_pool_list(self):
        '''
        
        '''
        nt_ks = self.compute_conn
        pools = nt_ks.floating_ip_pools.list()
        response = {}
        for pool in pools:
            response[pool.name] = {
                'name': pool.name,
            }
        return response
714310
def execute_with(host_list, options = {}, &block)
      host_list.each { |host| @connections[host] ||= LazyConnection.new(host, @net_ssh_options) }
      args = options[:args] || []
      num_threads = options[:num_threads] || DEFAULT_THREAD_POOL_SIZE
      if options[:serial]
        host_list.each { |host| @connections[host].self_eval args, &block }
      elsif options[:batch_by]
        num_threads = options[:batch_by] if num_threads == :unlimited
        host_list.each_slice(options[:batch_by]) do |batch|
          Weave.with_thread_pool(batch, num_threads) do |host, mutex|
            @connections[host].self_eval args, mutex, &block
          end
        end
      else
        num_threads = host_list.size if num_threads == :unlimited
        Weave.with_thread_pool(host_list, num_threads) do |host, mutex|
          @connections[host].self_eval args, mutex, &block
        end
      end
    end