11import argparse
22
33from src .common import validate_collections , get_collections_data , write_global_docker_file , \
4- write_collections_docker_files , write_python_settings_files , write_env_files
4+ write_collections_docker_files , write_python_settings_files , write_env_files ,\
5+ update_collections_settings , write_collections_settings ,\
6+ get_collections_data_old , collections_settings_file_name
7+ import os
58
69
710def get_args ():
@@ -24,6 +27,14 @@ def get_args():
2427 help = 'Remove profiling settings for the given collections. ' +
2528 'If no collections were specified profiling will be disabled for all.' )
2629
30+ profiling = parser .add_mutually_exclusive_group ()
31+ profiling .add_argument ('-t' , '--tracing' , action = 'append' , nargs = '*' ,
32+ help = 'Add tracing settings for the given collections. ' +
33+ 'If no collections were specified the tracing will be enabled for all.' )
34+ profiling .add_argument ('-z' , '--no-tracing' , action = 'append' , nargs = '*' ,
35+ help = 'Remove tracing settings for the given collections. ' +
36+ 'If no collections were specified the tracing will be disabled for all.' )
37+
2738 autoindex = parser .add_mutually_exclusive_group ()
2839 autoindex .add_argument ('-a' , '--autoindex' , action = 'append' , nargs = '*' ,
2940 help = 'Enable automatic indexing for the given collections. ' +
@@ -32,13 +43,6 @@ def get_args():
3243 help = 'Enable automatic indexing for the given collections. ' +
3344 'If no collections were specified auto-indexing will be disabled for all.' )
3445
35- stats = parser .add_mutually_exclusive_group ()
36- stats .add_argument ('--enable-stats' , action = 'append' , nargs = '*' ,
37- help = 'Enable kibana stats for the given collections. ' +
38- 'If no collections were specified kibana will be enabled for all.' )
39- stats .add_argument ('--disable-stats' , action = 'append' , nargs = '*' ,
40- help = 'Disable kibana stats for the given collections. ' +
41- 'If no collections were specified kibana will be disabled for all.' )
4246 return parser .parse_args ()
4347
4448
@@ -58,24 +62,38 @@ def read_collections_arg(add_list, remove_list, all_collections):
5862
5963
6064def update_settings (args ):
61- collections = get_collections_data ()['collections' ]
65+ if not os .path .isfile (collections_settings_file_name ):
66+ data = get_collections_data_old ()
67+ else :
68+ data = get_collections_data ()
69+
70+ collections = data ['collections' ]
6271 if len (collections ):
6372 validate_collections (collections )
6473
6574 collections_names = set (collections .keys ())
75+
76+ indexing , disable_indexing = read_collections_arg (args .autoindex , args .manual_indexing ,
77+ collections_names )
78+ update_collections_settings (data , {'autoindex' : not disable_indexing }, indexing )
79+
6680 profiling , remove_profiling = read_collections_arg (args .profiling , args .no_profiling ,
6781 collections_names )
82+ update_collections_settings (data , {'profiling' : not remove_profiling }, profiling )
83+
84+ tracing , disable_tracing = read_collections_arg (args .tracing , args .no_tracing ,
85+ collections_names )
86+ update_collections_settings (data , {'tracing' : not disable_tracing }, tracing )
87+
6888 for_dev , remove_dev = read_collections_arg (args .dev , args .remove_dev , collections_names )
69- indexing , disable_indexing = read_collections_arg (args .autoindex , args .manual_indexing ,
70- collections_names )
71- stats , disable_stats = read_collections_arg (args .enable_stats , args .disable_stats , collections_names )
72-
73- stats_clients = write_env_files (collections , stats , disable_stats )
74- write_python_settings_files (collections , profiling , remove_profiling , for_dev , remove_dev )
75- dev_instances = write_collections_docker_files (collections , args .snoop_image , profiling ,
76- remove_profiling , for_dev , remove_dev ,
77- indexing , disable_indexing , stats , disable_stats )
78- write_global_docker_file (collections , bool (dev_instances ), bool (stats_clients ))
89+ update_collections_settings (data , {'for_dev' : not remove_dev }, for_dev )
90+
91+ write_env_files (collections )
92+
93+ write_python_settings_files (collections )
94+ dev_instances = write_collections_docker_files (collections )
95+ write_global_docker_file (collections , bool (dev_instances ))
96+ write_collections_settings (collections )
7997
8098 print ('Restart docker-compose:' )
8199 print (' $ docker-compose down && docker-compose up -d' )
0 commit comments