pyegeria 0.8.4.9__py3-none-any.whl → 0.8.4.11__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.
- examples/widgets/ops/README.md +24 -0
- examples/widgets/ops/__init__.py +19 -0
- examples/widgets/ops/engine_actions.py +83 -0
- examples/widgets/ops/integration_daemon_actions.py +139 -0
- examples/widgets/ops/list_catalog_targets.py +157 -0
- examples/widgets/ops/load_archive.py +62 -0
- examples/widgets/ops/monitor_asset_events.py +102 -0
- examples/widgets/ops/monitor_coco_status.py +103 -0
- examples/widgets/ops/monitor_engine_activity.py +236 -0
- examples/widgets/ops/monitor_engine_activity_c.py +253 -0
- examples/widgets/ops/monitor_gov_eng_status.py +188 -0
- examples/widgets/ops/monitor_integ_daemon_status.py +256 -0
- examples/widgets/ops/monitor_platform_status.py +176 -0
- examples/widgets/ops/monitor_server_list.py +140 -0
- examples/widgets/ops/monitor_server_status.py +109 -0
- examples/widgets/ops/refresh_integration_daemon.py +73 -0
- examples/widgets/ops/restart_integration_daemon.py +73 -0
- pyegeria/classification_manager_omvs.py +396 -1
- pyegeria/runtime_manager_omvs.py +120 -0
- {pyegeria-0.8.4.9.dist-info → pyegeria-0.8.4.11.dist-info}/METADATA +1 -1
- {pyegeria-0.8.4.9.dist-info → pyegeria-0.8.4.11.dist-info}/RECORD +24 -7
- {pyegeria-0.8.4.9.dist-info → pyegeria-0.8.4.11.dist-info}/LICENSE +0 -0
- {pyegeria-0.8.4.9.dist-info → pyegeria-0.8.4.11.dist-info}/WHEEL +0 -0
- {pyegeria-0.8.4.9.dist-info → pyegeria-0.8.4.11.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,188 @@
|
|
1
|
+
#!/usr/bin/env 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 status display for Governance Actions
|
10
|
+
"""
|
11
|
+
import argparse
|
12
|
+
import json
|
13
|
+
import os
|
14
|
+
import time
|
15
|
+
|
16
|
+
from rich import box
|
17
|
+
from rich.console import Console
|
18
|
+
from rich.live import Live
|
19
|
+
from rich.markdown import Markdown
|
20
|
+
from rich.table import Table
|
21
|
+
|
22
|
+
from pyegeria import (
|
23
|
+
InvalidParameterException,
|
24
|
+
PropertyServerException,
|
25
|
+
UserNotAuthorizedException,
|
26
|
+
print_exception_response,
|
27
|
+
)
|
28
|
+
from pyegeria.server_operations import ServerOps
|
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(
|
35
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
36
|
+
)
|
37
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get(
|
38
|
+
"EGERIA_INTEGRATION_DAEMON", "integration-daemon"
|
39
|
+
)
|
40
|
+
EGERIA_ENGINE_HOST = os.environ.get("EGERIA_ENGINE_HOST", "engine-host")
|
41
|
+
EGERIA_ENGINE_HOST_URL = os.environ.get(
|
42
|
+
"EGERIA_ENGINE_HOST_URL", "https://localhost:9443"
|
43
|
+
)
|
44
|
+
EGERIA_ADMIN_USER = os.environ.get("EGERIA_ADMIN_USER", "garygeeke")
|
45
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("EGERIA_ADMIN_PASSWORD", "secret")
|
46
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
47
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
48
|
+
EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
|
49
|
+
EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
|
50
|
+
|
51
|
+
|
52
|
+
disable_ssl_warnings = True
|
53
|
+
|
54
|
+
|
55
|
+
def display_gov_eng_status(
|
56
|
+
server: str,
|
57
|
+
url: str,
|
58
|
+
username: str,
|
59
|
+
user_pass: str,
|
60
|
+
paging: bool,
|
61
|
+
jupyter: bool = EGERIA_JUPYTER,
|
62
|
+
width: int = EGERIA_WIDTH,
|
63
|
+
):
|
64
|
+
console = Console(width=EGERIA_WIDTH)
|
65
|
+
server_name = server
|
66
|
+
s_client = ServerOps(server_name, url, username, user_pass)
|
67
|
+
|
68
|
+
def generate_table() -> Table:
|
69
|
+
"""Make a new table."""
|
70
|
+
table = Table(
|
71
|
+
title=f"Governance Engine Status @ {time.asctime()}",
|
72
|
+
style="bold white on black",
|
73
|
+
row_styles=["bold white on black"],
|
74
|
+
header_style="white on dark_blue",
|
75
|
+
title_style="bold white on black",
|
76
|
+
caption_style="white on black",
|
77
|
+
show_lines=True,
|
78
|
+
box=box.ROUNDED,
|
79
|
+
caption=f"Server: '{server_name}' running on {url}",
|
80
|
+
expand=True,
|
81
|
+
)
|
82
|
+
# table.footer: f"Server {server_name} on Platform {good_platform1_url}"
|
83
|
+
table.add_column("Gov Engine")
|
84
|
+
table.add_column("Gov Engine Type")
|
85
|
+
table.add_column("Gov Engine Desc")
|
86
|
+
table.add_column("Engine Status")
|
87
|
+
table.add_column("Request Types")
|
88
|
+
|
89
|
+
gov_eng_status = s_client.get_governance_engine_summaries()
|
90
|
+
sorted_gov_eng_status = sorted(
|
91
|
+
gov_eng_status, key=lambda k: k.get("governanceEngineName", " ")
|
92
|
+
)
|
93
|
+
for engine in sorted_gov_eng_status:
|
94
|
+
gov_eng = engine["governanceEngineName"]
|
95
|
+
eng_type = engine.get("governanceEngineTypeName", " ")
|
96
|
+
|
97
|
+
eng_desc = engine.get("governanceEngineDescription", " ")
|
98
|
+
eng_req_types = engine.get("governanceRequestTypes", " ")
|
99
|
+
eng_req_type_md = " "
|
100
|
+
if type(eng_req_types) is list:
|
101
|
+
for i in eng_req_types:
|
102
|
+
eng_req_type_md += f"* {i}\n"
|
103
|
+
eng_req_type_out = Markdown(eng_req_type_md)
|
104
|
+
else:
|
105
|
+
eng_req_type_out = " "
|
106
|
+
status = engine["governanceEngineStatus"]
|
107
|
+
if status in ("RUNNING"):
|
108
|
+
eng_status = f"[green]{status}"
|
109
|
+
elif status in ("FAILED"):
|
110
|
+
eng_status = f"[red]{status}"
|
111
|
+
else:
|
112
|
+
eng_status = f"[yellow]{status}"
|
113
|
+
|
114
|
+
table.add_row(gov_eng, eng_type, eng_desc, eng_status, eng_req_type_out)
|
115
|
+
|
116
|
+
table.caption = f"Server {server_name} running on {url}"
|
117
|
+
return table
|
118
|
+
|
119
|
+
try:
|
120
|
+
if paging is True:
|
121
|
+
console = Console(width=width, force_terminal=not jupyter)
|
122
|
+
with console.pager():
|
123
|
+
console.print(generate_table())
|
124
|
+
else:
|
125
|
+
with Live(
|
126
|
+
generate_table(),
|
127
|
+
refresh_per_second=1,
|
128
|
+
screen=True,
|
129
|
+
vertical_overflow="visible",
|
130
|
+
) as live:
|
131
|
+
while True:
|
132
|
+
time.sleep(2)
|
133
|
+
live.update(generate_table())
|
134
|
+
|
135
|
+
except (
|
136
|
+
InvalidParameterException,
|
137
|
+
PropertyServerException,
|
138
|
+
UserNotAuthorizedException,
|
139
|
+
) as e:
|
140
|
+
console.print_exception(show_locals=True)
|
141
|
+
|
142
|
+
except KeyboardInterrupt:
|
143
|
+
pass
|
144
|
+
|
145
|
+
finally:
|
146
|
+
s_client.close_session()
|
147
|
+
|
148
|
+
|
149
|
+
def main_live():
|
150
|
+
parser = argparse.ArgumentParser()
|
151
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
152
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
153
|
+
parser.add_argument("--userid", help="User Id")
|
154
|
+
parser.add_argument("--password", help="User Password")
|
155
|
+
parser.add_argument("--paging", help="Paging")
|
156
|
+
args = parser.parse_args()
|
157
|
+
|
158
|
+
server = args.server if args.server is not None else EGERIA_ENGINE_HOST
|
159
|
+
url = args.url if args.url is not None else EGERIA_ENGINE_HOST_URL
|
160
|
+
userid = args.userid if args.userid is not None else EGERIA_USER
|
161
|
+
user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
162
|
+
paging = args.paging if args.paging is not None else False
|
163
|
+
display_gov_eng_status(server, url, userid, user_pass, paging)
|
164
|
+
|
165
|
+
|
166
|
+
def main_paging():
|
167
|
+
parser = argparse.ArgumentParser()
|
168
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
169
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
170
|
+
parser.add_argument("--userid", help="User Id")
|
171
|
+
parser.add_argument("--password", help="User Password")
|
172
|
+
args = parser.parse_args()
|
173
|
+
|
174
|
+
server = args.server if args.server is not None else EGERIA_ENGINE_HOST
|
175
|
+
url = args.url if args.url is not None else EGERIA_ENGINE_HOST_URL
|
176
|
+
userid = args.userid if args.userid is not None else EGERIA_USER
|
177
|
+
user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
178
|
+
|
179
|
+
display_gov_eng_status(
|
180
|
+
server=server, url=url, username=userid, user_pass=user_pass, paging=True
|
181
|
+
)
|
182
|
+
|
183
|
+
|
184
|
+
if __name__ == "__main__":
|
185
|
+
main_live()
|
186
|
+
|
187
|
+
if __name__ == "__main_paging__":
|
188
|
+
main_paging()
|
@@ -0,0 +1,256 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
|
7
|
+
A simple status display for the Integration Daemon.
|
8
|
+
|
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.live import Live
|
18
|
+
from rich.table import Table
|
19
|
+
|
20
|
+
from pyegeria import ServerOps, AutomatedCuration
|
21
|
+
from pyegeria._exceptions import (
|
22
|
+
InvalidParameterException,
|
23
|
+
PropertyServerException,
|
24
|
+
UserNotAuthorizedException,
|
25
|
+
print_exception_response,
|
26
|
+
)
|
27
|
+
|
28
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
29
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
30
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
31
|
+
EGERIA_VIEW_SERVER = os.environ.get("VIEW_SERVER", "view-server")
|
32
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
33
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
34
|
+
)
|
35
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("INTEGRATION_DAEMON", "integration-daemon")
|
36
|
+
EGERIA_INTEGRATION_DAEMON_URL = os.environ.get(
|
37
|
+
"EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443"
|
38
|
+
)
|
39
|
+
EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
|
40
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
|
41
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
42
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
43
|
+
EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
|
44
|
+
EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
|
45
|
+
|
46
|
+
disable_ssl_warnings = True
|
47
|
+
|
48
|
+
|
49
|
+
def display_integration_daemon_status(
|
50
|
+
integ_server: str,
|
51
|
+
integ_url: str,
|
52
|
+
view_server: str,
|
53
|
+
view_url: str,
|
54
|
+
user: str,
|
55
|
+
user_pass: str,
|
56
|
+
paging: bool,
|
57
|
+
jupyter: bool = EGERIA_JUPYTER,
|
58
|
+
width: int = EGERIA_WIDTH,
|
59
|
+
sort: bool = True,
|
60
|
+
):
|
61
|
+
s_client = ServerOps(integ_server, integ_url, user)
|
62
|
+
a_client = AutomatedCuration(view_server, view_url, user, user_pass)
|
63
|
+
token = a_client.create_egeria_bearer_token()
|
64
|
+
|
65
|
+
def generate_table() -> Table:
|
66
|
+
"""Make a new table."""
|
67
|
+
table = Table(
|
68
|
+
title=f"Integration Daemon Status @ {time.asctime()}",
|
69
|
+
style="bold white on black",
|
70
|
+
row_styles=["bold white on black"],
|
71
|
+
header_style="white on dark_blue",
|
72
|
+
title_style="bold white on black",
|
73
|
+
caption_style="white on black",
|
74
|
+
show_lines=True,
|
75
|
+
box=box.ROUNDED,
|
76
|
+
caption=f"Integration Daemon Status for Server '{integ_server}' @ Platform - {integ_url}",
|
77
|
+
expand=True,
|
78
|
+
)
|
79
|
+
table.add_column("Connector Name", min_width=15)
|
80
|
+
table.add_column("Status", max_width=6)
|
81
|
+
|
82
|
+
table.add_column("Last Refresh Time", min_width=12)
|
83
|
+
table.add_column("Min Refresh (mins)", max_width=6)
|
84
|
+
table.add_column("Target Element", min_width=20)
|
85
|
+
table.add_column("Exception Message", min_width=10)
|
86
|
+
|
87
|
+
daemon_status = s_client.get_integration_daemon_status()
|
88
|
+
|
89
|
+
reports = daemon_status["integrationConnectorReports"]
|
90
|
+
if sort is True:
|
91
|
+
connector_reports = sorted(
|
92
|
+
reports, key=lambda x: x.get("connectorName", "---")
|
93
|
+
)
|
94
|
+
else:
|
95
|
+
connector_reports = reports
|
96
|
+
|
97
|
+
for connector in connector_reports:
|
98
|
+
connector_name = connector.get("connectorName", "---")
|
99
|
+
connector_status = connector.get("connectorStatus", "---")
|
100
|
+
connector_guid = connector.get("connectorGUID", "---")
|
101
|
+
last_refresh_time = connector.get("lastRefreshTime", "---")[:-10]
|
102
|
+
refresh_interval = str(connector.get("minMinutesBetweenRefresh", "---"))
|
103
|
+
exception_msg = " "
|
104
|
+
if connector_guid != "---":
|
105
|
+
targets = a_client.get_catalog_targets(connector_guid)
|
106
|
+
tgt_tab = Table()
|
107
|
+
tgt_tab.add_column("Target")
|
108
|
+
tgt_tab.add_column("UniqueName")
|
109
|
+
tgt_tab.add_column("Relationship GUID", no_wrap=True)
|
110
|
+
|
111
|
+
if type(targets) == list:
|
112
|
+
targets_md = True
|
113
|
+
for target in targets:
|
114
|
+
t_name = target["catalogTargetName"]
|
115
|
+
# t_sync = target["permittedSynchronization"]
|
116
|
+
t_unique_name = target["catalogTargetElement"]["uniqueName"]
|
117
|
+
t_rel_guid = target["relationshipGUID"]
|
118
|
+
# targets_m += f"* Target Name: __{t_name}__\n* Sync: {t_sync}\n* Unique Name: {t_unique_name}\n\n"
|
119
|
+
tgt_tab.add_row(t_name, t_unique_name, t_rel_guid)
|
120
|
+
# targets_md = Markdown(targets_m)
|
121
|
+
else:
|
122
|
+
targets_md = False
|
123
|
+
else:
|
124
|
+
targets_md = False
|
125
|
+
if targets_md is False:
|
126
|
+
targets_out = ""
|
127
|
+
else:
|
128
|
+
targets_out = tgt_tab
|
129
|
+
|
130
|
+
if connector_status in ("RUNNING", "REFRESHING", "WAITING"):
|
131
|
+
connector_status = f"[green]{connector_status}"
|
132
|
+
elif connector_status in ("INITIALIZE FAILED", "CONFIG_FAILED", "FAILED"):
|
133
|
+
connector_status = f"[red]{connector_status}"
|
134
|
+
else:
|
135
|
+
connector_status = f"[yellow]{connector_status}"
|
136
|
+
|
137
|
+
table.add_row(
|
138
|
+
connector_name,
|
139
|
+
connector_status,
|
140
|
+
last_refresh_time,
|
141
|
+
refresh_interval,
|
142
|
+
targets_out,
|
143
|
+
exception_msg,
|
144
|
+
)
|
145
|
+
return table
|
146
|
+
|
147
|
+
try:
|
148
|
+
if paging is True:
|
149
|
+
console = Console(width=width, force_terminal=not jupyter)
|
150
|
+
with console.pager():
|
151
|
+
console.print(generate_table())
|
152
|
+
else:
|
153
|
+
with Live(
|
154
|
+
generate_table(),
|
155
|
+
refresh_per_second=1,
|
156
|
+
screen=True,
|
157
|
+
vertical_overflow="visible",
|
158
|
+
) as live:
|
159
|
+
while True:
|
160
|
+
time.sleep(2)
|
161
|
+
live.update(generate_table())
|
162
|
+
|
163
|
+
except (
|
164
|
+
InvalidParameterException,
|
165
|
+
PropertyServerException,
|
166
|
+
UserNotAuthorizedException,
|
167
|
+
) as e:
|
168
|
+
print_exception_response(e)
|
169
|
+
|
170
|
+
except KeyboardInterrupt:
|
171
|
+
pass
|
172
|
+
|
173
|
+
finally:
|
174
|
+
s_client.close_session()
|
175
|
+
a_client.close_session()
|
176
|
+
|
177
|
+
|
178
|
+
def main_live():
|
179
|
+
parser = argparse.ArgumentParser()
|
180
|
+
parser.add_argument(
|
181
|
+
"--integ_server", help="Name of the integration server to display status for"
|
182
|
+
)
|
183
|
+
parser.add_argument("--integ_url", help="URL Platform to connect to")
|
184
|
+
parser.add_argument("--view_server", help="Name of the view server to use")
|
185
|
+
parser.add_argument("--view_url", help="view server URL Platform to connect to")
|
186
|
+
parser.add_argument("--userid", help="User Id")
|
187
|
+
parser.add_argument("--password", help="User Password")
|
188
|
+
args = parser.parse_args()
|
189
|
+
|
190
|
+
integ_server = (
|
191
|
+
args.integ_server
|
192
|
+
if args.integ_server is not None
|
193
|
+
else EGERIA_INTEGRATION_DAEMON
|
194
|
+
)
|
195
|
+
integ_url = (
|
196
|
+
args.integ_url if args.integ_url is not None else EGERIA_INTEGRATION_DAEMON_URL
|
197
|
+
)
|
198
|
+
view_server = (
|
199
|
+
args.view_server if args.view_server is not None else EGERIA_VIEW_SERVER
|
200
|
+
)
|
201
|
+
view_url = args.view_url if args.view_url is not None else EGERIA_VIEW_SERVER_URL
|
202
|
+
userid = args.userid if args.userid is not None else EGERIA_USER
|
203
|
+
user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
204
|
+
display_integration_daemon_status(
|
205
|
+
integ_server=integ_server,
|
206
|
+
integ_url=integ_url,
|
207
|
+
view_server=view_server,
|
208
|
+
view_url=view_url,
|
209
|
+
user=userid,
|
210
|
+
user_pass=user_pass,
|
211
|
+
paging=False,
|
212
|
+
)
|
213
|
+
|
214
|
+
|
215
|
+
def main_paging():
|
216
|
+
parser = argparse.ArgumentParser()
|
217
|
+
parser.add_argument(
|
218
|
+
"--integ_server", help="Name of the integration server to display status for"
|
219
|
+
)
|
220
|
+
parser.add_argument("--integ_url", help="URL Platform to connect to")
|
221
|
+
parser.add_argument("--view_server", help="Name of the view server to use")
|
222
|
+
parser.add_argument("--view_url", help="view server URL Platform to connect to")
|
223
|
+
parser.add_argument("--userid", help="User Id")
|
224
|
+
parser.add_argument("--password", help="User Password")
|
225
|
+
args = parser.parse_args()
|
226
|
+
|
227
|
+
integ_server = (
|
228
|
+
args.integ_server
|
229
|
+
if args.integ_server is not None
|
230
|
+
else EGERIA_INTEGRATION_DAEMON
|
231
|
+
)
|
232
|
+
integ_url = (
|
233
|
+
args.integ_url if args.integ_url is not None else EGERIA_INTEGRATION_DAEMON_URL
|
234
|
+
)
|
235
|
+
view_server = (
|
236
|
+
args.view_server if args.view_server is not None else EGERIA_VIEW_SERVER
|
237
|
+
)
|
238
|
+
view_url = args.view_url if args.view_url is not None else EGERIA_VIEW_SERVER_URL
|
239
|
+
userid = args.userid if args.userid is not None else EGERIA_USER
|
240
|
+
user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
241
|
+
display_integration_daemon_status(
|
242
|
+
integ_server=integ_server,
|
243
|
+
integ_url=integ_url,
|
244
|
+
view_server=view_server,
|
245
|
+
view_url=view_url,
|
246
|
+
user=userid,
|
247
|
+
user_pass=user_pass,
|
248
|
+
paging=True,
|
249
|
+
)
|
250
|
+
|
251
|
+
|
252
|
+
if __name__ == "__main__":
|
253
|
+
main_live()
|
254
|
+
|
255
|
+
if __name__ == "__main_paging__":
|
256
|
+
main_paging()
|
@@ -0,0 +1,176 @@
|
|
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
|
+
|
9
|
+
import argparse
|
10
|
+
import os, sys
|
11
|
+
import time
|
12
|
+
|
13
|
+
from rich.console import Console
|
14
|
+
from rich.live import Live
|
15
|
+
from rich.table import Table
|
16
|
+
|
17
|
+
from pyegeria import RuntimeManager
|
18
|
+
from pyegeria._exceptions import (
|
19
|
+
InvalidParameterException,
|
20
|
+
PropertyServerException,
|
21
|
+
UserNotAuthorizedException,
|
22
|
+
print_exception_response,
|
23
|
+
)
|
24
|
+
|
25
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
26
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
27
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
28
|
+
EGERIA_VIEW_SERVER = os.environ.get("VIEW_SERVER", "view-server")
|
29
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
30
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
31
|
+
)
|
32
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("INTEGRATION_DAEMON", "integration-daemon")
|
33
|
+
EGERIA_INTEGRATION_DAEMON_URL = os.environ.get(
|
34
|
+
"EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443"
|
35
|
+
)
|
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
|
+
disable_ssl_warnings = True
|
44
|
+
console = Console(width=200)
|
45
|
+
|
46
|
+
|
47
|
+
def display_status(
|
48
|
+
server: str,
|
49
|
+
url: str,
|
50
|
+
username: str,
|
51
|
+
user_pass: str,
|
52
|
+
jupyter: bool = EGERIA_JUPYTER,
|
53
|
+
width: int = EGERIA_WIDTH,
|
54
|
+
):
|
55
|
+
r_client = RuntimeManager(server, url, username)
|
56
|
+
token = r_client.create_egeria_bearer_token(username, user_pass)
|
57
|
+
|
58
|
+
def generate_table() -> Table:
|
59
|
+
"""Make a new table."""
|
60
|
+
table = Table(
|
61
|
+
title=f"Server Status for Platform - {time.asctime()}",
|
62
|
+
# style="bold white on black",
|
63
|
+
row_styles=["bold white on black"],
|
64
|
+
header_style="white on dark_blue",
|
65
|
+
title_style="bold white on black",
|
66
|
+
caption_style="white on black",
|
67
|
+
caption=f"Status of Platforms - '{url}'",
|
68
|
+
show_lines=True,
|
69
|
+
# expand=True
|
70
|
+
)
|
71
|
+
table.add_column("Platform Name")
|
72
|
+
# table.add_column("Platform GUID")
|
73
|
+
table.add_column("Platform URL")
|
74
|
+
table.add_column("Platform Origin")
|
75
|
+
table.add_column("Description")
|
76
|
+
table.add_column("Platform Started")
|
77
|
+
table.add_column("Servers")
|
78
|
+
|
79
|
+
server_types = {
|
80
|
+
"Metadata Access Store": "Store",
|
81
|
+
"View Server": "View",
|
82
|
+
"Engine Host Server": "EngineHost",
|
83
|
+
"Integration Daemon": "Integration",
|
84
|
+
}
|
85
|
+
try:
|
86
|
+
platform_list = r_client.get_platforms_by_type()
|
87
|
+
if type(platform_list) is str:
|
88
|
+
print("No OMAG Server Platforms found?")
|
89
|
+
sys.exit(1)
|
90
|
+
|
91
|
+
for platform in platform_list:
|
92
|
+
platform_name = platform["properties"].get("displayName", "---")
|
93
|
+
platform_guid = platform["elementHeader"]["guid"]
|
94
|
+
platform_desc = platform["properties"].get("resourceDescription", "---")
|
95
|
+
server_list = ""
|
96
|
+
|
97
|
+
platform_report = r_client.get_platform_report(platform_guid)
|
98
|
+
platform_url = platform_report.get("platformURLRoot", " ")
|
99
|
+
platform_origin = platform_report.get("platformOrigin", " ")
|
100
|
+
platform_started = platform_report.get("platformStartTime", " ")
|
101
|
+
|
102
|
+
servers = platform_report.get("omagservers", None)
|
103
|
+
|
104
|
+
if servers is not None:
|
105
|
+
for server in servers:
|
106
|
+
server_name = server.get("serverName", " ")
|
107
|
+
server_type = server.get("serverType", " ")
|
108
|
+
server_status = server.get("serverActiveStatus", "UNKNOWN")
|
109
|
+
if server_status in ("RUNNING", "STARTING"):
|
110
|
+
status_flag = "[bright green]"
|
111
|
+
elif server_status in ("INACTIVE", "STOPPING"):
|
112
|
+
status_flag = "[bright red]"
|
113
|
+
else:
|
114
|
+
server_status = "UNKNOWN"
|
115
|
+
status_flag = "[bright yellow]"
|
116
|
+
|
117
|
+
server_list = (
|
118
|
+
f"{status_flag}{server_types[server_type]}: {server_name}\n"
|
119
|
+
)
|
120
|
+
# server_list = server_list + serv
|
121
|
+
|
122
|
+
table.add_row(
|
123
|
+
platform_name,
|
124
|
+
platform_url,
|
125
|
+
platform_origin,
|
126
|
+
platform_desc,
|
127
|
+
platform_started,
|
128
|
+
server_list,
|
129
|
+
style="bold white on black",
|
130
|
+
)
|
131
|
+
|
132
|
+
except Exception as e:
|
133
|
+
# console.print_exception(e)
|
134
|
+
platform_url = " "
|
135
|
+
platform_origin = " "
|
136
|
+
platform_started = " "
|
137
|
+
|
138
|
+
return table
|
139
|
+
|
140
|
+
try:
|
141
|
+
with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
142
|
+
while True:
|
143
|
+
time.sleep(2)
|
144
|
+
live.update(generate_table())
|
145
|
+
|
146
|
+
except (
|
147
|
+
InvalidParameterException,
|
148
|
+
PropertyServerException,
|
149
|
+
UserNotAuthorizedException,
|
150
|
+
) as e:
|
151
|
+
print_exception_response(e)
|
152
|
+
|
153
|
+
except KeyboardInterrupt:
|
154
|
+
pass
|
155
|
+
finally:
|
156
|
+
r_client.close_session()
|
157
|
+
|
158
|
+
|
159
|
+
def main():
|
160
|
+
parser = argparse.ArgumentParser()
|
161
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
162
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
163
|
+
parser.add_argument("--userid", help="User Id")
|
164
|
+
parser.add_argument("--password", help="User Password")
|
165
|
+
args = parser.parse_args()
|
166
|
+
|
167
|
+
server = args.server if args.server is not None else EGERIA_VIEW_SERVER
|
168
|
+
url = args.url if args.url is not None else EGERIA_PLATFORM_URL
|
169
|
+
userid = args.userid if args.userid is not None else EGERIA_USER
|
170
|
+
user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
171
|
+
|
172
|
+
display_status(server, url, userid, user_pass)
|
173
|
+
|
174
|
+
|
175
|
+
if __name__ == "__main__":
|
176
|
+
main()
|