Returns VpcConfig dict either from this Estimator's subnets and security groups,
        or else validate and return an optional override value.
15322
def get_vpc_config(self, vpc_config_override=vpc_utils.VPC_CONFIG_DEFAULT):
        
        if vpc_config_override is vpc_utils.VPC_CONFIG_DEFAULT:
            return vpc_utils.to_dict(self.subnets, self.security_group_ids)
        else:
            return vpc_utils.sanitize(vpc_config_override)
593914
def authenticate(self):  # pylint: disable=too-many-locals
        
        mapping_override = self.config.resolve('lexicon:auto:mapping_override')
        mapping_override_processed = {}
        if mapping_override:
            for one_mapping in mapping_override.split(','):
                one_mapping_processed = one_mapping.split(':')
                mapping_override_processed[one_mapping_processed[0]
                                           ] = one_mapping_processed[1]

        override_provider = mapping_override_processed.get(self.domain)
        if override_provider:
            provider = [
                element for element in AVAILABLE_PROVIDERS.items()
                if element[0] == override_provider][0]
            LOGGER.info('Provider authoritatively mapped for domain %s: %s.',
                        self.domain, provider.__name__)
            (provider_name, provider_module) = provider
        else:
            (provider_name, provider_module) = _relevant_provider_for_domain(self.domain)
            LOGGER.info('Provider discovered for domain %s: %s.',
                        self.domain, provider_name)

        new_config = ConfigResolver()
        new_config.with_dict({'lexicon:provider_name': provider_name})

        target_prefix = 'auto_{0}_'.format(provider_name)
        for config_source in self.config._config_sources:  # pylint: disable=protected-access
            if not isinstance(config_source, ArgsConfigSource):
                new_config.with_config_source(config_source)
            else:
                # ArgsConfigSource needs to be reprocessed to rescope the provided
                # args to the delegate provider
                new_dict = {}
                for key, value in config_source._parameters.items():  # pylint: disable=protected-access
                    if key.startswith(target_prefix):
                        new_param_name = re.sub(
                            '^{0}'.format(target_prefix), '', key)
                        new_dict['lexicon:{0}:{1}'.format(
                            provider_name, new_param_name)] = value
                    elif not key.startswith('auto_'):
                        new_dict['lexicon:{0}'.format(key)] = value
                new_config.with_dict(new_dict)

        self.proxy_provider = provider_module.Provider(new_config)
        self.proxy_provider.authenticate()
