示例#1
0
文件: nodes.py 项目: seryl/Nodetraq
 def destroy_comment(self, id, commentid):
     comment = Session.query(NodeComment)\
             .filter(NodeComment.id == commentid).first()
     Session.delete(comment)
     Session.commit()
     return redirect(url(
         controller='nodes', action='show', id=id))
示例#2
0
文件: nodes.py 项目: seryl/Nodetraq
    def destroy_game(self, id):
        game = Session.query(Game).filter(Game.id == id).first()
        Session.delete(game)
        Session.commit()

        session['flash'] = "Success"
        session.save()
        return {'success': True}
示例#3
0
文件: nodes.py 项目: seryl/Nodetraq
    def destroy_studio(self, id):
        studio = Session.query(Studio).filter(Studio.id == id).first()
        Session.delete(studio)
        Session.commit()

        session['flash'] = "Success"
        session.save()
        return {'success': True}
示例#4
0
    def destroy_game(self, id):
        game = Session.query(Game).filter(Game.id == id).first()
        Session.delete(game)
        Session.commit()

        session['flash'] = "Success"
        session.save()
        return {'success': True}
示例#5
0
    def destroy_studio(self, id):
        studio = Session.query(Studio).filter(Studio.id == id).first()
        Session.delete(studio)
        Session.commit()

        session['flash'] = "Success"
        session.save()
        return {'success': True}
示例#6
0
    def destroy(self, id, backup_id):
        dbbackup = Session.query(NodeDatabaseBackup)\
            .filter(NodeDatabaseBackup.id == backup_id).first()
        Session.delete(dbbackup)
        Session.commit()
        session['flash'] = "Successfully destroyed dbbackup"
        session.save()

        return redirect(url(controller='dbbackups', action='index', id=id))
示例#7
0
    def destroy(self, id, backup_id):
        dbbackup = Session.query(NodeDatabaseBackup)\
            .filter(NodeDatabaseBackup.id == backup_id).first()
        Session.delete(dbbackup)
        Session.commit()
        session['flash'] = "Successfully destroyed dbbackup"
        session.save()

        return redirect(url(controller='dbbackups', action='index', id=id))
示例#8
0
    def delete(self, id):
        if id.isdigit():
            graph = Session.query(Graph)\
                .filter(Graph.id == int(id)).first()
        else:
            graph = Session.query(Graph)\
                .filter(Graph.name == id).first()

        Session.delete(graph)
        Session.commit()
        session['flash'] = "Successfully deleted %s" % graph.name
        session.save()
        return redirect(url(
                controller='graphs', action='index'))
示例#9
0
文件: nodes.py 项目: seryl/Nodetraq
    def update_disks(self, diskinfo):
        if self.disks:
            current_serials = [d.serial_no for d in self.disks]
            new_serials = [d['serial_no'] for d in diskinfo['disks']]
            diff_serials = list(set(new_serials) - set(current_serials))
            remove_serials = [ serial for serial in current_serials \
                                   if serial not in new_serials ]

            for s in remove_serials:
                for rd in self.disks:
                    if rd.serial_no == s:
                        self.disks.remove(rd)
                        Session.delete(rd)

            for s in diff_serials:
                for disk in diskinfo['disks']:
                    if disk['serial_no'] == s:
                        new_disk = Disk()
                        new_disk.serial_no = disk['serial_no']
                        new_disk.capacity = disk['capacity']
                        new_disk.type = disk['type']
                        new_disk.controller_slot = disk['controller_slot']
                        new_disk.controller_id = DiskController\
                            .grab_controller(disk['controller'])
                        Session.add(new_disk)
                        self.disks.append(new_disk)

        else:
            self.disks = []
            for disk in diskinfo['disks']:
                new_disk = Disk()
                new_disk.serial_no = disk['serial_no']
                new_disk.capacity = disk['capacity']
                new_disk.type = disk['type']
                new_disk.controller_slot = disk['controller_slot']
                new_disk.controller_id = DiskController\
                    .grab_controller(disk['controller'])
                Session.add(new_disk)
                self.disks.append(new_disk)

        Session.add(self)
        Session.commit()
示例#10
0
文件: nodes.py 项目: seryl/Nodetraq
    def update_disks(self, diskinfo):
        if self.disks:
            current_serials = [d.serial_no for d in self.disks]
            new_serials = [d["serial_no"] for d in diskinfo["disks"]]
            diff_serials = list(set(new_serials) - set(current_serials))
            remove_serials = [serial for serial in current_serials if serial not in new_serials]

            for s in remove_serials:
                for rd in self.disks:
                    if rd.serial_no == s:
                        self.disks.remove(rd)
                        Session.delete(rd)

            for s in diff_serials:
                for disk in diskinfo["disks"]:
                    if disk["serial_no"] == s:
                        new_disk = Disk()
                        new_disk.serial_no = disk["serial_no"]
                        new_disk.capacity = disk["capacity"]
                        new_disk.type = disk["type"]
                        new_disk.controller_slot = disk["controller_slot"]
                        new_disk.controller_id = DiskController.grab_controller(disk["controller"])
                        Session.add(new_disk)
                        self.disks.append(new_disk)

        else:
            self.disks = []
            for disk in diskinfo["disks"]:
                new_disk = Disk()
                new_disk.serial_no = disk["serial_no"]
                new_disk.capacity = disk["capacity"]
                new_disk.type = disk["type"]
                new_disk.controller_slot = disk["controller_slot"]
                new_disk.controller_id = DiskController.grab_controller(disk["controller"])
                Session.add(new_disk)
                self.disks.append(new_disk)

        Session.add(self)
        Session.commit()
示例#11
0
 def delete(self, backup_id):
     dbbackup = Session.query(NodeDatabaseBackup)\
         .filter(NodeDatabaseBackup.id == backup_id).first()
     Session.delete(dbbackup)
     Session.commit()
     return {"success": True}
示例#12
0
 def destroy_comment(self, id, commentid):
     comment = Session.query(NodeComment)\
             .filter(NodeComment.id == commentid).first()
     Session.delete(comment)
     Session.commit()
     return redirect(url(controller='nodes', action='show', id=id))
示例#13
0
文件: network.py 项目: seryl/Nodetraq
 def destroy(self, id):
     network_device = Session.query(NetworkDevice).filter(
         NetworkDevice.id == id).first()
     Session.delete(network_device)
     Session.commit()
     return {'success': True}
示例#14
0
 def delete(self, backup_id):
     dbbackup = Session.query(NodeDatabaseBackup)\
         .filter(NodeDatabaseBackup.id == backup_id).first()
     Session.delete(dbbackup)
     Session.commit()
     return {"success": True}
示例#15
0
文件: network.py 项目: seryl/Nodetraq
 def destroy(self, id):
     network_device = Session.query(NetworkDevice).filter(
         NetworkDevice.id == id).first()
     Session.delete(network_device)
     Session.commit()
     return {'success': True}