diff --git a/ingestion/src/metadata/ingestion/source/database/db2/connection.py b/ingestion/src/metadata/ingestion/source/database/db2/connection.py index cadde6775f3..b25ac3efc75 100644 --- a/ingestion/src/metadata/ingestion/source/database/db2/connection.py +++ b/ingestion/src/metadata/ingestion/source/database/db2/connection.py @@ -12,6 +12,7 @@ """ Source connection handler """ +from pathlib import Path from typing import Optional from sqlalchemy.engine import Engine @@ -32,13 +33,25 @@ from metadata.ingestion.connections.builders import ( ) from metadata.ingestion.connections.test_connections import test_connection_db_common from metadata.ingestion.ometa.ometa_api import OpenMetadata -from metadata.utils.constants import THREE_MIN +from metadata.utils.constants import THREE_MIN, UTF_8 def get_connection(connection: Db2Connection) -> Engine: """ Create connection """ + # prepare license + # pylint: disable=import-outside-toplevel + if connection.license and connection.licenseFileName: + import clidriver + + with open( + Path(clidriver.__path__[0], "license", connection.licenseFileName), + "w", + encoding=UTF_8, + ) as file: + file.write(connection.license) + return create_generic_db_connection( connection=connection, get_connection_url_fn=get_connection_url_common, diff --git a/openmetadata-docs/content/v1.6.x-SNAPSHOT/connectors/database/db2/index.md b/openmetadata-docs/content/v1.6.x-SNAPSHOT/connectors/database/db2/index.md index a892213d65e..66994e79848 100644 --- a/openmetadata-docs/content/v1.6.x-SNAPSHOT/connectors/database/db2/index.md +++ b/openmetadata-docs/content/v1.6.x-SNAPSHOT/connectors/database/db2/index.md @@ -87,6 +87,8 @@ Executing the profiler workflow or data quality tests, will require the user to - **Password**: Password to connect to DB2. - **database**: Database of the data source. - **Host and Port**: Enter the fully qualified hostname and port number for your DB2 deployment in the Host and Port field. +- **License File Name**: License file name in case the license is required for connection. +- **License**: Contents of your license file if applicable, make sure to replace new lines with `\n` before pasting it here. {% note %} If you are using DB2 for IBM i: diff --git a/openmetadata-docs/content/v1.6.x-SNAPSHOT/connectors/database/db2/yaml.md b/openmetadata-docs/content/v1.6.x-SNAPSHOT/connectors/database/db2/yaml.md index 773e0edca41..79b87980194 100644 --- a/openmetadata-docs/content/v1.6.x-SNAPSHOT/connectors/database/db2/yaml.md +++ b/openmetadata-docs/content/v1.6.x-SNAPSHOT/connectors/database/db2/yaml.md @@ -108,6 +108,18 @@ This is a sample config for DB2: {% /codeInfo %} +{% codeInfo srNumber=7 %} + +**license**: Contents of your license file if applicable, make sure to replace new lines with `\n` before pasting it here. + +{% /codeInfo %} + +{% codeInfo srNumber=8 %} + +**licenseFileName**: License file name in case the license is required for connection. + +{% /codeInfo %} + {% partial file="/v1.6/connectors/yaml/database/source-config-def.md" /%} {% partial file="/v1.6/connectors/yaml/ingestion-sink-def.md" /%} @@ -151,6 +163,12 @@ source: ```yaml {% srNumber=3 %} hostPort: localhost:5432 ``` +```yaml {% srNumber=7 %} + # license: content.....\n..of your....\n...license...\n..file... +``` +```yaml {% srNumber=8 %} + # licenseFileName: your_license.llc +``` ```yaml {% srNumber=4 %} # databaseSchema: schema ``` diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/database/db2Connection.json b/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/database/db2Connection.json index 21eccba7698..9c49ce73a19 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/database/db2Connection.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/database/db2Connection.json @@ -53,6 +53,16 @@ "description": "Database of the data source.", "type": "string" }, + "licenseFileName": { + "title": "License File Name", + "description": "License file name to connect to DB2.", + "type": "string" + }, + "license": { + "title": "License", + "description": "License to connect to DB2.", + "type": "string" + }, "connectionOptions": { "title": "Connection Options", "$ref": "../connectionBasicType.json#/definitions/connectionOptions" diff --git a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Db2.md b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Db2.md index da50e3321a8..c510a55030c 100644 --- a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Db2.md +++ b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Db2.md @@ -69,6 +69,20 @@ $$section Database name of the DB2 database to establish the connection. $$ + +$$section +### License File Name $(id="licenseFileName") + +License file name in case the license is required for connection. +$$ + + +$$section +### License $(id="license") + +Contents of your license file if applicable, make sure to replace new lines with `\n` before pasting it here. +$$ + $$section ### Connection Options $(id="connectionOptions")