Skip to content

Commit

Permalink
manual_override: Enable root option for quota #52
Browse files Browse the repository at this point in the history
log revert_command if membership is empty

append quota to revert_command (including root)
  • Loading branch information
astrochun committed Sep 10, 2020
1 parent e7a00af commit a374eaa
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions requiam/manual_override.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def update_dataframe(self, netid, uaid, group, group_type):
else:
if group != 'root':
self.log.info(f"Updating entry for {netid[i]}")
revised_df.loc[loc0[0]] = [netid, list(uaid)[i], group]
revised_df.loc[loc0[0]] = [netid[i], list(uaid)[i], group]
else:
self.log.info(f"Removing entry for {netid[i]}")
revised_df = revised_df.drop(loc0)
Expand Down Expand Up @@ -234,15 +234,18 @@ def get_current_groups(uid, ldap_dict, log, verbose=True):

figshare_dict = dict()

revert_command = f'--netid {uid} '

if isinstance(membership, type(None)):
log.warning("No ismembersof attributes")

figshare_dict['portal'] = ''
figshare_dict['quota'] = ''
figshare_dict['portal'] = 'root'
figshare_dict['quota'] = 'root'
figshare_dict['active'] = False
return figshare_dict

revert_command = f'--netid {uid} '
revert_command += f'--active_remove --portal root --quota root '
log.info(revert_command)
return figshare_dict

# Check for active group
active_stem = figshare_stem('active')
Expand Down Expand Up @@ -276,7 +279,7 @@ def get_current_groups(uid, ldap_dict, log, verbose=True):
quota = [s for s in membership if ((quota_stem in s) and ('grouper' not in s))]
if len(quota) == 0:
log.info(f"No quota Grouper group found for {uid}!")
figshare_dict['quota'] = '' # Initialize to use later
figshare_dict['quota'] = 'root' # Initialize to use later
else:
if len(quota) != 1:
log.warning(f"ERROR! Multiple Grouper quota found {uid}")
Expand All @@ -286,8 +289,7 @@ def get_current_groups(uid, ldap_dict, log, verbose=True):
if verbose:
log.info(f"Current quota is : {figshare_dict['quota']} bytes")

if len(quota) != 0:
revert_command += f"--quota {figshare_dict['quota']} "
revert_command += f"--quota {figshare_dict['quota']} "

log.info(f"To revert, use: {revert_command}")
return figshare_dict

0 comments on commit a374eaa

Please sign in to comment.