-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrule.py
27 lines (19 loc) · 792 Bytes
/
rule.py
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
from tokenize import Double
from InstancesFunction import InstancesFunctions
# from ruleHandler import ruleHandler
class Rule:
def __init__(self,serverType,command,data,tresh,ruleHandler):
self.Command = command
self.Data = data
self.TH = tresh
self.serverType = serverType
self.RuleHandler = ruleHandler
def Execute(self):
json = self.RuleHandler.model_EC2.getCPUUtilization()
if(self.Data == "CPU"):
if(self.Command == "Create"):
if(json["Average"] > self.TH):
self.RuleHandler.createInstance(json["ID"])
if(json["Average"] < self.TH):
self.RuleHandler.removeInstance(json["ID"])
#add cpu and io getter