예제 #1
0
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')
예제 #2
0
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)
        })
예제 #3
0
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')
예제 #4
0
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 ''
예제 #5
0
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')
예제 #6
0
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)
예제 #7
0
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=[])
예제 #8
0
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)
예제 #9
0
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)