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.
@@ -0,0 +1,140 @@
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
10
+ """
11
+ import argparse
12
+ import os
13
+ import time
14
+
15
+ from rich.live import Live
16
+ from rich.table import Table
17
+
18
+ from pyegeria._exceptions import (
19
+ InvalidParameterException,
20
+ PropertyServerException,
21
+ UserNotAuthorizedException,
22
+ print_exception_response,
23
+ )
24
+ from pyegeria.core_omag_server_config import CoreServerConfig
25
+ from pyegeria.server_operations import ServerOps
26
+
27
+ disable_ssl_warnings = True
28
+
29
+ EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
30
+ EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
31
+ EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
32
+ EGERIA_VIEW_SERVER = os.environ.get("VIEW_SERVER", "view-server")
33
+ EGERIA_VIEW_SERVER_URL = os.environ.get(
34
+ "EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
35
+ )
36
+ EGERIA_INTEGRATION_DAEMON = os.environ.get("INTEGRATION_DAEMON", "integration-daemon")
37
+ EGERIA_INTEGRATION_DAEMON_URL = os.environ.get(
38
+ "EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443"
39
+ )
40
+ EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
41
+ EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
42
+ EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
43
+ EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
44
+ EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
45
+ EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
46
+
47
+
48
+ def display_status(
49
+ server: str,
50
+ url: str,
51
+ username: str,
52
+ user_pass: str,
53
+ jupyter: bool = EGERIA_JUPYTER,
54
+ width: int = EGERIA_WIDTH,
55
+ ):
56
+ p_client = ServerOps(server, url, username)
57
+ c_client = CoreServerConfig(server, url, username, user_pass)
58
+
59
+ def generate_table() -> Table:
60
+ """Make a new table."""
61
+ table = Table(
62
+ title=f"Server Status for Platform - {time.asctime()}",
63
+ style="bold white on black",
64
+ row_styles=["bold white on black"],
65
+ header_style="white on dark_blue",
66
+ title_style="bold white on black",
67
+ caption_style="white on black",
68
+ caption=f"Server Status for Platform - '{url}'",
69
+ show_lines=True,
70
+ # expand=True
71
+ )
72
+
73
+ table.add_column("Known Server")
74
+ table.add_column("Status")
75
+ table.add_column("Server Type")
76
+ table.add_column("Server Description")
77
+ known_server_list = p_client.get_known_servers()
78
+ active_server_list = p_client.get_active_server_list()
79
+ if len(known_server_list) == 0:
80
+ return table
81
+
82
+ for server in known_server_list:
83
+ if server in active_server_list:
84
+ status = "Active"
85
+ else:
86
+ status = "Inactive"
87
+ server_type = c_client.get_server_type_classification(server)[
88
+ "serverTypeName"
89
+ ]
90
+ description = c_client.get_basic_server_properties(server).get(
91
+ "localServerDescription", " "
92
+ )
93
+
94
+ table.add_row(
95
+ server,
96
+ "[red]Inactive" if status == "Inactive" else "[green]Active",
97
+ server_type,
98
+ description,
99
+ )
100
+
101
+ return table
102
+
103
+ try:
104
+ with Live(generate_table(), refresh_per_second=4, screen=True) as live:
105
+ while True:
106
+ time.sleep(2)
107
+ live.update(generate_table())
108
+
109
+ except (
110
+ InvalidParameterException,
111
+ PropertyServerException,
112
+ UserNotAuthorizedException,
113
+ ) as e:
114
+ print_exception_response(e)
115
+ except KeyboardInterrupt:
116
+ pass
117
+
118
+ finally:
119
+ p_client.close_session()
120
+ c_client.close_session()
121
+
122
+
123
+ def main():
124
+ parser = argparse.ArgumentParser()
125
+ parser.add_argument("--server", help="Name of the server to display status for")
126
+ parser.add_argument("--url", help="URL Platform to connect to")
127
+ parser.add_argument("--userid", help="User Id")
128
+ parser.add_argument("--password", help="User Password")
129
+ args = parser.parse_args()
130
+
131
+ server = args.server if args.server is not None else EGERIA_METADATA_STORE
132
+ url = args.url if args.url is not None else EGERIA_PLATFORM_URL
133
+ userid = args.userid if args.userid is not None else EGERIA_ADMIN_USER
134
+ user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
135
+
136
+ display_status(server, url, userid, user_pass)
137
+
138
+
139
+ if __name__ == "__main__":
140
+ main()
@@ -0,0 +1,109 @@
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
10
+ """
11
+ import argparse
12
+ import os
13
+ import time
14
+
15
+ from rich.live import Live
16
+ from rich.table import Table
17
+
18
+ from pyegeria import (
19
+ InvalidParameterException,
20
+ PropertyServerException,
21
+ UserNotAuthorizedException,
22
+ print_exception_response,
23
+ ServerOps
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('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
31
+ EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
32
+ EGERIA_INTEGRATION_DAEMON_URL = os.environ.get('EGERIA_INTEGRATION_DAEMON_URL', 'https://localhost:9443')
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
+ EGERIA_JUPYTER = bool(os.environ.get('EGERIA_JUPYTER', 'False'))
38
+ EGERIA_WIDTH = int(os.environ.get('EGERIA_WIDTH', '200'))
39
+
40
+
41
+ def display_status(server: str, url: str, username: str, user_pass: str, jupyter: bool = EGERIA_JUPYTER,
42
+ width: int = EGERIA_WIDTH):
43
+ p_client = ServerOps(server, url, username, user_pass)
44
+
45
+ def generate_table() -> Table:
46
+ """Make a new table."""
47
+ table = Table(
48
+ title=f"Server Status for Platform - {time.asctime()}",
49
+ style="bold white on black",
50
+ row_styles=["bold white on black"],
51
+ header_style="white on dark_blue",
52
+ title_style="bold white on black",
53
+ caption_style="white on black",
54
+ caption=f"Server Status for Platform - '{url}'",
55
+ # show_lines=True,
56
+ )
57
+
58
+ table.add_column("Known Server")
59
+ table.add_column("Status")
60
+
61
+ known_server_list = p_client.get_known_servers()
62
+ active_server_list = p_client.get_active_server_list()
63
+ if len(known_server_list) == 0:
64
+ return table
65
+
66
+ for server in known_server_list:
67
+ if server in active_server_list:
68
+ status = "Active"
69
+ else:
70
+ status = "Inactive"
71
+
72
+ table.add_row(server,
73
+ "[red]Inactive" if status == "Inactive" else "[green]Active",
74
+ )
75
+ # p_client.close_session()
76
+ return table
77
+
78
+ try:
79
+ with Live(generate_table(), refresh_per_second=4, screen=True) as live:
80
+ while True:
81
+ time.sleep(2)
82
+ live.update(generate_table())
83
+
84
+ except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
85
+ print_exception_response(e)
86
+ except KeyboardInterrupt:
87
+ pass
88
+ finally:
89
+ p_client.close_session()
90
+
91
+
92
+ def main():
93
+ parser = argparse.ArgumentParser()
94
+ parser.add_argument("--server", help="Name of the server to display status for")
95
+ parser.add_argument("--url", help="URL Platform to connect to")
96
+ parser.add_argument("--userid", help="User Id")
97
+ parser.add_argument("--password", help="User Password")
98
+ args = parser.parse_args()
99
+
100
+ server = args.server if args.server is not None else EGERIA_METADATA_STORE
101
+ url = args.url if args.url is not None else EGERIA_PLATFORM_URL
102
+ userid = args.userid if args.userid is not None else EGERIA_ADMIN_USER
103
+ user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
104
+
105
+ display_status(server, url, userid, user_pass)
106
+
107
+
108
+ if __name__ == "__main__":
109
+ main()
@@ -0,0 +1,73 @@
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
+
15
+ from pyegeria import ServerOps, AutomatedCuration
16
+ from pyegeria._exceptions import (
17
+ InvalidParameterException,
18
+ PropertyServerException,
19
+ UserNotAuthorizedException,
20
+ print_exception_response,
21
+ )
22
+ EGERIA_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('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
27
+ EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
28
+ EGERIA_INTEGRATION_DAEMON_URL = os.environ.get('EGERIA_INTEGRATION_DAEMON_URL', 'https://localhost:9443')
29
+ EGERIA_ADMIN_USER = os.environ.get('ADMIN_USER', 'garygeeke')
30
+ EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
31
+ EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
32
+ EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
33
+
34
+
35
+
36
+ def refresh_connector(connector: str, server:str, url:str, userid:str, password:str):
37
+ try:
38
+
39
+ s_client = ServerOps(server, url, userid)
40
+ if connector == 'all':
41
+ connector = None
42
+ statement = "ALL connectors"
43
+ else:
44
+ statement = f"the {connector} "
45
+
46
+ s_client.refresh_integration_connectors(connector, server, time_out = 60)
47
+
48
+ print(f"\n===> Integration Daemon \'{server}\' refreshed {statement}.")
49
+
50
+
51
+ except (InvalidParameterException, PropertyServerException) as e:
52
+ print_exception_response(e)
53
+
54
+
55
+
56
+
57
+ def main():
58
+ parser = argparse.ArgumentParser()
59
+ parser.add_argument("--server", help="Name of the integration daemon to refresh")
60
+ parser.add_argument("--url", help="URL Platform to connect to")
61
+ parser.add_argument("--userid", help="User Id")
62
+ parser.add_argument("--password", help="User Password")
63
+ parser.add_argument("--connector", default='all', help="Name of the connector to refresh")
64
+ args = parser.parse_args()
65
+
66
+ server = args.server if args.server is not None else EGERIA_INTEGRATION_DAEMON
67
+ url = args.url if args.url is not None else EGERIA_INTEGRATION_DAEMON_URL
68
+ userid = args.userid if args.userid is not None else EGERIA_ADMIN_USER
69
+ user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
70
+ refresh_connector(args.connector, server, url, userid, user_pass)
71
+
72
+ if __name__ == "__main__":
73
+ main()
@@ -0,0 +1,73 @@
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
+ import argparse
13
+ import time
14
+
15
+ from pyegeria import ServerOps, AutomatedCuration
16
+ from pyegeria._exceptions import (
17
+ InvalidParameterException,
18
+ PropertyServerException,
19
+ UserNotAuthorizedException,
20
+ print_exception_response,
21
+ )
22
+ EGERIA_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('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
27
+ EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
28
+ EGERIA_INTEGRATION_DAEMON_URL = os.environ.get('EGERIA_INTEGRATION_DAEMON_URL', 'https://localhost:9443')
29
+ EGERIA_ADMIN_USER = os.environ.get('ADMIN_USER', 'garygeeke')
30
+ EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
31
+ EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
32
+ EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
33
+
34
+
35
+
36
+ def restart_connector(connector: str, server:str, url:str, userid:str, password:str):
37
+ try:
38
+
39
+ s_client = ServerOps(server, url, userid)
40
+ if connector == 'all':
41
+ connector = None
42
+ statement = "ALL connectors"
43
+ else:
44
+ statement = f"the {connector} "
45
+
46
+ s_client.restart_integration_connector(connector, server, time_out = 60)
47
+
48
+ print(f"\n===> Integration Daemon \'{server}\' restarted {statement}.")
49
+
50
+
51
+ except (InvalidParameterException, PropertyServerException) as e:
52
+ print_exception_response(e)
53
+
54
+
55
+
56
+
57
+ def main():
58
+ parser = argparse.ArgumentParser()
59
+ parser.add_argument("--server", help="Name of the integration daemon to refresh")
60
+ parser.add_argument("--url", help="URL Platform to connect to")
61
+ parser.add_argument("--userid", help="User Id")
62
+ parser.add_argument("--password", help="User Password")
63
+ parser.add_argument("--connector", default='all', help="Name of the connector to refresh")
64
+ args = parser.parse_args()
65
+
66
+ server = args.server if args.server is not None else EGERIA_INTEGRATION_DAEMON
67
+ url = args.url if args.url is not None else EGERIA_INTEGRATION_DAEMON_URL
68
+ userid = args.userid if args.userid is not None else EGERIA_ADMIN_USER
69
+ user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
70
+ restart_connector(args.connector, server, url, userid, user_pass)
71
+
72
+ if __name__ == "__main__":
73
+ main()