def create(self):
     with database.database.atomic() as txn:
         cell = Cell()
         if not self._save_cell(cell):
             txn.rollback()
             return False
         for idx, nform in enumerate(self.nodes):
             if not self._save_cnode(nform, None, idx, cell):
                 txn.rollback()
                 return False
     try:
         cell.deploy_conf()
     except Exception as e:
         logger.exceptions(e)
     return True
Exemple #2
0
 def create(self):
     with database.database.atomic() as txn:
         cell = Cell()
         if not self._save_cell(cell):
             txn.rollback()
             return False
         for idx, nform in enumerate(self.nodes):
             if not self._save_cnode(nform, None, idx, cell):
                 txn.rollback()
                 return False
     try:
         cell.deploy_conf()
     except Exception as e:
         logger.exceptions(e)
     return True
 def update(self, id):
     with database.database.atomic() as txn:
         cell = Cell().get(Cell.id == id)
         if not self._save_cell(cell):
             txn.rollback()
             return False
         for cnode in cell.nodes:
             if not self.exists_cnode(cnode):
                 cnode.delete().where(CellNode.id == cnode.id).execute()
         for idx, nform in enumerate(self.nodes):
             node_id = nform.form['node_id'].data
             nid = (int(node_id) if node_id is not None
                    and node_id.isnumeric() else None)
             if not self._save_cnode(nform, nid, idx, cell):
                 txn.rollback()
                 return False
     try:
         cell.deploy_conf()
     except Exception as e:
         logger.exceptions(e)
     return True
Exemple #4
0
 def update(self, id):
     with database.database.atomic() as txn:
         cell = Cell().get(Cell.id == id)
         if not self._save_cell(cell):
             txn.rollback()
             return False
         for cnode in cell.nodes:
             if not self.exists_cnode(cnode):
                 cnode.delete().where(CellNode.id == cnode.id).execute()
         for idx, nform in enumerate(self.nodes):
             node_id = nform.form['node_id'].data
             nid = (int(node_id)
                    if node_id is not None and node_id.isnumeric()
                    else None)
             if not self._save_cnode(nform, nid, idx, cell):
                 txn.rollback()
                 return False
     try:
         cell.deploy_conf()
     except Exception as e:
         logger.exceptions(e)
     return True