-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstartDeployGUIContainer
More file actions
executable file
·168 lines (149 loc) · 5.07 KB
/
startDeployGUIContainer
File metadata and controls
executable file
·168 lines (149 loc) · 5.07 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
#!/usr/bin/python3
# -----------------------------------------------------------------------------
# Licensed Materials - Property of IBM
#
# (C) Copyright IBM Corp. 2024 All Rights Reserved
#
# US Government Users Restricted Rights - Use, duplication or disclosure
# restricted by GSA ADP Schedule Contract with IBM Corp.
#
# -----------------------------------------------------------------------------
#
# File name: startDeployGUIContainer
# Description: It creates a sanitized deployguimgr.yml based on input and system
# -----------------------------------------------------------------------------
#
# Changelog:
# YYYY/MM/DD
# 2024/04/03 0.1 Initial Creation
# -----------------------------------------------------------------------------
import sys
import argparse
from classes.deployguimgr_yml import deployguimgr_yml
import os
import shutil
ownFile = __file__
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument(
'-v',
'--verbose',
action='store_true',
dest='verbose',
help='Display verbose messages in the console..',
default=False)
parser.add_argument(
'-f',
'--file-name',
action='store',
dest='filename',
help='Restore the container from a local tar file. (defult: SSSDEPLOYGUI.tar)',
default=None)
parser.add_argument(
'-p',
'--port',
action='store',
dest='port',
help='Port on which the Deploy from GUI server listens. (default: 30443)',
default=None)
parser.add_argument(
'-ap',
'--api-port',
action='store',
dest='api_port',
help='Port on which the API server listens. (default: 46443)',
default=None)
parser.add_argument(
'-i',
'--campus-interface',
action='store',
dest='campus_interface',
help='Name of the interface connected to the campus network. (default: campus)',
default=None)
parser.add_argument(
'-vn',
'--image-version',
action='store',
dest='image_version',
help='API Server version to be deployed. (default: 7.0.0.2)',
default=None)
args = parser.parse_args()
return args.verbose, args.filename, args.port, args.api_port, args.campus_interface, args.image_version
def copyLogs():
baseVarLogDirExists = os.path.isdir("/var/log/deploygui")
if baseVarLogDirExists:
startRCLcontVarLogExists = os.path.isdir("/var/log/deploygui/startDeployGUIContainer")
if not startRCLcontVarLogExists:
os.mkdir("/var/log/deploygui/startDeployGUIContainer")
logsExists = os.path.isdir("logs")
if not logsExists:
os.mkdir("logs")
for logFile in os.listdir("logs"):
srcLogFile = "logs/" + logFile
dstLogFile = "/var/log/deploygui/startDeployGUIContainer/" + logFile
if os.path.isfile(srcLogFile):
shutil.copy(srcLogFile, dstLogFile)
def main():
verbose, filename, port, api_port, campus_interface, image_version = parse_arguments()
our_yml = deployguimgr_yml(
verbose,
filename,
port,
api_port,
campus_interface,
image_version
)
# We need to ensure exit before this if clean up
our_yml.run_log.debug(
"Going to invoke input data method from main program"
)
entries_NOK = our_yml.startDeployGUIContainer()
if entries_NOK:
our_yml.run_log.error(
"The file has been written but does not " +
"pass the checks. You CANNOT continue with the next steps. " +
"Check the ERROR messages above to " +
"understand which tests failed and fix them. " +
"You can run this tool again, the data you entered will " +
"be shown as default entries."
)
sys.exit(1)
else:
our_yml.run_log.debug(
"Could generate the needed information into YML, " +
"going to start the Deployment GUI container"
)
our_yml.run_log.debug(
"Going to prepare the container"
)
canPrep = our_yml.prep_container()
our_yml.run_log.debug(
"back from prepare the container"
)
if canPrep:
could_start = our_yml.start_container()
if could_start:
our_yml.run_log.info(
"We are back from the container run. " +
"To start a new container again run " +
ownFile
)
sys.exit(0)
else:
our_yml.run_log.info(
"They had been some issues on the run, " +
"check the above messages and follow up with " +
"using './startDeployGUIContainer'."
)
sys.exit(5)
else:
our_yml.run_log.error(
"Could not prepare the container"
)
sys.exit(6)
if __name__ == '__main__':
try:
main()
copyLogs()
finally:
copyLogs()