def get_data_path(connection): """ Tries to get data path from /etc/fstab and than from moosefs_tool.ini. Returns empty if it fails. """ path = '' try: logger.info('Getting data path from /etc/fstab.') f = connection.get_file('/etc/fstab', 'r') for line in f.readlines(): if 'fuse' in line and 'mfsmount' in line: path = line.split()[1] logger.info('Data path %s was got successfully.' % path) except IOError: logger.exception(mfs_exceptions.DataPathGettingFailed( 'Cannot read /etc/fstab file.')) except IndexError: logger.exception(mfs_exceptions.DataPathGettingFailed( 'Cannot parse /etc/fstab.')) except Exception as e: logger.exception(mfs_exceptions.DataPathGettingFailed( 'Unresolved exception:\n%s' % e)) if not path: logger.info('Getting data path from moosefs_tool.ini.') path = roots.get('data_path', '') if path: logger.info('Data path %s was got successfully.' % path) return path
def home(): host = roots['master_host'] port = roots.get('master_port', 9421) servers = [1] try: mfs = MooseFS(masterhost=host, masterport=port) # servers = mfs.mfs_mounts() except Exception as e: error = 'Error while trying to connect to %s:%s<br/>%s' % (host, port, e) return render_template('home.html', master_host = host, servers = servers, title = 'Home')
def home(): host = roots['master_host'] port = int(roots.get('master_port', 9421)) chunkservers = [{'ip':'192.168.56.12' + str(i), 'name' : 'chunkserver'} for i in range(3)] metaloggers = [{'ip':'192.168.56.13' + str(i), 'name' : 'metalogger'} for i in range(10)] clients = [{'ip':'192.168.56.14' + str(i), 'name' : 'client'} for i in range(10)] try: mfs = MooseFS(masterhost=host, masterport=port) # servers = mfs.mfs_mounts() except Exception as e: error = 'Error while trying to connect to %s:%s<br/>%s' % (host, port, e) return render_template('home.html', master_host = host, metaloggers = metaloggers, chunkservers = chunkservers, clients = clients, title = 'Home')
def master(): host = roots['master_host'] port = roots.get('master_port', 9421) configs_path = roots['configs'] if request.method == 'POST': action = request.values['action'] # save or edit return globals()[action + '_config'](host, configs_path, request.values['config_name']) configs = get_configs(host, configs_path) metafiles_path = roots['metafiles'] metafiles = get_metafiles_info(metafiles_path) return render_template('master.html', configs_path = configs_path, configs = configs, metafiles_path = metafiles_path, metafiles = metafiles, base_info = get_master_info(host, port), title = 'Master')
def trash(): host = roots['master_host'] port = roots.get('master_port', 9421) con = transport.Connect(host) path = '/mnt/mfs-test' tree = make_remote_tree(con, path) errors = {} command = '/usr/bin/mfsmount /mnt/mfs-test -H mfsmaster -o mfsmeta' resp = con.remote_command(command, 'stdout') if resp: errors['mount'] = 'Failed to mount trash folder with command \"%s\".<br/>Got following error:<br/> %s.' % (command, resp) if request.method == 'POST': return render_template('data/files_items.html', tree = make_remote_tree(con, request.values['full_name'])) return render_template('trash.html', errors = errors, tree = tree, title = 'Trash')
def master(): errors = {} host = roots['master_host'] port = roots.get('master_port', 9421) con = transport.Connect(host) backup_form = BackupForm(request.form) master_info, errors = get_master_info(host, port, errors) config_path, configs, errors = get_config_info(con, errors) meta_path, metafiles, errors = get_meta_info(con, errors, config_path) if request.method == 'POST': if 'action' in request.values: # save or edit config action = request.values['action'] return globals()[action + '_config'](con, config_path, request.values['config_name']) else: # backup request path = backup_form.path.data if con.path_exists(path): err = create_targz(path, meta_path, suffix='mfs_metadata') if err: backup_form.path.errors += ('Exception occured while creating backup:<br>%s.' % err,) else: return redirect(url_for('master')) else: backup_form.path.errors += ('This path does not exist.',) if PY3: master_info.iteritems = master_info.items return render_template('master/master.html', config_path = config_path, configs = configs, meta_path = meta_path, metafiles = metafiles, master_info = master_info, backup_form = backup_form, errors = errors, title = 'Master')