def _save_runtime_settings(): consul_settings = {} consul_settings['is_commander'] = is_ship_commander() consul_settings['name'] = get_ship_name() consul_settings['ships'] = get_other_ship_ips() consul_settings['datacenter'] = get_current_datacenter() consul_settings['dockyards'] = alias.get_list() with open(consul_config.RUNTIME_SETTINGS_PATH, 'w') as runtime_settings: runtime_settings.write(json.dumps(consul_settings, sort_keys=True, indent=4))
def _save_runtime_settings(): consul_settings = {} consul_settings['is_commander'] = is_ship_commander() consul_settings['name'] = get_ship_name() consul_settings['ships'] = get_other_ship_ips() consul_settings['datacenter'] = get_current_datacenter() consul_settings['dockyards'] = alias.get_list() with open(consul_config.RUNTIME_SETTINGS_PATH, 'w') as runtime_settings: runtime_settings.write( json.dumps(consul_settings, sort_keys=True, indent=4))
def get_default_alias(): default_alias = alias.get_default() if default_alias: dockyard = alias.get_alias(default_alias) if not dockyard: raise DockyardException('Default dockyard does not exist.') return default_alias alias_list = alias.get_list() if not alias_list: raise DockyardException('There are no running dockyards.') if len(alias_list) > 1: raise CriticalDockyardException('There are multiple running dockyards and no default set.' 'Please specify dockyard by -d/--dockyard or set the default.') return alias_list[0]['name']
def command_dockyard_list(args): output_header = ['Default', 'Alias', 'Address', 'User', 'Password'] output_rows = [output_header] alias_list = alias.get_list() for alias_dict in alias_list: default_string = '->'.rjust(len( output_header[0])) if alias_dict['is_default'] else '' row = [ default_string, alias_dict['name'], alias_dict['address'], alias_dict.get('user', ''), _hide_password(alias_dict.get('password', '')) ] output_rows.append(row) print_table(output_rows)
def get_default_alias(): default_alias = alias.get_default() if default_alias: dockyard = alias.get_alias(default_alias) if not dockyard: raise DockyardException('Default dockyard does not exist.') return default_alias alias_list = alias.get_list() if not alias_list: raise DockyardException('There are no running dockyards.') if len(alias_list) > 1: raise CriticalDockyardException('There are multiple running dockyards and no default set.' 'Please specify dockyard by -d/--dockyard or set the default.') return alias_list[0]['name']