def _insert_vm_to_db(self, uuid, name, state): session_maker = db.get_session() session = session_maker() vm = models.VM(name=name, state=state) vm.uuid = uuid session.add(vm) session.commit()
def _vm_exists_in_db(self, uuid): session_maker = db.get_session() session = session_maker() try: session.query(models.VM).filter(models.VM.uuid == uuid).one() return True except exc.NoResultFound: return False
def get_session(self): if self._Session is None: self._Session = db.get_session() return self._Session()