Takes an InstanceGroup; returns a dict that, when its keys are
        properly prefixed, can be used for describing InstanceGroups in
        RunJobFlow or AddInstanceGroups requests.
509975
def _build_instance_group_args(self, instance_group):
        
        params = {
            'InstanceCount' : instance_group.num_instances,
            'InstanceRole' : instance_group.role,
            'InstanceType' : instance_group.type,
            'Name' : instance_group.name,
            'Market' : instance_group.market
        }
        if instance_group.market == 'SPOT':
            params['BidPrice'] = instance_group.bidprice
        return params
1198901
def _data_keys(self):
        
        return [name for name, child in iteritems(self._children) if not isinstance(child, GroupNode)]
50864
def _get_config_instance(group_or_term, session, **kwargs):
    
    path = group_or_term._get_path()
    cached = group_or_term._top._cached_configs.get(path)
    if cached:
        config = cached
        created = False
    else:
        # does not exist or not yet cached
        config, created = get_or_create(session, Config, **kwargs)
    return config, created
1087095
def _api_group_for_type(cls):
    
    _groups = {
        (u"v1beta1", u"Deployment"): u"extensions",
        (u"v1beta1", u"DeploymentList"): u"extensions",
        (u"v1beta1", u"ReplicaSet"): u"extensions",
        (u"v1beta1", u"ReplicaSetList"): u"extensions",
    }
    key = (
        cls.apiVersion,
        cls.__name__.rsplit(u".")[-1],
    )
    group = _groups.get(key, None)
    return group
1185304
def initialize():
    
    global runtime_context

    try:
        runtime_context = {}

        r = urlopen('http://169.254.169.254/latest/meta-data/instance-id', timeout=1)
        runtime_context['instance_id'] = r.read().decode('utf-8')

        r = urlopen('http://169.254.169.254/latest/meta-data/placement/availability-zone',
                    timeout=1)
        runtime_context['availability_zone'] = r.read().decode('utf-8')

    except Exception:
        runtime_context = None
        log.warning("failed to get ec2 instance metadata.")
1104496
public java.util.List<InstanceGroup> getInstanceGroups() {
        if (instanceGroups == null) {
            instanceGroups = new com.amazonaws.internal.SdkInternalList<InstanceGroup>();
        }
        return instanceGroups;
    }
574147
def parse_groups(self, group, params):
        
        # When resuming upon throttling error, skip if already fetched
        if group['GroupName'] in self.groups:
            return
        api_client = params['api_client']
        # Ensure consistent attribute names across resource types
        group['id'] = group.pop('GroupId')
        group['name'] = group.pop('GroupName')
        group['arn'] = group.pop('Arn')
        # Get group's members
        group['users'] = self.__fetch_group_users(api_client, group['name']);
        # Get inline policies
        policies = self.__get_inline_policies(api_client, 'group', group['id'], group['name'])
        if len(policies):
            group['inline_policies'] = policies
        group['inline_policies_count'] = len(policies)
        self.groups[group['id']] = group
318057
def to_dict(self):
        
        return {'domain_type': self.domain_type,
                'max_memory': self.max_memory,
                'current_memory': self.current_memory,
                'num_cpus': self.num_cpus,
                'running': self.is_running(),
                'name': self.name,
                }
486408
def _setup_metric_group_definitions(self):
        
        # Dictionary of MetricGroupDefinition objects, by metric group name
        metric_group_definitions = dict()
        for mg_info in self.properties['metric-group-infos']:
            mg_name = mg_info['group-name']
            mg_def = MetricGroupDefinition(
                name=mg_name,
                resource_class=_resource_class_from_group(mg_name),
                metric_definitions=dict())
            for i, m_info in enumerate(mg_info['metric-infos']):
                m_name = m_info['metric-name']
                m_def = MetricDefinition(
                    index=i,
                    name=m_name,
                    type=_metric_type(m_info['metric-type']),
                    unit=_metric_unit_from_name(m_name))
                mg_def.metric_definitions[m_name] = m_def
            metric_group_definitions[mg_name] = mg_def
        return metric_group_definitions
