pyegeria 0.3.3__py3-none-any.whl → 0.3.5__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.
- pyegeria/__init__.py +3 -1
- pyegeria/automated_curation_omvs.py +15 -10
- pyegeria/collection_manager_omvs.py +2428 -0
- pyegeria/core_omag_server_config.py +15 -22
- pyegeria/full_omag_server_config.py +0 -1
- pyegeria/glossary_omvs.py +14 -2
- pyegeria/gov_engine.py +1 -8
- pyegeria/governance_author.py +2 -0
- pyegeria/my_profile_omvs.py +1 -1
- pyegeria/platform_services.py +2 -39
- pyegeria/project_manager_omvs.py +1689 -0
- pyegeria/registered_info.py +3 -1
- pyegeria/server_operations.py +2 -2
- pyegeria/valid_metadata_omvs.py +779 -0
- pyegeria-0.3.5.data/scripts/engine_action_status.py +145 -0
- pyegeria-0.3.5.data/scripts/find_todos.py +152 -0
- pyegeria-0.3.5.data/scripts/glossary_view.py +135 -0
- pyegeria-0.3.5.data/scripts/gov_engine_status.py +120 -0
- pyegeria-0.3.5.data/scripts/integration_daemon_status.py +130 -0
- pyegeria-0.3.5.data/scripts/list_asset_types.py +114 -0
- pyegeria-0.3.5.data/scripts/multi-server_status.py +120 -0
- pyegeria-0.3.5.data/scripts/my_todos.py +162 -0
- pyegeria-0.3.5.data/scripts/open_todos.py +140 -0
- pyegeria-0.3.5.data/scripts/server_status.py +105 -0
- pyegeria-0.3.5.data/scripts/server_status_widget.py +93 -0
- pyegeria-0.3.5.data/scripts/view_my_profile.py +140 -0
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.5.dist-info}/METADATA +1 -1
- pyegeria-0.3.5.dist-info/RECORD +36 -0
- pyegeria/exceptions.py +0 -382
- pyegeria-0.3.3.dist-info/RECORD +0 -22
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.5.dist-info}/LICENSE +0 -0
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.5.dist-info}/WHEEL +0 -0
- {pyegeria-0.3.3.dist-info → pyegeria-0.3.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,145 @@
|
|
1
|
+
#!python
|
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 Engine Actions
|
10
|
+
"""
|
11
|
+
|
12
|
+
import argparse
|
13
|
+
import json
|
14
|
+
import time
|
15
|
+
|
16
|
+
from rich import box
|
17
|
+
from rich.live import Live
|
18
|
+
from rich.table import Table
|
19
|
+
from rich import console
|
20
|
+
|
21
|
+
from pyegeria import (
|
22
|
+
InvalidParameterException,
|
23
|
+
PropertyServerException,
|
24
|
+
UserNotAuthorizedException,
|
25
|
+
print_exception_response,
|
26
|
+
)
|
27
|
+
from pyegeria import GovEng, AutomatedCuration
|
28
|
+
|
29
|
+
disable_ssl_warnings = True
|
30
|
+
|
31
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
32
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
33
|
+
bad_platform1_url = "https://localhost:9443"
|
34
|
+
|
35
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
36
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
37
|
+
# bad_platform1_url = "https://localhost:9443"
|
38
|
+
|
39
|
+
good_user_1 = "garygeeke"
|
40
|
+
good_user_2 = "erinoverview"
|
41
|
+
bad_user_1 = "eviledna"
|
42
|
+
bad_user_2 = ""
|
43
|
+
|
44
|
+
good_server_1 = "active-metadata-store"
|
45
|
+
good_server_2 = "simple-metadata-store"
|
46
|
+
good_server_3 = "view-server"
|
47
|
+
good_server_4 = "engine-host"
|
48
|
+
bad_server_1 = "coco"
|
49
|
+
bad_server_2 = ""
|
50
|
+
|
51
|
+
|
52
|
+
def display_status_engine_actions(server: str = good_server_3, url: str = good_platform1_url, user: str = good_user_1):
|
53
|
+
g_client = AutomatedCuration(server, url, user, user_pwd="secret")
|
54
|
+
|
55
|
+
def generate_table() -> Table:
|
56
|
+
"""Make a new table."""
|
57
|
+
table = Table(
|
58
|
+
title=f"Engine Action Status for Platform {good_platform1_url} @ {time.asctime()}",
|
59
|
+
# style = "black on grey66",
|
60
|
+
header_style="white on dark_blue",
|
61
|
+
show_lines=True,
|
62
|
+
box=box.ROUNDED,
|
63
|
+
caption=f"Engine Status for Server '{server}' @ Platform - {url}",
|
64
|
+
expand=True
|
65
|
+
)
|
66
|
+
table.add_column("Requested Time")
|
67
|
+
table.add_column("Start Time")
|
68
|
+
|
69
|
+
table.add_column("Engine Name")
|
70
|
+
table.add_column("Request Type")
|
71
|
+
table.add_column("Action Status")
|
72
|
+
table.add_column("Target Element")
|
73
|
+
table.add_column("Completion Time")
|
74
|
+
table.add_column("Process Name")
|
75
|
+
table.add_column("Completion Message")
|
76
|
+
|
77
|
+
token = g_client.create_egeria_bearer_token()
|
78
|
+
action_status = g_client.get_engine_actions()
|
79
|
+
if action_status is None:
|
80
|
+
requested_time = " "
|
81
|
+
start_time = " "
|
82
|
+
completion_time = " "
|
83
|
+
engine_name = " "
|
84
|
+
request_type = " "
|
85
|
+
action_status = " "
|
86
|
+
target_element = " "
|
87
|
+
process_name = " "
|
88
|
+
completion_message = " "
|
89
|
+
else:
|
90
|
+
for action in action_status:
|
91
|
+
requested_time = action["requestedTime"]
|
92
|
+
start_time = action.get("startTime", " ")
|
93
|
+
completion_time = action.get("completionTime", " ")
|
94
|
+
|
95
|
+
engine_name = action["governanceEngineName"]
|
96
|
+
request_type = action["requestType"]
|
97
|
+
|
98
|
+
if action["actionStatus"] in ("REQUESTED", "APPROVED", "WAITING", "ACTIVATING"):
|
99
|
+
action_status = f"[yellow]{action['actionStatus']}"
|
100
|
+
elif action["actionStatus"] in ("IN_PROGRESS", "ACTIONED"):
|
101
|
+
action_status = f"[green]{action['actionStatus']}"
|
102
|
+
else:
|
103
|
+
action_status = f"[red]{action['actionStatus']}"
|
104
|
+
|
105
|
+
target= action.get("actionTargetElements","Empty")
|
106
|
+
if type(target) is list:
|
107
|
+
target_element = json.dumps(target[0]["targetElement"]["elementProperties"]["propertiesAsStrings"])
|
108
|
+
else:
|
109
|
+
target_element = " "
|
110
|
+
|
111
|
+
process_name = action.get("processName", " ")
|
112
|
+
completion_message = action.get("completionMessage", " ")
|
113
|
+
|
114
|
+
table.add_row(
|
115
|
+
requested_time, start_time, engine_name, request_type,
|
116
|
+
action_status, target_element, completion_time, process_name, completion_message
|
117
|
+
)
|
118
|
+
|
119
|
+
# g_client.close_session()
|
120
|
+
return table
|
121
|
+
|
122
|
+
try:
|
123
|
+
with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
124
|
+
while True:
|
125
|
+
time.sleep(2)
|
126
|
+
live.update(generate_table())
|
127
|
+
live.console.pager()
|
128
|
+
|
129
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
130
|
+
print_exception_response(e)
|
131
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
132
|
+
|
133
|
+
|
134
|
+
if __name__ == "__main__":
|
135
|
+
parser = argparse.ArgumentParser()
|
136
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
137
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
138
|
+
parser.add_argument("--userid", help="User Id")
|
139
|
+
args = parser.parse_args()
|
140
|
+
|
141
|
+
server = args.server if args.server is not None else "view-server"
|
142
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
143
|
+
userid = args.userid if args.userid is not None else 'garygeeke'
|
144
|
+
print(f"Starting display_status_engine_actions with {server}, {url}, {userid}")
|
145
|
+
display_status_engine_actions(server=server, url=url, user=userid)
|
@@ -0,0 +1,152 @@
|
|
1
|
+
#!python
|
2
|
+
"""
|
3
|
+
SPDX-Lic
|
4
|
+
ense-Identifier: Apache-2.0
|
5
|
+
Copyright Contributors to the ODPi Egeria project.
|
6
|
+
|
7
|
+
Unit tests for the Utils helper functions using the Pytest framework.
|
8
|
+
|
9
|
+
|
10
|
+
A simple display for glossary terms
|
11
|
+
"""
|
12
|
+
|
13
|
+
import time
|
14
|
+
import json
|
15
|
+
import argparse
|
16
|
+
from pyegeria import (
|
17
|
+
InvalidParameterException,
|
18
|
+
PropertyServerException,
|
19
|
+
UserNotAuthorizedException,
|
20
|
+
print_exception_response,
|
21
|
+
)
|
22
|
+
from rich.table import Table
|
23
|
+
from rich.live import Live
|
24
|
+
from rich import box
|
25
|
+
from rich.prompt import Prompt
|
26
|
+
from rich.tree import Tree
|
27
|
+
from rich import print
|
28
|
+
from rich.console import Console
|
29
|
+
from pyegeria.my_profile_omvs import MyProfile
|
30
|
+
|
31
|
+
from pyegeria.server_operations import ServerOps
|
32
|
+
from pyegeria.gov_engine import GovEng
|
33
|
+
from pyegeria.glossary_omvs import GlossaryBrowser
|
34
|
+
disable_ssl_warnings = True
|
35
|
+
|
36
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
37
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
38
|
+
bad_platform1_url = "https://localhost:9443"
|
39
|
+
|
40
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
41
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
42
|
+
# bad_platform1_url = "https://localhost:9443"
|
43
|
+
|
44
|
+
good_user_1 = "garygeeke"
|
45
|
+
good_user_2 = "erinoverview"
|
46
|
+
bad_user_1 = "eviledna"
|
47
|
+
bad_user_2 = ""
|
48
|
+
|
49
|
+
good_server_1 = "active-metadata-store"
|
50
|
+
good_server_2 = "simple-metadata-store"
|
51
|
+
good_server_3 = "view-server"
|
52
|
+
good_server_4 = "engine-host"
|
53
|
+
bad_server_1 = "coco"
|
54
|
+
bad_server_2 = ""
|
55
|
+
|
56
|
+
|
57
|
+
def display_to_dos(search_string: str, guid: str=None, server: str = good_server_3, url: str = good_platform1_url, username: str = good_user_2):
|
58
|
+
|
59
|
+
m_client = MyProfile(server, url, user_id=username)
|
60
|
+
token = m_client.create_egeria_bearer_token(username, "secret")
|
61
|
+
|
62
|
+
def generate_table(search_string:str = '*') -> Table:
|
63
|
+
"""Make a new table."""
|
64
|
+
table = Table(
|
65
|
+
title=f"Open ToDos for Platform {good_platform1_url} @ {time.asctime()}",
|
66
|
+
# style = "black on grey66",
|
67
|
+
header_style="white on dark_blue",
|
68
|
+
show_lines=True,
|
69
|
+
box=box.ROUNDED,
|
70
|
+
caption=f"ToDos for Server '{server}' @ Platform - {url}",
|
71
|
+
expand=True
|
72
|
+
)
|
73
|
+
|
74
|
+
table.add_column("Name")
|
75
|
+
table.add_column("Type Name")
|
76
|
+
|
77
|
+
table.add_column("Created")
|
78
|
+
table.add_column("Priority")
|
79
|
+
table.add_column("Due")
|
80
|
+
table.add_column("Completion")
|
81
|
+
table.add_column("Status")
|
82
|
+
table.add_column("Sponsor")
|
83
|
+
|
84
|
+
todo_items = m_client.find_to_do("*", starts_with=True)
|
85
|
+
|
86
|
+
if todo_items is None:
|
87
|
+
name = " "
|
88
|
+
type_name = " "
|
89
|
+
created = " "
|
90
|
+
priority = " "
|
91
|
+
due = " "
|
92
|
+
completed = " "
|
93
|
+
status = " "
|
94
|
+
sponsor = " "
|
95
|
+
else:
|
96
|
+
for item in todo_items:
|
97
|
+
props = item["properties"]
|
98
|
+
name = props["name"]
|
99
|
+
type_name = props.get("toDoType", " ")
|
100
|
+
created = props.get("creationTime", " ")
|
101
|
+
priority = str(props.get("priority", " "))
|
102
|
+
due = props.get("dueTime", " ")
|
103
|
+
completed = props.get("completionTime", " ")
|
104
|
+
status = props.get("status")
|
105
|
+
# assigned_actors = item["assignedActors"]
|
106
|
+
# sponsor = assigned_actors[0].get("uniqueName", " ")
|
107
|
+
sponsor = "erinoverview"
|
108
|
+
if status in ("WAITING", "OPEN"):
|
109
|
+
status = f"[yellow]{status}"
|
110
|
+
elif status in ("INPROGRESS", "COMPLETE"):
|
111
|
+
status = f"[green]{status}"
|
112
|
+
else:
|
113
|
+
status = f"[red]{status}"
|
114
|
+
|
115
|
+
table.add_row(
|
116
|
+
name, type_name, created, priority, due, completed, status, sponsor
|
117
|
+
)
|
118
|
+
|
119
|
+
m_client.close_session()
|
120
|
+
return table
|
121
|
+
|
122
|
+
try:
|
123
|
+
# with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
124
|
+
# while True:
|
125
|
+
# time.sleep(2)
|
126
|
+
# live.update(generate_table())
|
127
|
+
console = Console()
|
128
|
+
with console.pager():
|
129
|
+
console.print(generate_table(search_string))
|
130
|
+
|
131
|
+
|
132
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
133
|
+
print_exception_response(e)
|
134
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
135
|
+
|
136
|
+
if __name__ == "__main__":
|
137
|
+
sus_guid = "f9b78b26-6025-43fa-9299-a905cc6d1575"
|
138
|
+
parser = argparse.ArgumentParser()
|
139
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
140
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
141
|
+
parser.add_argument("--userid", help="User Id")
|
142
|
+
# parser.add_argument("--sponsor", help="Name of sponsor to search")
|
143
|
+
args = parser.parse_args()
|
144
|
+
|
145
|
+
server = args.server if args.server is not None else "view-server"
|
146
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
147
|
+
userid = args.userid if args.userid is not None else 'erinoverview'
|
148
|
+
# guid = args.guid if args.guid is not None else None
|
149
|
+
guid = None
|
150
|
+
|
151
|
+
search_string = Prompt.ask("Enter the ToDo you are searching for:", default="*")
|
152
|
+
display_to_dos(search_string, guid,server, url, userid)
|
@@ -0,0 +1,135 @@
|
|
1
|
+
#!python
|
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 display for glossary terms
|
10
|
+
"""
|
11
|
+
|
12
|
+
import time
|
13
|
+
import json
|
14
|
+
import argparse
|
15
|
+
from pyegeria import (
|
16
|
+
InvalidParameterException,
|
17
|
+
PropertyServerException,
|
18
|
+
UserNotAuthorizedException,
|
19
|
+
print_exception_response,
|
20
|
+
)
|
21
|
+
from rich.table import Table
|
22
|
+
from rich.live import Live
|
23
|
+
from rich import box
|
24
|
+
from rich.prompt import Prompt
|
25
|
+
from rich.tree import Tree
|
26
|
+
from rich import print
|
27
|
+
from rich.console import Console
|
28
|
+
|
29
|
+
|
30
|
+
from pyegeria.server_operations import ServerOps
|
31
|
+
from pyegeria.gov_engine import GovEng
|
32
|
+
from pyegeria.glossary_omvs import GlossaryBrowser
|
33
|
+
disable_ssl_warnings = True
|
34
|
+
|
35
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
36
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
37
|
+
bad_platform1_url = "https://localhost:9443"
|
38
|
+
|
39
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
40
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
41
|
+
# bad_platform1_url = "https://localhost:9443"
|
42
|
+
|
43
|
+
good_user_1 = "garygeeke"
|
44
|
+
good_user_2 = "erinoverview"
|
45
|
+
bad_user_1 = "eviledna"
|
46
|
+
bad_user_2 = ""
|
47
|
+
|
48
|
+
good_server_1 = "active-metadata-store"
|
49
|
+
good_server_2 = "simple-metadata-store"
|
50
|
+
good_server_3 = "view-server"
|
51
|
+
good_server_4 = "engine-host"
|
52
|
+
bad_server_1 = "coco"
|
53
|
+
bad_server_2 = ""
|
54
|
+
|
55
|
+
|
56
|
+
def display_glossary_terms(search_string: str, guid: str=None, server: str = good_server_3, url: str = good_platform1_url, username: str = good_user_2):
|
57
|
+
|
58
|
+
g_client = GlossaryBrowser(server, url)
|
59
|
+
token = g_client.create_egeria_bearer_token(username, "secret")
|
60
|
+
|
61
|
+
|
62
|
+
def generate_table(search_string:str = '*') -> Table:
|
63
|
+
"""Make a new table."""
|
64
|
+
table = Table(
|
65
|
+
title=f"Glossary Definitions for Terms like {search_string} @ {time.asctime()}",
|
66
|
+
# style = "black on grey66",
|
67
|
+
header_style="white on dark_blue",
|
68
|
+
show_lines=True,
|
69
|
+
box=box.ROUNDED,
|
70
|
+
caption=f"Glossary View Server '{server}' @ Platform - {url}",
|
71
|
+
expand=True
|
72
|
+
)
|
73
|
+
table.add_column("Display Name")
|
74
|
+
table.add_column("Qualified Name")
|
75
|
+
|
76
|
+
table.add_column("Abbreviation")
|
77
|
+
table.add_column("Summary")
|
78
|
+
table.add_column("Description")
|
79
|
+
|
80
|
+
terms = g_client.find_glossary_terms(search_string, guid, starts_with=True,
|
81
|
+
ends_with=False, status_filter=[], page_size=500)
|
82
|
+
if type(terms) is str:
|
83
|
+
return table
|
84
|
+
|
85
|
+
for term in terms:
|
86
|
+
props = term.get("glossaryTermProperties","None")
|
87
|
+
if props == "None":
|
88
|
+
return table
|
89
|
+
|
90
|
+
display_name = props["displayName"]
|
91
|
+
qualified_name = props["qualifiedName"]
|
92
|
+
abbrev = props.get("abbreviation"," ")
|
93
|
+
summary = props.get("summary", " ")
|
94
|
+
description = props.get("description", " ")
|
95
|
+
|
96
|
+
|
97
|
+
table.add_row(
|
98
|
+
display_name,qualified_name, abbrev, summary, description
|
99
|
+
)
|
100
|
+
|
101
|
+
g_client.close_session()
|
102
|
+
return table
|
103
|
+
|
104
|
+
try:
|
105
|
+
# with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
106
|
+
# while True:
|
107
|
+
# time.sleep(2)
|
108
|
+
# live.update(generate_table())
|
109
|
+
console = Console()
|
110
|
+
with console.pager():
|
111
|
+
console.print(generate_table(search_string))
|
112
|
+
|
113
|
+
|
114
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
115
|
+
print_exception_response(e)
|
116
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
117
|
+
|
118
|
+
if __name__ == "__main__":
|
119
|
+
sus_guid = "f9b78b26-6025-43fa-9299-a905cc6d1575"
|
120
|
+
parser = argparse.ArgumentParser()
|
121
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
122
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
123
|
+
parser.add_argument("--userid", help="User Id")
|
124
|
+
parser.add_argument("--guid", help="GUID of glossary to search")
|
125
|
+
parser.add_argument("--sustainability", help="Set True for Sustainability Glossary")
|
126
|
+
args = parser.parse_args()
|
127
|
+
|
128
|
+
server = args.server if args.server is not None else "view-server"
|
129
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
130
|
+
userid = args.userid if args.userid is not None else 'garygeeke'
|
131
|
+
guid = args.guid if args.guid is not None else None
|
132
|
+
guid = sus_guid if args.sustainability else None
|
133
|
+
|
134
|
+
search_string = Prompt.ask("Enter the term you are searching for:", default="*")
|
135
|
+
display_glossary_terms(search_string, guid,server, url, userid)
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#!python
|
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
|
+
|
12
|
+
import time
|
13
|
+
import json
|
14
|
+
import argparse
|
15
|
+
|
16
|
+
from pyegeria import (
|
17
|
+
InvalidParameterException,
|
18
|
+
PropertyServerException,
|
19
|
+
UserNotAuthorizedException,
|
20
|
+
print_exception_response,
|
21
|
+
)
|
22
|
+
from rich.table import Table
|
23
|
+
from rich.live import Live
|
24
|
+
from rich import box
|
25
|
+
from rich import console
|
26
|
+
|
27
|
+
from pyegeria.server_operations import ServerOps
|
28
|
+
from pyegeria.gov_engine import GovEng
|
29
|
+
|
30
|
+
disable_ssl_warnings = True
|
31
|
+
|
32
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
33
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
34
|
+
bad_platform1_url = "https://localhost:9443"
|
35
|
+
|
36
|
+
# good_platform1_url = "https://127.0.0.1:30080"
|
37
|
+
# good_platform2_url = "https://127.0.0.1:30081"
|
38
|
+
# bad_platform1_url = "https://localhost:9443"
|
39
|
+
|
40
|
+
good_user_1 = "garygeeke"
|
41
|
+
good_user_2 = "erinoverview"
|
42
|
+
bad_user_1 = "eviledna"
|
43
|
+
bad_user_2 = ""
|
44
|
+
|
45
|
+
good_server_1 = "active-metadata-store"
|
46
|
+
good_server_2 = "simple-metadata-store"
|
47
|
+
good_server_3 = "engine-host"
|
48
|
+
good_server_4 = "engine-host"
|
49
|
+
bad_server_1 = "coco"
|
50
|
+
bad_server_2 = ""
|
51
|
+
|
52
|
+
|
53
|
+
def display_gov_actions_status(server: str = good_server_3, url: str = good_platform1_url, username: str = good_user_1):
|
54
|
+
server_name = server
|
55
|
+
s_client = ServerOps(server_name, url, username)
|
56
|
+
|
57
|
+
def generate_table() -> Table:
|
58
|
+
"""Make a new table."""
|
59
|
+
table = Table(
|
60
|
+
title=f"Governance Engine Status @ {time.asctime()}",
|
61
|
+
# style = "black on grey66",
|
62
|
+
header_style="white on dark_blue",
|
63
|
+
show_lines=True,
|
64
|
+
box=box.ROUNDED,
|
65
|
+
caption=f"Server: '{server_name}' running on {url}",
|
66
|
+
expand=True
|
67
|
+
)
|
68
|
+
# table.footer: f"Server {server_name} on Platform {good_platform1_url}"
|
69
|
+
table.add_column("Gov Engine")
|
70
|
+
table.add_column("Gov Engine Type")
|
71
|
+
table.add_column("Gov Engine Desc")
|
72
|
+
table.add_column("Engine Status")
|
73
|
+
table.add_column("Request Types")
|
74
|
+
|
75
|
+
gov_eng_status = s_client.get_governance_engine_summaries()
|
76
|
+
for engine in gov_eng_status:
|
77
|
+
gov_eng = engine["governanceEngineName"]
|
78
|
+
eng_type = engine["governanceEngineTypeName"]
|
79
|
+
|
80
|
+
eng_desc = engine["governanceEngineDescription"]
|
81
|
+
eng_req_type = json.dumps(engine["governanceRequestTypes"], indent = 2)
|
82
|
+
status = engine["governanceEngineStatus"]
|
83
|
+
if status in ("RUNNING"):
|
84
|
+
eng_status = f"[green]{status}"
|
85
|
+
elif status in ("FAILED"):
|
86
|
+
eng_status = f"[red]{status}"
|
87
|
+
else: eng_status = f"[yellow]{status}"
|
88
|
+
|
89
|
+
table.add_row(
|
90
|
+
gov_eng, eng_type, eng_desc, eng_status,eng_req_type
|
91
|
+
)
|
92
|
+
|
93
|
+
table.caption = f"Server {server_name} running on {url}"
|
94
|
+
return table
|
95
|
+
|
96
|
+
try:
|
97
|
+
with Live(generate_table(), refresh_per_second=1, screen=True, vertical_overflow="visible") as live:
|
98
|
+
while True:
|
99
|
+
time.sleep(2)
|
100
|
+
live.update(generate_table())
|
101
|
+
|
102
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
103
|
+
print_exception_response(e)
|
104
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
105
|
+
|
106
|
+
finally:
|
107
|
+
s_client.close_session()
|
108
|
+
|
109
|
+
|
110
|
+
if __name__ == "__main__":
|
111
|
+
parser = argparse.ArgumentParser()
|
112
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
113
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
114
|
+
parser.add_argument("--userid", help="User Id")
|
115
|
+
args = parser.parse_args()
|
116
|
+
|
117
|
+
server = args.server if args.server is not None else "engine-host"
|
118
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
119
|
+
userid = args.userid if args.userid is not None else 'garygeeke'
|
120
|
+
display_gov_actions_status(server=server, url=url, username=userid)
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#!python
|
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 Engine Actions
|
10
|
+
"""
|
11
|
+
|
12
|
+
import argparse
|
13
|
+
import json
|
14
|
+
import time
|
15
|
+
|
16
|
+
from rich import box
|
17
|
+
from rich.live import Live
|
18
|
+
from rich.table import Table
|
19
|
+
from rich import console
|
20
|
+
|
21
|
+
from pyegeria._exceptions import (
|
22
|
+
InvalidParameterException,
|
23
|
+
PropertyServerException,
|
24
|
+
UserNotAuthorizedException,
|
25
|
+
print_exception_response,
|
26
|
+
)
|
27
|
+
from pyegeria.server_operations import ServerOps
|
28
|
+
|
29
|
+
disable_ssl_warnings = True
|
30
|
+
|
31
|
+
good_platform1_url = "https://127.0.0.1:9443"
|
32
|
+
good_platform2_url = "https://egeria.pdr-associates.com:7443"
|
33
|
+
bad_platform1_url = "https://localhost:9443"
|
34
|
+
|
35
|
+
good_user_1 = "garygeeke"
|
36
|
+
good_user_2 = "erinoverview"
|
37
|
+
bad_user_1 = "eviledna"
|
38
|
+
bad_user_2 = ""
|
39
|
+
|
40
|
+
good_server_1 = "active-metadata-store"
|
41
|
+
good_server_2 = "simple-metadata-store"
|
42
|
+
good_server_3 = "view-server"
|
43
|
+
good_server_4 = "engine-host"
|
44
|
+
bad_server_1 = "coco"
|
45
|
+
bad_server_2 = ""
|
46
|
+
|
47
|
+
|
48
|
+
def display_integration_daemon_status(server: str = good_server_4, url: str = good_platform1_url,
|
49
|
+
user: str = good_user_1):
|
50
|
+
s_client = ServerOps(server, url, user)
|
51
|
+
|
52
|
+
def generate_table() -> Table:
|
53
|
+
"""Make a new table."""
|
54
|
+
table = Table(
|
55
|
+
title=f"Integration Daemon Status @ {time.asctime()}",
|
56
|
+
# style = "black on grey66",
|
57
|
+
header_style="white on dark_blue",
|
58
|
+
show_lines=True,
|
59
|
+
box=box.ROUNDED,
|
60
|
+
caption=f"Integration Daemon Status for Server '{server}' @ Platform - {url}",
|
61
|
+
expand=True
|
62
|
+
)
|
63
|
+
table.add_column("Connector Name")
|
64
|
+
table.add_column("Connector Status")
|
65
|
+
|
66
|
+
table.add_column("Last Refresh Time")
|
67
|
+
table.add_column("Minimum Refresh Interval (min)")
|
68
|
+
table.add_column("Target Element")
|
69
|
+
table.add_column("Exception Message")
|
70
|
+
|
71
|
+
daemon_status = s_client.get_integration_daemon_status()
|
72
|
+
connector_reports = daemon_status["integrationConnectorReports"]
|
73
|
+
for connector in connector_reports:
|
74
|
+
connector_name = connector["connectorName"]
|
75
|
+
connector_status = connector["connectorStatus"]
|
76
|
+
last_refresh_time = connector.get("lastRefreshTime","---")
|
77
|
+
refresh_interval = str(connector.get("minMinutesBetweenRefresh","---"))
|
78
|
+
target_element = " "
|
79
|
+
exception_msg = " "
|
80
|
+
|
81
|
+
if connector_name is None:
|
82
|
+
connector_name = "connector name"
|
83
|
+
if connector_status is None:
|
84
|
+
connector_status = "connector status"
|
85
|
+
|
86
|
+
if connector_status in ("RUNNING", "REFRESHING", "WAITING"):
|
87
|
+
connector_status = f"[green]{connector_status}"
|
88
|
+
elif connector_status in ("INITIALIZE FAILED","CONFIG_FAILED","FAILED"):
|
89
|
+
connector_status = f"[red]{connector_status}"
|
90
|
+
else:
|
91
|
+
connector_status = f"[yellow]{connector_status}"
|
92
|
+
|
93
|
+
# target= action.get("actionTargetElements","Empty")
|
94
|
+
# if type(target) is list:
|
95
|
+
# target_element = json.dumps(target[0]["targetElement"]["elementProperties"]["propertiesAsStrings"])
|
96
|
+
# else:
|
97
|
+
# target_element = " "
|
98
|
+
|
99
|
+
table.add_row(
|
100
|
+
connector_name,connector_status,last_refresh_time,refresh_interval,
|
101
|
+
target_element, exception_msg
|
102
|
+
)
|
103
|
+
return table
|
104
|
+
|
105
|
+
try:
|
106
|
+
with Live(generate_table(), refresh_per_second=4, screen=True) as live:
|
107
|
+
while True:
|
108
|
+
time.sleep(2)
|
109
|
+
live.update(generate_table())
|
110
|
+
live.console.pager()
|
111
|
+
|
112
|
+
except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
|
113
|
+
print_exception_response(e)
|
114
|
+
assert e.related_http_code != "200", "Invalid parameters"
|
115
|
+
|
116
|
+
finally:
|
117
|
+
s_client.close_session()
|
118
|
+
|
119
|
+
|
120
|
+
if __name__ == "__main__":
|
121
|
+
parser = argparse.ArgumentParser()
|
122
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
123
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
124
|
+
parser.add_argument("--userid", help="User Id")
|
125
|
+
args = parser.parse_args()
|
126
|
+
|
127
|
+
server = args.server if args.server is not None else "integration-daemon"
|
128
|
+
url = args.url if args.url is not None else "https://localhost:9443"
|
129
|
+
userid = args.userid if args.userid is not None else 'garygeeke'
|
130
|
+
display_integration_daemon_status(server=server, url=url, user=userid)
|