Repository navigation
Expand file tree
/
Copy pathLogthrash.py
More file actions
87 lines (75 loc) · 3.31 KB
/
Copy pathLogthrash.py
File metadata and controls
87 lines (75 loc) · 3.31 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
79
80
81
82
83
84
85
86
87
#This Script is used to increase the logthrash instances in kafka-es6 folder
from types import SimpleNamespace
import requests
import tkinter as tk
from tkinter import ttk
from pprint import pprint
from tkinter.messagebox import askyesno
class Alert(tk.Tk):
def __init__(self,job_name):
super().__init__()
self.job_name = job_name
self.title('Clear Checkpoint Dialog')
self.geometry('300x150')
# Confirm button
confirm_button = ttk.Button(self, text='Update Instances', command=self.confirm)
confirm_button.pack(expand=True)
def confirm(self):
answer = askyesno(title='Confirmation',
message='Are you sure that you want to change the number logthrash instances?')
if answer:
self.destroy()
Logthrash.update_logthrash_instances(self,self.job_name)
class Logthrash:
def update_logthrash_instances(self,job_name):
while True:
try:
no_of_instance = input("Enter the number logthrash instances :-")
if not no_of_instance:
raise ValueError('Job name is not defined')
payload = {"instances": int(no_of_instance)}
response = requests.put("http://odh.lgi.io/marathon/v2/apps//kafka-es6/{0}".format(job_name),
json=payload,
auth=('odhuser', 'password'))
if response.status_code == 200:
pprint(response.json())
print('Logthrash instances have been changed to',no_of_instance)
else:
print('Query failed to run')
break
except ValueError as e:
print("Sorry, I didn't understand that.", e)
continue
except:
print("Something went wrong while getting the response")
def check_logthrash_kafka_instances(self):
logthrash_config = self.get_logthrash_properties()
instance = logthrash_config.instances
print("There are currently {} Logthrash instances for this parsing job.".format(instance))
alert = Alert(logthrash_config.job_name)
alert.mainloop()
def get_logthrash_properties(self):
while True:
try:
job_name = input("Enter the logthrash parsing job name :-")
if not job_name:
raise ValueError('Job name is not defined')
response = requests.get("http://odh.lgi.io/marathon/v2/apps//kafka-es6/{0}".format(job_name),
auth=('odhuser', 'password'))
data = response.json()
no_logthrash_instances = data['app']['instances']
kafka_topic = data ['app']['args'][1]
obj = SimpleNamespace()
obj.instances = no_logthrash_instances
obj.topic = kafka_topic
obj.job_name = job_name
return obj
break
except ValueError as e:
print("Sorry, I didn't understand that.", e)
continue
except:
print("Something went wrong while getting the response")
l = Logthrash()
l.check_logthrash_kafka_instances()
#es6-thinkanalytics-parsing-v2-hu