Skip to content

Commit

Permalink
Merge pull request os-autoinst#16061 from grisu48/ec2_upload
Browse files Browse the repository at this point in the history
Simplify default instance type for ec2
  • Loading branch information
mimi1vx committed Dec 7, 2022
2 parents 354cc62 + f3e1aa4 commit e44777c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/publiccloud/ec2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ sub find_img {
return;
}

sub get_default_instance_type {
# Returns the default machine family type to be used, based on the public cloud architecture

my $arch = get_var("PUBLIC_CLOUD_ARCH", "x86_64");
return "a1.large" if ($arch eq 'arm64');
return "t2.large";
}

sub create_keypair {
my ($self, $prefix, $out_file) = @_;

Expand Down Expand Up @@ -126,9 +134,7 @@ sub upload_img {
my $img_arch = get_var('PUBLIC_CLOUD_ARCH', 'x86_64');
my $sec_group = get_var('PUBLIC_CLOUD_EC2_UPLOAD_SECGROUP');
my $vpc_subnet = get_var('PUBLIC_CLOUD_EC2_UPLOAD_VPCSUBNET');
my @instance_main_type = split(/\./, get_var('PUBLIC_CLOUD_INSTANCE_TYPE'));
my $instance_size = get_var('PUBLIC_CLOUD_IMAGE_LOCATION') =~ /-SAP-/ ? 'large' : 'micro';
my $instance_type = get_var('PUBLIC_CLOUD_EC2_UPLOAD_INSTANCE_TYPE', "$instance_main_type[0].$instance_size");
my $instance_type = get_var('PUBLIC_CLOUD_EC2_UPLOAD_INSTANCE_TYPE', get_default_instance_type());

# ec2uploadimg will fail without this file, but we can have it empty
# because we passing all needed info via params anyway
Expand Down

0 comments on commit e44777c

Please sign in to comment.