def status(request): from PYME.cluster.status import get_polled_status nodes = get_polled_status() total_storage = 0 free_storage = 0 for i, node in enumerate(nodes): nodes[i]['percent_free'] = int(100 * float(node['Disk']['free']) / node['Disk']['total']) total_storage += node['Disk']['total'] free_storage += node['Disk']['free'] nodes[i]['percent_mem_free'] = 100 - node['MemUsage']['percent'] context = { 'storage_nodes': nodes, 'total_storage': total_storage, 'free_storage': free_storage, 'used_storage': total_storage - free_storage, 'percent_total_free': int(100 * float(free_storage + 1) / (total_storage + 1)) } if '_ajax' in request.GET.keys(): return render(request, 'clusterstatus/status_dash_content.html', context) else: return render(request, 'clusterstatus/status_dash.html', context)
def load(request): from PYME.cluster.status import get_polled_status nodes = get_polled_status() total_storage = 0 free_storage = 0 context = {'storage_nodes': nodes} return render(request, 'clusterstatus/load_content.html', context)
def get_free_space(self): """ Get available space in the target spool directory Returns ------- free space in GB """ if self.spoolType == 'Cluster': from PYME.cluster import status nodes = status.get_polled_status() free_storage = sum([n['Disk']['free'] for n in nodes]) return free_storage / 1e9 else: from PYME.IO.FileUtils.freeSpace import get_free_space # avoid dirname property here so we can differ building # 'acquire-spool_subdirectories' to `start_spooling` return get_free_space(self._dirname)/1e9