930986
def get_bgp_config(self, group="", neighbor=""):
        """"""

        def _check_nhs(policies, nhs_policies):
            if not isinstance(policies, list):
                # Make it a list if it is a single policy
                policies = [policies]
            # Return True if "next-hop self" was found in any of the policies p
            for p in policies:
                if nhs_policies[p] is True:
                    return True
            return False

        def update_dict(d, u):  # for deep dictionary update
            for k, v in u.items():
                if isinstance(d, collections.Mapping):
                    if isinstance(v, collections.Mapping):
                        r = update_dict(d.get(k, {}), v)
                        d[k] = r
                    else:
                        d[k] = u[k]
                else:
                    d = {k: u[k]}
            return d

        def build_prefix_limit(**args):
            """
            Transform the lements of a dictionary into nested dictionaries.

            Example:
                {
                    'inet_unicast_limit': 500,
                    'inet_unicast_teardown_threshold': 95,
                    'inet_unicast_teardown_timeout': 5
                }

                becomes:

                {
                    'inet': {
                        'unicast': {
                            'limit': 500,
                            'teardown': {
                                'threshold': 95,
                                'timeout': 5
                            }
                        }
                    }
                }
            """
            prefix_limit = {}

            for key, value in args.items():
                key_levels = key.split("_")
                length = len(key_levels) - 1
                temp_dict = {key_levels[length]: value}
                for index in reversed(range(length)):
                    level = key_levels[index]
                    temp_dict = {level: temp_dict}
                update_dict(prefix_limit, temp_dict)

            return prefix_limit

        _COMMON_FIELDS_DATATYPE_ = {
            "description": py23_compat.text_type,
            "local_address": py23_compat.text_type,
            "local_as": int,
            "remote_as": int,
            "import_policy": py23_compat.text_type,
            "export_policy": py23_compat.text_type,
            "inet_unicast_limit_prefix_limit": int,
            "inet_unicast_teardown_threshold_prefix_limit": int,
            "inet_unicast_teardown_timeout_prefix_limit": int,
            "inet_unicast_novalidate_prefix_limit": int,
            "inet_flow_limit_prefix_limit": int,
            "inet_flow_teardown_threshold_prefix_limit": int,
            "inet_flow_teardown_timeout_prefix_limit": int,
            "inet_flow_novalidate_prefix_limit": py23_compat.text_type,
            "inet6_unicast_limit_prefix_limit": int,
            "inet6_unicast_teardown_threshold_prefix_limit": int,
            "inet6_unicast_teardown_timeout_prefix_limit": int,
            "inet6_unicast_novalidate_prefix_limit": int,
            "inet6_flow_limit_prefix_limit": int,
            "inet6_flow_teardown_threshold_prefix_limit": int,
            "inet6_flow_teardown_timeout_prefix_limit": int,
            "inet6_flow_novalidate_prefix_limit": py23_compat.text_type,
        }

        _PEER_FIELDS_DATATYPE_MAP_ = {
            "authentication_key": py23_compat.text_type,
            "route_reflector_client": bool,
            "nhs": bool,
        }
        _PEER_FIELDS_DATATYPE_MAP_.update(_COMMON_FIELDS_DATATYPE_)

        _GROUP_FIELDS_DATATYPE_MAP_ = {
            "type": py23_compat.text_type,
            "apply_groups": list,
            "remove_private_as": bool,
            "multipath": bool,
            "multihop_ttl": int,
        }
        _GROUP_FIELDS_DATATYPE_MAP_.update(_COMMON_FIELDS_DATATYPE_)

        _DATATYPE_DEFAULT_ = {py23_compat.text_type: "", int: 0, bool: False, list: []}

        bgp_config = {}

        if group:
            bgp = junos_views.junos_bgp_config_group_table(self.device)
            bgp.get(group=group)
        else:
            bgp = junos_views.junos_bgp_config_table(self.device)
            bgp.get()
            neighbor = ""  # if no group is set, no neighbor should be set either
        bgp_items = bgp.items()

        if neighbor:
            neighbor_ip = napalm.base.helpers.ip(neighbor)

        # Get all policies configured in one go and check if "next-hop self" is found in each policy
        # Save the result in a dict indexed by policy name (junos policy-statement)
        # The value is a boolean. True if "next-hop self" was found
        # The resulting dict (nhs_policies) will be used by _check_nhs to determine if "nhs"
        # is configured or not in the policies applied to a BGP neighbor
        policy = junos_views.junos_policy_nhs_config_table(self.device)
        policy.get()
        nhs_policies = dict()
        for policy_name, is_nhs_list in policy.items():
            # is_nhs_list is a list with one element. Ex: [('is_nhs', True)]
            is_nhs, boolean = is_nhs_list[0]
            nhs_policies[policy_name] = boolean if boolean is not None else False

        for bgp_group in bgp_items:
            bgp_group_name = bgp_group[0]
            bgp_group_details = bgp_group[1]
            bgp_config[bgp_group_name] = {
                field: _DATATYPE_DEFAULT_.get(datatype)
                for field, datatype in _GROUP_FIELDS_DATATYPE_MAP_.items()
                if "_prefix_limit" not in field
            }
            for elem in bgp_group_details:
                if not ("_prefix_limit" not in elem[0] and elem[1] is not None):
                    continue
                datatype = _GROUP_FIELDS_DATATYPE_MAP_.get(elem[0])
                default = _DATATYPE_DEFAULT_.get(datatype)
                key = elem[0]
                value = elem[1]
                if key in ["export_policy", "import_policy"]:
                    if isinstance(value, list):
                        value = " ".join(value)
                if key == "local_address":
                    value = napalm.base.helpers.convert(
                        napalm.base.helpers.ip, value, value
                    )
                if key == "neighbors":
                    bgp_group_peers = value
                    continue
                bgp_config[bgp_group_name].update(
                    {key: napalm.base.helpers.convert(datatype, value, default)}
                )
            prefix_limit_fields = {}
            for elem in bgp_group_details:
                if "_prefix_limit" in elem[0] and elem[1] is not None:
                    datatype = _GROUP_FIELDS_DATATYPE_MAP_.get(elem[0])
                    default = _DATATYPE_DEFAULT_.get(datatype)
                    prefix_limit_fields.update(
                        {
                            elem[0].replace(
                                "_prefix_limit", ""
                            ): napalm.base.helpers.convert(datatype, elem[1], default)
                        }
                    )
            bgp_config[bgp_group_name]["prefix_limit"] = build_prefix_limit(
                **prefix_limit_fields
            )
            if "multihop" in bgp_config[bgp_group_name].keys():
                # Delete 'multihop' key from the output
                del bgp_config[bgp_group_name]["multihop"]
                if bgp_config[bgp_group_name]["multihop_ttl"] == 0:
                    # Set ttl to default value 64
                    bgp_config[bgp_group_name]["multihop_ttl"] = 64

            bgp_config[bgp_group_name]["neighbors"] = {}
            for bgp_group_neighbor in bgp_group_peers.items():
                bgp_peer_address = napalm.base.helpers.ip(bgp_group_neighbor[0])
                if neighbor and bgp_peer_address != neighbor:
                    continue  # if filters applied, jump over all other neighbors
                bgp_group_details = bgp_group_neighbor[1]
                bgp_peer_details = {
                    field: _DATATYPE_DEFAULT_.get(datatype)
                    for field, datatype in _PEER_FIELDS_DATATYPE_MAP_.items()
                    if "_prefix_limit" not in field
                }
                for elem in bgp_group_details:
                    if not ("_prefix_limit" not in elem[0] and elem[1] is not None):
                        continue
                    datatype = _PEER_FIELDS_DATATYPE_MAP_.get(elem[0])
                    default = _DATATYPE_DEFAULT_.get(datatype)
                    key = elem[0]
                    value = elem[1]
                    if key in ["export_policy"]:
                        # next-hop self is applied on export IBGP sessions
                        bgp_peer_details["nhs"] = _check_nhs(value, nhs_policies)
                    if key in ["export_policy", "import_policy"]:
                        if isinstance(value, list):
                            value = " ".join(value)
                    if key == "local_address":
                        value = napalm.base.helpers.convert(
                            napalm.base.helpers.ip, value, value
                        )
                    bgp_peer_details.update(
                        {key: napalm.base.helpers.convert(datatype, value, default)}
                    )
                    bgp_peer_details["local_as"] = napalm.base.helpers.as_number(
                        bgp_peer_details["local_as"]
                    )
                    bgp_peer_details["remote_as"] = napalm.base.helpers.as_number(
                        bgp_peer_details["remote_as"]
                    )
                    if key == "cluster":
                        bgp_peer_details["route_reflector_client"] = True
                        # we do not want cluster in the output
                        del bgp_peer_details["cluster"]

                if "cluster" in bgp_config[bgp_group_name].keys():
                    bgp_peer_details["route_reflector_client"] = True
                prefix_limit_fields = {}
                for elem in bgp_group_details:
                    if "_prefix_limit" in elem[0] and elem[1] is not None:
                        datatype = _PEER_FIELDS_DATATYPE_MAP_.get(elem[0])
                        default = _DATATYPE_DEFAULT_.get(datatype)
                        prefix_limit_fields.update(
                            {
                                elem[0].replace(
                                    "_prefix_limit", ""
                                ): napalm.base.helpers.convert(
                                    datatype, elem[1], default
                                )
                            }
                        )
                bgp_peer_details["prefix_limit"] = build_prefix_limit(
                    **prefix_limit_fields
                )
                bgp_config[bgp_group_name]["neighbors"][
                    bgp_peer_address
                ] = bgp_peer_details
                if neighbor and bgp_peer_address == neighbor_ip:
                    break  # found the desired neighbor

            if "cluster" in bgp_config[bgp_group_name].keys():
                # we do not want cluster in the output
                del bgp_config[bgp_group_name]["cluster"]

        return bgp_config
