Commit 22c7af1f authored by Łukasz Nowak's avatar Łukasz Nowak

playbook: Adapt erp5-show to unusual software releases

As only two software releases shall be present on a box, assume that one
which is NOT apache frontend is the ERP5 one.

We have no control over how the ERP5 SR will be named, so this change
support this case.
parent 00f70c3d
...@@ -28,16 +28,14 @@ def get_connection_information(software_release): ...@@ -28,16 +28,14 @@ def get_connection_information(software_release):
conn = sqlite3.connect("/opt/slapos/slapproxy.db") conn = sqlite3.connect("/opt/slapos/slapproxy.db")
cur = conn.cursor() cur = conn.cursor()
if 'software/erp5' in software_release: if 'software/apache-frontend' not in software_release:
partition_reference = 'instance-of-erp5' partition_reference = 'instance-of-%'
elif 'software/wendelin' in software_release:
partition_reference = 'instance-of-wendelin'
elif 'software/apache-frontend' in software_release: elif 'software/apache-frontend' in software_release:
partition_reference = 'apache-frontend-1' partition_reference = 'apache-frontend-1'
else: else:
raise ValueError raise ValueError
qry = cur.execute("SELECT connection_xml FROM partition11 WHERE connection_xml IS NOT NULL AND software_release=? AND partition_reference=?", (software_release, partition_reference) ) 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) )
xml = None xml = None
for row in qry: for row in qry:
xml = str(row[0]) xml = str(row[0])
...@@ -47,7 +45,7 @@ def get_connection_information(software_release): ...@@ -47,7 +45,7 @@ def get_connection_information(software_release):
return (None, None) return (None, None)
instance = minidom.parseString(xml) instance = minidom.parseString(xml)
if partition_reference in ['instance-of-erp5', 'instance-of-wendelin']: if partition_reference.startswith('instance-of-'):
try: try:
el = instance.getElementsByTagName('parameter')[0] el = instance.getElementsByTagName('parameter')[0]
value = el.childNodes[0].nodeValue value = el.childNodes[0].nodeValue
...@@ -118,7 +116,7 @@ def status(): ...@@ -118,7 +116,7 @@ def status():
build = False build = False
if build: if build:
erp5_sr = [q for q in software_release_list if 'software/erp5' in q or 'software/wendelin' in q][0] erp5_sr = [q for q in software_release_list if 'software/apache-frontend' not in q][0]
frn_sr = [q for q in software_release_list frn_sr = [q for q in software_release_list
if 'software/apache-frontend' in q][0] if 'software/apache-frontend' in q][0]
zope_ip, pw = get_connection_information(erp5_sr) zope_ip, pw = get_connection_information(erp5_sr)
......
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