Skip to content

Commit

Permalink
Merge pull request #32 from matyasselmeci/sw2321
Browse files Browse the repository at this point in the history
Put new content into the beginning of the authorize_only section
  • Loading branch information
matyasselmeci authored Jun 22, 2016
2 parents 348a889 + 9cbd6cc commit 7b29086
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
25 changes: 12 additions & 13 deletions osg_configure/configure_modules/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,20 +261,21 @@ def _update_lcmaps_text(self, lcmaps_db, gums, gums_host):
#
# Update "authorize_only" section
#
addition_comment = ("\n"
addition_comment = ("\n\n"
"## Added by osg-configure\n"
"## Set 'edit_lcmaps_db=False' in the [%s] section of your OSG configs\n"
"## to keep osg-configure from modifying this file\n" %
self.config_section)

# Split the string into three:
# Split the string into four:
# 1. Everything before the authorize_only section
# 2. The authorize_only section (including the header 'authorize_only:')
# 3. Everything after the authorize_only section (if present)
# 2. The header line to the authorize_only section
# 3. The body of the authorize_only section
# 4. Everything after the authorize_only section (if present)
#
# The authorize_only section ends at the end of the file (\Z) or when
# another section begins (^[ \t]*[a-zA-Z_]+:)
authorize_only_re = re.compile(r'\A(.+)(^[ \t]*authorize_only:.+?)(^[ \t]*[a-zA-Z_]+:.+|\Z)',
authorize_only_re = re.compile(r'\A(.+)(^[ \t]*authorize_only:[^\n]*?$)(.+?)(^[ \t]*[a-zA-Z_]+:.+|\Z)',
re.MULTILINE|re.DOTALL)
match = authorize_only_re.search(lcmaps_db)

Expand All @@ -283,7 +284,7 @@ def _update_lcmaps_text(self, lcmaps_db, gums, gums_host):
level=logging.ERROR)
raise exceptions.ConfigureError("No valid 'authorize_only' section in lcmaps.db")

pre_authorize_only, authorize_only, post_authorize_only = match.group(1, 2, 3)
pre_authorize_only, authorize_only_header, authorize_only, post_authorize_only = match.group(1, 2, 3, 4)

# Look for lines like
# "gumsclient -> good | bad" and
Expand All @@ -298,26 +299,24 @@ def _update_lcmaps_text(self, lcmaps_db, gums, gums_host):
# Comment out gridmapfile line
authorize_only = gridmapfile_re.sub("#gridmapfile -> good | bad", authorize_only)

# If there's a gumsclient line, uncomment it. If not, add one to the end of the authorize_only section.
# If there's a gumsclient line, uncomment it. If not, add one to the beginning of the authorize_only section.
authorize_only, changed = gumsclient_re.subn("gumsclient -> good | bad", authorize_only, count=1)
if not changed:
authorize_only += addition_comment
authorize_only += "gumsclient -> good | bad\n"
authorize_only = addition_comment + "gumsclient -> good | bad\n\n" + authorize_only
self.log("Added 'gumsclient' authorization method to authorize_only section of %s" % LCMAPS_DB_LOCATION,
level=logging.WARNING)
else:
# Comment out gumsclient line
authorize_only = gumsclient_re.sub("#gumsclient -> good | bad", authorize_only)

# If there's a gridmapfile line, uncomment it. If not, add one to the end of the authorize_only section.
# If there's a gridmapfile line, uncomment it. If not, add one to the beginning of the authorize_only section.
authorize_only, changed = gridmapfile_re.subn("gridmapfile -> good | bad", authorize_only, count=1)
if not changed:
authorize_only += addition_comment
authorize_only += "gridmapfile -> good | bad\n"
authorize_only = addition_comment + "gridmapfile -> good | bad\n\n" + authorize_only
self.log("Added 'gridmapfile' authorization method to authorize_only section of %s" % LCMAPS_DB_LOCATION,
level=logging.WARNING)

return pre_authorize_only + authorize_only + post_authorize_only
return pre_authorize_only + authorize_only_header + authorize_only + post_authorize_only

def _disable_callout(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion tests/configs/misc/lcmaps.db.missing_gridmap.post
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ bad = "lcmaps_dummy_bad.mod"


authorize_only:
#gumsclient -> good | bad

## Added by osg-configure
## Set 'edit_lcmaps_db=False' in the [Misc Services] section of your OSG configs
## to keep osg-configure from modifying this file
gridmapfile -> good | bad

#gumsclient -> good | bad
glexec:

## Policy 1: GUMS (most common)
Expand Down
3 changes: 2 additions & 1 deletion tests/configs/misc/lcmaps.db.missing_gums.post
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ bad = "lcmaps_dummy_bad.mod"


authorize_only:
#gridmapfile -> good | bad

## Added by osg-configure
## Set 'edit_lcmaps_db=False' in the [Misc Services] section of your OSG configs
## to keep osg-configure from modifying this file
gumsclient -> good | bad

#gridmapfile -> good | bad
glexec:

## Policy 1: GUMS (most common)
Expand Down

0 comments on commit 7b29086

Please sign in to comment.