498572
def get_default_config(self):
        
        config = super(SentryHandler, self).get_default_config()

        config.update({
            'dsn': '',
        })

        return config
346725
def config(self):
        
        if self._full_config is None:
            self._full_config = DotDict()
            self._full_config.merge(self._default)
            self._full_config.merge(self._config)
            self._full_config.merge(self._environment)
            self._full_config.merge(self._override)
        return self._full_config
723124
def _find_subnets(subnet_name=None, vpc_id=None, cidr=None, tags=None, conn=None):
    '''
    
    '''

    if not any([subnet_name, tags, cidr]):
        raise SaltInvocationError('At least one of the following must be '
                                  'specified: subnet_name, cidr or tags.')

    filter_parameters = {'filters': {}}

    if cidr:
        filter_parameters['filters']['cidr'] = cidr

    if subnet_name:
        filter_parameters['filters']['tag:Name'] = subnet_name

    if vpc_id:
        filter_parameters['filters']['VpcId'] = vpc_id

    if tags:
        for tag_name, tag_value in six.iteritems(tags):
            filter_parameters['filters']['tag:{0}'.format(tag_name)] = tag_value

    subnets = conn.get_all_subnets(**filter_parameters)
    log.debug('The filters criteria %s matched the following subnets: %s',
              filter_parameters, subnets)

    if subnets:
        return [subnet.id for subnet in subnets]
    else:
        return False
