pyegeria 0.8.4.7__py3-none-any.whl → 0.8.4.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. pyegeria/__init__.py +0 -1
  2. pyegeria/egeria_config_client.py +3 -4
  3. pyegeria/egeria_tech_client.py +5 -0
  4. {pyegeria-0.8.4.7.dist-info → pyegeria-0.8.4.9.dist-info}/METADATA +1 -1
  5. {pyegeria-0.8.4.7.dist-info → pyegeria-0.8.4.9.dist-info}/RECORD +8 -28
  6. examples/doc_samples/Create_Collection_Sample.py +0 -320
  7. examples/doc_samples/Create_Sustainability_Collection_Sample.py +0 -149
  8. examples/widgets/ops/README.md +0 -24
  9. examples/widgets/ops/__init__.py +0 -19
  10. examples/widgets/ops/engine_actions.py +0 -83
  11. examples/widgets/ops/integration_daemon_actions.py +0 -139
  12. examples/widgets/ops/list_catalog_targets.py +0 -157
  13. examples/widgets/ops/load_archive.py +0 -62
  14. examples/widgets/ops/monitor_asset_events.py +0 -102
  15. examples/widgets/ops/monitor_coco_status.py +0 -103
  16. examples/widgets/ops/monitor_engine_activity.py +0 -236
  17. examples/widgets/ops/monitor_engine_activity_c.py +0 -253
  18. examples/widgets/ops/monitor_gov_eng_status.py +0 -188
  19. examples/widgets/ops/monitor_integ_daemon_status.py +0 -256
  20. examples/widgets/ops/monitor_platform_status.py +0 -176
  21. examples/widgets/ops/monitor_server_list.py +0 -140
  22. examples/widgets/ops/monitor_server_status.py +0 -109
  23. examples/widgets/ops/refresh_integration_daemon.py +0 -73
  24. examples/widgets/ops/restart_integration_daemon.py +0 -73
  25. pyegeria/egeria_ops_client.py +0 -75
  26. {pyegeria-0.8.4.7.dist-info → pyegeria-0.8.4.9.dist-info}/LICENSE +0 -0
  27. {pyegeria-0.8.4.7.dist-info → pyegeria-0.8.4.9.dist-info}/WHEEL +0 -0
  28. {pyegeria-0.8.4.7.dist-info → pyegeria-0.8.4.9.dist-info}/entry_points.txt +0 -0
