Ejemplo n.º 1
0
 def get_export_id(self, bump=True):
     """Get a new export id."""
     # XXX overflowing the export id (16 bit unsigned integer)
     # is not handled
     if self.ganesha_rados_store_enable:
         # TODO(rraja): Ensure that the export counter object's update is
         # atomic, e.g., retry object update until the object version
         # between the 'get' and 'put' operations remains the same.
         export_id = int(
             self._get_rados_object(self.ganesha_rados_export_counter))
         if not bump:
             return export_id
         export_id += 1
         self._put_rados_object(self.ganesha_rados_export_counter,
                                str(export_id))
         return export_id
     else:
         if bump:
             bumpcode = 'update ganesha set value = value + 1;'
         else:
             bumpcode = ''
         out = self.execute(
             "sqlite3", self.ganesha_db_path,
             bumpcode + 'select * from ganesha where key = "exportid";',
             run_as_root=False)[0]
         match = re.search('\Aexportid\|(\d+)$', out)
         if not match:
             LOG.error("Invalid export database on "
                       "Ganesha node %(tag)s: %(db)s.",
                       {'tag': self.tag, 'db': self.ganesha_db_path})
             raise exception.InvalidSqliteDB()
         return int(match.groups()[0])
Ejemplo n.º 2
0
 def get_export_id(self, bump=True):
     """Get a new export id."""
     # XXX overflowing the export id (16 bit unsigned integer)
     # is not handled
     if bump:
         bumpcode = 'update ganesha set value = value + 1;'
     else:
         bumpcode = ''
     out = self.execute(
         "sqlite3", self.ganesha_db_path,
         bumpcode + 'select * from ganesha where key = "exportid";',
         run_as_root=False)[0]
     match = re.search('\Aexportid\|(\d+)$', out)
     if not match:
         LOG.error(_LE("Invalid export database on "
                   "Ganesha node %(tag)s: %(db)s."),
                   {'tag': self.tag, 'db': self.ganesha_db_path})
         raise exception.InvalidSqliteDB()
     return int(match.groups()[0])