Changeset 3cec20c for fedd/federation
- Timestamp:
- Dec 2, 2010 5:48:01 PM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master
- Children:
- 5d7f1e8
- Parents:
- 4c65f67
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/protogeni_access.py
r4c65f67 r3cec20c 18 18 from util import * 19 19 from fedid import fedid, generate_fedid 20 from authorizer import authorizer 20 from authorizer import authorizer, abac_authorizer 21 21 from service_error import service_error 22 22 from remote_service import xmlrpc_handler, soap_handler, service_caller … … 106 106 self.keys = self.state['keys'] 107 107 self.types = self.state['types'] 108 # Add the ownership attributes to the authorizer. Note that the109 # indices of the allocation dict are strings, but the attributes are110 # fedids, so there is a conversion.111 for k in self.state.get('allocation', {}).keys():112 for o in self.state['allocation'][k].get('owners', []):113 self.auth.set_attribute(o, fedid(hexstr=k))114 self.auth.set_attribute(fedid(hexstr=k),fedid(hexstr=k))115 116 108 self.state_lock.release() 117 109 … … 120 112 set_log_level(config, "access", self.log) 121 113 122 self.access = { } 123 if config.has_option("access", "accessdb"): 124 self.read_access(config.get("access", "accessdb"), 125 access_obj=self.make_access_info) 126 127 self.lookup_access = self.lookup_access_base 128 114 # authorization information 115 self.auth_type = config.get('access', 'auth_type') \ 116 or 'legacy' 117 self.auth_dir = config.get('access', 'auth_dir') 118 accessdb = config.get("access", "accessdb") 119 # initialize the authorization system 120 if self.auth_type == 'legacy': 121 self.access = { } 122 if accessdb: 123 self.legacy_read_access(accessdb, self.make_access_info) 124 # Add the ownership attributes to the authorizer. Note that the 125 # indices of the allocation dict are strings, but the attributes are 126 # fedids, so there is a conversion. 127 self.state_lock.acquire() 128 for k in self.state.get('allocation', {}).keys(): 129 for o in self.state['allocation'][k].get('owners', []): 130 self.auth.set_attribute(o, fedid(hexstr=k)) 131 self.auth.set_attribute(fedid(hexstr=k),fedid(hexstr=k)) 132 133 self.state_lock.release() 134 self.lookup_access = self.legacy_lookup_access_base 135 elif self.auth_type == 'abac': 136 self.auth = abac_authorizer(load=self.auth_dir) 137 self.access = [ ] 138 if accessdb: 139 self.read_access(accessdb, self.make_access_info) 140 else: 141 raise service_error(service_error.internal, 142 "Unknown auth_type: %s" % self.auth_type) 129 143 api = config.get("access", "api") or "protogeni" 130 144 if api == "protogeni": … … 247 261 248 262 # Request for this fedd 249 found, match = self.lookup_access(req, fid)263 found, match, owners = self.lookup_access(req, fid) 250 264 services, svc_state = self.export_services(req.get('service',[]), 251 265 None, None) … … 259 273 self.allocation[aid]['credentials'] = found 260 274 # The list of owner FIDs 261 self.allocation[aid]['owners'] = [ fid ]275 self.allocation[aid]['owners'] = owners 262 276 self.write_state() 263 277 self.state_lock.release() 264 278 self.auth.set_attribute(fid, allocID) 265 279 self.auth.set_attribute(allocID, allocID) 280 self.auth.save() 266 281 267 282 try: … … 673 688 for i in [ i for i in elem.interface \ 674 689 if not i.get_attribute('portal')]: 675 pinf = node['interfaces'].get(i.name, None) 676 pmac = node['mac'].get(i.name, None) 690 if 'interfaces' in node: 691 pinf = node['interfaces'].get(i.name, None) 692 else: 693 pinf = None 694 695 if 'mac' in node: 696 pmac = node['mac'].get(i.name, None) 697 else: 698 pmac = None 677 699 addr = i.get_attribute('ip4_address') 678 700 netmask = i.get_attribute('ip4_netmask') or '255.255.255.0' … … 871 893 'type': 'Slice' 872 894 } 873 segment_commands.slice_authority_call('Resolve', param, ctxt) 895 896 if not self.create_debug: 897 segment_commands.slice_authority_call('Resolve', param, 898 ctxt) 899 else: 900 raise segment_commands.ProtoGENIError(0,0,'Debug') 874 901 except segment_commands.ProtoGENIError, e: 875 902 print e … … 905 932 else: 906 933 raise service_error(service_error.federant, 907 "No URN returned for slice %s" % hrn)934 "No URN returned for slice %s" % slicename) 908 935 909 936 if 'creator_urn' in data: … … 911 938 else: 912 939 raise service_error(service_error.federant, 913 "No creator URN returned for slice %s" % hrn)940 "No creator URN returned for slice %s" % slicename) 914 941 # Populate the ssh keys (let PG format them) 915 942 param = {
Note: See TracChangeset
for help on using the changeset viewer.