Commit af5a60eb authored by Jérome Perrin's avatar Jérome Perrin

Fix scripts to use new slapos proxy table names

In slapos.core!76 and then slapos.core!105 we increased the slap proxy table name, so all scripts using `software11` or `partition11` directly break - because table name is different.

/reviewed-on !77
parents 9aa825f5 407eda57
......@@ -20,7 +20,7 @@ def fmt_date():
def discover_software():
conn = sqlite3.connect("/opt/slapos/slapproxy.db")
cur = conn.cursor()
qry = cur.execute("SELECT DISTINCT url FROM software11")
qry = cur.execute("SELECT DISTINCT url FROM software13")
return [row[0] for row in qry if row[0]]
def get_connection_information(software_release):
......@@ -34,7 +34,7 @@ def get_connection_information(software_release):
else:
raise ValueError
qry = cur.execute("SELECT connection_xml FROM partition11 WHERE connection_xml IS NOT NULL AND software_release=? AND partition_reference LIKE ?", (software_release, partition_reference) )
qry = cur.execute("SELECT connection_xml FROM partition13 WHERE connection_xml IS NOT NULL AND software_release=? AND partition_reference LIKE ?", (software_release, partition_reference) )
xml = None
for row in qry:
xml = str(row[0])
......@@ -75,7 +75,7 @@ def get_connection_information(software_release):
def check_tables():
conn = sqlite3.connect("/opt/slapos/slapproxy.db")
cur = conn.cursor()
qry = cur.execute("SELECT CASE WHEN tbl_name = 'partition11' THEN 1 ELSE 0 END FROM sqlite_master WHERE tbl_name = 'partition11' AND type = 'table'")
qry = cur.execute("SELECT CASE WHEN tbl_name = 'partition13' THEN 1 ELSE 0 END FROM sqlite_master WHERE tbl_name = 'partition13' AND type = 'table'")
if qry is None:
print "tables aren't ready yet, your build may have failed, check logs in /opt/slapos/log/"
......
......@@ -5,7 +5,7 @@ export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Once caucase is merged and used by the master the need of this workarround will be gone, and
# A better configuration can be proposes
slap_ipv4=`/opt/slapos/parts/sqlite3/bin/sqlite3 /opt/slapos/slapproxy.db "select address from partition_network11 where partition_reference=(select reference from partition11 where software_type = 'balancer' and requested_by = (select reference from partition11 where partition_reference='{{ backend_instance_reference }}')) and netmask='255.255.255.255';"`
slap_ipv4=`/opt/slapos/parts/sqlite3/bin/sqlite3 /opt/slapos/slapproxy.db "select address from partition_network13 where partition_reference=(select reference from partition13 where software_type = 'balancer' and requested_by = (select reference from partition13 where partition_reference='{{ backend_instance_reference }}')) and netmask='255.255.255.255';"`
local_access_comment="Local {{ playbook_name }} IPv4 access"
remote_access_comment="Remote {{ playbook_name }} IPv4 access"
......
#!/bin/bash
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
frontend_ipv4=`/opt/slapos/parts/sqlite3/bin/sqlite3 /opt/slapos/slapproxy.db "select address from partition_network11 where partition_reference=(select reference from partition11 where requested_by = (select reference from partition11 where partition_reference='{{ frontend_master_reference }}')) and netmask='255.255.255.255';"`
frontend_ipv4=`/opt/slapos/parts/sqlite3/bin/sqlite3 /opt/slapos/slapproxy.db "select address from partition_network13 where partition_reference=(select reference from partition13 where requested_by = (select reference from partition13 where partition_reference='{{ frontend_master_reference }}')) and netmask='255.255.255.255';"`
local_access_comment="Local {{ playbook_name }} IPv4 access"
remote_access_comment="Remote {{ playbook_name }} IPv4 access"
......
......@@ -79,7 +79,10 @@ slapos node format --now --alter_user=True >> $LOG_FILE 2>&1
# and they request the old software releases
rm -f /etc/cron.d/ansible*request* >> $LOG_FILE 2>&1
# remove any other software from the proxy
/opt/slapos/parts/sqlite3/bin/sqlite3 /opt/slapos/slapproxy.db 'delete from software11 where url not in ("$FRONTEND_SR_URL","$ERP5_SR_URL");' >> $LOG_FILE 2>&1
# first guess the software table name (slap proxy prefix tables by a version number)
SLAPPROXY_SOFTWARE_TABLE=$(/opt/slapos/parts/sqlite3/bin/sqlite3 /opt/slapos/slapproxy.db ".table software__")
# then delete from table XXX this should use a slapos API I guess
/opt/slapos/parts/sqlite3/bin/sqlite3 /opt/slapos/slapproxy.db "delete from $SLAPPROXY_SOFTWARE_TABLE where url not in ('$FRONTEND_SR_URL', '$ERP5_SR_URL');" >> $LOG_FILE 2>&1
echo "done."
echo -n "Installing ERP5 software..."
yum install -y erp5*rpm >> $LOG_FILE 2>&1
......
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