Example #1
0
 def _quotas(cls, request, pool):
     new_quota_state = cls._validate_new_quota_state(request)
     # If no change from current pool quota state then do nothing
     current_state = "Enabled"
     if not pool.quotas_enabled:
         current_state = "Disabled"
     if new_quota_state == current_state:
         return Response()
     try:
         if new_quota_state == "Enabled":
             # Current issue with requiring enable to be executed twice !!!
             # As of 4.12.4-1.el7.elrepo.x86_64
             # this avoids "ERROR: quota rescan failed: Invalid argument"
             # when attempting a rescan.
             # Look similar to https://patchwork.kernel.org/patch/9928635/
             enable_quota(pool)
             enable_quota(pool)
             # As of 4.12.4-1.el7.elrepo.x86_64
             # The second above enable_quota() call currently initiates a
             # rescan so the following is redundant; however this may not
             # always be the case so leaving as it will auto skip if a scan
             # in in progress anyway.
             rescan_quotas(pool)
         else:
             disable_quota(pool)
     except:
         e_msg = ("Failed to Enable (and rescan) / Disable Quotas for "
                  "Pool ({}). Requested quota state "
                  "was ({}).".format(pool.name, new_quota_state))
         handle_exception(Exception(e_msg), request)
     return Response(PoolInfoSerializer(pool).data)
Example #2
0
 def _quotas(cls, request, pool):
     new_quota_state = cls._validate_new_quota_state(request)
     # If no change from current pool quota state then do nothing
     current_state = 'Enabled'
     if not pool.quotas_enabled:
         current_state = 'Disabled'
     if new_quota_state == current_state:
         return Response()
     try:
         if new_quota_state == 'Enabled':
             # Current issue with requiring enable to be executed twice !!!
             # As of 4.12.4-1.el7.elrepo.x86_64
             # this avoids "ERROR: quota rescan failed: Invalid argument"
             # when attempting a rescan.
             # Look similar to https://patchwork.kernel.org/patch/9928635/
             enable_quota(pool)
             enable_quota(pool)
             # As of 4.12.4-1.el7.elrepo.x86_64
             # The second above enable_quota() call currently initiates a
             # rescan so the following is redundant; however this may not
             # always be the case so leaving as it will auto skip if a scan
             # in in progress anyway.
             rescan_quotas(pool)
         else:
             disable_quota(pool)
     except:
         e_msg = 'Failed to Enable (and rescan) / Disable Quotas for ' \
                 'Pool ({}). Requested quota state ' \
                 'was ({}).'.format(pool.name, new_quota_state)
         handle_exception(Exception(e_msg), request)
     return Response(PoolInfoSerializer(pool).data)