def status(req, name, params): location = 'admin:status' status = 'stopped' if vsutil.is_running(name): status = 'running' elif os.path.exists(os.path.join(cfg.ETC_VSERVERS, name, '.rebuild')): status = 'rebuilding' elif os.path.exists(os.path.join(cfg.VAR_DB_OPENVPS, 'suspend', name)): status = 'suspended' # avoid caching at all costs req.err_headers_out['Pragma'] = 'no-cache' req.err_headers_out['Cache-Control'] = 'no-cache' req.err_headers_out['Expires'] = 'Tue, 25 Jan 2000 10:30:00 GMT' body_tmpl = _tmpl_path('status_body.html') body_vars = {'status':status} vars = {'global_menu': _global_menu(req, name, location), 'body':psp.PSP(req, body_tmpl, vars=body_vars), 'name':name} p = psp.PSP(req, _tmpl_path('main_frame.html'), vars=vars) p.run() return apache.OK
def status(req, name, params): location = 'admin:status' status = 'stopped' if vsutil.is_running(name): status = 'running' elif os.path.exists(os.path.join(cfg.ETC_VSERVERS, name, '.rebuild')): status = 'rebuilding' elif os.path.exists(os.path.join(cfg.VAR_DB_OPENVPS, 'suspend', name)): status = 'suspended' # avoid caching at all costs req.err_headers_out['Pragma'] = 'no-cache' req.err_headers_out['Cache-Control'] = 'no-cache' req.err_headers_out['Expires'] = 'Tue, 25 Jan 2000 10:30:00 GMT' body_tmpl = _tmpl_path('status_body.html') body_vars = {'status': status} vars = { 'global_menu': _global_menu(req, name, location), 'body': psp.PSP(req, body_tmpl, vars=body_vars), 'name': name } p = psp.PSP(req, _tmpl_path('main_frame.html'), vars=vars) p.run() return apache.OK
def start(req, name, params): req.log_error('Starting vserver %s at request of %s' % (name, req.user)) if not vsutil.is_running(name): if not os.path.exists(os.path.join(cfg.VAR_DB_OPENVPS, 'suspend', name)): vsutil.start(name) time.sleep(3) # note - this redirect is relative because absolute won't work with # our proxypass proxy util.redirect(req, 'status')
def stop(req, name, params): req.log_error('Stopping vserver %s at request of %s' % (name, req.user)) if vsutil.is_running(name): vsutil.stop(name) time.sleep(3) # note - this redirect is relative because absolute won't work with # our proxypass proxy util.redirect(req, 'status')
def dorebuild(req, name, params): # make sure it is stopped if vsutil.is_running(name): return error(req, "%s is running, you must first stop it" % name) req.log_error('Rebuilding vds %s at request of %s' % (name, req.user)) # we could check for "cannot rebuild" error, but since the only # cause for that would be a broken shadow file, the user won't be # able access the control panel in the first place. pid = os.fork() if pid == 0: # in child cmd = '%s openvps-rebuild %s %s' % (cfg.OVWRAPPER, cfg.REFROOTS[0], name) pipe = os.popen(cmd, 'r', 0) s = pipe.readline() while s: req.log_error('%s: %s' % (name, s)) s = pipe.readline() pipe.close() req.log_error('Rebuild of vds %s at request of %s DONE' % (name, req.user)) # exit child os._exit(0) else: # in parent try: time.sleep(3) util.redirect(req, 'status') finally: # wait on the child to avoid a defunct (zombie) process os.wait() return apache.OK