-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAzureGenerat0r.py
executable file
·108 lines (93 loc) · 3.62 KB
/
AzureGenerat0r.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python
#
import sys, os, readline, json, argparse, paramiko
from src.Model import *
from src.Controller import *
from src.Completer import Completer
from src.Setup import setup
version = "1.1"
def print_banner():
'''
prints the banner of AzureGenerat0r
'''
print("""
___ _____ _ _____
/ _ \ | __ \ | | | _ |
/ /_\ \_____ _ _ __ ___| | \/ ___ _ __ ___ _ __ __ _| |_| |/' |_ __
| _ |_ / | | | '__/ _ \ | __ / _ \ '_ \ / _ \ '__/ _` | __| /| | '__|
| | | |/ /| |_| | | | __/ |_\ \ __/ | | | __/ | | (_| | |_\ |_/ / |
\_| |_/___|\__,_|_| \___|\____/\___|_| |_|\___|_| \__,_|\__|\___/|_|
version %s
""" % version)
def print_usage():
'''
prints the usage of AzureGenerat0r
'''
print(
"Commands \n"
"create - creates infrastructure in azure \n"
"enrich - enriches existing VMs in Azure \n"
"godmode - creates infrastructure and enriches machines in one (long-lasting) step. \n"
"destroy - destroys infrastructure in Azure \n"
"ips - shows IPs of existing VMs \n"
"refresh - refreshes Terraform state file \n"
"exit - exit AzureGenerat0r \n \n")
def read_commands():
'''
a loop where commands are read and executed
'''
completer = Completer(
["create", "destroy", "enrich", "exit", "godmode", "help", "refresh", "ips"])
readline.set_completer(completer.complete)
readline.parse_and_bind('tab: complete')
exit = False
try:
while exit is False:
command = input(">> ")
if command == "create":
Specification.init()
Mapper.process(Specification.data)
Pluginer.process(Specification.data)
Connecter.process(Specification.data)
Predeployer.process(Specification.data)
Deployer.process(Specification.data)
elif command == "enrich":
Specification.init()
Pluginer.process(Specification.data_enricher)
Enricher.process(Specification.data_enricher)
elif command == "godmode":
Specification.init()
Mapper.process(Specification.data)
Pluginer.process(Specification.data)
Connecter.process(Specification.data)
Predeployer.process(Specification.data)
Deployer.process(Specification.data)
Pluginer.process(Specification.data_enricher)
Enricher.process(Specification.data_enricher)
elif command == "ips":
os.system("terraform output")
elif command == "destroy":
os.system("terraform destroy --auto-approve")
elif command == "refresh":
os.system("terraform refresh")
elif command == "help":
print_usage()
elif command == "exit":
sys.exit(0)
except (KeyboardInterrupt):
pass
if __name__ == '__main__':
# setup
parser = argparse.ArgumentParser()
parser.add_argument('--setup', action='store_true')
args = parser.parse_args()
if args.setup:
setup()
exit(0)
os.chdir('./src')
Configuration.init()
# set environment for ansible
os.environ['ANSIBLE_HOST_KEY_CHECKING'] = str(Configuration.ansible_host_key_checking)
print_banner()
print_usage()
read_commands()