Returns a tuple of (user, host, port) with config, pillar, or default
    values assigned to missing values.
487197
def _connect(host=DEFAULT_HOST, port=DEFAULT_PORT):
    '''
    
    '''
    if six.text_type(port).isdigit():
        return memcache.Client(['{0}:{1}'.format(host, port)], debug=0)
    raise SaltInvocationError('port must be an integer')
437219
def config_get(pattern='*', host=None, port=None, db=None, password=None):
    '''
    
    '''
    server = _connect(host, port, db, password)
    return server.config_get(pattern)
845002
def _convert_port_bindings(self, value):
        
        converted = {}

        if not value:
            return converted

        if isinstance(value, list):
            value = self._convert_port_bindings_from_list(value)

        if isinstance(value, dict):
            for port_protocol, host_bindings in six.iteritems(value):
                if '/' in port_protocol:
                    port, protocol = port_protocol.split('/')

                    if protocol not in ('tcp', 'udp'):
                        raise ValueError('only supported protocols are tcp and udp. {0} was passed.'.format(protocol))
                else:
                    port_protocol = "{0}/tcp".format(port_protocol)

                converted[port_protocol] = []

                if isinstance(host_bindings, list):
                    for host_binding in host_bindings:
                        if isinstance(host_binding, dict):
                            if "host_port" not in host_binding:
                                raise ValueError("host_port must be provided.")

                            if 'host_ip' not in host_binding:
                                host_binding['host_ip'] = ''

                            converted[port_protocol].append(host_binding)
                        else:
                            raise TypeError("The host binding information must be a dict.")
                else:
                    raise TypeError("The host binding information in port bindings must be in a list.")

        return converted
352689
function getDefaultSiteSettings(hostname) {
  const name = _.takeRight(hostname.split('.'), 2)[0]; // penultimate or last

  return {
    slug: name.toLowerCase(),
    name: _.startCase(name),
    host: hostname,
    path: '/',
    prefix: hostname,
    assetDir: 'public'
  };
}
17882
def _get_cassandra_config(self):
        """"""
        parts = urlsplit(os.environ.get('CASSANDRA_URI', DEFAULT_URI))
        if parts.scheme != 'cassandra':
            raise RuntimeError(
                'CASSANDRA_URI scheme is not "cassandra://"!')

        _, _, ip_addresses = socket.gethostbyname_ex(parts.hostname)
        if not ip_addresses:
            raise RuntimeError('Unable to find Cassandra in DNS!')

        return {
            'contact_points': ip_addresses,
            'port': parts.port or DEFAULT_PORT,
        }
896713
def get_default_config_help(self):
        
        config = super(StatsdHandler, self).get_default_config_help()

        config.update({
            'host': '',
            'port': '',
            'batch': '',
        })

        return config
1247697
def get_default_config(self):
        
        config = super(HostedGraphiteHandler, self).get_default_config()

        config.update({
            'apikey': '',
            'host': 'carbon.hostedgraphite.com',
            'port': 2003,
            'proto': 'tcp',
            'timeout': 15,
            'batch': 1,
            'max_backlog_multiplier': 5,
            'trim_backlog_multiplier': 4,
        })

        return config
244135
def collect_hosts(hosts, randomize=True):
    

    if isinstance(hosts, six.string_types):
        hosts = hosts.strip().split(',')

    result = []
    for host_port in hosts:

        res = host_port.split(':')
        host = res[0]
        port = int(res[1]) if len(res) > 1 else DEFAULT_KAFKA_PORT
        result.append((host.strip(), port))

    if randomize:
        shuffle(result)

    return result
1012952
def _get_existing_conf(config):
    
    try:
        with open(os.path.join(config, 'local.conf'), 'r') as f:
            lines = [line for line in f.readlines()
                     if not (line.startswith('service_id') or line.startswith('client_secret'))]
    except IOError:
        lines = []
    return lines
