From bfcd0ac934a92e9ba7b9fbf185fff3a0917b1c26 Mon Sep 17 00:00:00 2001 From: amanda Date: Thu, 19 Mar 2020 11:59:25 +0000 Subject: [PATCH 1/7] Test new alias --- aliases/ec2_start_instance.yaml | 4 ++-- aliases/ec2_stop_instance.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aliases/ec2_start_instance.yaml b/aliases/ec2_start_instance.yaml index 1806aed1..59acba7a 100644 --- a/aliases/ec2_start_instance.yaml +++ b/aliases/ec2_start_instance.yaml @@ -4,7 +4,7 @@ pack: "aws" description: "start instance" action_ref: "aws.ec2_start_instances" formats: - - "aws ec2 start {{instance_ids}}" + - "aws ec2 start {{InstanceIds}}" ack: enabled: false append_url: false @@ -16,5 +16,5 @@ result: footer: "AWS Pack" format: | {% for ec2 in execution.result.result -%} - • {{ ec2.id }} - {{ ec2.state }} + • {{ ec2.StartingInstances.InstanceId }} - {{ ec2.StartingInstances.CurrentState }} {%+ endfor %} diff --git a/aliases/ec2_stop_instance.yaml b/aliases/ec2_stop_instance.yaml index 6d417041..2c4d6547 100644 --- a/aliases/ec2_stop_instance.yaml +++ b/aliases/ec2_stop_instance.yaml @@ -4,7 +4,7 @@ pack: "aws" description: "stop instance" action_ref: "aws.ec2_stop_instances" formats: - - "aws ec2 stop {{instance_ids}}" + - "aws ec2 stop {{InstanceIds}}" ack: enabled: true append_url: true @@ -15,5 +15,5 @@ result: footer: "AWS Pack" format: | {% for ec2 in execution.result.result -%} - • {{ ec2.id }} - {{ ec2.state }} + • {{ ec2.StoppingInstances.InstanceId }} - {{ ec2.StoppingInstances.CurrentState }} {%+ endfor %} From cbefeacbefd991927f52e1916c436835567c7c30 Mon Sep 17 00:00:00 2001 From: amanda Date: Thu, 19 Mar 2020 12:19:26 +0000 Subject: [PATCH 2/7] Test new alias --- aliases/ec2_start_instance.yaml | 4 ++-- aliases/ec2_stop_instance.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aliases/ec2_start_instance.yaml b/aliases/ec2_start_instance.yaml index 59acba7a..1b74fbe6 100644 --- a/aliases/ec2_start_instance.yaml +++ b/aliases/ec2_start_instance.yaml @@ -15,6 +15,6 @@ result: color: "#00ad52" # aka Slack 'good' footer: "AWS Pack" format: | - {% for ec2 in execution.result.result -%} - • {{ ec2.StartingInstances.InstanceId }} - {{ ec2.StartingInstances.CurrentState }} + {% for ec2 in execution.result.result[0].StartingInstances -%} + • {{ ec2.InstanceId }} - {{ ec2.CurrentState }} {%+ endfor %} diff --git a/aliases/ec2_stop_instance.yaml b/aliases/ec2_stop_instance.yaml index 2c4d6547..9a9d2e90 100644 --- a/aliases/ec2_stop_instance.yaml +++ b/aliases/ec2_stop_instance.yaml @@ -14,6 +14,6 @@ result: color: "#00ad52" # aka Slack 'good' footer: "AWS Pack" format: | - {% for ec2 in execution.result.result -%} - • {{ ec2.StoppingInstances.InstanceId }} - {{ ec2.StoppingInstances.CurrentState }} + {% for ec2 in execution.result.result[0].StoppingInstances -%} + • {{ ec2.InstanceId }} - {{ ec2.CurrentState }} {%+ endfor %} From f50b63cb725c21fabcb1da9dbad406e716ac96bf Mon Sep 17 00:00:00 2001 From: amanda Date: Thu, 19 Mar 2020 12:24:43 +0000 Subject: [PATCH 3/7] Test new alias --- aliases/ec2_start_instance.yaml | 6 ++++-- aliases/ec2_stop_instance.yaml | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/aliases/ec2_start_instance.yaml b/aliases/ec2_start_instance.yaml index 1b74fbe6..1f5d433c 100644 --- a/aliases/ec2_start_instance.yaml +++ b/aliases/ec2_start_instance.yaml @@ -15,6 +15,8 @@ result: color: "#00ad52" # aka Slack 'good' footer: "AWS Pack" format: | - {% for ec2 in execution.result.result[0].StartingInstances -%} - • {{ ec2.InstanceId }} - {{ ec2.CurrentState }} + {% 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 9a9d2e90..ae948701 100644 --- a/aliases/ec2_stop_instance.yaml +++ b/aliases/ec2_stop_instance.yaml @@ -14,6 +14,8 @@ result: color: "#00ad52" # aka Slack 'good' footer: "AWS Pack" format: | - {% for ec2 in execution.result.result[0].StoppingInstances -%} - • {{ ec2.InstanceId }} - {{ ec2.CurrentState }} + {% for line in execution.result.result -%} + {% for ec2 in line.StoppingInstances -%} + • {{ ec2.InstanceId }} - {{ ec2.CurrentState.Name }} + {% endfor %} {%+ endfor %} From 272862b85f066bd97d91ebafae2a6c2e9d46db9a Mon Sep 17 00:00:00 2001 From: amanda Date: Thu, 19 Mar 2020 13:07:38 +0000 Subject: [PATCH 4/7] Update alias --- aliases/ec2_get_all_instances.yaml | 4 +++- aliases/ec2_start_instance.yaml | 4 +++- aliases/ec2_stop_instance.yaml | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) 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 1f5d433c..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 {{InstanceIds}}" + - display: "aws ec2 start " + representation: + - "aws ec2 start {{InstanceIds}}" ack: enabled: false append_url: false diff --git a/aliases/ec2_stop_instance.yaml b/aliases/ec2_stop_instance.yaml index ae948701..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 {{InstanceIds}}" + - display: "aws ec2 stop " + representation: + - "aws ec2 stop {{InstanceIds}}" ack: enabled: true append_url: true From 37cf91e369400b10fa50504436622c503f970cf9 Mon Sep 17 00:00:00 2001 From: Cloud User Date: Fri, 1 May 2020 16:36:48 +0000 Subject: [PATCH 5/7] Re-submit unit-test, update pack.yaml and CHANGES.md --- CHANGES.md | 9 +++++ pack.yaml | 2 +- tests/test_action_aliases.py | 77 ++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 tests/test_action_aliases.py diff --git a/CHANGES.md b/CHANGES.md index db93d5f2..b9955f4e 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,14 @@ # Changelog +## 1.3.2 +- Fix aliases 'ec2_start_instance' and 'ec2_stop_instance' + +## 1.3.1 +- Actions support multiaccount integration. + +## 1.3.0 +- `sqs_sensor` supports multiaccount integration. + ## 1.2.3 - Support Python 3 everywhere diff --git a/pack.yaml b/pack.yaml index aa0b4da7..55f4ea90 100755 --- a/pack.yaml +++ b/pack.yaml @@ -19,7 +19,7 @@ keywords: - SQS - lambda - kinesis -version : 1.2.3 +version : 1.3.2 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..e0eb4a5e --- /dev/null +++ b/tests/test_action_aliases.py @@ -0,0 +1,77 @@ +# 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 + +import mock + +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) + + From 2617a6b89d5b7a914b0f558f5f1f8449acc6e822 Mon Sep 17 00:00:00 2001 From: Cloud User Date: Fri, 1 May 2020 16:50:06 +0000 Subject: [PATCH 6/7] Fix pep8 failures on test --- tests/test_action_aliases.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/test_action_aliases.py b/tests/test_action_aliases.py index e0eb4a5e..ef8774b1 100644 --- a/tests/test_action_aliases.py +++ b/tests/test_action_aliases.py @@ -12,10 +12,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and -import mock - from st2tests.base import BaseActionAliasTestCase + class EC2Get(BaseActionAliasTestCase): action_alias_name = "ec2_get_all_instances" @@ -73,5 +72,3 @@ def test_alias_ec2_stop(self): self.assertCommandMatchesExactlyOneFormatString( format_strings=format_strings, command=command) - - From e8445f036fb99145a78d640dee27591d1b748e44 Mon Sep 17 00:00:00 2001 From: amanda11 Date: Thu, 14 May 2020 09:22:57 +0100 Subject: [PATCH 7/7] Update pack.yaml follow other merges --- pack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: