def __init__(self): # SQLAlchemy connect self.db2 = lyorm.dbsession # TEST db connect try: from sqlalchemy.exc import OperationalError, ProgrammingError from tool.network import set_network_pool set_network_pool(self.db2) # Normal web server return tornado.web.Application.__init__( self, app_handlers, **app_settings ) except OperationalError, msg: # DB connect error, show the install step logging.warning('OperationalError: %s' % msg)
def __init__(self): # SQLAlchemy connect self.db2 = lyorm.dbsession # TEST db connect try: from sqlalchemy.exc import OperationalError, ProgrammingError from tool.network import set_network_pool set_network_pool(self.db2) # Normal web server return tornado.web.Application.__init__(self, app_handlers, **app_settings) except OperationalError, msg: # DB connect error, show the install step logging.warning('OperationalError: %s' % msg)
def post(self): saved = None form = NetworkPoolForm( self.request.arguments ) if form.validate(): networkpool = { 'start': form.start.data, 'end': form.end.data, 'netmask': form.netmask.data, 'gateway': form.gateway.data, 'nameservers': form.nameservers.data, 'exclude_ips': form.exclude_ips.data, } nameservers = form.nameservers.data if self.nameservers: #self.nameservers.value = nameservers pass else: c = LuoYunConfig('nameservers', nameservers) self.db2.add( c ) networkpool = json.dumps( [networkpool, ] ) if self.networkpool: self.networkpool.value = networkpool else: c = LuoYunConfig('networkpool', networkpool) self.db2.add(c) self.db2.commit() from tool.network import set_network_pool # set settings.NETWORK_POOL set_network_pool(self.db2) saved = True # TODO: redirect to ? url = self.reverse_url('system:networkpool') self.redirect( url ) self.render('system/networkpool_edit.html', form = form, saved = saved)
def post(self): saved = None form = NetworkPoolForm(self.request.arguments) if form.validate(): networkpool = { 'start': form.start.data, 'end': form.end.data, 'netmask': form.netmask.data, 'gateway': form.gateway.data, 'nameservers': form.nameservers.data, 'exclude_ips': form.exclude_ips.data, } nameservers = form.nameservers.data if self.nameservers: #self.nameservers.value = nameservers pass else: c = LuoYunConfig('nameservers', nameservers) self.db2.add(c) networkpool = json.dumps([ networkpool, ]) if self.networkpool: self.networkpool.value = networkpool else: c = LuoYunConfig('networkpool', networkpool) self.db2.add(c) self.db2.commit() from tool.network import set_network_pool # set settings.NETWORK_POOL set_network_pool(self.db2) saved = True # TODO: redirect to ? url = self.reverse_url('system:networkpool') self.redirect(url) self.render('system/networkpool_edit.html', form=form, saved=saved)