@@ -1,83 +0,0 @@
1
- """
2
- SPDX-License-Identifier: Apache-2.0
3
- Copyright Contributors to the ODPi Egeria project.
4
-
5
-
6
-
7
- Execute engine actions.
8
-
9
- """
10
- import os
11
-
12
- import click
13
-
14
- # from ops_config import Config, pass_config
15
- from pyegeria import Platform
16
- from pyegeria._exceptions import (
17
- InvalidParameterException,
18
- PropertyServerException,
19
- print_exception_response,
20
- )
21
-
22
- GERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
23
- EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
24
- EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
25
- EGERIA_VIEW_SERVER = os.environ.get("VIEW_SERVER", "view-server")
26
- EGERIA_VIEW_SERVER_URL = os.environ.get(
27
- "EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
28
- )
29
- EGERIA_INTEGRATION_DAEMON = os.environ.get("INTEGRATION_DAEMON", "integration-daemon")
30
- EGERIA_INTEGRATION_DAEMON_URL = os.environ.get(
31
- "EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443"
32
- )
33
- EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
34
- EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
35
- EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
36
- EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
37
-
38
-
39
- @click.command("stop")
40
- @click.option(
41
- "--server", default=EGERIA_VIEW_SERVER, help="Egeria metadata store to load"
42
- )
43
- @click.option(
44
- "--url", default=EGERIA_VIEW_SERVER_URL, help="URL of Egeria platform to connect to"
45
- )
46
- @click.option("--userid", default=EGERIA_ADMIN_USER, help="Egeria admin user")
47
- @click.option("--password", default=EGERIA_ADMIN_PASSWORD, help="Egeria admin password")
48
- @click.option("--timeout", default=60, help="Number of seconds to wait")
49
- def stop_daemon(file, server, url, userid, password, timeout):
50
- """Stop an engine-host daemon"""
51
- p_client = Platform(server, url, userid, password)
52
- try:
53
- p_client.shutdown_server()
54
-
55
- click.echo(f"Stopped server {server}")
56
- except (InvalidParameterException, PropertyServerException) as e:
57
- print_exception_response(e)
58
- finally:
59
- p_client.close_session()
60
-
61
-
62
- @click.command("start")
63
- @click.option(
64
- "--server", default=EGERIA_VIEW_SERVER, help="Egeria metadata store to load"
65
- )
66
- @click.option(
67
- "--url", default=EGERIA_VIEW_SERVER_URL, help="URL of Egeria platform to connect to"
68
- )
69
- @click.option("--userid", default=EGERIA_ADMIN_USER, help="Egeria admin user")
70
- @click.option("--password", default=EGERIA_ADMIN_PASSWORD, help="Egeria admin password")
71
- @click.option("--timeout", default=60, help="Number of seconds to wait")
72
- def start_daemon(file, server, url, userid, password, timeout):
73
- """Start or restart an engine-host from its known configuration"""
74
- p_client = Platform(server, url, userid, password)
75
- try:
76
- p_client.activate_server_stored_config()
77
-
78
- click.echo(f"Started server {server}")
79
-
80
- except (InvalidParameterException, PropertyServerException) as e:
81
- print_exception_response(e)
82
- finally:
83
- p_client.close_session()
@@ -1,139 +0,0 @@
1
- """
2
- SPDX-License-Identifier: Apache-2.0
3
- Copyright Contributors to the ODPi Egeria project.
4
-
5
-
6
-
7
- This script restarts an integration daemon.
8
-
9
- """
10
-
11
- import os
12
- from rich import print, print_json
13
- from rich.console import Console
14
-
15
- import click
16
- from pyegeria import ServerOps, AutomatedCuration, INTEGRATION_GUIDS, Platform
17
- from pyegeria._exceptions import (
18
- InvalidParameterException,
19
- PropertyServerException,
20
- UserNotAuthorizedException,
21
- print_exception_response,
22
- )
23
-
24
-
25
- @click.command("add-target")
26
- @click.argument("integration-connector")
27
- @click.argument("metadata-element-guid")
28
- @click.argument("catalog-target-name")
29
- @click.pass_context
30
- def add_catalog_target(
31
- ctx,
32
- integration_connector: str,
33
- metadata_element_guid: str,
34
- catalog_target_name: str,
35
- ) -> str:
36
- """Add catalog targets to the specified integration connector"""
37
- try:
38
- if integration_connector not in INTEGRATION_GUIDS.keys():
39
- click.echo("Integration connector is not known")
40
-
41
- c = ctx.obj
42
- a_client = AutomatedCuration(
43
- c.view_server, c.view_server_url, c.userid, c.password
44
- )
45
- token = a_client.create_egeria_bearer_token()
46
-
47
- guid = a_client.add_catalog_target(
48
- INTEGRATION_GUIDS[integration_connector],
49
- metadata_element_guid,
50
- catalog_target_name,
51
- )
52
-
53
- click.echo(
54
- f"Added catalog target to {integration_connector} with a return guid of {guid}"
55
- )
56
-
57
- except (InvalidParameterException, PropertyServerException) as e:
58
- print_exception_response(e)
59
-
60
-
61
- @click.command("remove-target")
62
- @click.argument("relationship-guid")
63
- @click.pass_context
64
- def remove_catalog_target(ctx, relationship_guid: str):
65
- """Remove the catalog target specified by the relationship guidr"""
66
- try:
67
- c = ctx.obj
68
- a_client = AutomatedCuration(
69
- c.view_server, c.view_server_url, c.userid, c.password
70
- )
71
- token = a_client.create_egeria_bearer_token()
72
-
73
- a_client.remove_catalog_target(relationship_guid)
74
-
75
- click.echo(
76
- f"Removed catalog target with relationship guid of {relationship_guid}"
77
- )
78
-
79
- except (InvalidParameterException, PropertyServerException) as e:
80
- print_exception_response(e)
81
-
82
-
83
- @click.command("update-target")
84
- @click.argument("relationship-guid")
85
- @click.argument("catalog-target-name")
86
- @click.pass_context
87
- def update_catalog_target(ctx, relationship_guid: str, catalog_target_name: str):
88
- """Update the catalog target specified by the relationship guid"""
89
- try:
90
- c = ctx.obj
91
- a_client = AutomatedCuration(
92
- c.view_server, c.view_server_url, c.userid, c.password
93
- )
94
- token = a_client.create_egeria_bearer_token()
95
-
96
- guid = a_client.update_catalog_target(relationship_guid, catalog_target_name)
97
-
98
- click.echo(
99
- f"Update catalog target with relationship guid of {relationship_guid} to a catalog target name of "
100
- f"{catalog_target_name} with a return guid of {guid}"
101
- )
102
-
103
- except (InvalidParameterException, PropertyServerException) as e:
104
- print_exception_response(e)
105
-
106
-
107
- @click.command("stop")
108
- @click.pass_context
109
- def stop_server(ctx):
110
- """Stop an integration daemon"""
111
- try:
112
- c = ctx.obj
113
- p_client = Platform(
114
- c.integration_daemon, c.integration_daemon_url, c.userid, c.password
115
- )
116
-
117
- p_client.shutdown_server()
118
-
119
- click.echo(f"Stopped server {c.integration_daemon}")
120
- except (InvalidParameterException, PropertyServerException) as e:
121
- print_exception_response(e)
122
-
123
-
124
- @click.command("start")
125
- @click.pass_context
126
- def start_server(ctx):
127
- """Start or restart an integration daemon from its known configuration"""
128
- try:
129
- c = ctx.obj
130
- p_client = Platform(
131
- c.integration_daemon, c.integration_daemon_url, c.userid, c.password
132
- )
133
-
134
- p_client.activate_server_stored_config()
135
-
136
- click.echo(f"Started server {c.integration_daemon}")
137
-
138
- except (InvalidParameterException, PropertyServerException) as e:
139
- print_exception_response(e)
@@ -1,157 +0,0 @@
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
- List catalog targets
9
-
10
- """
11
- import argparse
12
- import os
13
- import time
14
-
15
- from rich import box
16
- from rich.console import Console
17
- from rich.markdown import Markdown
18
- from rich.prompt import Prompt
19
- from rich.table import Table
20
-
21
- from pyegeria import (
22
- InvalidParameterException,
23
- PropertyServerException,
24
- UserNotAuthorizedException,
25
- print_exception_response,
26
- AutomatedCuration,
27
- INTEGRATION_GUIDS
28
- )
29
-
30
- EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
31
- EGERIA_KAFKA_ENDPOINT = os.environ.get('KAFKA_ENDPOINT', 'localhost:9092')
32
- EGERIA_PLATFORM_URL = os.environ.get('EGERIA_PLATFORM_URL', 'https://localhost:9443')
33
- EGERIA_VIEW_SERVER = os.environ.get('VIEW_SERVER', 'view-server')
34
- EGERIA_VIEW_SERVER_URL = os.environ.get('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
35
- EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
36
- EGERIA_ADMIN_USER = os.environ.get('ADMIN_USER', 'garygeeke')
37
- EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
38
- EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
39
- EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
40
- EGERIA_JUPYTER = bool(os.environ.get('EGERIA_JUPYTER', 'False'))
41
- EGERIA_WIDTH = int(os.environ.get('EGERIA_WIDTH', '200'))
42
-
43
-
44
-
45
- def display_catalog_targets(connector: str, server: str, url: str, username: str, user_password: str,
46
- jupyter: bool = EGERIA_JUPYTER, width: int = EGERIA_WIDTH):
47
- console = Console(force_terminal=not jupyter, width=width, soft_wrap=True)
48
- def generate_table() -> Table:
49
- """Make a new table."""
50
- table = Table(
51
- title=f"All Catalog Targets for Integration Connector {connector} @ {time.asctime()}",
52
- style="bold white on black",
53
- row_styles=["bold white on black"],
54
- header_style="white on dark_blue",
55
- title_style="bold white on black",
56
- show_lines=True,
57
- box=box.ROUNDED,
58
- caption=f"Catalog Targets for '{server}' @ Platform - {url}",
59
- expand=True
60
- )
61
- table.add_column("Name of Target")
62
- table.add_column("Catalog Target")
63
-
64
- # table.add_column("Relationship GUID", no_wrap=True)
65
- table.add_column('Configuration Properties')
66
- table.add_column('Template Properties')
67
- table.add_column("Operational Instructions", max_width=20)
68
- # table.add_column("Delete Method")
69
-
70
- if type(cat_targets) is list:
71
- for target in cat_targets:
72
- target_name = target.get('catalogTargetName', '---')
73
- target_source = target.get('metadataSourceQualifiedName', '---')
74
- target_rel = target.get('relationshipGUID', '---')
75
- target_sync = target.get('permittedSynchronization')
76
- target_delete = target.get('deleteMethod', '---')
77
- op_instruct = f"* {target_sync}\n* {target_delete}"
78
- op_instruct_out = Markdown(op_instruct)
79
- # target_guid = target['catalogTargetElement']['guid']
80
- connector_unique = target['catalogTargetElement']['uniqueName']
81
-
82
- cat_target_out = Markdown(f"* Target Name: {target_name}\n* Target Source: {target_source}\n"
83
- f"* Relationship Guid: {target_rel}")
84
-
85
- config_props = target.get('configurationProperties', '---')
86
- if type(config_props) is dict:
87
- config_props_md = ''
88
- for prop in config_props:
89
- config_props_md += f"* {prop}: {config_props[prop]}\n"
90
- config_props_out = Markdown(config_props_md)
91
- else:
92
- config_props_out = '---'
93
-
94
- template_props = target.get('templateProperties', '---')
95
- if type(template_props) is dict:
96
- template_props_md = ''
97
- for prop in template_props:
98
- template_props_md += f"* {prop}: {template_props[prop]}\n"
99
- template_props_out = Markdown(template_props_md)
100
- else:
101
- template_props_out = '---'
102
-
103
- table.add_row(
104
- connector_unique, cat_target_out,
105
- config_props_out, template_props_out, op_instruct_out)
106
-
107
- return table
108
-
109
- try:
110
- a_client = AutomatedCuration(server, url, username)
111
- token = a_client.create_egeria_bearer_token(username, user_password)
112
- if connector not in INTEGRATION_GUIDS.keys():
113
- raise Exception
114
-
115
- connector_guid = INTEGRATION_GUIDS[connector]
116
- cat_targets = a_client.get_catalog_targets(connector_guid)
117
- console = Console(force_terminal=not jupyter, width=width, soft_wrap=True)
118
- with console.pager(styles=True):
119
- console.print(generate_table(), soft_wrap=True)
120
-
121
- except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
122
- print_exception_response(e)
123
- except Exception as e:
124
- print(f"\n\n===> Perhaps integration connector {connector} is not known?\n\n")
125
- console.print_exception()
126
- finally:
127
- a_client.close_session()
128
-
129
-
130
- def main():
131
- parser = argparse.ArgumentParser()
132
- parser.add_argument("--server", help="Name of the server to display status for")
133
- parser.add_argument("--url", help="URL Platform to connect to")
134
- parser.add_argument("--userid", help="User Id")
135
- parser.add_argument("--password", help="User Password")
136
- parser.add_argument("--jupyter", help="Enable for Jupyter terminal compatibility")
137
- parser.add_argument("--width", help="Screen width, in characters, to use")
138
-
139
- args = parser.parse_args()
140
-
141
- server = args.server if args.server is not None else EGERIA_VIEW_SERVER
142
- url = args.url if args.url is not None else EGERIA_VIEW_SERVER_URL
143
- userid = args.userid if args.userid is not None else EGERIA_USER
144
- user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
145
- jupyter = args.jupyter if args.jupyter is not None else EGERIA_JUPYTER
146
- width = args.width if args.width is not None else EGERIA_WIDTH
147
-
148
- try:
149
- connector = Prompt.ask("Enter the Integration Connector to list catalog targets for")
150
- display_catalog_targets(connector, server, url, userid, user_pass, jupyter, width=width)
151
-
152
- except KeyboardInterrupt:
153
- pass
154
-
155
-
156
- if __name__ == "__main__":
157
- main()
@@ -1,62 +0,0 @@
1
- """
2
- SPDX-License-Identifier: Apache-2.0
3
- Copyright Contributors to the ODPi Egeria project.
4
-
5
-
6
-
7
- This script refreshed an integration daemon.
8
-
9
- """
10
-
11
- import os
12
- import argparse
13
- import time
14
- import click
15
- from trogon import tui
16
- from pyegeria import ServerOps, AutomatedCuration
17
- from pyegeria._exceptions import (
18
- InvalidParameterException,
19
- PropertyServerException,
20
- UserNotAuthorizedException,
21
- print_exception_response,
22
- )
23
- EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
24
- EGERIA_KAFKA_ENDPOINT = os.environ.get('KAFKA_ENDPOINT', 'localhost:9092')
25
- EGERIA_PLATFORM_URL = os.environ.get('EGERIA_PLATFORM_URL', 'https://localhost:9443')
26
- EGERIA_VIEW_SERVER = os.environ.get('VIEW_SERVER', 'view-server')
27
- EGERIA_VIEW_SERVER_URL = os.environ.get('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
28
- EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
29
- EGERIA_INTEGRATION_DAEMON_URL = os.environ.get('EGERIA_INTEGRATION_DAEMON_URL', 'https://localhost:9443')
30
- EGERIA_ADMIN_USER = os.environ.get('ADMIN_USER', 'garygeeke')
31
- EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
32
- EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
33
- EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
34
-
35
-
36
- @click.command('load-archive')
37
- @click.option('--file', prompt= "Path on the Metadata Server of the archive file to load",
38
- default='content-packs/CocoComboArchive.omarchive',
39
- help='Full path on the Metadata Server to the archive file to load')
40
- @click.option('--server', default = EGERIA_METADATA_STORE, help='Egeria metadata store to load')
41
- @click.option('--url', default = EGERIA_PLATFORM_URL, help='URL of Egeria platform to connect to')
42
- @click.option('--userid', default = EGERIA_ADMIN_USER, help='Egeria admin user')
43
- @click.option('--password', default = EGERIA_ADMIN_PASSWORD, help='Egeria admin password')
44
- @click.option('--timeout', default = 60, help = 'Number of seconds to wait')
45
- def load_archive(file, server, url, userid, password, timeout):
46
- """Load an Open Metadata Archive"""
47
-
48
- try:
49
-
50
- s_client = ServerOps(server, url, userid, password)
51
-
52
- s_client.add_archive_file(file, server, timeout = timeout)
53
-
54
- click.echo(f"Loaded archive: {file}")
55
-
56
-
57
- except (InvalidParameterException, PropertyServerException) as e:
58
- print_exception_response(e)
59
-
60
-
61
- if __name__ == "__main__":
62
- load_archive()
@@ -1,102 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- SPDX-License-Identifier: Apache-2.0
4
- Copyright Contributors to the ODPi Egeria project.
5
-
6
- Display the status of cataloged platforms and servers.
7
- """
8
- import json
9
- import os
10
- import time
11
- import argparse
12
- from datetime import datetime
13
- from rich.prompt import Prompt
14
- from rich.table import Table
15
- from rich.live import Live
16
- from rich.console import Console
17
- from rich.markdown import Markdown
18
- from confluent_kafka import Consumer, KafkaException
19
-
20
- EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
21
- EGERIA_KAFKA_ENDPOINT = os.environ.get('KAFKA_ENDPOINT', 'localhost:9192')
22
- EGERIA_PLATFORM_URL = os.environ.get('EGERIA_PLATFORM_URL', 'https://localhost:9443')
23
- EGERIA_VIEW_SERVER = os.environ.get('VIEW_SERVER', 'view-server')
24
- EGERIA_VIEW_SERVER_URL = os.environ.get('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
25
- EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
26
- EGERIA_ADMIN_USER = os.environ.get('ADMIN_USER', 'garygeeke')
27
- EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
28
- EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
29
- EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
30
- EGERIA_JUPYTER = os.environ.get('EGERIA_JUPYTER', False)
31
- EGERIA_WIDTH = os.environ.get('EGERIA_WIDTH', 200)
32
-
33
- def main(ep: str = EGERIA_KAFKA_ENDPOINT):
34
-
35
- disable_ssl_warnings = True
36
- console = Console(width=200)
37
- now = datetime.now()
38
- current_time = now.strftime("%H:%M:%S")
39
-
40
- earliest_latest = Prompt.ask("Msgs from earliest or latest:", default="earliest")
41
-
42
- # Define the Kafka consumer configuration.
43
- config = {
44
- 'bootstrap.servers': ep, # replace with your Kafka broker(s)
45
- 'group.id': f"view_asset_events:{current_time}", # replace with your consumer group
46
- 'auto.offset.reset': earliest_latest # can be set to 'earliest' or 'latest'
47
- }
48
- print(f"Kafka config is {json.dumps(config)}")
49
- # Initialize a Kafka consumer.
50
- consumer = Consumer(config)
51
-
52
- # Subscribe to a Kafka topic.
53
- consumer.subscribe(['egeria.omag.server.active-metadata-store.omas.assetconsumer.outTopic']) # replace with your Kafka topic
54
-
55
- try:
56
- while True:
57
- msg = consumer.poll(2.0) # timeout set to 1 second
58
-
59
- if msg is None:
60
- continue
61
- elif msg.error():
62
- raise KafkaException(msg.error())
63
- else:
64
- event = json.loads(msg.value())
65
- event_time = event["eventTime"]
66
- event_type = event["eventType"]
67
- guid = event["elementHeader"]["guid"]
68
-
69
- type_name = event["elementHeader"]["type"]["typeName"]
70
- origin = event["elementHeader"]["origin"]["sourceServer"]
71
-
72
- element_properties = event["elementProperties"]
73
- element_properties_keys = element_properties.keys()
74
- props = " "
75
- for key in element_properties_keys:
76
- value = element_properties[key]
77
- props += f"* {key}: {value}\n"
78
- console.rule(style= "[bold red]")
79
- console.rule(f"\tMessage TimeStamp: {event_time}\t eventType: {event_type}\t typeName: {type_name}\t guid: {guid}")
80
- msg = (
81
-
82
- f"properties: \n[bright white on black]{props}\n\n")
83
- msg = Markdown(msg)
84
-
85
- console.print(msg)
86
-
87
- except KeyboardInterrupt:
88
- pass
89
-
90
- finally:
91
- # Close down consumer to commit final offsets.
92
- consumer.close()
93
-
94
- if __name__ == "__main__":
95
- parser = argparse.ArgumentParser()
96
-
97
- parser.add_argument("--ep", help="Endpoint to connect to")
98
- args = parser.parse_args()
99
-
100
- ep = args.ep if args.ep is not None else EGERIA_KAFKA_ENDPOINT
101
-
102
- main(ep)
@@ -1,103 +0,0 @@
1
- #!/usr/bin/python3
2
- """
3
- SPDX-License-Identifier: Apache-2.0
4
- Copyright Contributors to the ODPi Egeria project.
5
-
6
- Unit tests for the Utils helper functions using the Pytest framework.
7
-
8
-
9
- A simple server status display for the Coco Pharmaceuticals Configuration
10
- """
11
-
12
- import argparse
13
- import time
14
-
15
- from rich import box
16
- from rich import print
17
- from rich.layout import Layout
18
- from rich.live import Live
19
- from rich.panel import Panel
20
- from rich.table import Table
21
-
22
- from pyegeria._exceptions import (
23
- InvalidParameterException,
24
- PropertyServerException,
25
- UserNotAuthorizedException,
26
- print_exception_response,
27
- )
28
- from pyegeria.server_operations import ServerOps
29
-
30
- disable_ssl_warnings = True
31
-
32
-
33
- def display_status(server: str, url: str, username: str):
34
- layout = Layout()
35
-
36
- p_client1 = ServerOps("Core Catalog", "https://localhost:9443", username)
37
- p_client2 = ServerOps('Datalake Catalog', "https://localhost:9444", username)
38
- p_client3 = ServerOps('DevCatalog', "https://localhost:9445", username)
39
-
40
- def generate_table(p_client) -> Table:
41
- """Make a new table."""
42
- table = Table(
43
- title=f"Server Status for {p_client.server_name}- {time.asctime()}",
44
- # style = "black on grey66",
45
- header_style="white on dark_blue",
46
- caption=f"Server Status for Platform - '{p_client.platform_url}'",
47
- # show_lines=True,
48
- )
49
-
50
- table.add_column("Known Server")
51
- table.add_column("Status")
52
- known_server_list = p_client.get_known_servers()
53
- active_server_list = p_client.get_active_server_list()
54
- if type(known_server_list) is str:
55
- return table
56
-
57
- for server in known_server_list:
58
- if server in active_server_list:
59
- status = "Active"
60
- else:
61
- status = "Inactive"
62
-
63
- table.add_row(server,
64
- "[red]Inactive" if status == "Inactive" else "[green]Active",
65
- )
66
- return table
67
-
68
- try:
69
- layout.split_row(
70
- Layout(Panel(generate_table(p_client1), box.ROUNDED)),
71
- Layout(Panel(generate_table(p_client2), box.ROUNDED)),
72
- Layout(Panel(generate_table(p_client3), box.ROUNDED))
73
- )
74
- with Live(layout, refresh_per_second=4, screen=True) as live:
75
- while True:
76
- time.sleep(2)
77
- live.update(layout)
78
-
79
- except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
80
- print_exception_response(e)
81
- except KeyboardInterrupt:
82
- pass
83
-
84
- finally:
85
- p_client1.close_session()
86
- p_client2.close_session()
87
- p_client3.close_session()
88
-
89
- def main():
90
- parser = argparse.ArgumentParser()
91
- parser.add_argument("--server", help="Name of the server to display status for")
92
- parser.add_argument("--url", help="URL Platform to connect to")
93
- parser.add_argument("--userid", help="User Id")
94
- args = parser.parse_args()
95
-
96
- server = args.server if args.server is not None else "active-metadata-store"
97
- url = args.url if args.url is not None else "https://localhost:9443"
98
- userid = args.userid if args.userid is not None else 'garygeeke'
99
-
100
- display_status(server, url, userid)
101
-
102
- if __name__ == "__main__":
103
- main()