[keystone] Align db scripts with Sqlalchemy 2

Depends-On: I52db7dd4563639a55c12850147cf256cec8b1ee4
Change-Id: Iebf6575d140efb16201fb8c05d16e1e9516d4691
This commit is contained in:
Vladimir Kozhukalov 2024-10-10 12:05:59 -05:00
parent fe2633dab2
commit cefe51327b
4 changed files with 22 additions and 19 deletions

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Keystone
name: keystone
version: 0.3.15
version: 0.3.16
home: https://docs.openstack.org/keystone/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Keystone/OpenStack_Project_Keystone_vertical.png
sources:

View File

@ -30,6 +30,7 @@ except ImportError:
PARSER_OPTS = {"strict": False}
import logging
from sqlalchemy import create_engine
from sqlalchemy import text
# Create logger, console handler and formatter
logger = logging.getLogger('OpenStack-Helm DB Drop')
@ -127,7 +128,7 @@ except:
# Delete all entries from credential table
try:
cmd = "DELETE FROM credential"
cmd = text("DELETE FROM credential")
with user_engine.connect() as connection:
connection.execute(cmd)
try:

View File

@ -4,6 +4,7 @@ import logging
import sys
from sqlalchemy import create_engine
from sqlalchemy import text
try:
import ConfigParser
@ -69,12 +70,12 @@ except:
try:
endpoint_url = os.environ['OS_BOOTSTRAP_INTERNAL_URL']
region_id = os.environ['OS_REGION_NAME']
cmd = ("update endpoint set url = %s where interface ='internal' and "
"service_id = (select id from service where "
"service.type = 'identity') and "
"region_id = %s")
cmd = text("update endpoint set url = :endpoint_url where interface ='internal' and "
"service_id = (select id from service where "
"service.type = 'identity') and "
"region_id = :region_id")
with user_engine.connect() as connection:
connection.execute(cmd, (endpoint_url,region_id))
connection.execute(cmd, {"endpoint_url": endpoint_url, "region_id": region_id})
try:
connection.commit()
except AttributeError:
@ -87,12 +88,12 @@ except:
try:
endpoint_url = os.environ['OS_BOOTSTRAP_ADMIN_URL']
region_id = os.environ['OS_REGION_NAME']
cmd = ("update endpoint set url = %s where interface ='admin' "
"and service_id = (select id from service where "
"service.type = 'identity') "
"and region_id = %s")
cmd = text("update endpoint set url = :endpoint_url where interface ='admin' "
"and service_id = (select id from service where "
"service.type = 'identity') "
"and region_id = :region_id")
with user_engine.connect() as connection:
connection.execute(cmd, (endpoint_url,region_id))
connection.execute(cmd, {"endpoint_url": endpoint_url, "region_id": region_id})
try:
connection.commit()
except AttributeError:
@ -105,12 +106,12 @@ except:
try:
endpoint_url = os.environ['OS_BOOTSTRAP_PUBLIC_URL']
region_id = os.environ['OS_REGION_NAME']
cmd = ("update endpoint set url = %s where interface ='public' "
"and service_id = (select id from service where "
"service.type = 'identity') "
"and region_id = %s")
cmd = text("update endpoint set url = :endpoint_url where interface ='public' "
"and service_id = (select id from service where "
"service.type = 'identity') "
"and region_id = :region_id")
with user_engine.connect() as connection:
connection.execute(cmd, (endpoint_url,region_id))
connection.execute(cmd, {"endpoint_url": endpoint_url, "region_id": region_id})
try:
connection.commit()
except AttributeError:
@ -123,8 +124,8 @@ except:
try:
with user_engine.connect() as connection:
endpoints = connection.execute(
("select interface, url from endpoint where service_id = "
"(select id from service where service.type = 'identity')")
text("select interface, url from endpoint where service_id = "
"(select id from service where service.type = 'identity')")
).fetchall()
for row in endpoints:
logger.info("endpoint ({0}): {1}".format(row[0], row[1]))

View File

@ -62,4 +62,5 @@ keystone:
- 0.3.13 Update images used by default
- 0.3.14 Align db scripts with sqlalchemy 2.0
- 0.3.15 Use quay.io/airshipit/kubernetes-entrypoint:latest-ubuntu_focal by default
- 0.3.16 Align db scripts with Sqlalchemy 2
...