diff --git a/CHANGES.md b/CHANGES.md index 8e2cfdcc..a4a46f1c 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ # Changelog +## 1.3.3 +- Fix aliases 'ec2_start_instance' and 'ec2_stop_instance' + ## 1.3.2 - Solved the bug regarding `aws_session_token` parameter for `boto3` cross account authentication in `actions.py`. diff --git a/aliases/ec2_get_all_instances.yaml b/aliases/ec2_get_all_instances.yaml index 6d5dbfc8..6e36a947 100644 --- a/aliases/ec2_get_all_instances.yaml +++ b/aliases/ec2_get_all_instances.yaml @@ -4,7 +4,9 @@ pack: "aws" description: "get all instances" action_ref: "aws.ec2_get_all_instances" formats: - - "aws ec2 get" + - display: "aws ec2 get" + representation: + - "aws ec2 get" ack: enabled: false append_url: false diff --git a/aliases/ec2_start_instance.yaml b/aliases/ec2_start_instance.yaml index 1806aed1..14a5a930 100644 --- a/aliases/ec2_start_instance.yaml +++ b/aliases/ec2_start_instance.yaml @@ -4,7 +4,9 @@ pack: "aws" description: "start instance" action_ref: "aws.ec2_start_instances" formats: - - "aws ec2 start {{instance_ids}}" + - display: "aws ec2 start " + representation: + - "aws ec2 start {{InstanceIds}}" ack: enabled: false append_url: false @@ -15,6 +17,8 @@ result: color: "#00ad52" # aka Slack 'good' footer: "AWS Pack" format: | - {% for ec2 in execution.result.result -%} - • {{ ec2.id }} - {{ ec2.state }} + {% for line in execution.result.result -%} + {% for ec2 in line.StartingInstances -%} + • {{ ec2.InstanceId }} - {{ ec2.CurrentState.Name }} + {% endfor %} {%+ endfor %} diff --git a/aliases/ec2_stop_instance.yaml b/aliases/ec2_stop_instance.yaml index 6d417041..c92bfc3e 100644 --- a/aliases/ec2_stop_instance.yaml +++ b/aliases/ec2_stop_instance.yaml @@ -4,7 +4,9 @@ pack: "aws" description: "stop instance" action_ref: "aws.ec2_stop_instances" formats: - - "aws ec2 stop {{instance_ids}}" + - display: "aws ec2 stop " + representation: + - "aws ec2 stop {{InstanceIds}}" ack: enabled: true append_url: true @@ -14,6 +16,8 @@ result: color: "#00ad52" # aka Slack 'good' footer: "AWS Pack" format: | - {% for ec2 in execution.result.result -%} - • {{ ec2.id }} - {{ ec2.state }} + {% for line in execution.result.result -%} + {% for ec2 in line.StoppingInstances -%} + • {{ ec2.InstanceId }} - {{ ec2.CurrentState.Name }} + {% endfor %} {%+ endfor %} diff --git a/pack.yaml b/pack.yaml index 55f4ea90..8eff8ddd 100755 --- a/pack.yaml +++ b/pack.yaml @@ -19,7 +19,7 @@ keywords: - SQS - lambda - kinesis -version : 1.3.2 +version : 1.3.3 author : StackStorm, Inc. email : info@stackstorm.com python_versions: diff --git a/tests/test_action_aliases.py b/tests/test_action_aliases.py new file mode 100644 index 00000000..ef8774b1 --- /dev/null +++ b/tests/test_action_aliases.py @@ -0,0 +1,74 @@ +# Licensed to the StackStorm, Inc ('StackStorm') under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and + +from st2tests.base import BaseActionAliasTestCase + + +class EC2Get(BaseActionAliasTestCase): + action_alias_name = "ec2_get_all_instances" + + def test_alias_ec2_get(self): + format_string = self.action_alias_db.formats[0]['representation'][0] + format_strings = self.action_alias_db.get_format_strings() + + command = "aws ec2 get" + expected_parameters = { + } + + self.assertExtractedParametersMatch(format_string=format_string, + command=command, + parameters=expected_parameters) + self.assertCommandMatchesExactlyOneFormatString( + format_strings=format_strings, + command=command) + + +class EC2Start(BaseActionAliasTestCase): + action_alias_name = "ec2_start_instances" + + def test_alias_ec2_start(self): + format_string = self.action_alias_db.formats[0]['representation'][0] + format_strings = self.action_alias_db.get_format_strings() + + command = "aws ec2 start i-01234" + expected_parameters = { + 'InstanceIds': 'i-01234' + } + + self.assertExtractedParametersMatch(format_string=format_string, + command=command, + parameters=expected_parameters) + self.assertCommandMatchesExactlyOneFormatString( + format_strings=format_strings, + command=command) + + +class EC2Stop(BaseActionAliasTestCase): + action_alias_name = "ec2_stop_instances" + + def test_alias_ec2_stop(self): + format_string = self.action_alias_db.formats[0]['representation'][0] + format_strings = self.action_alias_db.get_format_strings() + + command = "aws ec2 stop i-01234" + expected_parameters = { + 'InstanceIds': 'i-01234' + } + + self.assertExtractedParametersMatch(format_string=format_string, + command=command, + parameters=expected_parameters) + self.assertCommandMatchesExactlyOneFormatString( + format_strings=format_strings, + command=command)