-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
167 lines (136 loc) · 5.97 KB
/
install.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import os
from zipfile import ZipFile
import shutil
import sys
#RUN WITH PYTHON 3 AND IN SUDO MODE
IGUASSU_BRANCH=
ARREBOL_BRANCH=
WEB_UI_BRANCH=
iguassu_dir_name = "iguassu-{}".format(IGUASSU_BRANCH.replace("/", "-"))
arrebol_dir_name = "arrebol-{}".format(ARREBOL_BRANCH.replace("/", "-"))
iwi_dir_name = "iwi-{}".format(WEB_UI_BRANCH.replace("/", "-"))
#Properties names
oauth_storage_service_token_url="oauth_storage_service_token_url"
oauth_storage_service_client_id="oauth_storage_service_client_id"
oauth_storage_service_client_secret="oauth_storage_service_client_secret"
storage_service_host_url="storage_service_host_url"
arrebol_service_host_url="arrebol_service_host_url"
iguassu_service_host_url="iguassu_service_host_url"
web_ui_host_url="web_ui_host_url"
job_state_monitor_period="job_state_monitor_period"
session_monitor_period="session_monitor_period"
job_submission_monitor_period="job_submission_monitor_period"
VUE_APP_EXTERNAL_LINK_DOCS="VUE_APP_EXTERNAL_LINK_DOCS"
VUE_APP_EXTERNAL_LINK_GITHUB_REPO="VUE_APP_EXTERNAL_LINK_GITHUB_REPO"
VUE_APP_EXTERNAL_LINK_ABOUT="VUE_APP_EXTERNAL_LINK_ABOUT"
VUE_APP_OWNCLOUD_SERVER_HOST="VUE_APP_OWNCLOUD_SERVER_HOST"
VUE_APP_OWNCLOUD_OAUTH_CLIENT_ID="VUE_APP_OWNCLOUD_OAUTH_CLIENT_ID"
VUE_APP_OWNCLOUD_OAUTH_SECRET="VUE_APP_OWNCLOUD_OAUTH_SECRET"
VUE_APP_OWNCLOUD_OAUTH_REDIRECT_URI="VUE_APP_OWNCLOUD_OAUTH_REDIRECT_URI"
VUE_APP_IGUASSU_API="VUE_APP_IGUASSU_API"
FAIL = '\033[91m'
ENDC = '\033[0m'
def unzip_file(file_name):
zf = ZipFile(file_name, 'r')
zf.extractall()
zf.close()
# Download/extract the archive file from repository and delete zip
def download_repository(url):
os.system("wget {}".format(url))
file_name = os.path.basename(url)
unzip_file(file_name)
os.remove(file_name)
def install_iguassu():
print("---> Installing Iguassu")
url = "https://github.com/ufcg-lsd/iguassu/archive/{}.zip".format(IGUASSU_BRANCH)
download_repository(url)
os.chdir(iguassu_dir_name)
os.system("mvn clean install -DskipTests")
os.chdir("..")
def install_arrebol():
print("---> Installing Arrebol")
url = "https://github.com/ufcg-lsd/arrebol/archive/{}.zip".format(ARREBOL_BRANCH)
download_repository(url)
os.chdir(arrebol_dir_name)
os.system("mvn clean install -DskipTests")
os.chdir("..")
def install_web_ui():
print("---> Installing Web UI")
url = "https://github.com/emanueljoivo/iwi/archive/{}.zip".format(WEB_UI_BRANCH)
download_repository(url)
os.chdir(iwi_dir_name)
os.system("yarn install")
os.chdir("..")
def input_datastore_properties():
properties = {}
print("Datastore Service Configuration Properties")
properties[oauth_storage_service_token_url]=input(oauth_storage_service_token_url + "=")
properties[oauth_storage_service_client_id]=input(oauth_storage_service_client_id + "=")
properties[oauth_storage_service_client_secret]=input(oauth_storage_service_client_secret + "=")
return properties
def input_service_host_addresses():
addresses = {}
print("Service Host Addresses")
print("Requires http prefix 'http://")
addresses[storage_service_host_url]=input(storage_service_host_url + "=")
addresses[iguassu_service_host_url]=input(iguassu_service_host_url + "=")
addresses[arrebol_service_host_url]=input(arrebol_service_host_url + "=")
addresses[web_ui_host_url]=input(web_ui_host_url + "=")
return addresses
def get_monitors_periods():
periods = {}
periods[job_state_monitor_period]=5000
periods[session_monitor_period]=3600000
periods[job_submission_monitor_period]=5000
return periods
def write_conf_file(confs, path, file_name):
os.chdir(path)
f = open(file_name, "w+")
for key, value in confs.items():
f.write(str(key)+"="+str(value)+"\n")
f.close()
os.chdir("..")
def get_web_ui_conf(confs):
ui_conf = {}
ui_conf[VUE_APP_EXTERNAL_LINK_DOCS] = "https://nicedoc.io/ufcg-lsd/iguassu"
ui_conf[VUE_APP_EXTERNAL_LINK_GITHUB_REPO] = "https://github.com/ufcg-lsd/iguassu"
ui_conf[VUE_APP_EXTERNAL_LINK_ABOUT] = "http://cloudlab-brasil.rnp.br/iguassu"
ui_conf[VUE_APP_OWNCLOUD_SERVER_HOST] = confs[storage_service_host_url]
ui_conf[VUE_APP_OWNCLOUD_OAUTH_CLIENT_ID] = confs[oauth_storage_service_client_id]
ui_conf[VUE_APP_OWNCLOUD_OAUTH_SECRET] = confs[oauth_storage_service_client_secret]
ui_conf[VUE_APP_OWNCLOUD_OAUTH_REDIRECT_URI] = confs[web_ui_host_url] + "/auth"
ui_conf[VUE_APP_IGUASSU_API] = confs[iguassu_service_host_url]
return ui_conf
def write_web_ui_conf(confs, web_ui_dir_name):
ui_confs = get_web_ui_conf(confs)
write_conf_file(ui_confs, web_ui_dir_name, ".env")
def write_iguassu_conf(confs, iguassu_dir_name):
confs.pop(web_ui_host_url, None)
write_conf_file(confs, iguassu_dir_name, "iguassu.conf")
def main():
print("---> Run with python 3 and in sudo mode\n")
print("---> Installing Iguassu System Service\n")
print("---> Requirements:\n------> OpenJDK8\n------> Maven\n------> Node < 11\n------> Yarn\n")
reply = input("Do you meet all the requirements?(y/n):").lower().strip()
if reply == "y":
print("Configure the following settings...\n")
ds_properties = input_datastore_properties()
host_addresses = input_service_host_addresses()
monitors_periods = get_monitors_periods()
confs = {**ds_properties, **host_addresses, **monitors_periods}
try:
install_iguassu()
install_arrebol()
install_web_ui()
write_web_ui_conf(confs, iwi_dir_name)
write_iguassu_conf(confs, iguassu_dir_name)
except:
print(FAIL + "An exception was thrown during an installation." + ENDC)
print(FAIL + "Rolling back..." + ENDC)
shutil.rmtree(iguassu_dir_name, ignore_errors=True)
shutil.rmtree(arrebol_dir_name, ignore_errors=True)
shutil.rmtree(iwi_dir_name, ignore_errors=True)
else:
sys.exit(0)
if __name__ == "__main__":
main()