def main(): setup_sentry() if not alias.get_initialized(): _init_dockyards() alias.set_initialized() _save_runtime_settings()
#!/usr/bin/env python3 from armada_command.dockyard import alias import sys if not alias.get_initialized(): sys.exit(1)
def _init_dockyards(): try: with open(consul_config.ORIGINAL_RUNTIME_SETTINGS_PATH) as runtime_settings_json: runtime_settings = json.load(runtime_settings_json) except: runtime_settings = {} # Initialize dockyard list with fallback dockyard. if not alias.get_alias(alias.DOCKYARD_FALLBACK_ALIAS): alias.set_alias(alias.DOCKYARD_FALLBACK_ALIAS, alias.DOCKYARD_FALLBACK_ADDRESS) dockyards = runtime_settings.get('dockyards', {}) default_alias = None for info in dockyards: dockyard_alias = info.get('name') if dockyard_alias and not alias.get_alias(dockyard_alias): alias.set_alias(dockyard_alias, info.get('address'), info.get('user'), info.get('password'), check_if_accessible=False) if info.get('is_default') == True: default_alias = dockyard_alias if default_alias: alias.set_default(default_alias) if __name__ == '__main__': if not alias.get_initialized(): _init_dockyards() alias.set_initialized() _save_runtime_settings()