|
@@ -8,6 +8,8 @@ CREATION_SCRIPT='../scripts/create_instance.sh'
|
8
|
8
|
INSTALL_TPL = './slim_ressources/slim_install_model'
|
9
|
9
|
EMFILE = './slim_ressources/emfile.pickle'
|
10
|
10
|
|
|
11
|
+CONFFILE='conf.d/lodel2.ini'
|
|
12
|
+
|
11
|
13
|
import os, os.path
|
12
|
14
|
import sys
|
13
|
15
|
import shutil
|
|
@@ -129,13 +131,34 @@ def save_datas(datas):
|
129
|
131
|
with open(STORE_FILE, 'w+') as sfp:
|
130
|
132
|
json.dump(datas, sfp)
|
131
|
133
|
|
|
134
|
+##@return conffile path
|
|
135
|
+def get_conffile(name):
|
|
136
|
+ validate_names([name])
|
|
137
|
+ store_datas = get_store_datas()
|
|
138
|
+ return os.path.join(store_datas[name]['path'], CONFFILE)
|
|
139
|
+
|
132
|
140
|
##@brief Print the list of instances and exit
|
133
|
141
|
def list_instances(verbosity):
|
|
142
|
+ verbosity = 0 if verbosity is None else verbosity
|
134
|
143
|
if not os.path.isfile(STORE_FILE):
|
135
|
144
|
print("No store file, no instances are existing. Exiting...",
|
136
|
145
|
file=sys.stderr)
|
137
|
146
|
exit(0)
|
|
147
|
+ store_datas = get_store_datas()
|
138
|
148
|
print('Instances list :')
|
|
149
|
+ for name in store_datas:
|
|
150
|
+ msg = "\t- '%s'" % name
|
|
151
|
+ if verbosity > 0:
|
|
152
|
+ msg += ' path = "%s"' % store_datas[name]['path']
|
|
153
|
+ if verbosity > 1:
|
|
154
|
+ ruler = (''.join(['=' for _ in range(20)])) + "\n"
|
|
155
|
+ msg += "\n\t\t====conf.d/lodel2.ini====\n"
|
|
156
|
+ with open(get_conffile(name)) as cfp:
|
|
157
|
+ for line in cfp:
|
|
158
|
+ msg += "\t\t"+line
|
|
159
|
+ msg += "\t\t=========================\n"
|
|
160
|
+
|
|
161
|
+ print(msg)
|
139
|
162
|
exit(0)
|
140
|
163
|
|
141
|
164
|
##@brief Returns instanciated parser
|
|
@@ -148,6 +171,13 @@ def get_parser():
|
148
|
171
|
help='list existing instances and exit', action='store_const',
|
149
|
172
|
const=True, default=False)
|
150
|
173
|
parser.add_argument('-v', '--verbose', action='count')
|
|
174
|
+
|
|
175
|
+ selector.add_argument('-a', '--all', action='store_const',
|
|
176
|
+ default=False, const=True,
|
|
177
|
+ help='Select all instances')
|
|
178
|
+ selector.add_argument('-n', '--name', metavar='NAME', type=str, nargs='*',
|
|
179
|
+ help="Specify an instance name")
|
|
180
|
+
|
151
|
181
|
actions.add_argument('-c', '--create', action='store_const',
|
152
|
182
|
default=False, const=True,
|
153
|
183
|
help="Create a new instance with given name (see -n --name)")
|
|
@@ -157,11 +187,9 @@ def get_parser():
|
157
|
187
|
actions.add_argument('-e', '--edit-config', action='store_const',
|
158
|
188
|
default=False, const=True,
|
159
|
189
|
help='Edit configuration of specified instance')
|
160
|
|
- selector.add_argument('-a', '--all', action='store_const',
|
|
190
|
+ actions.add_argument('-i', '--interactive', action='store_const',
|
161
|
191
|
default=False, const=True,
|
162
|
|
- help='Select all instances')
|
163
|
|
- selector.add_argument('-n', '--name', metavar='NAME', type=str, nargs='*',
|
164
|
|
- help="Specify an instance name")
|
|
192
|
+ help='Run a loader.py from ONE instance in foreground')
|
165
|
193
|
actions.add_argument('--stop', action='store_const',
|
166
|
194
|
default=False, const=True, help="Stop instances")
|
167
|
195
|
actions.add_argument('--start', action='store_const',
|
|
@@ -213,7 +241,14 @@ specified")
|
213
|
241
|
validate_names(names)
|
214
|
242
|
name = names[0]
|
215
|
243
|
store_datas = get_store_datas()
|
216
|
|
- conffile = os.path.join(store_datas[name]['path'], 'conf.d')
|
217
|
|
- conffile = os.path.join(conffile, 'lodel2.ini')
|
|
244
|
+ conffile = get_conffile(name)
|
218
|
245
|
os.system('editor "%s"' % conffile)
|
219
|
246
|
exit(0)
|
|
247
|
+ elif args.interactive:
|
|
248
|
+ if args.name is None or len(args.name) != 1:
|
|
249
|
+ print("\n-i option only allowed with ONE instance name")
|
|
250
|
+ validate_names(args.name)
|
|
251
|
+ name = args.name[0]
|
|
252
|
+ store_datas = get_store_datas()
|
|
253
|
+ os.chdir(store_datas[name]['path'])
|
|
254
|
+ os.execl('/usr/bin/env', '/usr/bin/env', 'python3', 'loader.py')
|