|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +SPDX-License-Identifier: Apache-2.0 |
| 4 | +Copyright Contributors to the ODPi Egeria project. |
| 5 | +
|
| 6 | +
|
| 7 | +
|
| 8 | +Egeria Coco Pharmaceutical demonstration labs. |
| 9 | +
|
| 10 | +This script creates and configures the cocoMDS2 - Governance metadata server |
| 11 | +
|
| 12 | +
|
| 13 | +""" |
| 14 | + |
| 15 | + |
| 16 | +import json |
| 17 | +import argparse |
| 18 | +from datetime import datetime |
| 19 | + |
| 20 | +from globals import (cocoMDS2Name, corePlatformURL, cocoCohort, devCohort, iotCohort, max_paging_size, adminUserId, |
| 21 | + cocoMDS5Name, cocoMDS6Name) |
| 22 | +from pyegeria import CoreServerConfig, Platform |
| 23 | +from pyegeria import ( |
| 24 | + print_exception_response, |
| 25 | +) |
| 26 | + |
| 27 | + |
| 28 | +def config_coco_core(url: str, userid: str): |
| 29 | + disable_ssl_warnings = True |
| 30 | + print("Configuring and activating the Datalake") |
| 31 | + platform_url = url |
| 32 | + admin_user = userid |
| 33 | + |
| 34 | + # event_bus_config = { |
| 35 | + # "producer": { |
| 36 | + # "bootstrap.servers": "{{kafkaEndpoint}}" |
| 37 | + # }, |
| 38 | + # "consumer": { |
| 39 | + # "bootstrap.servers": "{{kafkaEndpoint}}" |
| 40 | + # } |
| 41 | + # } |
| 42 | + event_bus_config = { |
| 43 | + "producer": { |
| 44 | + "bootstrap.servers": "host.docker.internal:9192" |
| 45 | + }, |
| 46 | + "consumer": { |
| 47 | + "bootstrap.servers": "host.docker.internal:9192" |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + security_connection_body = { |
| 52 | + "class": "Connection", |
| 53 | + "connectorType": { |
| 54 | + "class": "ConnectorType", |
| 55 | + "connectorProviderClassName": |
| 56 | + "org.odpi.openmetadata.metadatasecurity.samples.CocoPharmaServerSecurityProvider" |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + # |
| 61 | + # Configure MDS2 |
| 62 | + # |
| 63 | + mdr_server = cocoMDS2Name |
| 64 | + mdr_server_user_id = "cocoMDS2npa" |
| 65 | + mdr_server_password = "cocoMDS2passw0rd" |
| 66 | + metadataCollectionId = f"{mdr_server}-e915f2fa-aa3g-4396-8bde-bcd65e642b1d" |
| 67 | + metadataCollectionName = "Governance Catalog" |
| 68 | + |
| 69 | + |
| 70 | + try: |
| 71 | + o_client = CoreServerConfig(mdr_server, platform_url, admin_user) |
| 72 | + |
| 73 | + o_client.set_basic_server_properties("Governance Server", |
| 74 | + "Coco Pharmaceuticals", |
| 75 | + platform_url, |
| 76 | + mdr_server_user_id, mdr_server_password, |
| 77 | + max_paging_size) |
| 78 | + |
| 79 | + o_client.set_event_bus(event_bus_config) |
| 80 | + o_client.set_server_security_connection(security_connection_body) |
| 81 | + o_client.add_default_log_destinations() |
| 82 | + |
| 83 | + # o_client.set_in_mem_local_repository() |
| 84 | + o_client.set_xtdb_local_kv_repository() |
| 85 | + |
| 86 | + o_client.set_local_metadata_collection_id(metadataCollectionId) |
| 87 | + o_client.set_local_metadata_collection_name(metadataCollectionName) |
| 88 | + |
| 89 | + o_client.add_cohort_registration(cocoCohort) |
| 90 | + o_client.add_cohort_registration(devCohort) |
| 91 | + o_client.add_cohort_registration(iotCohort) |
| 92 | + |
| 93 | + # o_client.configure_access_service("asset-catalog", {}) |
| 94 | + o_client.configure_access_service("asset-consumer", {}) |
| 95 | + |
| 96 | + o_client.configure_access_service("asset-owner", {}) |
| 97 | + o_client.configure_access_service("community-profile", |
| 98 | + {"KarmaPointPlateau": "500"}) |
| 99 | + # o_client.configure_access_service("glossary-view", {}) |
| 100 | + # o_client.configure_access_service("subject-area", {}) |
| 101 | + o_client.configure_access_service("governance-engine", {}) |
| 102 | + o_client.configure_access_service("governance-server", {}) |
| 103 | + o_client.configure_access_service("governance-program", {}) |
| 104 | + # o_client.configure_access_service("data-privacy", {}) |
| 105 | + o_client.configure_access_service("digital-architecture", {}) |
| 106 | + o_client.configure_access_service("security-manager", {}) |
| 107 | + o_client.configure_access_service("asset-lineage", {}) |
| 108 | + o_client.configure_access_service("it-infrastructure", {}) |
| 109 | + o_client.configure_access_service("project-management", {}) |
| 110 | + print(f"Activating {mdr_server}") |
| 111 | + p_client = Platform(mdr_server, platform_url, admin_user) |
| 112 | + p_client.activate_server_stored_config() |
| 113 | + print(f"{mdr_server} activated") |
| 114 | + except Exception as e: |
| 115 | + print_exception_response(e) |
| 116 | + # |
| 117 | + # Configure MDS5 |
| 118 | + # |
| 119 | + disable_ssl_warnings = True |
| 120 | + |
| 121 | + mdr_server = cocoMDS5Name |
| 122 | + mdr_server_user_id = "cocoMDS5npa" |
| 123 | + mdr_server_password = "cocoMDS5passw0rd" |
| 124 | + metadataCollectionId = f"{mdr_server}-e915f2fa-aa3g-4396-8bde-bcd65e642b1d" |
| 125 | + metadataCollectionName = "Business Systems Catalog" |
| 126 | + |
| 127 | + print("Configuring " + mdr_server + "...") |
| 128 | + try: |
| 129 | + o_client = CoreServerConfig(mdr_server, platform_url, admin_user) |
| 130 | + |
| 131 | + o_client.set_basic_server_properties("Business Systems", |
| 132 | + "Coco Pharmaceuticals", |
| 133 | + platform_url, |
| 134 | + mdr_server_user_id, mdr_server_password, |
| 135 | + max_paging_size) |
| 136 | + |
| 137 | + o_client.set_event_bus(event_bus_config) |
| 138 | + o_client.set_server_security_connection(security_connection_body) |
| 139 | + o_client.add_default_log_destinations() |
| 140 | + |
| 141 | + # o_client.set_in_mem_local_repository() |
| 142 | + o_client.set_xtdb_local_kv_repository() |
| 143 | + |
| 144 | + o_client.set_local_metadata_collection_id(metadataCollectionId) |
| 145 | + o_client.set_local_metadata_collection_name(metadataCollectionName) |
| 146 | + |
| 147 | + o_client.add_cohort_registration(cocoCohort) |
| 148 | + |
| 149 | + proxy_details = ("org.odpi.openmetadata.adapters.repositoryservices.readonly.repositoryconnector." + |
| 150 | + "ReadOnlyOMRSRepositoryConnectorProvider") |
| 151 | + o_client.set_repository_proxy_details(proxy_details) |
| 152 | + print(f"Activating {mdr_server}") |
| 153 | + p_client = Platform(mdr_server, platform_url, admin_user) |
| 154 | + p_client.activate_server_stored_config() |
| 155 | + print(f"{mdr_server} activated") |
| 156 | + except Exception as e: |
| 157 | + print_exception_response(e) |
| 158 | + |
| 159 | + # |
| 160 | + # Configure MDS6 |
| 161 | + # |
| 162 | + disable_ssl_warnings = True |
| 163 | + |
| 164 | + mdr_server = cocoMDS6Name |
| 165 | + platform_url = corePlatformURL |
| 166 | + admin_user = "garygeeke" |
| 167 | + mdr_server_user_id = "cocoMDS6npa" |
| 168 | + mdr_server_password = "cocoMDS6passw0rd" |
| 169 | + metadataCollectionId = f"{mdr_server}-e915f2fa-aa3g-4396-8bde-bcd65e642b1d" |
| 170 | + metadataCollectionName = "Manufacturing Catalog" |
| 171 | + |
| 172 | + print("Configuring " + mdr_server + "...") |
| 173 | + |
| 174 | + try: |
| 175 | + o_client = CoreServerConfig(mdr_server, platform_url, admin_user) |
| 176 | + |
| 177 | + o_client.set_basic_server_properties("Manufacturing", |
| 178 | + "Coco Pharmaceuticals", |
| 179 | + platform_url, |
| 180 | + mdr_server_user_id, mdr_server_password, |
| 181 | + max_paging_size) |
| 182 | + |
| 183 | + o_client.set_event_bus(event_bus_config) |
| 184 | + |
| 185 | + o_client.set_server_security_connection(security_connection_body) |
| 186 | + o_client.add_default_log_destinations() |
| 187 | + |
| 188 | + # o_client.set_in_mem_local_repository() |
| 189 | + o_client.set_xtdb_local_kv_repository() |
| 190 | + |
| 191 | + o_client.set_local_metadata_collection_id(metadataCollectionId) |
| 192 | + o_client.set_local_metadata_collection_name(metadataCollectionName) |
| 193 | + |
| 194 | + o_client.add_cohort_registration(cocoCohort) |
| 195 | + o_client.add_cohort_registration(iotCohort) |
| 196 | + |
| 197 | + access_service_options = { |
| 198 | + "SupportedZones": ["manufacturing"], |
| 199 | + "DefaultZones": ["manufacturing"] |
| 200 | + } |
| 201 | + |
| 202 | + # o_client.configure_access_service("asset-catalog", access_service_options) |
| 203 | + o_client.configure_access_service("asset-consumer", access_service_options) |
| 204 | + o_client.configure_access_service("asset-owner", access_service_options) |
| 205 | + o_client.configure_access_service("community-profile", |
| 206 | + {"KarmaPointPlateau": "500"}) |
| 207 | + # o_client.configure_access_service("glossary-view", {}) |
| 208 | + o_client.configure_access_service("data-science", access_service_options) |
| 209 | + # o_client.configure_access_service("subject-area", {}) |
| 210 | + o_client.configure_access_service("asset-manager", access_service_options) |
| 211 | + o_client.configure_access_service("governance-engine", access_service_options) |
| 212 | + o_client.configure_access_service("governance-server", access_service_options) |
| 213 | + o_client.configure_access_service("asset-owner", access_service_options) |
| 214 | + # o_client.configure_access_service("data-engine", access_service_options) |
| 215 | + o_client.configure_access_service("data-manager", access_service_options) |
| 216 | + o_client.configure_access_service("it-infrastructure", access_service_options) |
| 217 | + o_client.configure_access_service("project-management", access_service_options) |
| 218 | + |
| 219 | + print(f"Activating {mdr_server}") |
| 220 | + p_client = Platform(mdr_server, platform_url, admin_user) |
| 221 | + p_client.activate_server_stored_config() |
| 222 | + print(f"{mdr_server} activated") |
| 223 | + except Exception as e: |
| 224 | + print_exception_response(e) |
| 225 | + |
| 226 | +def main(): |
| 227 | + parser = argparse.ArgumentParser() |
| 228 | + |
| 229 | + parser.add_argument("--url", help="URL Platform to connect to") |
| 230 | + parser.add_argument("--userid", help="User Id") |
| 231 | + args = parser.parse_args() |
| 232 | + |
| 233 | + url = args.url if args.url is not None else corePlatformURL |
| 234 | + userid = args.userid if args.userid is not None else adminUserId |
| 235 | + |
| 236 | + config_coco_core(url, userid) |
| 237 | + |
| 238 | +if __name__ == "__main__": |
| 239 | + main() |
0 commit comments