Commit f5eee79f authored by Nicolas Wavrant's avatar Nicolas Wavrant

slaprunner: correctly patch software release path on import

usually, the software release path is :
in a web runner : /srv/slapgrid/slappartXX/srv/runner/project/buildout.cfg
in a test node : /srv/slapgrid/slappartX/srv/testnode/xx/inst/test0-XX/srv/runner/project/buldout.cfg

the previous regex was replacing in all slappartX and test0-X by the new test0-Y
which of course would make an existing path : /srv/slapgrid/test0-Y/.../test0-Y/...

This commit only replace the latest occurence in order to have
compatible code in the "normal" case, and in the test nodes
parent 8618492a
......@@ -22,7 +22,7 @@ md5sum = e12255a8c946b3eb8c6373fff481339f
[template-runner-import-script]
filename = template/runner-import.sh.jinja2
md5sum = bdfcf6edc20cc9f390b3e34e2531377b
md5sum = ed2e08c07a6727b2012f15da67c0705d
[instance-runner-import]
filename = instance-runner-import.cfg.in
......
......@@ -154,7 +154,19 @@ fi
# XXX hardcoded
PARTITION=$(basename $HOME)
OLD_SOFTWARE_RELEASE=$(db_query "select software_release from partition11 where reference='slappart0';")
SOFTWARE_RELEASE=$(echo "$OLD_SOFTWARE_RELEASE" | sed 's/\/\(slappart\|test0-\)[0-9][0-9]*\//\/'"$PARTITION"'\//')
SOFTWARE_RELEASE=$({{ sys.executable }} - $OLD_SOFTWARE_RELEASE $PARTITION <<EOF
if 1:
import os, re, sys
# We want to replace the last occurence only
old_software_release, partition = sys.argv[1], sys.argv[2]
for match in re.finditer("(slappart|test0-)[0-9][0-9]*", old_software_release):
start, end = match.start(), match.end()
print old_software_release[:start] + partition + old_software_release[end:]
EOF
)
db_query "update partition11 set software_release='$SOFTWARE_RELEASE' where software_release NOT NULL;"
db_query "update software11 set url='$SOFTWARE_RELEASE' where url='$OLD_SOFTWARE_RELEASE';" || db_query "delete from software11 where url='$OLD_SOFTWARE_RELEASE';"
# Change slapproxy database to have all instances stopped
......
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