Changeset 7525 for cows_wps


Ignore:
Timestamp:
27/09/10 10:35:19 (9 years ago)
Author:
astephen
Message:

Added bin/create_policy_file.py
To allow auto-generation of policy.xml NDG-security file.

Location:
cows_wps/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cows_wps/trunk/bin/create_policy_file.py

    r7524 r7525  
    2727<Policy PolicyId="CEDA Test WPS Authorisation Policy" xmlns="urn:ndg:security:authz:1.1:policy"> 
    2828    <Description>Restrict access for CEDA WPS security tests</Description> 
    29  
    3029%(body)s 
    3130 
     
    4140            </Attribute> 
    4241        </Attributes> 
    43     </Target>""" 
     42    </Target> 
     43""" 
    4444 
    4545 
     
    6464def compilePolicy(): 
    6565    "Reads ``roles_info.ini`` config file and generates policy from it." 
     66    roles = roles_info["roles"] 
     67    roles_reversed = reverseMap(roles) 
    6668    role_map = roles_info["proc_role_map"] 
    67     roles = reverseMap(roles_info["roles"]) 
    6869    arg_map = reverseMap(roles_info["pattern_role_map"], rtype = "dict") 
    6970 
     
    8182                raise Exception("Unrecognised pattern in 'roles_info.ini' file: '%s'." % pattern) 
    8283 
    83             pattern_modified = pattern[4:].replace("=", ",") 
     84            pattern_modified = pattern[4:].replace("=", ",").replace("/", "\\/") 
    8485 
    85             for (role_number, role) in roles: 
     86            for (role_number, role) in roles_reversed: 
    8687 
    87                 pol = target_template % {"regex": pattern_modified, "role": role}    
     88                if role == "none": continue 
     89 
     90                mapped_role = arg_map[role]  
     91                role_specific_pattern = pattern_modified.replace("(.+?)", mapped_role) 
     92                proc_id_and_arg_pattern = ".*%s.*%s.*" % (proc_id, role_specific_pattern) 
     93 
     94                pol = target_template % {"regex": proc_id_and_arg_pattern, "role": role}    
    8895                policies += pol 
    8996 
    9097        else: 
    91             pol = target_template % {"regex": pattern, "role": role} 
    92             policies += pol 
     98 
     99            if pattern != "none": 
     100                pol = target_template % {"regex": ".*%s.*" % proc_id, "role": pattern} 
     101                policies += pol 
     102 
     103    # Now do download URLs based on numeric roles 
     104    for (rn, role) in roles_reversed: 
     105 
     106        if role == "none": continue 
     107 
     108        dl_pattern = "dl/%s/.*?/.*" % rn    
     109        pol = target_template % {"regex": dl_pattern, "role": role}  
     110        policies += pol 
    93111 
    94112    xml = policy_skeleton % {"body": policies} 
    95     print xml 
    96  
    97     # Now do downloads 
    98     print "NOW DO DOWNLOADS" 
    99  
    100      
     113    print xml  
    101114 
    102115if __name__ == "__main__": 
  • cows_wps/trunk/cows_wps/utils/case_sensitive_ordered_config_parser.py

    r5615 r7525  
    1414import logging 
    1515log = logging.getLogger(__name__) 
     16 
     17 
     18class CaseSensitiveConfigParser(ConfigParser): 
     19    "Sub-class allowing case sensitive keys." 
     20    # Fix parser to be case sensitive 
     21    optionxform = str 
     22 
    1623 
    1724class CaseSensitiveOrderedConfigParser(ConfigParser): 
  • cows_wps/trunk/cows_wps/utils/common.py

    r7116 r7525  
    1818import Cookie 
    1919 
    20 from cows_wps.utils import case_sensitive_ordered_config_parser as cp 
     20#from cows_wps.utils import case_sensitive_ordered_config_parser as cp 
    2121 
    2222import logging 
     
    274274    items = url.split("/") 
    275275    (job_id, file_name) = items[-2:] 
     276 
    276277    req = requestManager.getRequest(job_id, sgeUpdate=False) 
    277278    process_dir = req.job.process_dir 
     
    293294if __name__ == "__main__": 
    294295 
    295     print generateDownloadURL("/disks/westerly1/test_dirs/proc_outputs/help/outputs/help_007.nc") 
    296296    for i in "abcde": print getUniqueId(i)  
    297297 
  • cows_wps/trunk/cows_wps/utils/parse_roles_config.py

    r7521 r7525  
    1313# local imports 
    1414from cows_wps.utils.case_sensitive_ordered_config_parser import CaseSensitiveConfigParser 
    15 #from cows_wps.utils.parse_wps_config import wps_config_dict 
    16 wps_config_dict={} 
     15 
     16# When running in pylons the following import works but if run 
     17# from a script outside pylons we need to define an empty dict 
     18# so that it works. 
     19try: 
     20    from cows_wps.utils.parse_wps_config import wps_config_dict 
     21except: 
     22    wps_config_dict = {} 
    1723 
    1824log = logging.getLogger(__name__) 
  • cows_wps/trunk/cows_wps/utils/role_handler.py

    r7521 r7525  
    105105 
    106106    print "Proc Id & Args --> role (and role number)..." 
    107     inputs = [("GetUKWeatherStations", {}),  
     107    inputs = [("GetWeatherStations", {}),  
    108108              ("DoubleIt", {}), 
    109109              ("NCDumpIt", {"FilePath": "/badc/ecmwf-op/data/gg/ap/myfile.nc"}), 
Note: See TracChangeset for help on using the changeset viewer.