from sfa.plc.slices import *
from sfa.util.sfalogging import *
from sfa.util.record import SfaRecord
-from lxml import etree
from StringIO import StringIO
from time import mktime
return rspec
-def CreateSliver(api, slice_xrn, creds, rspec):
+def CreateSliver(api, slice_xrn, creds, rspec, users):
hrn, type = urn_to_hrn(slice_xrn)
hrn_auth = get_authority(hrn)
slice['pointer'] = 0
reg_objects['slice_record'] = slice
+
+ # Note:
+ # Left off here, need to properly fill out the slice record and
+ # stuff the user information in to get through slices.verify_persons
+ # Need to hear back from Tony Mack to find out how accurate the user
+ # information needs to be.
+ for user in users:
+ slice['researcher'].append(user.getdefault('name', 'geni_default_user'))
+
+
+ keys = []
+ for user in users:
+ keys += user['keys']
+
+ reg_objects['keys'] = keys
+
manager_base = 'sfa.managers'
mgr_type = 'pl'
manager_module = manager_base + ".aggregate_manager_%s" % mgr_type
accepts = [
Parameter(str, "Slice URN"),
Parameter(type([str]), "List of credentials"),
- Parameter(str, "RSpec")
+ Parameter(str, "RSpec"),
+ Parameter(type([]), "List of user information")
]
returns = Parameter(str, "Allocated RSpec")
return newrspec
- def call(self, slice_xrn, creds, rspec):
+ def call(self, slice_xrn, creds, rspec, users):
hrn, type = urn_to_hrn(slice_xrn)
self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name))
rspec = self.__run_sfatables(manager, SFATablesRules('INCOMING'),
hrn, origin_hrn, rspec)
- return manager.CreateSliver(self.api, slice_xrn, ValidCreds, rspec)
+ return manager.CreateSliver(self.api, slice_xrn, ValidCreds, rspec, users)
return ''
self.sync_slice(slice, slice_record, peer)
slice['peer_slice_id'] = slice_record['pointer']
- self.verify_persons(registry, credential, slice_record, site_id, remote_site_id, peer, sfa_peer)
+ self.verify_persons(registry, credential, slice_record, site_id, remote_site_id, peer, sfa_peer, reg_objects)
return slice
- def verify_persons(self, registry, credential, slice_record, site_id, remote_site_id, peer, sfa_peer):
+ def verify_persons(self, registry, credential, slice_record, site_id, remote_site_id, peer, sfa_peer, reg_objects=None):
# get the list of valid slice users from the registry and make
# sure they are added to the slice
slicename = hrn_to_pl_slicename(slice_record['hrn'])
researchers = slice_record.get('researcher', [])
for researcher in researchers:
person_record = {}
- person_records = registry.resolve(credential, researcher)
+ if reg_objects:
+ person_records = reg_objects['users']['researcher']
+ else:
+ person_records = registry.resolve(credential, researcher)
for record in person_records:
if record['type'] in ['user'] and record['enabled']:
person_record = record