示例#1
0
import subprocess
import time
import re
import hashlib
import sqlite3
import cPickle
import os
import ConfigParser

# configuration
config = ConfigParser.SafeConfigParser(allow_no_value=True)
config.readfp(open('lwp.conf'))

import lxclite as lxc
if lxc.version()[0] >= 1:
    import lxclite2 as lxc

import lwp

SECRET_KEY = '\xb13\xb6\xfb+Z\xe8\xd1n\x80\x9c\xe7KM\x1c\xc1\xa7\xf8\xbeY\x9a\xfa<.'

DEBUG = config.getboolean('global', 'debug')
DATABASE = config.get('database', 'file')
ADDRESS = config.get('global', 'address')
PORT = int(config.get('global', 'port'))


# Flask app
app = Flask(__name__)
app.config['TRAP_BAD_REQUEST_ERRORS'] = True
import sys
sys.path.append('../')
import subprocess
import os
import platform
import time
import urllib2
import ConfigParser
import re

from lxclite import version
if version()[0] >= 1:
    from lxclite2 import exists, stopped, ContainerDoesntExists
else:
    from lxclite import exists, stopped, ContainerDoesntExists

class CalledProcessError(Exception):
    pass

cgroup = {}
cgroup['type'] = 'lxc.network.type'
cgroup['link'] = 'lxc.network.link'
cgroup['flags'] = 'lxc.network.flags'
cgroup['hwaddr'] = 'lxc.network.hwaddr'
cgroup['rootfs'] = 'lxc.rootfs'
cgroup['utsname'] = 'lxc.utsname'
cgroup['arch'] = 'lxc.arch'
cgroup['ipv4'] = 'lxc.network.ipv4'
cgroup['memlimit'] = 'lxc.cgroup.memory.limit_in_bytes'
cgroup['swlimit'] = 'lxc.cgroup.memory.memsw.limit_in_bytes'
cgroup['cpus'] = 'lxc.cgroup.cpuset.cpus'