-
Notifications
You must be signed in to change notification settings - Fork 1
/
cancamusa.py
60 lines (51 loc) · 2.36 KB
/
cancamusa.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
from __future__ import print_function, unicode_literals
from PyInquirer import prompt
import sys
import os
import argparse
sys.path.append(os.path.join(os.path.dirname(__file__), 'lib'))
sys.path.append(os.path.join(os.path.dirname(__file__), 'lib', 'host'))
sys.path.append(os.path.join(os.path.dirname(__file__), 'lib','disguise'))
sys.path.append(os.path.join(os.path.dirname(__file__), 'lib','scripter'))
from lib.project import CancamusaProject
from lib.server import start_server
from lib.configuration import configuration_mode, CancamusaConfiguration
from lib.win_iso import process_windows_image
program_description = """
Design a full operational Windows Domain with Domain Controllers, a Exchange server and a list of Windows hosts that can be based on real ones by cloning the configuration.
"""
parser = argparse.ArgumentParser(description=program_description)
parser.add_argument('--config', dest='configuration', action='store_true', default=False,
help='Enter configuration mode to edit cancamusa preferences')
parser.add_argument('--register-iso', dest='register_iso', action='store',
help='Register a Windows Image to use as base image')
parser.add_argument('--server', dest='server', action='store',
help='Start server that servs binaries, updates and utilities needed by Cancamusa scripts')
args = parser.parse_args()
if args.configuration :
configuration_mode()
exit()
if args.server:
start_server(args.server)
exit()
if args.register_iso :
cancamusa_config = CancamusaConfiguration.load_or_create(None)
if not cancamusa_config.iso_in_proxmox_path(args.register_iso) and cancamusa_config.is_proxmox:
print("Iso Image not in a valid Proxmox storage folder")
win_image = process_windows_image(args.register_iso)
cancamusa_config.add_win_image(win_image)
cancamusa_config.save()
exit()
cancamusa = None
try:
cancamusa = CancamusaProject.load_from_current_path()
except Exception as e:
print(e)
# Ask user if want a new project
answers = prompt([{'type': 'confirm','name': 'new_project','message': 'Error loading project. Want to create a new Cancamusa project?'}])
if answers['new_project']:
cancamusa = CancamusaProject.new_project_in_current_path()
else:
exit()
# Do things with the configuration
cancamusa.edit_project_interactive()