summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYukinori Sagara <sagara177@gmail.com>2014-08-22 18:30:37 +0900
committerYukinori Sagara <sagara177@gmail.com>2014-08-24 08:24:01 +0900
commit8ef88a6e864fa49cdc6dda9b1c701a29e0557253 (patch)
tree882a99c749b56245c549ee00ee6b955a4a66127f
parent2e544679e1c4f84b2bb5f8fa2f293f0447fe4259 (diff)
downloadheat-cfntools-8ef88a6e864fa49cdc6dda9b1c701a29e0557253.tar.gz
Change wget to curl for using both of them is redundant1.2.8
heat-cfntools depends on wget and curl. It's redundant. Since the curl is widely used, replace wget command to curl. Change-Id: I691bdc046bd72a44c11f25e359c5036ae1a9e86b Closes-Bug: 1359430
-rw-r--r--heat_cfntools/cfntools/cfn_helper.py16
-rw-r--r--heat_cfntools/tests/test_cfn_helper.py22
2 files changed, 19 insertions, 19 deletions
diff --git a/heat_cfntools/cfntools/cfn_helper.py b/heat_cfntools/cfntools/cfn_helper.py
index 6f7574b..3e55087 100644
--- a/heat_cfntools/cfntools/cfn_helper.py
+++ b/heat_cfntools/cfntools/cfn_helper.py
@@ -592,7 +592,7 @@ class FilesHandler(object):
f.write(json.dumps(meta['content'], indent=4))
f.close()
elif 'source' in meta:
- CommandRunner('wget -O %s %s' % (dest, meta['source'])).run()
+ CommandRunner('curl -o %s %s' % (dest, meta['source'])).run()
else:
LOG.error('%s %s' % (dest, str(meta)))
continue
@@ -671,20 +671,20 @@ class SourcesHandler(object):
basename = os.path.basename(url)
stype = self._source_type(url)
if stype == '.tgz':
- cmd = "wget -q -O - '%s' | gunzip | tar -xvf -" % url
+ cmd = "curl -s '%s' | gunzip | tar -xvf -" % url
elif stype == '.tbz2':
- cmd = "wget -q -O - '%s' | bunzip2 | tar -xvf -" % url
+ cmd = "curl -s '%s' | bunzip2 | tar -xvf -" % url
elif stype == '.zip':
tmp = self._url_to_tmp_filename(url)
- cmd = "wget -q -O '%s' '%s' && unzip -o '%s'" % (tmp, url, tmp)
+ cmd = "curl -s -o '%s' '%s' && unzip -o '%s'" % (tmp, url, tmp)
elif stype == '.tar':
- cmd = "wget -q -O - '%s' | tar -xvf -" % url
+ cmd = "curl -s '%s' | tar -xvf -" % url
elif stype == '.gz':
(r, ext) = self._splitext(basename)
- cmd = "wget -q -O - '%s' | gunzip > '%s'" % (url, r)
+ cmd = "curl -s '%s' | gunzip > '%s'" % (url, r)
elif stype == '.bz2':
(r, ext) = self._splitext(basename)
- cmd = "wget -q -O - '%s' | bunzip2 > '%s'" % (url, r)
+ cmd = "curl -s '%s' | bunzip2 > '%s'" % (url, r)
if cmd != '':
cmd = "mkdir -p '%s'; cd '%s'; %s" % (dest, dest, cmd)
@@ -1149,7 +1149,7 @@ class Metadata(object):
url = 'http://169.254.169.254/openstack/2012-08-10/meta_data.json'
if not os.path.exists(cache_path):
- CommandRunner('wget -O %s %s' % (cache_path, url)).run()
+ CommandRunner('curl -o %s %s' % (cache_path, url)).run()
try:
with open(cache_path) as fd:
try:
diff --git a/heat_cfntools/tests/test_cfn_helper.py b/heat_cfntools/tests/test_cfn_helper.py
index e642e66..42fe7e2 100644
--- a/heat_cfntools/tests/test_cfn_helper.py
+++ b/heat_cfntools/tests/test_cfn_helper.py
@@ -1015,7 +1015,7 @@ class TestMetadataRetrieve(testtools.TestCase):
self.assertEqual(meta_in, meta_out)
- def test_nova_meta_wget(self):
+ def test_nova_meta_curl(self):
url = 'http://169.254.169.254/openstack/2012-08-10/meta_data.json'
temp_home = tempfile.mkdtemp()
cache_path = os.path.join(temp_home, 'meta_data.json')
@@ -1045,7 +1045,7 @@ class TestMetadataRetrieve(testtools.TestCase):
self.m.StubOutWithMock(subprocess, 'Popen')
subprocess.Popen(['su', 'root', '-c',
- 'wget -O %s %s' % (cache_path, url)],
+ 'curl -o %s %s' % (cache_path, url)],
cwd=None, env=None, stderr=-1, stdout=-1)\
.WithSideEffects(write_cache_file)\
.AndReturn(FakePOpen('Downloaded', '', 0))
@@ -1057,7 +1057,7 @@ class TestMetadataRetrieve(testtools.TestCase):
self.assertEqual(meta_in, meta_out)
self.m.VerifyAll()
- def test_nova_meta_wget_corrupt(self):
+ def test_nova_meta_curl_corrupt(self):
url = 'http://169.254.169.254/openstack/2012-08-10/meta_data.json'
temp_home = tempfile.mkdtemp()
cache_path = os.path.join(temp_home, 'meta_data.json')
@@ -1080,7 +1080,7 @@ class TestMetadataRetrieve(testtools.TestCase):
self.m.StubOutWithMock(subprocess, 'Popen')
subprocess.Popen(['su', 'root', '-c',
- 'wget -O %s %s' % (cache_path, url)],
+ 'curl -o %s %s' % (cache_path, url)],
cwd=None, env=None, stderr=-1, stdout=-1)\
.WithSideEffects(write_cache_file)\
.AndReturn(FakePOpen('Downloaded', '', 0))
@@ -1092,7 +1092,7 @@ class TestMetadataRetrieve(testtools.TestCase):
self.assertEqual(None, meta_out)
self.m.VerifyAll()
- def test_nova_meta_wget_failed(self):
+ def test_nova_meta_curl_failed(self):
url = 'http://169.254.169.254/openstack/2012-08-10/meta_data.json'
temp_home = tempfile.mkdtemp()
cache_path = os.path.join(temp_home, 'meta_data.json')
@@ -1106,7 +1106,7 @@ class TestMetadataRetrieve(testtools.TestCase):
self.m.StubOutWithMock(subprocess, 'Popen')
subprocess.Popen(['su', 'root', '-c',
- 'wget -O %s %s' % (cache_path, url)],
+ 'curl -o %s %s' % (cache_path, url)],
cwd=None, env=None, stderr=-1, stdout=-1)\
.AndReturn(FakePOpen('Failed', '', 1))
@@ -1230,10 +1230,10 @@ class TestSourcesHandler(MockPopenTestCase):
td = os.path.dirname(end_file)
self.m.StubOutWithMock(tempfile, 'mkdtemp')
tempfile.mkdtemp().AndReturn(td)
- er = "mkdir -p '%s'; cd '%s'; wget -q -O - '%s' | gunzip | tar -xvf -"
+ er = "mkdir -p '%s'; cd '%s'; curl -s '%s' | gunzip | tar -xvf -"
cmd = ['su', 'root', '-c',
er % (dest, dest, url)]
- self.mock_cmd_run(cmd).AndReturn(FakePOpen('Wget good'))
+ self.mock_cmd_run(cmd).AndReturn(FakePOpen('Curl good'))
self.m.ReplayAll()
sh = cfn_helper.SourcesHandler(sources)
sh.apply_sources()
@@ -1254,7 +1254,7 @@ class TestSourcesHandler(MockPopenTestCase):
def test_apply_source_cmd(self):
sh = cfn_helper.SourcesHandler({})
- er = "mkdir -p '%s'; cd '%s'; wget -q -O - '%s' | %s | tar -xvf -"
+ er = "mkdir -p '%s'; cd '%s'; curl -s '%s' | %s | tar -xvf -"
dest = '/tmp'
# test tgz
url = 'http://www.example.com/a.tgz'
@@ -1281,7 +1281,7 @@ class TestSourcesHandler(MockPopenTestCase):
cmd = sh._apply_source_cmd(dest, url)
self.assertEqual(er % (dest, dest, url, "bunzip2"), cmd)
# test zip
- er = "mkdir -p '%s'; cd '%s'; wget -q -O '%s' '%s' && unzip -o '%s'"
+ er = "mkdir -p '%s'; cd '%s'; curl -s -o '%s' '%s' && unzip -o '%s'"
url = 'http://www.example.com/a.zip'
d = "/tmp/tmp2I0yNK"
tmp = "%s/a.zip" % d
@@ -1291,7 +1291,7 @@ class TestSourcesHandler(MockPopenTestCase):
cmd = sh._apply_source_cmd(dest, url)
self.assertEqual(er % (dest, dest, tmp, url, tmp), cmd)
# test gz
- er = "mkdir -p '%s'; cd '%s'; wget -q -O - '%s' | %s > '%s'"
+ er = "mkdir -p '%s'; cd '%s'; curl -s '%s' | %s > '%s'"
url = 'http://www.example.com/a.sh.gz'
cmd = sh._apply_source_cmd(dest, url)
self.assertEqual(er % (dest, dest, url, "gunzip", "a.sh"), cmd)