Introduction
This story covers the work to allow the RDBMS system to be used by the Policy Framework to be configured at installation time to be whatever SQL based RDBMS is required.
Specifically, the MariaDB and Postgres databases are to be supported.
To complete this task changes will be made to all policy components that connect to the DB. References to MariaDB will be removed and property files will be created to allow users to choose their configuration. Changes to the db-migrator are also needed as this component is responsible for creating/updating tables in the policyadmin schema.
Solution:
Make changes to policy-api, policy-pap and all pdps to allow configurable connection of MariaDB or Postgres. This will require replacing references to MariaDB in the configuration json of the components with Maven properties to populate the connection fields. Renaming the persistence unit would also be a possible change from “PolicyMariaDb” to a more universal “PolicyDb”.
Changes in all components: (Example w/ policy-api)
{ "name":"ApiGroup", "restServerParameters":{ "host":"0.0.0.0", "port":6968, "userName":"healthcheck", "password":"zb!XztG34", "https":false }, "databaseProviderParameters": { "name": "PolicyProviderParameterGroup", "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl", "databaseDriver": "org.postgresql.Driver", "databaseUrl": "jdbc:postgresql://localhost:5432/policyadmin", "databaseUser": "policy_user", "databasePassword": "policy_user", "persistenceUnit": "PolicyDb" }, "preloadPolicyTypes": [ "policytypes/onap.policies.monitoring.tcagen2.yaml", "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml", "policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml", "policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml", "policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml", . . }
{ "name":"ApiGroup", "restServerParameters":{ "host":"0.0.0.0", "port":6968, "userName":"healthcheck", "password":"zb!XztG34", "https":false }, "databaseProviderParameters": { "name": "PolicyProviderParameterGroup", "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl", "databaseDriver": "${DATABASE_DRIVER}", "databaseUrl": "${DATABASE_URL}", "databaseUser": "${DATABASE_USER}", "databasePassword": "${DATABASE_PASSWORD}", "persistenceUnit": "${PERSISTENCE_UNIT}" }, "preloadPolicyTypes": [ "policytypes/onap.policies.monitoring.tcagen2.yaml", "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml", "policytypes/onap.policies.monitoring.dcae-restconfcollector.yaml", "policytypes/onap.policies.monitoring.dcae-pm-subscription-handler.yaml", "policytypes/onap.policies.monitoring.dcae-pm-mapper.yaml" ] . . . }
DATABASE_DRIVER=org.postgresql.Driver DATABASE_URL=dbc:postgresql://localhost:5432/policyadmin DATABASE_USER=policy_user DATABASE_PASSWORD=policy_user PERSISTENCE_UNIT=PolicyDb
db-migrator changes:
The db-migrator will also need to be configurable in order to select what database it will use to create/update tables in the policyadmin schema. As syntax is slightly different between MariaDB and Postgres respectively, the db-migrator main script will need to be updated to reflect this. At the moment, the db-migrator is tailored specifically to MariaDB.
Various checks in the db-migrator script use MariaDB statements to retrieve information from the database which will cause issues when changing to Postgres. For example; to retrieve a list of tables in a database in MariaDB the syntax is: USE DATABASE db_name; SHOW TABLES; whereas in Postgres the syntax is; \c db_name; \dt;
Updates:
12/7 - 90% of the work has been completed in the db-migrator. Due to syntax differences between MariaDB and Postgres, further changes are needed in the db-migrator to allow postgres to work while keeping the script common for both. Work ongoing on this.