pyegeria 0.8.4.48__py3-none-any.whl → 0.8.4.50__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.
commands/cli/egeria.py CHANGED
@@ -57,6 +57,8 @@ from commands.ops.monitor_server_status import (
57
57
  )
58
58
  from commands.ops.refresh_integration_daemon import refresh_connector
59
59
  from commands.ops.restart_integration_daemon import restart_connector
60
+ from commands.ops.monitor_server_startup import display_startup_status
61
+
60
62
  from commands.tech.get_element_info import display_elements
61
63
  from commands.tech.get_guid_info import display_guid
62
64
  from commands.tech.get_tech_details import tech_details_viewer
@@ -986,6 +988,21 @@ def show_server_status(ctx, full):
986
988
  )
987
989
 
988
990
 
991
+ @show_server.command("startup")
992
+ @click.pass_context
993
+ def show_startup_status(ctx):
994
+ """Display a live status view of Egeria servers for the specified Egeria platform"""
995
+ c = ctx.obj
996
+ display_startup_status(
997
+ c.server,
998
+ c.url,
999
+ c.userid,
1000
+ c.password,
1001
+ c.jupyter,
1002
+ c.width,
1003
+ )
1004
+
1005
+
989
1006
  @show.group("engines")
990
1007
  @click.pass_context
991
1008
  def engine_host(ctx):
@@ -39,6 +39,7 @@ from commands.ops.monitor_server_status import (
39
39
  )
40
40
  from commands.ops.refresh_integration_daemon import refresh_connector
41
41
  from commands.ops.restart_integration_daemon import restart_connector
42
+ from commands.ops.monitor_server_startup import display_startup_status
42
43
 
43
44
 
44
45
  # class Config(object):
@@ -247,6 +248,21 @@ def show_server_status(ctx, full):
247
248
  )
248
249
 
249
250
 
251
+ @show_server.command("startup")
252
+ @click.pass_context
253
+ def show_startup_status(ctx):
254
+ """Display a live status view of Egeria servers for the specified Egeria platform"""
255
+ c = ctx.obj
256
+ display_startup_status(
257
+ c.server,
258
+ c.url,
259
+ c.userid,
260
+ c.password,
261
+ c.jupyter,
262
+ c.width,
263
+ )
264
+
265
+
250
266
  @show.group("engines")
251
267
  @click.pass_context
252
268
  def engine_host(ctx):
@@ -0,0 +1,117 @@
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 server status display using the OMAS services.
10
+ """
11
+ import os
12
+ import time
13
+ import argparse
14
+
15
+ from pyegeria import (
16
+ InvalidParameterException,
17
+ PropertyServerException,
18
+ UserNotAuthorizedException,
19
+ print_exception_response,
20
+ ServerOps,
21
+ )
22
+ from rich.table import Table
23
+ from rich.live import Live
24
+
25
+
26
+ EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
27
+ EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
28
+ EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
29
+ EGERIA_VIEW_SERVER = os.environ.get("VIEW_SERVER", "view-server")
30
+ EGERIA_VIEW_SERVER_URL = os.environ.get(
31
+ "EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
32
+ )
33
+ EGERIA_INTEGRATION_DAEMON = os.environ.get("INTEGRATION_DAEMON", "integration-daemon")
34
+ EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
35
+ EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
36
+ EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
37
+ EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
38
+ EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
39
+ EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "220"))
40
+
41
+
42
+ def display_startup_status(
43
+ server: str,
44
+ url: str,
45
+ username: str,
46
+ password: str = EGERIA_USER_PASSWORD,
47
+ jupyter: bool = EGERIA_JUPYTER,
48
+ width: int = EGERIA_WIDTH,
49
+ ):
50
+ p_client = ServerOps(server, url, username)
51
+
52
+ def generate_table() -> Table:
53
+ """Make a new table."""
54
+ table = Table(
55
+ title=f"Server Status for Platform - {time.asctime()}",
56
+ # style = "black on grey66",
57
+ header_style="white on dark_blue",
58
+ caption=f"Server Status for Platform - '{url}'",
59
+ # show_lines=True,
60
+ )
61
+
62
+ table.add_column("Known Server")
63
+ table.add_column("Status")
64
+
65
+ known_server_list = p_client.get_known_servers()
66
+ active_server_list = p_client.get_active_server_list()
67
+ if len(known_server_list) == 0:
68
+ return table
69
+
70
+ for server in known_server_list:
71
+ if server in active_server_list:
72
+ status = "Active"
73
+ else:
74
+ status = "Inactive"
75
+
76
+ table.add_row(
77
+ server,
78
+ "[red]Inactive" if status == "Inactive" else "[green]Active",
79
+ )
80
+ # p_client.close_session()
81
+ return table
82
+
83
+ try:
84
+ with Live(generate_table(), refresh_per_second=4, screen=True) as live:
85
+ while True:
86
+ time.sleep(2)
87
+ live.update(generate_table())
88
+ # services = p_client.get_server_status(server)['serverStatus']['services']
89
+ # for service in services:
90
+ # service_name = service['serviceName']
91
+ # service_status = service['serviceStatus']
92
+
93
+ except (
94
+ InvalidParameterException,
95
+ PropertyServerException,
96
+ UserNotAuthorizedException,
97
+ ) as e:
98
+ print_exception_response(e)
99
+ assert e.related_http_code != "200", "Invalid parameters"
100
+
101
+
102
+ def main():
103
+ parser = argparse.ArgumentParser()
104
+ parser.add_argument("--server", help="Name of the server to display status for")
105
+ parser.add_argument("--url", help="URL Platform to connect to")
106
+ parser.add_argument("--userid", help="User Id")
107
+ args = parser.parse_args()
108
+
109
+ server = args.server if args.server is not None else "active-metadata-store"
110
+ url = args.url if args.url is not None else "https://localhost:9443"
111
+ userid = args.userid if args.userid is not None else "garygeeke"
112
+
113
+ display_startup_status(server, url, userid)
114
+
115
+
116
+ if __name__ == "__main__":
117
+ main()
@@ -366,10 +366,10 @@ class AutomatedCuration(Client):
366
366
  Returns
367
367
  -------
368
368
  str
369
- The GUID of the Postgres server element.
369
+ The GUID of the File Folder element.
370
370
  """
371
371
  body = {
372
- "templateGUID": TEMPLATE_GUIDS["FileFolder"],
372
+ "templateGUID": TEMPLATE_GUIDS["File System Directory"],
373
373
  "isOwnAnchor": "true",
374
374
  "placeholderPropertyValues": {
375
375
  "directoryPathName": path_name,
@@ -416,7 +416,7 @@ class AutomatedCuration(Client):
416
416
  Returns
417
417
  -------
418
418
  str
419
- The GUID of the Postgres server element.
419
+ The GUID of the File Folder element.
420
420
  """
421
421
  loop = asyncio.get_event_loop()
422
422
  response = loop.run_until_complete(