Skip to content

Commit 3995ce4

Browse files
authored
Merge of #25981
2 parents 5922663 + 29a48aa commit 3995ce4

2 files changed

Lines changed: 0 additions & 52 deletions

File tree

lib/sles4sap/qesap/aws.pm

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use Exporter 'import';
3535
use testapi;
3636

3737
our @EXPORT = qw(
38-
qesap_aws_get_vpc_id
3938
qesap_aws_get_tgw_attachments
4039
qesap_aws_delete_transit_gateway_vpc_attachment
4140
qesap_aws_create_credentials
@@ -96,41 +95,6 @@ sub qesap_aws_create_config {
9695
assert_script_run 'curl ' . autoinst_url . "/files/config -o ~/.aws/config";
9796
}
9897

99-
=head3 qesap_aws_get_vpc_id
100-
101-
Get the vpc_id of a given instance in the cluster.
102-
This function looks for the cluster using the aws describe-instances
103-
and filtering by terraform deployment_name value, that qe-sap-deployment
104-
is kind to use as tag for each resource.
105-
106-
=cut
107-
108-
=over
109-
110-
=item B<RESOURCE_GROUP> - value of the workspace tag configured in qe-sap-deployment, usually it is the deployment name
111-
112-
=back
113-
=cut
114-
115-
sub qesap_aws_get_vpc_id {
116-
my (%args) = @_;
117-
croak 'Missing mandatory resource_group argument' unless $args{resource_group};
118-
119-
# tag names has to be aligned to
120-
# https://github.com/SUSE/qe-sap-deployment/blob/main/terraform/aws/infrastructure.tf
121-
my $cmd = join(' ', 'aws ec2 describe-instances',
122-
'--region', get_required_var('PUBLIC_CLOUD_REGION'),
123-
'--filters',
124-
'"Name=tag-key,Values=workspace"',
125-
"\"Name=tag-value,Values=$args{resource_group}\"",
126-
'--query',
127-
# the two 0 index result in select only the vpc of vmhana01
128-
# that is always equal to the one used by vmhana02
129-
"'Reservations[0].Instances[0].VpcId'",
130-
'--output text');
131-
return script_output($cmd);
132-
}
133-
13498
=head3 qesap_aws_get_transit_gateway_vpc_attachment
13599
Ged a description of one or more transit-gateway-attachments
136100
Function support optional arguments that are translated to filters:

t/16_qesap_aws.t

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,6 @@ use Data::Dumper;
1212
use testapi 'set_var';
1313
use sles4sap::qesap::aws;
1414

15-
subtest '[qesap_aws_get_vpc_id]' => sub {
16-
my $qesap = Test::MockModule->new('sles4sap::qesap::aws', no_auto => 1);
17-
my @calls;
18-
my @soft_failure;
19-
$qesap->redefine(script_output => sub { push @calls, $_[0]; return 'FISHERMAN'; });
20-
set_var('PUBLIC_CLOUD_REGION', 'OCEAN');
21-
22-
qesap_aws_get_vpc_id(resource_group => 'LATTE');
23-
24-
set_var('PUBLIC_CLOUD_REGION', undef);
25-
note("\n C--> " . join("\n C--> ", @calls));
26-
ok((any { /aws ec2 describe-instances/ } @calls), 'Base command aws ec2 describe-instances');
27-
ok((any { /--region OCEAN/ } @calls), 'Region from argument');
28-
ok((any { /--filters.*Values=LATTE/ } @calls), 'Filter resource_group in tag');
29-
};
30-
3115
subtest '[qesap_aws_delete_transit_gateway_vpc_attachment]' => sub {
3216
my $qesap = Test::MockModule->new('sles4sap::qesap::aws', no_auto => 1);
3317
my @calls;

0 commit comments

Comments
 (0)