-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patholcf-s3m-streaming.py
More file actions
executable file
·78 lines (66 loc) · 3.18 KB
/
olcf-s3m-streaming.py
File metadata and controls
executable file
·78 lines (66 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
import argparse
from os import getenv
from olcf_s3m_api.client import OLCFAPIClient
from olcf_s3m_api.streaming import StreamingService
def list_services(service : StreamingService):
print('++++ OLCF S3M - Streaming Service Orchestration ++++ Listing Available Services')
success, msg = service.list_services()
if success:
print(msg)
print('\n\n')
def show(service : StreamingService):
print('++++ OLCF S3M - Streaming Service Orchestration ++++ Showing Existing Deployments')
success, msg = service.list_clusters()
if success:
print(msg)
print('\n\n')
def deploy(service : StreamingService, cluster : str, nodes : int = 1):
print(f'++++ OLCF S3M - Streaming Service Orchestration ++++ Deploying a {nodes}-node Service')
success, msg = service.start_cluster(cluster_name=cluster, wait_for_healthy=True, node_count=nodes)
if success:
print(f'{msg}\n\n')
print('++++ OLCF S3M - Streaming Service Orchestration ++++ Getting Cluster Deployment')
deployment = service.get_cluster_deployment(cluster_name=cluster)
if deployment:
print(deployment)
print('\n\n')
def info(service : StreamingService, cluster : str):
print('++++ OLCF S3M - Streaming Service Orchestration ++++ Getting Cluster Information')
success, msg = service.get_cluster_info(cluster_name=cluster)
if success:
print(msg)
print('\n\n')
def shutdown(service : StreamingService, cluster : str):
print('++++ OLCF S3M - Streaming Service Orchestration ++++ Shutting Down Service')
success, msg = service.stop_cluster(cluster_name=cluster)
if success:
print(msg)
print('\n\n')
def main(args):
my_strm_service_name = args.service
my_cluster_name = args.cluster
my_api_client = OLCFAPIClient(api_token=getenv("olcf_s3m_api_TOKEN", "InvalidToken"))
my_strm_service = StreamingService(service_name=my_strm_service_name,
api_client=my_api_client)
if args.avail:
list_services(my_strm_service)
elif args.deploy:
deploy(my_strm_service, my_cluster_name, args.hostcount)
elif args.info:
info(my_strm_service, my_cluster_name)
elif args.shutdown:
shutdown(my_strm_service, my_cluster_name)
else:
show(my_strm_service)
if __name__ == '__main__':
parser = argparse.ArgumentParser('olcf-s3m-streaming')
parser.add_argument('-a', '--avail', help='list available streaming services', action='store_true')
parser.add_argument('-d', '--deploy', help='deploy a service cluster', action='store_true')
parser.add_argument('-i', '--info', help='get information about a service cluster', action='store_true')
parser.add_argument('-s', '--shutdown', help='shutdown a service cluster', action='store_true')
parser.add_argument('service', nargs='?', help='name of a supported streaming service', default='rabbitmq')
parser.add_argument('cluster', nargs='?', help='name for your streaming service cluster', default='ds2hpc_demo')
parser.add_argument('hostcount', nargs='?', help='number of hosts for streaming service cluster', default=1)
args = parser.parse_args()
main(args)