Replace subprocess with run_local in _find_images
In the DevStack caching script/element for Nodepool images, use run_local instead of subprocess.check_output in the _find_images function. The latter wasn't introduced until Python 2.7 and so won't work on CentOS 6. The script called from this function returns quickly and doesn't benefit from non-blocking I/O anyway. Change-Id: I3129f1f5b3fece321ae132ea1a52b0e156e58365
This commit is contained in:
parent
bbc5915d18
commit
fd9c80208c
|
@ -17,7 +17,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# this is a bit weird; we want to get the filter to use on the
|
||||
|
@ -113,15 +112,16 @@ def _legacy_find_images(basedir):
|
|||
|
||||
def _find_images(basedir):
|
||||
images = []
|
||||
try:
|
||||
image_tool = os.path.join(basedir, 'tools', 'image_list.sh')
|
||||
if os.path.exists(image_tool):
|
||||
images = subprocess.check_output(image_tool).split('\n')
|
||||
except subprocess.CalledProcessError as ce:
|
||||
print "image_list.sh failed"
|
||||
print "Exit: %s, Output: %s" % (ce.returncode, ce.output)
|
||||
# reset images so we'll fall back
|
||||
images = []
|
||||
image_tool = os.path.join(basedir, 'tools', 'image_list.sh')
|
||||
if os.path.exists(image_tool):
|
||||
returncode, out = run_local(image_tool, status=True)
|
||||
if returncode:
|
||||
print "%s failed" % image_tool
|
||||
print "Exit: %s, Output: %s" % (returncode, out)
|
||||
# reset images so we'll fall back
|
||||
images = []
|
||||
else:
|
||||
images = out.split('\n')
|
||||
return images
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from common import run_local
|
||||
|
@ -82,15 +81,16 @@ def _legacy_find_images(basedir):
|
|||
|
||||
def _find_images(basedir):
|
||||
images = []
|
||||
try:
|
||||
image_tool = os.path.join(basedir, 'tools', 'image_list.sh')
|
||||
if os.path.exists(image_tool):
|
||||
images = subprocess.check_output(image_tool).split('\n')
|
||||
except subprocess.CalledProcessError as ce:
|
||||
print "image_list.sh failed"
|
||||
print "Exit: %s, Output: %s" % (ce.returncode, ce.output)
|
||||
# reset images so we'll fall back
|
||||
images = []
|
||||
image_tool = os.path.join(basedir, 'tools', 'image_list.sh')
|
||||
if os.path.exists(image_tool):
|
||||
returncode, out = run_local(image_tool, status=True)
|
||||
if returncode:
|
||||
print "%s failed" % image_tool
|
||||
print "Exit: %s, Output: %s" % (returncode, out)
|
||||
# reset images so we'll fall back
|
||||
images = []
|
||||
else:
|
||||
images = out.split('\n')
|
||||
return images
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue