diff --git a/heat/cfntools/cfn_helper.py b/heat/cfntools/cfn_helper.py index fa0812ea15..5322cb3630 100644 --- a/heat/cfntools/cfn_helper.py +++ b/heat/cfntools/cfn_helper.py @@ -575,13 +575,13 @@ class SourcesHandler(object): def _decompress(self, archive, dest_dir): cmd_str = '' (r, ext) = os.path.splitext(archive) - if ext is 'tar.gz' or ext is 'tgz': + if ext == '.tar.gz' or ext == '.tgz': cmd_str = 'tar -C %s -xzf %s' % (dest_dir, archive) - elif ext is 'tar.bz2' or ext is 'tbz2': + elif ext == '.tar.bz2' or ext == '.tbz2': cmd_str = 'tar -C %s -xjf %s' % (dest_dir, archive) - elif ext is 'zip': + elif ext == '.zip': cmd_str = 'unzip -d %s %s' % (dest_dir, archive) - elif ext is 'tar': + elif ext == '.tar': cmd_str = 'tar -C %s -xf %s' % (dest_dir, archive) else: pass diff --git a/heat/tests/test_cfn.py b/heat/tests/test_cfn.py index 5a2f1e30c5..6d68774a11 100644 --- a/heat/tests/test_cfn.py +++ b/heat/tests/test_cfn.py @@ -140,6 +140,9 @@ class MetadataTest(unittest.TestCase): j = ''' { "AWS::CloudFormation::Init" : { "config" : { + "sources": { + "/home/ec2-user/sample" : "https://s3.amazonaws.com/cloudformation-examples/CloudFormationRailsSample.zip" + }, "files" : { "/tmp/_files_test_/epel.repo" : { "source" : "https://raw.github.com/heat-api/heat/master/README.rst", @@ -175,6 +178,17 @@ class MetadataTest(unittest.TestCase): self.m.StubOutWithMock(os, 'chown') self.m.StubOutWithMock(os, 'chmod') + subprocess.Popen(['su', 'root', '-c', + 'wget -O /tmp/CloudFormationRailsSample.zip \ +https://s3.amazonaws.com/cloudformation-examples/CloudFormationRailsSample.zip'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).AndReturn(PopenMock()) + + subprocess.Popen(['su', 'root', '-c', +'unzip -d /home/ec2-user/sample /tmp/CloudFormationRailsSample.zip'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).AndReturn(PopenMock()) + subprocess.Popen(['su', 'root', '-c', 'wget -O /tmp/_files_test_/epel.repo \ https://raw.github.com/heat-api/heat/master/README.rst'],