Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: jans-linux-setup set db component based on dn #3290

Merged
merged 4 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions jans-linux-setup/jans_setup/schema/jans_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4297,30 +4297,6 @@
],
"x_origin": "Jans created objectclass"
},
{
"kind": "STRUCTURAL",
"may": [
"c",
"ou",
"description",
"inum",
"displayName",
"jansConfDyn",
"o",
"jansRevision"
],
"must": [
"objectclass"
],
"names": [
"jansAdminConfDyn"
],
"oid": "jansObjClass",
"sup": [
"top"
],
"x_origin": "Jans created objectclass"
},
{
"kind": "STRUCTURAL",
"may": [
Expand Down
18 changes: 11 additions & 7 deletions jans-linux-setup/jans_setup/setup_app/utils/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,29 +285,33 @@ def enable_service(self, service):
n1ql = 'UPDATE `{}` USE KEYS "configuration" SET {}=true'.format(self.default_bucket, service)
self.cbm.exec_query(n1ql)

def set_configuration(self, component, value):
def set_configuration(self, component, value, dn='ou=configuration,o=jans'):
if self.moddb == BackendTypes.LDAP:
if value is None:
value = []
ldap_operation_result = self.ldap_conn.modify(
'ou=configuration,o=jans',
dn,
{component: [ldap3.MODIFY_REPLACE, value]}
)
self.log_ldap_result(ldap_operation_result)

elif self.moddb in (BackendTypes.MYSQL, BackendTypes.PGSQL):
result = self.get_sqlalchObj_for_dn('ou=configuration,o=jans')
result = self.get_sqlalchObj_for_dn(dn)
table_name = result.objectClass
sqlalchemy_table = self.Base.classes[table_name]
sqlalchemyObj = self.session.query(sqlalchemy_table).filter(sqlalchemy_table.dn =='ou=configuration,o=jans').first()
sqlalchemyObj = self.session.query(sqlalchemy_table).filter(sqlalchemy_table.dn ==dn).first()
cur_val = getattr(sqlalchemyObj, component)
setattr(sqlalchemyObj, component, value)
self.session.commit()

elif self.moddb == BackendTypes.SPANNER:
self.spanner.update_data(table='jansAppConf', columns=["doc_id", component], values=[["configuration", value]])

table = self.get_spanner_table_for_dn(dn)
doc_id = self.get_doc_id_from_dn(dn)
self.spanner.update_data(table=table, columns=["doc_id", component], values=[[doc_id, value]])

elif self.moddb == BackendTypes.COUCHBASE:
n1ql = 'UPDATE `{}` USE KEYS "configuration" SET {}={}'.format(self.default_bucket, component, value)
key = ldif_utils.get_key_from(dn)
n1ql = 'UPDATE `{}` USE KEYS "{}" SET {}={}'.format(self.default_bucket, key, component, value)
self.cbm.exec_query(n1ql)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 1
dn: ou=admin-ui,ou=configuration,o=jans
objectClass: jansAdminConfDyn
objectClass: jansAppConf
objectClass: top
jansConfDyn: %(role_scope_mappings)s
jansRevision: 1
Expand Down

This file was deleted.