Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCM-9228 | test: get instance by nodepool and cluster id #67

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions pkg/aws/aws_client/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,37 @@ func (client *AWSClient) GetInstancesByInfraID(infraID string) ([]types.Instance
return instances, err
}

// GetInstancesByNodePoolID will return the instances with tag tag:api.openshift.com/nodepool-ocm:<nodepool_id>
func (client *AWSClient) GetInstancesByNodePoolID(nodePoolID string, clusterID string) ([]types.Instance, error) {
filter1 := types.Filter{
Name: aws.String("tag:api.openshift.com/nodepool-ocm"),
Values: []string{
nodePoolID,
},
}
filter2 := types.Filter{
Name: aws.String("tag:api.openshift.com/id"),
Values: []string{
clusterID,
},
}
output, err := client.Ec2Client.DescribeInstances(context.TODO(), &ec2.DescribeInstancesInput{
Filters: []types.Filter{
filter1,
filter2,
},
MaxResults: aws.Int32(100),
})
if err != nil {
return nil, err
}
var instances []types.Instance
for _, reservation := range output.Reservations {
instances = append(instances, reservation.Instances...)
}
return instances, err
}

func (client *AWSClient) ListAvaliableRegionsFromAWS() ([]types.Region, error) {
optInStatus := "opt-in-status"
optInNotRequired := "opt-in-not-required"
Expand Down
Loading