Commit 38552c68 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Fix various bugs in snf-image-helper

* In, use subprocess.Popen method instead of
  subprocess.check_output, which is introduced in python 2.7

* Fix a bug in snf-image-helper where was not
  properly called

* Fix a bug in FixPartitionTable task
parent 7a474322
......@@ -46,10 +46,11 @@ def main():
for key, value in properties.items():
os.environ['SNF_IMAGE_PROPERTY_' + key] = value
output = StringIO(subprocess.check_output(['bash', '-c', 'set']))
p = subprocess.Popen(['bash', '-c', 'set'], stdout=subprocess.PIPE)
output = StringIO(p.communicate()[0]);
for line in iter(output):
if line.startswith('SNF_IMAGE_PROPERTY_'):
outfh.write('export ' + line)
......@@ -62,8 +62,8 @@ fi
if [ -n "$SNF_IMAGE_PROPERTIES" ]; then
properties=$(mktemp --tmpdir properties.XXXXXX)
add_cleanup rm "$properties"
"@scriptsdir@/" > "$properties"
"@scriptsdir@/" "$properties"
source "$properties"
log_error "SNF_IMAGE_PROPERTIES variable is missing"
......@@ -37,12 +37,17 @@ fi
new_pend=$(get_last_free_sector "$SNF_IMAGE_DEV")
#Extend the partition
if [ -z "$new_pend" ] ; then
# Nothing to do
exit 0
# Extend the partition
$PARTED -s -m "$SNF_IMAGE_DEV" rm "$id"
$PARTED -s -m "$SNF_IMAGE_DEV" mkpart primary "$ptype" "$pstart" "$new_pend"
#inform the kernel about the changes
# Inform the kernel about the changes
partprobe "$SNF_IMAGE_DEV"
exit 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment