def allocate(self, urn, rspec_string, expiration, options={}):
        xrn = Xrn(urn)
        aggregate = unigetestbedAggregate(self)
        slices = unigetestbedSlices(self)
        slice_record = None
        users = options.get('geni_users', [])
        if users:
            slice_record = users[0].get('slice_record', {})

        # parse rspec
        rspec = RSpec(rspec_string)
        requested_attributes = rspec.version.get_slice_attributes()

        # ensure slice record exists
        slice = slices.verify_slice(xrn.hrn,
                                    slice_record,
                                    expiration=expiration,
                                    options=options)
        # ensure person records exists
        #persons = slices.verify_persons(xrn.hrn, slice, users, peer, sfa_peer, options=options)

        # add/remove slice from nodes
        request_nodes = rspec.version.get_nodes_with_slivers()
        nodes = slices.verify_slice_nodes(urn, slice, request_nodes)

        return aggregate.describe([xrn.get_urn()], version=rspec.version)
 def provision(self, urns, options={}):
     # update users
     slices = unigetestbedSlices(self)
     aggregate = unigetestbedAggregate(self)
     slivers = aggregate.get_slivers(urns)
     slice = slivers[0]
     geni_users = options.get('geni_users', [])
     #users = slices.verify_users(None, slice, geni_users, options=options)
     # update sliver allocation states and set them to geni_provisioned
     sliver_ids = [sliver['sliver_id'] for sliver in slivers]
     dbsession=self.api.dbsession()
     SliverAllocation.set_allocations(sliver_ids, 'geni_provisioned',dbsession)
     version_manager = VersionManager()
     rspec_version = version_manager.get_version(options['geni_rspec_version'])
     return self.describe(urns, rspec_version, options=options)
 def provision(self, urns, options={}):
     # update users
     slices = unigetestbedSlices(self)
     aggregate = unigetestbedAggregate(self)
     slivers = aggregate.get_slivers(urns)
     slice = slivers[0]
     geni_users = options.get('geni_users', [])
     #users = slices.verify_users(None, slice, geni_users, options=options)
     # update sliver allocation states and set them to geni_provisioned
     sliver_ids = [sliver['sliver_id'] for sliver in slivers]
     dbsession = self.api.dbsession()
     SliverAllocation.set_allocations(sliver_ids, 'geni_provisioned',
                                      dbsession)
     version_manager = VersionManager()
     rspec_version = version_manager.get_version(
         options['geni_rspec_version'])
     return self.describe(urns, rspec_version, options=options)
    def allocate (self, urn, rspec_string, expiration, options={}):
        xrn = Xrn(urn)
        aggregate = unigetestbedAggregate(self)
        slices = unigetestbedSlices(self)
        slice_record=None
        users = options.get('geni_users', [])
        if users:
            slice_record = users[0].get('slice_record', {})

        # parse rspec
        rspec = RSpec(rspec_string)
        requested_attributes = rspec.version.get_slice_attributes()

        # ensure slice record exists
        slice = slices.verify_slice(xrn.hrn, slice_record, expiration=expiration, options=options)
        # ensure person records exists
        #persons = slices.verify_persons(xrn.hrn, slice, users, peer, sfa_peer, options=options)

        # add/remove slice from nodes
        request_nodes = rspec.version.get_nodes_with_slivers()
        nodes = slices.verify_slice_nodes(urn, slice, request_nodes)

        return aggregate.describe([xrn.get_urn()], version=rspec.version)