diff --git a/docs/source/Explanation/CommandLineGuide.rst b/docs/source/Explanation/CommandLineGuide.rst index 6ad09967a..fc304ff10 100644 --- a/docs/source/Explanation/CommandLineGuide.rst +++ b/docs/source/Explanation/CommandLineGuide.rst @@ -70,7 +70,7 @@ the broker, or manage the configurations. - remove: remove a configuration. - disable: mark a configuration as ineligible to run. - enable: mark a configuration as eligible to run. - - convert: converts a v2 config to a v3 config. + - convert: converts v2 configs to a v3 config. For example: *sr3 foreground subscribe/dd* runs the subscribe component with @@ -103,7 +103,7 @@ started or restarted by the **start**, **foreground**, or **restart** actions. It can be used to set aside a configuration temporarily. -The **convert** action is used to translate a configuration file written with Sarracenia version 2 +The **convert** action is used to translate configuration files written with Sarracenia version 2 options into Sarracenia version 3 options. The v2 configuration file must be placed in the *~/.config/sarra/component/v2_config.conf* directory and the translated version will be placed in the *~/.config/sr3/component/v3_config.conf* directory. For example, one would invoke this action @@ -396,6 +396,11 @@ Converting a config: both formats are accepted, as well as include files:: $ sr3 convert shovel/no_trouble_f00.inc 2022-06-14 15:03:29,918 1093655 [INFO] root convert converting shovel/no_trouble_f00.inc from v2 to v3 +To overwrite an existing sr3 configuration use the *--wololo* option. +When overwriting multiple sr3 configurations, one must also use *--dangerWillRobinson=n* in the +normal way... where *n* is the number of configurations to convert. + + start ~~~~~ diff --git a/docs/source/Reference/sr3.1.rst b/docs/source/Reference/sr3.1.rst index 85c7037b2..0cb8c5359 100644 --- a/docs/source/Reference/sr3.1.rst +++ b/docs/source/Reference/sr3.1.rst @@ -61,7 +61,7 @@ The type of action to take. One of: - add: copy to the list of available configurations. - cleanup: deletes the component's resources on the server. - - convert: copy a configuration from v2 to sr3 location, updating on the way. + - convert: copy configurations from v2 to sr3 location, updating on the way. - declare: creates the component's resources on the server. - disable: mark a configuration as ineligible to run. - edit: modify an existing configuration. diff --git a/docs/source/Reference/sr3_options.7.rst b/docs/source/Reference/sr3_options.7.rst index 245270105..e4ad916b6 100644 --- a/docs/source/Reference/sr3_options.7.rst +++ b/docs/source/Reference/sr3_options.7.rst @@ -1955,6 +1955,14 @@ When an **sr3 instance** does not find the vip, it sleeps for 5 seconds and retr If it does, it consumes and processes a message and than rechecks for the vip. Multiple vips form a list, where any individual address being active is enough. +wololo +------ + +A command line option to overwite an existing sr3 configuration when converting +from v2. + + + SEE ALSO ======== diff --git a/docs/source/fr/Explication/GuideLigneDeCommande.rst b/docs/source/fr/Explication/GuideLigneDeCommande.rst index e1322e572..ff4843872 100644 --- a/docs/source/fr/Explication/GuideLigneDeCommande.rst +++ b/docs/source/fr/Explication/GuideLigneDeCommande.rst @@ -397,6 +397,11 @@ Conversion d’une configuration : les deux formats sont acceptés, ainsi que le $ sr3 convert shovel/no_trouble_f00.inc 2022-06-14 15:03:29,918 1093655 [INFO] root convert converting shovel/no_trouble_f00.inc from v2 to v3 +Pour écraser une configuration SR3 existante, utilisez l'option *--wololo*. +Lors de l'écrasement de plusieurs configurations SR3 est voulu, il faut également +utiliser *--dangerWillRobinson=n* dans le mode normale... où *n* est le nombre de configurations à convertir. + + start ~~~~~ diff --git a/docs/source/fr/Reference/sr3.1.rst b/docs/source/fr/Reference/sr3.1.rst index 6ace4469a..d33144c84 100644 --- a/docs/source/fr/Reference/sr3.1.rst +++ b/docs/source/fr/Reference/sr3.1.rst @@ -61,7 +61,7 @@ Les types d'actions disponible. Une seule parmi: - add: copier a la liste de configurations disponible. - cleanup: supprimer les ressources des composants sur le serveur. - - convert: copie et mets à jour une configuration de v2 dans le répertoire sr3. + - convert: copie et mets à jour un ou plusieurs configuration de v2 dans le répertoire sr3. - declare: crée les ressources d'un composant sur le serveur. - disbale: marquer une configuration comme non-éligible à exécuter. - edit: modifier une configuration existante. diff --git a/docs/source/fr/Reference/sr3_options.7.rst b/docs/source/fr/Reference/sr3_options.7.rst index 782a9bc41..3c6827574 100644 --- a/docs/source/fr/Reference/sr3_options.7.rst +++ b/docs/source/fr/Reference/sr3_options.7.rst @@ -1915,6 +1915,12 @@ Lorsqu’une **instance sr3** ne trouve pas l’adresse IP, elle se met en veill Si c’est le cas, elle consomme et traite un message d'annonce et revérifie pour le vip. lorsque plus qu'un vip est spécifié, n´importe lequel des addresses IP dans la liste est suffisant. +wololo +------ + +Une option de ligne de commande pour écraser une configuration SR3 existante lors de la conversion +à partir de la v2. + SEE ALSO ======== diff --git a/sarracenia/config.py b/sarracenia/config.py index 4972fa6f6..27345d711 100755 --- a/sarracenia/config.py +++ b/sarracenia/config.py @@ -122,7 +122,8 @@ def __repr__(self) -> str: 'sourceFromMessage': False, 'topicCopy': False, 'v2compatRenameDoublePost': False, - 'varTimeOffset': 0 + 'varTimeOffset': 0, + 'wololo': False } count_options = [ @@ -138,8 +139,9 @@ def __repr__(self) -> str: 'follow_symlinks', 'force_polling', 'inline', 'inlineOnly', 'inplace', 'logMetrics', 'logStdout', 'logReject', 'restore', \ 'messageDebugDump', 'mirror', 'timeCopy', 'notify_only', 'overwrite', 'post_on_start', \ 'permCopy', 'persistent', 'queueBind', 'queueDeclare', 'randomize', 'recursive', 'realpathPost', \ - 'reconnect', 'report', 'reset', 'retry_refilter', 'retryEmptyBeforeExit', 'save', 'sundew_compat_regex_first_match_is_zero', \ - 'sourceFromExchange', 'sourceFromMessage', 'topicCopy', 'statehost', 'users', 'v2compatRenameDoublePost' + 'reconnect', 'report', 'reset', 'retry_refilter', 'retryEmptyBeforeExit', 'save', + 'sundew_compat_regex_first_match_is_zero', 'sourceFromExchange', 'sourceFromMessage', 'topicCopy', + 'statehost', 'users', 'v2compatRenameDoublePost', 'wololo' ] float_options = [ ] @@ -2461,6 +2463,10 @@ def parse_args(self, isPost=False): action='store_true', default=self.debug, help='print debugging output (very verbose)') + parser.add_argument('--wololo', + action='store_true', + default=self.wololo, + help='force overwrite of converted configs') parser.add_argument('--dry_run', '--simulate', '--simulation', action='store_true', default=self.dry_run, diff --git a/sarracenia/sr.py b/sarracenia/sr.py index de7ac2be2..e8b5ff944 100755 --- a/sarracenia/sr.py +++ b/sarracenia/sr.py @@ -2623,7 +2623,26 @@ def status(self): print("exchange with no bindings: %s-%s " % (h, x), end='') def convert(self): - cfg = self.v2_config[0] + + print( f"v2_config: {self.v2_config}") + if len(self.v2_config) == 0: + print("need to specify what to convert from v2") + return + + conversion_targets = self.v2_config + if self.options.wololo and len(conversion_targets) > 1: + if len(conversion_targets) != self.options.dangerWillRobinson : + print( f" will not overwrite multiple configurations unless really sure" ) + print( f" If you are really sure, use --dangerWillRobinson={len(conversion_targets)}" ) + return + + for c in conversion_targets: + self.convert1(c) + + def convert1(self,cfg): + """ + converts one config. + """ component = cfg.split('/')[0] base_v2 = self.user_config_dir.replace('sr3', 'sarra') + os.sep base_v3 = self.user_config_dir + os.sep @@ -2646,8 +2665,10 @@ def convert(self): if not os.path.isdir(base_v3 + component): os.makedirs(base_v3 + component) - if os.path.exists(v3_config_path): - logger.error( f"{component}/{cfg} already exists in v3, remove {v3_config_path} to convert again") + if self.options.wololo: + logger.warning("Wololo!" ) + elif os.path.exists(v3_config_path): + logger.error( f"{component}/{cfg} already exists in v3. To overwrite, use --wololo" ) return synonyms = sarracenia.config.Config.synonyms @@ -2765,7 +2786,7 @@ def convert(self): elif component in [ 'subscribe', 'poll', 'sender' ]: # accomodate change of default from v2 to sr3 v3_cfg.write( f"acceptUnmatched False") - logging.info( f'wrote conversion from v2 {cfg} to sr3' ) + logger.info( f'wrote conversion from v2 {cfg} to sr3' ) def overview(self):