713628
def _config():
    '''
    
    '''
    status_url = __salt__['config.get']('nagios.status_url') or \
        __salt__['config.get']('nagios:status_url')
    if not status_url:
        raise CommandExecutionError('Missing Nagios URL in the configuration.')

    username = __salt__['config.get']('nagios.username') or \
        __salt__['config.get']('nagios:username')
    password = __salt__['config.get']('nagios.password') or \
        __salt__['config.get']('nagios:password')
    return {
        'url': status_url,
        'username': username,
        'password': password
    }
1244333
def get_config_groups(self, groups_conf, groups_pillar_name):
        '''
        
        '''
        # Get groups
        # Default to returning something that'll never match
        ret_groups = {
            'default': {
                'users': set(),
                'commands': set(),
                'aliases': {},
                'default_target': {},
                'targets': {}
            }
        }

        # allow for empty groups in the config file, and instead let some/all of this come
        # from pillar data.
        if not groups_conf:
            use_groups = {}
        else:
            use_groups = groups_conf
        # First obtain group lists from pillars, then in case there is any overlap, iterate over the groups
        # that come from pillars.  The configuration in files on disk/from startup
        # will override any configs from pillars.  They are meant to be complementary not to provide overrides.
        log.debug('use_groups %s', use_groups)
        try:
            groups_gen = itertools.chain(self._groups_from_pillar(groups_pillar_name).items(), use_groups.items())
        except AttributeError:
            log.warning('Failed to get groups from %s: %s or from config: %s',
                groups_pillar_name,
                self._groups_from_pillar(groups_pillar_name),
                use_groups
            )
            groups_gen = []
        for name, config in groups_gen:
            log.info('Trying to get %s and %s to be useful', name, config)
            ret_groups.setdefault(name, {
                'users': set(), 'commands': set(), 'aliases': {},
                'default_target': {}, 'targets': {}
            })
            try:
                ret_groups[name]['users'].update(set(config.get('users', [])))
                ret_groups[name]['commands'].update(set(config.get('commands', [])))
                ret_groups[name]['aliases'].update(config.get('aliases', {}))
                ret_groups[name]['default_target'].update(config.get('default_target', {}))
                ret_groups[name]['targets'].update(config.get('targets', {}))
            except (IndexError, AttributeError):
                log.warning("Couldn't use group %s. Check that targets is a dictionary and not a list", name)

        log.debug('Got the groups: %s', ret_groups)
        return ret_groups
1353246
def hosts_to_endpoints(hosts, port=2181):
    
    endpoints = []
    for host in hosts.split(","):
        endpoints.append(tuple(host.rsplit(":", 1)) if ":" in host else (host, port))
    return endpoints
693888
def get_default_config(self):
        
        config = super(SlonyCollector, self).get_default_config()
        config.update({
            'path': 'postgres',
            'host': 'localhost',
            'user': 'postgres',
            'password': 'postgres',
            'port': 5432,
            'slony_node_string': 'Node [0-9]+ - postgres@localhost',
            'method': 'Threaded',
            'instances': {},
        })
        return config
508466
def dsn():
    
    configs = {'host': host,
               'port': port,
               'dbname': database,
               'user': user,
               'password': password}
    return ' '.join(['{0}={1}'.format(_[0], _[1]) for _ in configs.items() if _[1] is not None and _[1] != ''])
236735
def get_default_config_help(self):
        
        config = super(RiemannHandler, self).get_default_config_help()

        config.update({
            'host': '',
            'port': '',
            'transport': 'tcp or udp',
        })

        return config
1214379
def _build_connstr(host, port, bucket):
    
    hostlist = []
    if isinstance(host, (tuple, list)):
        for curhost in host:
            if isinstance(curhost, (list, tuple)):
                hostlist.append(_fmthost(*curhost))
            else:
                hostlist.append(curhost)
    else:
        hostlist.append(_fmthost(host, port))

    return 'http://{0}/{1}'.format(','.join(hostlist), bucket)
1323758
def get_default_config(self):
        
        config = super(SockstatCollector, self).get_default_config()
        config.update({
            'path':     'sockets',
        })
        return config