1046099
def as_dict(self):
        

        output_dictionary = dict()

        for attribute_name, type_instance in inspect.getmembers(self):

            if attribute_name.startswith('__') or inspect.ismethod(type_instance):
                continue

            if isinstance(type_instance, bool):
                output_dictionary[attribute_name] = type_instance
            elif isinstance(type_instance, self.__class__):
                output_dictionary[attribute_name] = type_instance.as_dict()

        return output_dictionary
1185245
def to_dict(self):
        ''''''
        d = {'groupId': self.group_id}
        members = []
        for m in self.members:
            members.append(m.to_dict())
        if members:
            d['members'] = members
        return d
38958
private String getGroupKey() {
        EntityIdentifier[] groups = null;
        try {
            groups =
                    GroupService.searchForGroups(
                            groupName, IGroupConstants.SearchMethod.DISCRETE, IPerson.class);
        } catch (GroupsException e1) {
            throw new RuntimeException(
                    "An exception occurred searching for " + "the group " + groupName + ".", e1);
        }
        if (groups == null || groups.length == 0)
            throw new RuntimeException(
                    "Group with name '"
                            + groupName
                            + "' not found for "
                            + this.getClass().getName()
                            + ". All evaluations will return false.");

        return groups[0].getKey();
    }
951808
def _group(self, group_data):
        
        if isinstance(group_data, dict):
            # get xid from dict
            xid = group_data.get('xid')
        else:
            # get xid from object
            xid = group_data.xid

        if self.groups.get(xid) is not None:
            # return existing group from memory
            group_data = self.groups.get(xid)
        elif self.groups_shelf.get(xid) is not None:
            # return existing group from shelf
            group_data = self.groups_shelf.get(xid)
        else:
            # store new group
            self.groups[xid] = group_data
        return group_data
803994
def as_dict(self):
        

        result_dict = super(Group, self).as_dict()

        statuses = list()
        version = None
        titles = list()
        descriptions = list()
        platforms = list()
        groups = list()
        rules = list()

        for child in self.children:
            if isinstance(child, Version):
                version = child.as_dict()
            elif isinstance(child, Status):
                statuses.append(child.as_dict())
            elif isinstance(child, Title):
                titles.append(child.as_dict())
            elif isinstance(child, Description):
                descriptions.append(child.as_dict())
            elif isinstance(child, Platform):
                platforms.append(child.as_dict())
            elif isinstance(child, Group):
                groups.append(child.as_dict())
            elif isinstance(child, Rule):
                rules.append(child.as_dict())

        if version is not None:
            result_dict['version'] = version
        if len(statuses) > 0:
            result_dict['statuses'] = statuses
        if len(titles) > 0:
            result_dict['titles'] = titles
        if len(descriptions) > 0:
            result_dict['descriptions'] = descriptions
        if len(platforms) > 0:
            result_dict['platforms'] = platforms
        if len(groups) > 0:
            result_dict['groups'] = groups
        if len(rules) > 0:
            result_dict['rules'] = rules

        return result_dict
953364
def get_security_group_dict():
  """"""

  client = get_ec2_client()
  response = client.describe_security_groups()
  assert is_good_response(response)

  result = OrderedDict()
  ec2 = get_ec2_resource()
  for security_group_response in response['SecurityGroups']:
    key = get_name(security_group_response.get('Tags', []))
    if not key or key == EMPTY_NAME:
      continue  # ignore unnamed security groups
    #    key = security_group_response['GroupName']
    if key in result:
      util.log(f"Warning: Duplicate security group {key}")
      if DUPLICATE_CHECKING:
        assert key not in result, ("Duplicate security group " + key)
    result[key] = ec2.SecurityGroup(security_group_response['GroupId'])

  return result
18899
public String getAutoScalingGroup() {
        DescribeAutoScalingInstancesRequest req = new DescribeAutoScalingInstancesRequest();
        req.setInstanceIds(Collections.singleton(this.getInstanceId()));
        DescribeAutoScalingInstancesResult result = this.autoScalingClient.describeAutoScalingInstances(req);
        if (result.getAutoScalingInstances().size() != 1) {
            throw new IllegalStateException("Found multiple auto scaling instances");
        }
        return result.getAutoScalingInstances().get(0).getAutoScalingGroupName();
    }
576444
def get_groups_dict(self) -> Dict:
        
        return {
            k: deserializer.inventory.InventoryElement.serialize(v).dict()
            for k, v in self.groups.items()
        }