// ParseCSVToInstancesWithAttributeGroups reads the CSV file given by filepath,
// and returns the read DenseInstances, but also makes sure to group any Attributes
// specified in the first argument and also any class Attributes specified in the second
772963
func ParseCSVToInstancesWithAttributeGroups(filepath string, attrGroups, classAttrGroups map[string]string, attrOverrides map[int]Attribute, hasHeaders bool) (instances *DenseInstances, err error) {
	// Open file
	f, err := os.Open(filepath)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	return ParseCSVToInstancesWithAttributeGroupsFromReader(f, attrGroups, classAttrGroups, attrOverrides, hasHeaders)
}
1175316
func ParseCSVSniffAttributeNames(filepath string, hasHeaders bool) []string {
	f, err := os.Open(filepath)
	if err != nil {
		panic(err)
	}
	defer f.Close()

	return ParseCSVSniffAttributeNamesFromReader(f, hasHeaders)
}
1311703
func InstancesFromMat64(rows, cols int, data *mat.Dense) *Mat64Instances {

	var ret Mat64Instances
	for i := 0; i < cols; i++ {
		ret.attributes = append(ret.attributes, NewFloatAttribute(fmt.Sprintf("%d", i)))
	}

	ret.classAttrs = make(map[int]bool)
	ret.Data = data
	ret.rows = rows

	return &ret
}
374276
func TypeGroups() []WorkItemTypeGroup {
	scenariosID := uuid.FromStringOrNil("feb28a28-44a6-43f8-946a-bae987713891")
	experiencesID := uuid.FromStringOrNil("d4e2c859-f416-4e9a-a3e0-e7bb4e1b454b")
	requirementsID := uuid.FromStringOrNil("bb1de8b6-3175-4821-abe9-50d0a64f19a2")
	executionID := uuid.FromStringOrNil("7fdfde54-9cf2-4098-b33b-30cd505dcfc3")

	return []WorkItemTypeGroup{
		// There can be more than one groups in the "Portfolio" bucket
		{
			ID:     scenariosID,
			Bucket: BucketPortfolio,
			Name:   "Scenarios",
			Icon:   "fa fa-bullseye",
			TypeList: []uuid.UUID{
				SystemScenario,
				SystemFundamental,
				SystemPapercuts,
			},
		},
		{
			ID:     experiencesID,
			Bucket: BucketPortfolio,
			Name:   "Experiences",
			Icon:   "pficon pficon-infrastructure",
			TypeList: []uuid.UUID{
				SystemExperience,
				SystemValueProposition,
			},
		},
		// There's always only one group in the "Requirement" bucket
		{
			ID:     requirementsID,
			Bucket: BucketRequirement,
			Name:   "Requirements",
			Icon:   "fa fa-list-ul",
			TypeList: []uuid.UUID{
				SystemFeature,
				SystemBug,
			},
		},
		// There's always only one group in the "Iteration" bucket
		{
			ID:     executionID,
			Bucket: BucketIteration,
			Name:   "Execution",
			Icon:   "fa fa-repeat",
			TypeList: []uuid.UUID{
				SystemTask,
				SystemBug,
				SystemFeature,
			},
		},
	}
}
476676
func (c *VFSClientset) InstanceGroupsFor(cluster *kops.Cluster) kopsinternalversion.InstanceGroupInterface {
	return newInstanceGroupVFS(c, cluster)
}
733860
func (s *VMGroupService) ListInstanceGroups(p *ListInstanceGroupsParams) (*ListInstanceGroupsResponse, error) {
	resp, err := s.cs.newRequest("listInstanceGroups", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ListInstanceGroupsResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
1306168
func RenderInstanceGroupSubnets(cluster *kops.Cluster) InstanceGroupRenderFunction {
	return func(ig *kops.InstanceGroup) string {
		return strings.Join(ig.Spec.Subnets, ",")
	}
}
1173200
func (t *Template) GetAWSRedshiftClusterSubnetGroupWithName(name string) (*resources.AWSRedshiftClusterSubnetGroup, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSRedshiftClusterSubnetGroup:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSRedshiftClusterSubnetGroup not found", name)
}
1228811
func getInstancesIpsFromFilter(filter *api.AWSGroup) ([]net.IP, error) {
	region := filter.Region
	if filter.Region == "" {
		region = getDefaultRegion()
	}
	input := &ec2.DescribeInstancesInput{}
	for labelKey, labelValue := range filter.Labels {
		newFilter := ec2.Filter{
			Name:   aws.String(fmt.Sprintf("%s:%s", policyEC2Labelskey, labelKey)),
			Values: []string{labelValue},
		}
		input.Filters = append(input.Filters, newFilter)
	}
	if len(filter.SecurityGroupsIds) > 0 {
		newFilter := ec2.Filter{
			Name:   policySecurityGroupIDKey,
			Values: filter.SecurityGroupsIds,
		}
		input.Filters = append(input.Filters, newFilter)
	}
	if len(filter.SecurityGroupsNames) > 0 {
		newFilter := ec2.Filter{
			Name:   policySecurityGroupName,
			Values: filter.SecurityGroupsNames,
		}
		input.Filters = append(input.Filters, newFilter)
	}
	cfg, err := initializeAWSAccount(region)
	if err != nil {
		return []net.IP{}, err
	}
	svc := ec2.New(*cfg)
	req := svc.DescribeInstancesRequest(input)
	result, err := req.Send()
	if err != nil {
		return []net.IP{}, fmt.Errorf("Cannot retrieve aws information: %s", err)
	}
	return awsDumpIpsFromRequest(result), nil
}
524839
func (m *KopsModelContext) FindZonesForInstanceGroup(ig *kops.InstanceGroup) ([]string, error) {
	return model.FindZonesForInstanceGroup(m.Cluster, ig)
}
464084
func (m *KopsModelContext) MasterInstanceGroups() []*kops.InstanceGroup {
	var groups []*kops.InstanceGroup
	for _, ig := range m.InstanceGroups {
		if !ig.IsMaster() {
			continue
		}
		groups = append(groups, ig)
	}
	return groups
}
741265
func (c *Cloud) DescribeInstanceGroup(instanceGroupName string) (InstanceGroupInfo, error) {
	return DescribeInstanceGroup(c.asg, instanceGroupName)
}
660281
func ParseCSVGetRowsFromReader(r io.ReadSeeker) (int, error) {
	r.Seek(0, 0)
	reader := csv.NewReader(r)
	counter := 0
	for {
		_, err := reader.Read()
		if err == io.EOF {
			break
		} else if err != nil {
			return 0, err
		}
		counter++
	}
	return counter, nil
}
980503
func (g *Cloud) ListInstancesInInstanceGroup(name string, zone string, state string) ([]*compute.InstanceWithNamedPorts, error) {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newInstanceGroupMetricContext("list_instances", zone)
	req := &compute.InstanceGroupsListInstancesRequest{InstanceState: state}
	v, err := g.c.InstanceGroups().ListInstances(ctx, meta.ZonalKey(name, zone), req, filter.None)
	return v, mc.Observe(err)
}
671635
func (m *KopsModelContext) NodeInstanceGroups() []*kops.InstanceGroup {
	var groups []*kops.InstanceGroup
	for _, ig := range m.InstanceGroups {
		if ig.Spec.Role != kops.InstanceGroupRoleNode {
			continue
		}
		groups = append(groups, ig)
	}
	return groups
}
720728
func ParseCgroupFile(path string) (map[string]string, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	return parseCgroupFromReader(f)
}
1345494
func dataSourceAwsInstanceRead(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).ec2conn

	filters, filtersOk := d.GetOk("filter")
	instanceID, instanceIDOk := d.GetOk("instance_id")
	tags, tagsOk := d.GetOk("instance_tags")

	if !filtersOk && !instanceIDOk && !tagsOk {
		return fmt.Errorf("One of filters, instance_tags, or instance_id must be assigned")
	}

	// Build up search parameters
	params := &ec2.DescribeInstancesInput{}
	if filtersOk {
		params.Filters = buildAwsDataSourceFilters(filters.(*schema.Set))
	}
	if instanceIDOk {
		params.InstanceIds = []*string{aws.String(instanceID.(string))}
	}
	if tagsOk {
		params.Filters = append(params.Filters, buildEC2TagFilterList(
			tagsFromMap(tags.(map[string]interface{})),
		)...)
	}

	log.Printf("[DEBUG] Reading IAM Instance: %s", params)
	resp, err := conn.DescribeInstances(params)
	if err != nil {
		return err
	}

	// If no instances were returned, return
	if len(resp.Reservations) == 0 {
		return fmt.Errorf("Your query returned no results. Please change your search criteria and try again.")
	}

	var filteredInstances []*ec2.Instance

	// loop through reservations, and remove terminated instances, populate instance slice
	for _, res := range resp.Reservations {
		for _, instance := range res.Instances {
			if instance.State != nil && *instance.State.Name != "terminated" {
				filteredInstances = append(filteredInstances, instance)
			}
		}
	}

	var instance *ec2.Instance
	if len(filteredInstances) < 1 {
		return fmt.Errorf("Your query returned no results. Please change your search criteria and try again.")
	}

	// (TODO: Support a list of instances to be returned)
	// Possibly with a different data source that returns a list of individual instance data sources
	if len(filteredInstances) > 1 {
		return fmt.Errorf("Your query returned more than one result. Please try a more " +
			"specific search criteria.")
	} else {
		instance = filteredInstances[0]
	}

	log.Printf("[DEBUG] aws_instance - Single Instance ID found: %s", *instance.InstanceId)
	if err := instanceDescriptionAttributes(d, instance, conn); err != nil {
		return err
	}

	if d.Get("get_password_data").(bool) {
		passwordData, err := getAwsEc2InstancePasswordData(*instance.InstanceId, conn)
		if err != nil {
			return err
		}
		d.Set("password_data", passwordData)
	}

	// ARN
	arn := arn.ARN{
		Partition: meta.(*AWSClient).partition,
		Region:    meta.(*AWSClient).region,
		Service:   "ec2",
		AccountID: meta.(*AWSClient).accountid,
		Resource:  fmt.Sprintf("instance/%s", d.Id()),
	}
	d.Set("arn", arn.String())

	return nil
}