1210722
def get_vsan_cluster_config_system(service_instance):
    '''
    
    '''

    #TODO Replace when better connection mechanism is available

    #For python 2.7.9 and later, the defaul SSL conext has more strict
    #connection handshaking rule. We may need turn of the hostname checking
    #and client side cert verification
    context = None
    if sys.version_info[:3] > (2, 7, 8):
        context = ssl.create_default_context()
        context.check_hostname = False
        context.verify_mode = ssl.CERT_NONE

    stub = service_instance._stub
    vc_mos = vsanapiutils.GetVsanVcMos(stub, context=context)
    return vc_mos['vsan-cluster-config-system']
709494
def get_configured_provider():
    '''
    
    '''
    def __is_provider_configured(opts, provider, required_keys=()):
        '''
        Check if the provider is configured.
        '''
        if ':' in provider:
            alias, driver = provider.split(':')
            if alias not in opts['providers']:
                return False
            if driver not in opts['providers'][alias]:
                return False
            for key in required_keys:
                if opts['providers'][alias][driver].get(key, None) is None:
                    return False
            return opts['providers'][alias][driver]

        for alias, drivers in six.iteritems(opts['providers']):
            for driver, provider_details in six.iteritems(drivers):
                if driver != provider:
                    continue

                skip_provider = False
                for key in required_keys:
                    if provider_details.get(key, None) is None:
                        # This provider does not include all necessary keys,
                        # continue to next one.
                        skip_provider = True
                        break

                if skip_provider:
                    continue

                return provider_details
        return False

    provider = __is_provider_configured(
        __opts__,
        __active_provider_name__ or __virtualname__,
        ('subscription_id', 'tenant', 'client_id', 'secret'),
    )

    if provider is False:
        provider = __is_provider_configured(
            __opts__,
            __active_provider_name__ or __virtualname__,
            ('subscription_id', 'username', 'password'),
        )

    if provider is False:
        # check if using MSI style credentials...
        provider = config.is_provider_configured(
            __opts__,
            __active_provider_name__ or __virtualname__,
            required_keys=('subscription_id',),
        )

    return provider
