예제 #1
0
    def purge(self, age_in_days=30, max_rows=100):
        """Purge deleted rows older than a given age from glance tables."""
        try:
            age_in_days = int(age_in_days)
        except ValueError:
            sys.exit(
                _("Invalid int value for age_in_days: "
                  "%(age_in_days)s") % {'age_in_days': age_in_days})

        try:
            max_rows = int(max_rows)
        except ValueError:
            sys.exit(
                _("Invalid int value for max_rows: "
                  "%(max_rows)s") % {'max_rows': max_rows})

        if age_in_days < 0:
            sys.exit(_("Must supply a non-negative value for age."))
        if age_in_days >= (int(time.time()) / 86400):
            sys.exit(_("Maximal age is count of days since epoch."))
        if max_rows < 1:
            sys.exit(_("Minimal rows limit is 1."))
        ctx = context.get_admin_context(show_deleted=True)
        try:
            db_api.purge_deleted_rows(ctx, age_in_days, max_rows)
        except exception.Invalid as exc:
            sys.exit(exc.msg)
예제 #2
0
파일: manage.py 프로젝트: muraliran/glance
    def purge(self, age_in_days=30, max_rows=100):
        """Purge deleted rows older than a given age from glance tables."""
        try:
            age_in_days = int(age_in_days)
        except ValueError:
            sys.exit(_("Invalid int value for age_in_days: "
                       "%(age_in_days)s") % {'age_in_days': age_in_days})

        try:
            max_rows = int(max_rows)
        except ValueError:
            sys.exit(_("Invalid int value for max_rows: "
                       "%(max_rows)s") % {'max_rows': max_rows})

        if age_in_days <= 0:
            sys.exit(_("Must supply a positive, non-zero value for age."))
        if age_in_days >= (int(time.time()) / 86400):
            sys.exit(_("Maximal age is count of days since epoch."))
        if max_rows < 1:
            sys.exit(_("Minimal rows limit is 1."))
        ctx = context.get_admin_context(show_deleted=True)
        try:
            db_api.purge_deleted_rows(ctx, age_in_days, max_rows)
        except exception.Invalid as exc:
            sys.exit(exc.msg)
예제 #3
0
 def _purge(self, age_in_days, max_rows, purge_images_only=False):
     try:
         age_in_days = int(age_in_days)
     except ValueError:
         sys.exit(
             _("Invalid int value for age_in_days: "
               "%(age_in_days)s") % {'age_in_days': age_in_days})
     try:
         max_rows = int(max_rows)
     except ValueError:
         sys.exit(
             _("Invalid int value for max_rows: "
               "%(max_rows)s") % {'max_rows': max_rows})
     if age_in_days < 0:
         sys.exit(_("Must supply a non-negative value for age."))
     if age_in_days >= (int(time.time()) / 86400):
         sys.exit(_("Maximal age is count of days since epoch."))
     if max_rows < 1:
         sys.exit(_("Minimal rows limit is 1."))
     ctx = context.get_admin_context(show_deleted=True)
     try:
         if purge_images_only:
             db_api.purge_deleted_rows_from_images(ctx, age_in_days,
                                                   max_rows)
         else:
             db_api.purge_deleted_rows(ctx, age_in_days, max_rows)
     except exception.Invalid as exc:
         sys.exit(exc.msg)
     except db_exc.DBReferenceError:
         sys.exit(
             _("Purge command failed, check glance-manage"
               " logs for more details."))
예제 #4
0
 def purge(self, age_in_days=30, max_rows=100):
     """Purge deleted rows older than a given age from glance tables."""
     age_in_days = int(age_in_days)
     max_rows = int(max_rows)
     if age_in_days <= 0:
         sys.exit(_("Must supply a positive, non-zero value for age."))
     if age_in_days >= (int(time.time()) / 86400):
         sys.exit(_("Maximal age is count of days since epoch."))
     if max_rows < 1:
         sys.exit(_("Minimal rows limit is 1."))
     ctx = context.get_admin_context(show_deleted=True)
     db_api.purge_deleted_rows(ctx, age_in_days, max_rows)
예제 #5
0
파일: manage.py 프로젝트: qianqunyi/glance
 def purge(self, age_in_days=30, max_rows=100):
     """Purge deleted rows older than a given age from glance tables."""
     age_in_days = int(age_in_days)
     max_rows = int(max_rows)
     if age_in_days <= 0:
         sys.exit(_("Must supply a positive, non-zero value for age."))
     if age_in_days >= (int(time.time()) / 86400):
         sys.exit(_("Maximal age is count of days since epoch."))
     if max_rows < 1:
         sys.exit(_("Minimal rows limit is 1."))
     ctx = context.get_admin_context(show_deleted=True)
     db_api.purge_deleted_rows(ctx, age_in_days, max_rows)