def command_dockyard_set(args): warning_header = " Warning!\n Your dockyard alias has been set BUT:" alias.set_alias(args.name, args.address, args.user, args.password) try: dockyard = dockyard_factory(args.address, args.user, args.password) if dockyard.is_http(): print_http_dockyard_unavailability_warning(args.address, args.name, warning_header) except (DockyardFactoryException, DockyardDetectionException) as e: print_err('{}\n{}'.format(warning_header, e))
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')) if info.get('is_default'): default_alias = dockyard_alias if default_alias: alias.set_default(default_alias)