-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpluginManager.py
executable file
·67 lines (56 loc) · 1.61 KB
/
pluginManager.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
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
#!/usr/bin/python3
import boto3
import json
import plugins
import importlib
#
# Dictionaries for plugin output
#
ec2PlugOutput = {}
s3PlugOutput = {}
ebsPlugOutput = {}
#
# Lists for informational functions
#
plugs = []
services = []
# Import the plugins that we are configured to run
# gather the output and store the output in the
# correct list
def doRunPlugins(ec2, s3, ebs, resources):
for p in resources["Plugins"]:
try:
m = importlib.import_module("plugins."+p)
except:
print("Failed import : plugins."+str(p))
continue
if "ec2_" in p and resources["Plugins"][p] == True:
currPlugin = m.lambda_handler(ec2)
ec2PlugOutput[p] = currPlugin
plugs.append(p)
elif "s3_" in p and resources["Plugins"][p] == True:
currPlugin = m.lambda_handler(s3)
s3PlugOutput[p] = currPlugin
plugs.append(p)
elif "ebs_" in p and resources["Plugins"][p] == True:
currPlugin = m.lambda_handler(ebs)
ebsPlugOutput[p] = currPlugin
plugs.append(p)
for s in resources["Resources"]:
if resources["Resources"][s] == True:
services.append(s)
# Return the EC2 plugin outputs
def getEc2Plugs():
return ec2PlugOutput
# Return the S3 plugins outputs
def getS3Plugs():
return s3PlugOutput
# Return the EBS plugins outputs
def getEbsPlugs():
return ebsPlugOutput
# Return the list of configured plugins
def getConfiguredPlugins():
return plugs
# Returnt the list of configured services
def getConfiguredServices():
return services