542673
def get_config(self):
        ''
        return (self.bus.read_byte_data(self.address, self.CONTROL_PORT0), self.bus.read_byte_data(self.address, self.CONTROL_PORT1));
715513
def _generate_configs_from_default(self, overrides=None):
        # type: (Dict[str, int]) -> Dict[str, int]
        
        config = DEFAULT_CONFIG.copy()
        if not overrides:
            overrides = {}
        for k, v in overrides.items():
            config[k] = v
        return config
555503
def get_default_config(self):
        
        config = super(SquidCollector, self).get_default_config()
        config.update({
            'hosts': ['localhost:3128'],
            'path': 'squid',
        })
        return config
240412
def get_default_config(self):
        
        config = super(UDPCollector, self).get_default_config()
        config.update({
            'path':          'udp',
            'allowed_names': 'InDatagrams, NoPorts, InErrors, ' +
                             'OutDatagrams, RcvbufErrors, SndbufErrors'
        })
        return config
766024
def get_default_config(self):
        
        config = super(cloudwatchHandler, self).get_default_config()

        config.update({
            'region': 'us-east-1',
            'collector': 'loadavg',
            'metric': '01',
            'namespace': 'MachineLoad',
            'name': 'Avg01',
            'unit': 'None',
            'collect_by_instance': True,
            'collect_without_dimension': False
        })

        return config
774826
private Dictionary<String,String> getConfiguration() {
        Dictionary<String,String> config = new Hashtable<String,String>();
        for (ConfigKey key : ConfigKey.values()) {
            String value = getConfiguration(key);
            if (value != null) {
                config.put(key.getKeyValue(),value);
            }
        }
        String jolokiaId = NetworkUtil.replaceExpression(config.get(ConfigKey.AGENT_ID.getKeyValue()));
        if (jolokiaId == null) {
            config.put(ConfigKey.AGENT_ID.getKeyValue(),
                       NetworkUtil.getAgentId(hashCode(),"osgi"));
        }
        config.put(ConfigKey.AGENT_TYPE.getKeyValue(),"osgi");
        return config;
    }
46527
def get_securitygroup(vm_):
    '''
    
    '''
    sgs = list_securitygroup()
    securitygroup = config.get_cloud_config_value(
        'securitygroup', vm_, __opts__, search_global=False
    )

    if not securitygroup:
        raise SaltCloudNotFound('No securitygroup ID specified for this VM.')

    if securitygroup and six.text_type(securitygroup) in sgs:
        return sgs[securitygroup]['SecurityGroupId']
    raise SaltCloudNotFound(
        'The specified security group, \'{0}\', could not be found.'.format(
            securitygroup)
    )
205218
def get_conn():
    '''
    
    '''
    vm_ = get_configured_provider()
    driver = get_driver(Provider.DIMENSIONDATA)

    region = config.get_cloud_config_value(
         'region', vm_, __opts__
    )

    user_id = config.get_cloud_config_value(
        'user_id', vm_, __opts__
    )
    key = config.get_cloud_config_value(
        'key', vm_, __opts__
    )

    if key is not None:
        log.debug('DimensionData authenticating using password')

    return driver(
        user_id,
        key,
        region=region
    )
1132289
def get_default_config(self):
        
        config = super(TCPCollector, self).get_default_config()
        config.update({
            'path': 'tcp',
            'allowed_names':
                'ListenOverflows, ListenDrops, TCPLoss, ' +
                'TCPTimeouts, TCPFastRetrans, TCPLostRetransmit, ' +
                'TCPForwardRetrans, TCPSlowStartRetrans, CurrEstab, ' +
                'TCPAbortOnMemory, TCPBacklogDrop, AttemptFails, ' +
                'EstabResets, InErrs, ActiveOpens, PassiveOpens',
            'gauges': 'CurrEstab, MaxConn',
        })
        return config