Exemple #1
0
    def purge(self, age_in_days):
        """Purge deleted rows older than a given age from karbor tables."""
        age_in_days = int(age_in_days)
        if age_in_days <= 0:
            print(_("Must supply a positive, non-zero value for age"))
            sys.exit(1)
        ctxt = context.get_admin_context()

        try:
            db.purge_deleted_rows(ctxt, age_in_days)
        except Exception as e:
            print(_("Purge command failed, check karbor-manage "
                    "logs for more details. %s") % e)
            sys.exit(1)
Exemple #2
0
    def purge(self, age_in_days):
        """Purge deleted rows older than a given age from karbor tables."""
        age_in_days = int(age_in_days)
        if age_in_days <= 0:
            print(_("Must supply a positive, non-zero value for age"))
            sys.exit(1)
        ctxt = context.get_admin_context()

        try:
            db.purge_deleted_rows(ctxt, age_in_days)
        except Exception as e:
            print(
                _("Purge command failed, check karbor-manage "
                  "logs for more details. %s") % e)
            sys.exit(1)
Exemple #3
0
 def test_purge_deleted_rows_old(self):
     dialect = self.engine.url.get_dialect()
     if dialect == sqlite.dialect:
         # We're seeing issues with foreign key support in SQLite 3.6.20
         # SQLAlchemy doesn't support it at all with < SQLite 3.6.19
         # It works fine in SQLite 3.7.
         # Force foreign_key checking if running SQLite >= 3.7
         import sqlite3
         tup = sqlite3.sqlite_version_info
         if tup[0] > 3 or (tup[0] == 3 and tup[1] >= 7):
             self.conn.execute("PRAGMA foreign_keys = ON")
     # Purge at 30 days old, should only delete 2 rows
     db.purge_deleted_rows(self.context, age_in_days=30)
     plans_rows = self.session.query(self.plans).count()
     resources_rows = self.session.query(self.resources).count()
     # Verify that we only deleted 2
     self.assertEqual(4, plans_rows)
     self.assertEqual(4, resources_rows)
Exemple #4
0
 def test_purge_deleted_rows_old(self):
     dialect = self.engine.url.get_dialect()
     if dialect == sqlite.dialect:
         # We're seeing issues with foreign key support in SQLite 3.6.20
         # SQLAlchemy doesn't support it at all with < SQLite 3.6.19
         # It works fine in SQLite 3.7.
         # Force foreign_key checking if running SQLite >= 3.7
         import sqlite3
         tup = sqlite3.sqlite_version_info
         if tup[0] > 3 or (tup[0] == 3 and tup[1] >= 7):
             self.conn.execute("PRAGMA foreign_keys = ON")
     # Purge at 30 days old, should only delete 2 rows
     db.purge_deleted_rows(self.context, age_in_days=30)
     plans_rows = self.session.query(self.plans).count()
     resources_rows = self.session.query(self.resources).count()
     # Verify that we only deleted 2
     self.assertEqual(4, plans_rows)
     self.assertEqual(4, resources_rows)