-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeployguimgr
More file actions
executable file
·575 lines (499 loc) · 25 KB
/
deployguimgr
File metadata and controls
executable file
·575 lines (499 loc) · 25 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
#!/usr/bin/python3
import sys
import os
import subprocess
import argparse
from argparse import RawTextHelpFormatter
import time
import datetime
from string import *
import yaml
# -----------------------------------------------------------------------------
# Read container config
# -----------------------------------------------------------------------------
def readconf(input0):
global cfg
global UTILITY_HOSTNAME
global IMAGE_NAME
global IMAGE_VERSION
global API_PORT
global DEPLOY_GUI_PORT
global SSH_PORT
UTILITY_HOSTNAME = None
IMAGE_NAME = None
IMAGE_VERSION = None
API_PORT = None
DEPLOY_GUI_PORT = None
SSH_PORT = None
with open(input0.config_file, 'r') as ymlfile:
# cfg = yaml.safe_load(ymlfile, Loader=yaml.SafeLoader)
cfg = yaml.safe_load(ymlfile)
# Utility hostname
if "UTILITY_HOSTNAME" in cfg["CONTAINER"]:
UTILITY_HOSTNAME = cfg["CONTAINER"]["UTILITY_HOSTNAME"]
if UTILITY_HOSTNAME is None:
print("-- [ERROR] Utility hostname should be provided inside deployguimgr.yml file... --")
sys.exit(1)
# Image Name
if "IMAGE_NAME" in cfg["CONTAINER"]:
IMAGE_NAME = str(cfg["CONTAINER"]["IMAGE_NAME"])
if IMAGE_NAME is None:
print("-- [ERROR] Image name should be provided inside deployguimgr.yml file... --")
sys.exit(1)
# Image Version
if "IMAGE_VERSION" in cfg["CONTAINER"]:
IMAGE_VERSION = str(cfg["CONTAINER"]["IMAGE_VERSION"])
if IMAGE_VERSION is None:
print("-- [ERROR] Image version should be provided inside deployguimgr.yml file... --")
sys.exit(1)
# ESS API Server Port, default 46443
if "API_PORT" in cfg["CONTAINER"]:
API_PORT = str(cfg["CONTAINER"]["API_PORT"])
if API_PORT is None:
print("-- [ERROR] API Server port should be provided inside apimgr.yml file... --")
sys.exit(1)
# ESS Deployment GUI Server Port, default 9090
if "DEPLOY_GUI_PORT" in cfg["CONTAINER"]:
DEPLOY_GUI_PORT = str(cfg["CONTAINER"]["DEPLOY_GUI_PORT"])
if DEPLOY_GUI_PORT is None:
print("-- [ERROR] Deployment GUI Server port should be provided inside deployguimgr.yml file... --")
sys.exit(1)
# ESS Deployment GUI container SSH Port, default 30022
if "SSH_PORT" in cfg["CONTAINER"]:
SSH_PORT = str(cfg["CONTAINER"]["SSH_PORT"])
if SSH_PORT is None:
SSH_PORT = "30022"
checkdir()
# -----------------------------------------------------------------------------
# Check if required directories exists
# -----------------------------------------------------------------------------
def checkdir():
if not (os.path.isdir(cfg["CONTAINER"]["LOG"])):
os.makedirs(cfg["CONTAINER"]["LOG"])
print("-- [INFO] Log directory does not exist, created now --")
if not (os.path.isdir(cfg["CONTAINER"]["BKUP"])):
os.makedirs(cfg["CONTAINER"]["BKUP"])
print("-- [INFO] Backup directory does not exist, created now --")
# -----------------------------------------------------------------------------
# Depreciation warning
# -----------------------------------------------------------------------------
def deployguimgr_EOL_warning():
ALLOW_DEPLOYGUIMGR = os.getenv('ALLOW_DEPLOYGUIMGR')
if ALLOW_DEPLOYGUIMGR is None:
print("-- [ERROR] You cannot run deployguimgr directly, use startContainer instead")
print(" If you still want to run deployguimgr directly, set ALLOW_DEPLOYGUIMGR to value 1 on the shell")
print(" but be aware this is not supported and any error you encounter you need to run with startContainer")
time.sleep(2)
sys.exit(1)
elif ALLOW_DEPLOYGUIMGR == "1":
print(
"-- [WARNING] You should not run deployguimgr directly, use startContainer instead")
print(
"-- [WARNING] deployguimgr it is going to be depreciated in a future release")
print(
"-- [WARNING] Be aware that any error you encounter you need to reproduce running startContainer")
time.sleep(5)
else:
print("-- [ERROR] You cannot run deployguimgr directly, use startContainer instead")
print(" If you still want to run deployguimgr directly, set ALLOW_DEPLOYGUIMGR to value 1 on the shell")
print(" Now it has a value but it is not set to '1'.")
print(" Be aware this is not supported and any error you encounter you need to run with startContainer")
time.sleep(2)
sys.exit(1)
# -----------------------------------------------------------------------------
# Clean nftables
# -----------------------------------------------------------------------------
def clean_nftables():
if ( subprocess.call("which nft > /dev/null 2>&1", shell=True) == 0 ):
cmd = "nft -a list chain ip nat PREROUTING 2> /dev/null | grep 'NETAVARK-HOSTPORT-DNAT' > /dev/null 2>&1 && " + \
"nft delete rule ip nat PREROUTING handle " + \
"$(nft -a list chain ip nat PREROUTING | grep 'NETAVARK-HOSTPORT-DNAT' " + \
"| awk '{print $(NF)}') 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft -a list chain ip nat OUTPUT 2> /dev/null | grep 'NETAVARK-HOSTPORT-DNAT' > /dev/null 2>&1 && " + \
"nft delete rule ip nat OUTPUT handle " + \
"$(nft -a list chain ip nat OUTPUT | grep 'NETAVARK-HOSTPORT-DNAT' " + \
"| awk '{print $(NF)}') 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft delete chain ip nat NETAVARK-HOSTPORT-DNAT 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft -a list chain ip nat POSTROUTING 2> /dev/null | grep 'NETAVARK-HOSTPORT-MASQ' > /dev/null 2>&1 && " + \
"nft delete rule ip nat POSTROUTING handle " + \
"$(nft -a list chain ip nat POSTROUTING | grep 'NETAVARK-HOSTPORT-MASQ' " + \
"| awk '{print $(NF)}') 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft delete chain ip nat NETAVARK-HOSTPORT-MASQ 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft delete chain ip nat NETAVARK-DN-1D8721804F16F 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft delete chain ip nat NETAVARK-HOSTPORT-SETMARK 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft -a list chain ip nat POSTROUTING 2> /dev/null | grep 'NETAVARK-1D8721804F16F' > /dev/null 2>&1 && " + \
"nft delete rule ip nat POSTROUTING handle " + \
"$(nft -a list chain ip nat POSTROUTING | grep 'NETAVARK-1D8721804F16F' " + \
"| awk '{print $(NF)}') 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft delete chain ip nat NETAVARK-1D8721804F16F 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft -a list chain ip filter FORWARD 2> /dev/null | grep 'NETAVARK_FORWARD' > /dev/null 2>&1 && " + \
"nft delete rule ip filter FORWARD handle " + \
"$(nft -a list chain ip filter FORWARD | grep 'NETAVARK_FORWARD' " + \
"| awk '{print $(NF)}') 2> /dev/null || true"
subprocess.call(cmd, shell=True)
cmd = "nft delete chain ip filter NETAVARK_FORWARD 2> /dev/null || true"
subprocess.call(cmd, shell=True)
# -----------------------------------------------------------------------------
# Run Container
# -----------------------------------------------------------------------------
def run_container(force, is_startdeployguicont=False):
global UTILITY_HOSTNAME
global DEPLOY_GUI_PORT
global SSH_PORT
global IMAGE_NAME
global IMAGE_VERSION
rc = 1
if not is_startdeployguicont:
deployguimgr_EOL_warning()
print("-- [INFO] Running the container image - " + IMAGE_NAME + ":" +
str(IMAGE_VERSION))
if force:
print(
"-- [WARNING] The '-x' or '--force’ option removes containers that are in the EXIT state. --")
cmd = "systemctl --user stop container-" +cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + " && "\
"podman container rm -f " + cfg["CONTAINER"]["CONTAINER_HOSTNAME"]
subprocess.call(cmd, shell=True)
cmd = "podman ps -a --format {{.Names}} --filter name=" + \
cfg["CONTAINER"]["CONTAINER_HOSTNAME"]
returned_output = subprocess.check_output(cmd, shell=True)
if (returned_output != "".encode()):
print("-- [INFO] Container \'" +
cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + "\' already exists --")
cmd = "podman ps -a --format {{.Status}} --filter name=" + \
cfg["CONTAINER"]["CONTAINER_HOSTNAME"]
returned_output = subprocess.check_output(cmd, shell=True)
if "Exited".encode() in returned_output:
# Deleting all Virtual interface related to Management Interface
# cleanup_virtual_interfaces()
print(
"-- [INFO] Already installed container found on EXIT state. " +
"Trying to restart the existing container --"
)
print(
"-- [INFO] It will be a same old container which was " +
"exited earlier with all data intact --"
)
time.sleep(3)
clean_nftables()
cmd = "systemctl --user start container-" + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + ".service "
subprocess.call(cmd, shell=True)
elif "Created".encode() in returned_output:
# Deleting all Virtual interface related to Management Interface
# cleanup_virtual_interfaces()
print(
"-- [INFO] Already installed container found on CREATED state. " +
"Trying to start the existing container --")
time.sleep(3)
clean_nftables()
cmd = "systemctl --user start container-" + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + ".service "
subprocess.call(cmd, shell=True)
else:
print(
"-- [INFO] Container with ACTIVE state found. Trying to attach the existing container --")
print("-- [INFO] Container resumed/started. Check \"systemctl --user status container-" + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + ".service\" ")
print("-- [INFO] Re-login to container using \"podman exec -it " + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + " /bin/bash\" command --")
else:
# Deleting all Virtual interface related to Management Interface
# cleanup_virtual_interfaces()
print("-- [INFO] Automatic initialization of the container will begin shortly --")
print("-- [INFO] Startup can take several minutes. --")
time.sleep(3)
clean_nftables()
# ------------------------------------
# Forming correct podman create command.
# ------------------------------------
cmd = "podman create --privileged --syslog" + \
" --hostname=\"" + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + '.' + cfg["CONTAINER"]["CONTAINER_DOMAIN_NAME"] + "\"" + \
" --name " + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + \
" -v /dev/log:/dev/log" + \
" -v /var/log/messages:/var/log/messages" + \
" -v " + cfg["CONTAINER"]["LOG"] + ":/var/log/" + \
" -v " + cfg["CONTAINER"]["BKUP"] + ":/home/backup/" + \
" -v /sys/fs/cgroup:/sys/fs/cgroup:ro"
container_env_details = \
" --env \"API_CONTAINER_PORT=" + API_PORT + "\"" + \
" --env \"DEPLOY_FROM_GUI_CONTAINER=Y\"" + \
" --env \"UTILITY_HOSTNAME=" + UTILITY_HOSTNAME + "\"" + \
" --env \"UTILITY_CAMPUS_IP=" + cfg["CONTAINER"]["CAMPUS_INTERFACE_IP"] + "\"" + \
" --env \"UTILITY_RAS_IP=" + cfg["CONTAINER"]["RAS_INTERFACE_IP"] + "\"" + \
" --env \"CONTAINER_HOSTNAME=" + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + "\"" + \
" --env \"CONTAINER_DOMAIN_NAME=" + cfg["CONTAINER"]["CONTAINER_DOMAIN_NAME"] + "\"" \
" --env \"CONTAINER_VERSION=" + IMAGE_VERSION + "\""
if "CONTAINER_NETWORK_NAME" in cfg["CONTAINER"]:
network = " --net " + \
cfg["CONTAINER"]["CONTAINER_NETWORK_NAME"] + " "
cmd += network
cmd += container_env_details
container_ports_details = " -p " + DEPLOY_GUI_PORT + ":" + "443" + "/tcp" + \
" -p " + SSH_PORT + ":" + "22" + "/tcp"
cmd += container_ports_details
cmd += " --sysctl net.ipv6.conf.all.disable_ipv6=1"
cmd += " " + IMAGE_NAME + ":" + str(IMAGE_VERSION)
rc = subprocess.call(cmd, shell=True)
if rc != 0:
print("-- [ERROR] Failed to create container --")
print("-- Exiting... --")
sys.exit(rc)
print("-- [INFO] The deployment GUI container is being configured to start as a systemd service. --")
print("-- [INFO] SSS Deployment GUI Container is set to autostart --")
service_file = "container-" + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + ".service"
cmd = "cd ~; "
cmd += "podman generate systemd --files --name " + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + "; "
cmd += "sed -i '/ExecStart=/i ExecStartPre=/bin/bash -c \"until systemctl --machine=%u@.host is-active network-online.target; do sleep 2; done; until ping -c 2 127.0.0.1; do sleep 2; done; sleep 5\"' " + service_file + " ; "
cmd += "mkdir -p ~/.config/systemd/user; "
cmd += "cp -f ~/" + service_file + " ~/.config/systemd/user/ ; "
cmd += "rm -f ~/" + service_file + " ; "
cmd += "systemctl --user enable " + service_file + " ; "
cmd += "loginctl enable-linger deployguiadmin ; "
# cmd += "systemctl --user status container-"+ cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + ".service"
rc = subprocess.call(cmd, shell=True)
if rc != 0:
print("-- [ERROR] Failed to setup container into systemd services --")
print("-- Exiting... --")
sys.exit(rc)
print("-- [INFO] The container was created successfully in the background. To start this container, run the \"systemctl --user start container-" + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + ".service\" command. --")
print("-- [INFO] To log in to the container, run the \"podman exec -it " + cfg["CONTAINER"]["CONTAINER_HOSTNAME"] + " /bin/bash\" command. --")
return rc
# -----------------------------------------------------------------------------
# Install Image
# -----------------------------------------------------------------------------
def install_image_from_file(image_file_name, force):
global IMAGE_NAME
global IMAGE_VERSION
rc = 1
if force:
print("-- [WARNING] Running image installation with -x or --force option will remove older IMAGE forcibly --")
cmd = "podman image rm -f " + IMAGE_NAME + ":" + IMAGE_VERSION
rc = subprocess.call(cmd, shell=True)
if rc != 0:
print("-- [INFO] Removal of the podman image failed. Image doesn't exist... --")
rc = 0
# RESTORE CONTAINER IMAGE
print("-- [INFO] Installing container image " + image_file_name)
cmd = "podman image load -i " + image_file_name
returned_output = str(
subprocess.check_output(
cmd, shell=True), 'utf-8')
# img_tag=$(echo "Loaded image: cp.icr.io/cp/scalesystem/sss_deploygui:6.2.3.0" | grep "Loaded image" | awk -F": " '{print $2}')
cmd = "echo \"" + returned_output.rstrip() + "\" | grep \"Loaded image\" | awk -F\": \" '{print $2}'"
_image_url = str(subprocess.check_output(cmd, shell=True), 'utf-8').strip()
cmd = "podman images -nq " + _image_url
IMAGE_ID = str(subprocess.check_output(cmd, shell=True), 'utf-8').strip()
if IMAGE_ID != "":
print("-- [INFO] Successfully restored image " + image_file_name + " into local machine with image url " + _image_url + ", image id is " + IMAGE_ID)
rc = 0
else:
print("--[ERROR] Failed to restore image " + image_file_name + " into local machine with url " + _image_url)
rc = 1
sys.exit(1)
return rc
# -----------------------------------------------------------------------------
# Install Image
# -----------------------------------------------------------------------------
def install_image_from_repo(force):
global IMAGE_NAME
global IMAGE_VERSION
rc = 1
print("-- [INFO] The container image is about to be pulled from the IBM repository. --")
if IMAGE_VERSION == None:
print("-- [ERROR] Image version should be provided inside deployguimgr.yml file... --")
sys.exit(1)
cmd = ""
if force:
print("-- [WARNING] The existing container image " + IMAGE_NAME + ":" + IMAGE_VERSION + "is being deleted forcefully. --")
cmd = "podman image rm -f " + IMAGE_NAME + ":" + IMAGE_VERSION
rc = subprocess.call(cmd, shell=True)
if rc != 0:
print("-- [INFO] Removal of the podman image failed. Image doesn't exist... --")
rc = 0
cmd = "podman pull " + IMAGE_NAME + ":" + IMAGE_VERSION
rc = subprocess.call(cmd, shell=True)
if rc != 0:
print("-- [ERROR] Failed to pull service container image from IBM repository... --")
print("-- [ERROR] Login to IBM Container Repository using podman login command before starting container --")
print("-- Exiting... --")
rc = 1
sys.exit(1)
else:
print("-- [INFO] The container image was pulled successfully. --")
rc = 0
return rc
# -----------------------------------------------------------------------------
# Check for enough free space
# -----------------------------------------------------------------------------
def free_space_check():
print("-- [INFO] Checking if enough free space in /home --")
free_space_check = "df -k --output=avail /home | tail -n1"
output = subprocess.check_output(free_space_check, shell=True)
# print(int(output))
if (int(output) > 2000000):
print("-- [INFO] Free space check PASSED --")
else:
print(
"-- [ERROR] Not enough space in /home - Fix and re-run installer --")
sys.exit(1)
# -----------------------------------------------------------------------------
# Check for podman installation
# -----------------------------------------------------------------------------
def check_for_podman():
print(
"-- [INFO] Checking for podman version installed or needs update on node --")
cmd = "cat /etc/redhat-release"
output = subprocess.check_output(cmd, shell=True)
returned_output = output.rstrip()
if "Red Hat Enterprise Linux release 8.8 (Ootpa)" in returned_output:
print("Upgrading podman for RHEL 8 if required...")
cmd = "tar zxvf podman_rh8.tgz ; cd data/podman_rh8/ ; yum -y install podman* > /dev/null 2>&1"
subprocess.call(cmd, shell=True)
cmd = "podman --version"
subprocess.call(cmd, shell=True)
print(returned_output)
# -----------------------------------------------------------------------------
# create_network
# Create podman CNI network.
# -----------------------------------------------------------------------------
def create_network(network_name):
cmd = "podman network create " + network_name
rc = subprocess.call(cmd, shell=True)
if rc != 0:
print(
"-- [ERROR] Unable to cretae the podman CNI network " +
network_name +
" --")
print(
"-- [ERROR] Network either exist or some issue with network creation. --")
return rc
# -----------------------------------------------------------------------------
# delete_network
# Delete the podman CNI network.
# -----------------------------------------------------------------------------
def delete_network(network_name):
cmd = "podman network remove " + network_name
rc = subprocess.call(cmd, shell=True)
if rc != 0:
print(
"-- [ERROR] Unable to delete the podman CNI network " +
network_name +
" --")
print(
"-- [ERROR] Network either exist and in use by container or some issue with network creation. --")
print("-- [ERROR] Inspect the running container. Verify that the network is not in use before deletion. --")
return rc
# -----------------------------------------------------------------------------
# main
# -----------------------------------------------------------------------------
def main():
global IMAGE_NAME
global IMAGE_VERSION
parser = argparse.ArgumentParser(
epilog='This script run Deployment GUI container on IBM Utility host to serve Deployment GUI Panels.')
parser.add_argument('-c', '--config', action='store',
default="deployguimgr.yml", dest='config_file',
required=False,
help='Specify custom Config file name. '
'Default: deployguimgr.yml')
parser.add_argument('-x', '--force', action='store_true',
default=False, dest='force',
required=False,
help='Container operation with force.')
mutual_group = parser.add_mutually_exclusive_group(required=True)
mutual_group.add_argument('-i', '--install', action='store_true',
default=False, dest='install',
required=False,
help='Install container image.')
parser.add_argument('-f', '--file', action='store',
default=None, dest='image_file_name',
required=False,
help='Specify the Image file name in tarball format.')
mutual_group.add_argument('-n', '--create-network', action='store_true',
default=False, dest='create_network',
required=False,
help='Creates podman CNI network other than default podman CNI network')
parser.add_argument('-net', '--network-name', action='store',
default="deploygui_network", dest='network_name',
required=False,
help='Creates podman CNI network with default name deploygui_network.')
mutual_group.add_argument('-r', '--run', action='store_true',
default=False, dest='run',
required=False,
help='Runs SSS Deployment GUI Container.')
input0 = parser.parse_args()
readconf(input0)
ALLOW_DEPLOYGUIMGR = os.getenv('ALLOW_DEPLOYGUIMGR')
if ALLOW_DEPLOYGUIMGR is None:
print(
"-- [WARNING] The tool 'deployguimgr' has been deprecated from 6.2.3.0 and newer. " +
"Use 'startDeployGUIContainer' instead. --"
)
sys.exit(0)
elif ALLOW_DEPLOYGUIMGR == "1":
print(
"-- [WARNING] The tool 'deployguimgr' has been deprecated from 6.2.3.0 and newer. " +
"Proceeding to use deployguimgr since you are focing it by export ALLOW_DEPLOYGUIMGR=1. " +
"PAvoid using this flag out of an IBM facility. --"
)
else:
print(
"-- [WARNING] The tool 'deployguimgr' has been deprecated from 6.2.3.0 and newer. " +
"Use 'startDeployGUIContainer' instead. --"
)
sys.exit(0)
# -------------------
# Install Image
# -------------------
if input0.install:
if (input0.image_file_name is None and IMAGE_NAME is None):
print("-- [ERROR] Image tarball name using -f option or IMAGE_NAME should be inside deployguimgr.yml")
sys.exit(1)
elif (input0.image_file_name is None and IMAGE_NAME is not None):
rc = install_image_from_repo(input0.force)
sys.exit(rc)
elif (input0.image_file_name is not None):
print("-- [INFO] Going to install image from local file installation method --")
rc = install_image_from_file(input0.image_file_name, input0.force)
sys.exit(rc)
else:
print("-- [ERROR] Image tarball name using -f option or IMAGE_NAME should be inside deployguimgr.yml")
sys.exit(1)
# -------------------
# Running Container
# -------------------
if input0.run:
# check_for_podman(input0)
rc = 0
rc += run_container(input0.force)
sys.exit(rc)
# -------------------
# Create EMS networks
# -------------------
if input0.create_network:
rc = delete_network(input0.network_name)
if rc != 0:
print(" --[INFO] Contunuing to create the network --")
rc += create_network(input0.network_name)
sys.exit(rc)
if __name__ == '__main__':
try:
rc1 = main()
if rc1 > 0:
sys.exit(rc1)
except KeyboardInterrupt:
print("\n", datetime.datetime.now().isoformat(),
"Current task interrupted by user. ")
sys.exit(1)
except Exception as err:
print("\n", datetime.datetime.now().isoformat(),
"Current task terminated due to exception.")
print(err)
sys.exit(1)
finally:
sys.exit(1)