def add(self, **post): repo = YumRepositories.new(data="", environment="") if post: fields = ['data', 'environment'] data = self._get_data('repo', fields, post) self._set_data(repo, data) if repo.validates() and YumRepositories.add(repo): cherrypy.session['flash'] = "Repo successfully added" raise cherrypy.HTTPRedirect("/repos/index") cherrypy.session['flash'] = "The repository data contains errors." # Only list environments not having a repo. repos = YumRepositories.all() environments = Environments.all() envs = [env.code for env in environments] repos = [repo.environment for repo in repos] available = set(envs) - set(repos) return self.render("/repos/add.html", crumbs=self.crumbs, environments=environments, available=available, repo=repo)
def add(self, **post): jail = Jails.new(id="", url="", name="", ip="", jail_type="", netmask="", environment="") if post: fields = ['name', 'url', 'ip', 'jail_type', 'netmask', 'environment'] data = self._get_data('jail', fields, post) self._set_data(jail, data) if jail.validates() and Jails.add(jail): cherrypy.session['flash'] = "Jail successfully added" raise cherrypy.HTTPRedirect("/jails") cherrypy.session['flash'] = "The jail could not be created." env = dict( environments=Environments.all(), jailTypes=JailTypes.all(), jail=jail ) return self.render("jails/add.html", crumbs=self.crumbs, **env)
def edit(self, id, **post): jail = Jails.first(id=id) if not jail: cherrpy.session['flash'] = '404 Jail Not Found' raise cherrypy.HTTPRedirect('/jails/index') if post: fields = ['name', 'url', 'ip', 'jail_type', 'netmask', 'environment'] data = self._get_data('jail', fields, post) tmp = Jails.new() self._set_data(tmp, data) if tmp.validates() and jail.update(data, fields): cherrypy.session['flash'] = "Jail successfully updated." raise cherrypy.HTTPRedirect("/jails") cherrypy.session['flash'] = "The jail could not be updated." env = dict( environments=Environments.all(), jailTypes=JailTypes.all(), jail=jail ) return self.render("jails/edit.html", crumbs=self.crumbs, **env)
def GET(self): envs = Environments.all() return [e.to_dict() for e in envs]
def index(self): env = dict( repos=YumRepositories.all(), environments=Environments.all() ) return self.render("/repos/index.html", crumbs=self.crumbs[:-1], **env)
def index(self): env = dict(environments=Environments.all()) return self.render("/environments/index.html", crumbs=self.crumbs[:-1], **env)