Get an AWS id for a VPC resource by type and name.
339434
def _get_resource_id(resource, name, region=None, key=None,
                     keyid=None, profile=None):
    '''
    
    '''

    _id = _cache_id(name, sub_resource=resource,
                    region=region, key=key,
                    keyid=keyid, profile=profile)
    if _id:
        return _id

    r = _get_resource(resource, name=name, region=region, key=key,
                      keyid=keyid, profile=profile)

    if r:
        return r.id
1239462
def get_group_id(name, vpc_id=None, vpc_name=None, region=None, key=None,
                 keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    if name.startswith('sg-'):
        log.debug('group %s is a group id. get_group_id not called.', name)
        return name
    group = _get_group(conn=conn, name=name, vpc_id=vpc_id, vpc_name=vpc_name,
                       region=region, key=key, keyid=keyid, profile=profile)
    return getattr(group, 'id', None)
574512
def _get_type_id_options(name, configuration):
    '''
    
    '''
    # it's in a form of source.name
    if '.' in name:
        type_, sep, id_ = name.partition('.')
        options = configuration
    else:
        type_ = next(six.iterkeys(configuration))
        id_ = name
        options = configuration[type_]

    return type_, id_, options
1053570
public static String resolveCloudInstanceId(UtilityHttpClient httpClient) {
        // cached so we only attempt it once
        if (cachedCloudInstanceId == null) {
            String value = null;
            // AWS
            LOGGER.debug("Attempting to get AWS instanceId information");

            try {
                String response = httpClient
                        .performGetRequest("http://169.254.169.254/2014-02-25/meta-data/instance-id");
                // confirm it has a aws hostname
                if (response != null) {
                    value = response;
                    LOGGER.debug(format("Found AWS instanceId: %s", value));
                }
            } catch (Exception e) {
                // NOOP try next supported cloud provider if it exists
            }
            // TODO: Add more as we support cloud platforms
            cachedCloudInstanceId = value;
        }
        return cachedCloudInstanceId;
    }
612362
def get_boto_resource(
        resource,
        region=None,
        aws_access_key_id=None,
        aws_secret_access_key=None,
        aws_session_token=None,
        endpoint_url=None
        ):
    """"""
    cache_key = '{0}:{1}:{2}:{3}'.format(
        resource,
        region,
        aws_access_key_id,
        endpoint_url or ''
    )
    if not aws_session_token:
        if cache_key in RESOURCE_CACHE:
            return RESOURCE_CACHE[cache_key]
    session = get_boto_session(
        region,
        aws_access_key_id,
        aws_secret_access_key,
        aws_session_token
    )
    if not session:
        logging.error("Failed to get {0} resource.".format(resource))
        return None

    RESOURCE_CACHE[cache_key] = session.resource(
        resource,
        endpoint_url=endpoint_url
    )
    return RESOURCE_CACHE[cache_key]
1107219
def get_vm(self, resource_group_name, vm_name):
        '''
        
        '''
        return self.client.virtual_machines.get(
            resource_group_name, vm_name, expand='instanceView')
727417
def get_resource_manager(self, resource_type, data=None):
        
        if '.' in resource_type:
            provider_name, resource_type = resource_type.split('.', 1)
        else:
            provider_name = self.ctx.policy.provider_name

        provider_resources = clouds[provider_name].resources
        klass = provider_resources.get(resource_type)
        if klass is None:
            raise ValueError(resource_type)

        # if we're already querying via config carry it forward
        if not data and self.source_type == 'config' and getattr(
                klass.get_model(), 'config_type', None):
            return klass(self.ctx, {'source': self.source_type})
        return klass(self.ctx, data or {})
1271253
def get_ips(self, instance_id):
        
        self._load_instance(instance_id)
        instance = self._load_instance(instance_id)
        IPs = [ip for ip in (instance.private_ip_address, instance.ip_address) if ip]

        # We also need to check if there is any floating IP associated
        if self.request_floating_ip and not self._vpc:
            # We need to list the floating IPs for this instance
            floating_ips = [ip for ip in self._ec2_connection.get_all_addresses() if ip.instance_id == instance.id]
            if not floating_ips:
                log.debug("Public ip address has to be assigned through "
                          "elasticluster.")
                ip = self._allocate_address(instance)
                # This is probably the preferred IP we want to use
                IPs.insert(0, ip)
            else:
                IPs = [ip.public_ip for ip in floating_ips] + IPs

        return list(set(IPs))
824996
def get(provider_name, node_type_name)
      name = "#{provider_name}/#{node_type_name}/"
      response = http_get(resource_url(name))
      format_object(response, TYPE)
    end
1305619
def get_vm_id(kwargs=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The get_vm_id function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    name = kwargs.get('name', None)
    if name is None:
        raise SaltCloudSystemExit(
            'The get_vm_id function requires a name.'
        )

    try:
        ret = list_nodes()[name]['id']
    except KeyError:
        raise SaltCloudSystemExit(
            'The VM \'{0}\' could not be found.'.format(name)
        )

    return ret
733420
def _get_instance(self):
        """"""
        resource = self._connect()

        try:
            instance = resource.Instance(self.running_instance_id)
        except Exception:
            raise EC2CloudException(
                'Instance with ID: {instance_id} not found.'.format(
                    instance_id=self.running_instance_id
                )
            )
        return instance
821088
def _get_securitygroupname_id(securitygroupname_list):
    '''
    
    '''
    securitygroupid_set = set()
    if not isinstance(securitygroupname_list, list):
        securitygroupname_list = [securitygroupname_list]
    params = {'Action': 'DescribeSecurityGroups'}
    for sg in aws.query(params, location=get_location(),
                        provider=get_provider(), opts=__opts__, sigver='4'):
        if sg['groupName'] in securitygroupname_list:
            log.debug(
                'AWS SecurityGroup ID of %s is %s',
                sg['groupName'], sg['groupId']
            )
            securitygroupid_set.add(sg['groupId'])
    return list(securitygroupid_set)
98498
def _get_current_deployment_id(self):
        '''
        
        '''
        deploymentId = ''
        stage = __salt__['boto_apigateway.describe_api_stage'](restApiId=self.restApiId,
                                                               stageName=self._stage_name,
                                                               **self._common_aws_args).get('stage')
        if stage:
            deploymentId = stage.get('deploymentId')
        return deploymentId
1150595
def _get_id(vpc_name=None, cidr=None, tags=None, region=None, key=None,
            keyid=None, profile=None):
    '''
    
    '''

    if vpc_name and not any((cidr, tags)):
        vpc_id = _cache_id(vpc_name, region=region,
                           key=key, keyid=keyid,
                           profile=profile)
        if vpc_id:
            return vpc_id

    vpc_ids = _find_vpcs(vpc_name=vpc_name, cidr=cidr, tags=tags, region=region,
                         key=key, keyid=keyid, profile=profile)
    if vpc_ids:
        log.debug("Matching VPC: %s", " ".join(vpc_ids))
        if len(vpc_ids) == 1:
            vpc_id = vpc_ids[0]
            if vpc_name:
                _cache_id(vpc_name, vpc_id,
                          region=region, key=key,
                          keyid=keyid, profile=profile)
            return vpc_id
        else:
            raise CommandExecutionError('Found more than one VPC matching the criteria.')
    else:
        log.info('No VPC found.')
        return None
179544
def get_network_interface_id(name, region=None, key=None, keyid=None,
                             profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    r = {}
    try:
        enis = conn.get_all_network_interfaces(filters={'tag:Name': name})
        if not enis:
            r['error'] = {'message': 'No ENIs found.'}
        elif len(enis) > 1:
            r['error'] = {'message': 'Name specified is tagged on multiple ENIs.'}
        else:
            eni = enis[0]
            r['result'] = eni.id
    except boto.exception.EC2ResponseError as e:
        r['error'] = __utils__['boto.get_error'](e)
    return r
294514
def get_api_id(self, lambda_name):
        
        try:
            response = self.cf_client.describe_stack_resource(StackName=lambda_name,
                                                              LogicalResourceId='Api')
            return response['StackResourceDetail'].get('PhysicalResourceId', None)
        except: # pragma: no cover
            try:
                # Try the old method (project was probably made on an older, non CF version)
                response = self.apigateway_client.get_rest_apis(limit=500)

                for item in response['items']:
                    if item['name'] == lambda_name:
                        return item['id']

                logger.exception('Could not get API ID.')
                return None
            except: # pragma: no cover
                # We don't even have an API deployed. That's okay!
                return None
911575
private static String getMetricNameWithUniqueId(InstanceType instance, String name) {
    return instance
        + "."
        + NetworkAddressUtils.getLocalHostMetricName(sResolveTimeout)
        + "." + name;
  }