Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to convert overwriting, one must Wololo #1055

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/source/Explanation/CommandLineGuide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion docs/source/Reference/sr3.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions docs/source/Reference/sr3_options.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
========

Expand Down
5 changes: 5 additions & 0 deletions docs/source/fr/Explication/GuideLigneDeCommande.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion docs/source/fr/Reference/sr3.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions docs/source/fr/Reference/sr3_options.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
========

Expand Down
12 changes: 9 additions & 3 deletions sarracenia/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def __repr__(self) -> str:
'sourceFromMessage': False,
'topicCopy': False,
'v2compatRenameDoublePost': False,
'varTimeOffset': 0
'varTimeOffset': 0,
'wololo': False
}

count_options = [
Expand All @@ -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 = [ ]
Expand Down Expand Up @@ -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,
Expand Down
29 changes: 25 additions & 4 deletions sarracenia/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down
Loading