def home(): ''' home page function ''' if 'logged_in' in session: listx = lxc.listx() containers_all = [] for status in ['RUNNING', 'FROZEN', 'STOPPED']: containers_by_status = [] for container in listx[status]: containers_by_status.append({ 'name': container, 'memusg': lwp.memory_usage(container), 'settings': lwp.get_container_settings(container) }) containers_all.append({ 'status': status.lower(), 'containers': containers_by_status }) return render_template('index.html', containers=lxc.ls(), containers_all=containers_all, dist=lwp.check_ubuntu(), templates=lwp.get_templates_list()) return render_template('login.html')
def refresh_memory_containers(name=None): if 'logged_in' in session: if name == 'containers': listx = lxc.listx() containers = [] for container in listx['RUNNING']: container = container.replace(' (auto)', '') containers.append({ 'name': container, 'memusg': lwp.memory_usage_cgroup(container), 'max_memusg': lwp.max_memory_usage_cgroup(container) }) for container in listx['FROZEN']: container = container.replace(' (auto)', '') containers.append({ 'name': container, 'memusg': lwp.memory_usage_cgroup(container), 'max_memusg': lwp.max_memory_usage_cgroup(container) }) return jsonify(data=containers) elif name == 'host': return jsonify(lwp.host_memory_usage()) return jsonify({ 'memusg': lwp.memory_usage_cgroup(name), 'max_memusg': lwp.max_memory_usage_cgroup(name) })
def refresh_containers(): if 'logged_in' in session: listx = lxc.listx() containers_all = [] for status in ['RUNNING', 'FROZEN', 'STOPPED']: containers_by_status = [] for container in listx[status]: item = { 'name': container, 'settings': lwp.get_container_settings(container) } h = hashlib.md5() h.update(status) h.update(cPickle.dumps(item['settings'])) item['hash'] = h.hexdigest() containers_by_status.append(item) containers_all.append({ 'status' : status, 'containers' : containers_by_status }) return render_template('containers.html', containers_all=containers_all) return ''
def home(): if 'logged_in' in session: containers_all = [] listx = lxc.listx() sorted_list = listx['RUNNING'] + listx['FROZEN'] + listx['STOPPED'] for container in sorted_list: status = lxc.info(container)['state'] containers_all.append({'status':status, 'name':container, 'memusg':lwp.memory_usage(container), 'settings':lwp.get_container_settings(container)}) return render_template('index.html', containers=lwp.ls(), containers_all=containers_all, dist=lwp.check_ubuntu(), templates=lwp.get_templates_list()) return render_template('login.html')
def refresh_containers(): if 'logged_in' in session: listx = lxc.listx() containers_all = [] for status in ['RUNNING', 'FROZEN', 'STOPPED']: containers_by_status = [] for container in listx[status]: containers_by_status.append({ 'name': container, 'memusg': lwp.memory_usage(container), 'settings': lwp.get_container_settings(container) }) containers_all.append({ 'status' : status.lower(), 'containers' : containers_by_status }) return render_template('containers.html', containers_all=containers_all)
def update_containers(): if 'logged_in' in session: listx = lxc.listx() containers = [] for status in ['RUNNING', 'FROZEN', 'STOPPED']: for container in listx[status]: settings = lwp.get_container_settings(container) h = hashlib.md5() h.update(status) h.update(cPickle.dumps(settings)) containers.append({ "name": container, "hash": h.hexdigest() }) return jsonify(data=containers) return jsonify(data=[])
def home(): ''' home page function ''' listx = lxc.listx() containers_all = [] for status in ['RUNNING', 'FROZEN', 'STOPPED']: containers_by_status = [] for container in listx[status]: containers_by_status.append({ 'name': container, 'memusg': lwp.memory_usage(container), 'settings': lwp.get_container_settings(container), 'ipv4': lxc.get_ipv4(container), 'bucket': get_bucket_token(container) }) containers_all.append({ 'status': status.lower(), 'containers': containers_by_status }) return render_template('index.html', containers=lxc.ls(), containers_all=containers_all, dist=lwp.check_ubuntu(), host=socket.gethostname(), templates=lwp.get_templates_list(), storage_repos=storage_repos, auth=AUTH)
def refresh_containers(): if 'logged_in' in session: listx = lxc.listx() containers_all = [] for status in ['RUNNING', 'FROZEN', 'STOPPED']: containers_by_status = [] for container in listx[status]: containers_by_status.append({ 'name': container, 'memusg': lwp.memory_usage(container), 'settings': lwp.get_container_settings(container) }) containers_all.append({ 'status': status.lower(), 'containers': containers_by_status }) return render_template('containers.html', containers_all=containers_all)