def get_request_from_request(self, request: ABCAuthorityReservation, term: Term, ticket: Ticket):
     rset = ResourceSet(units=1, rtype=request.get_type())
     rset.set_resources(cset=ticket)
     result = AuthorityReservationFactory.create(resources=rset, term=term, slice_obj=request.get_slice(),
                                                 rid=request.get_reservation_id())
     result.set_sequence_in(sequence=request.get_sequence_in() + 1)
     return result
    def pass_reservation(*, reservation: ABCServerReservation,
                         plugin: ABCBasePlugin) -> ABCReservationMixin:
        slice_obj = reservation.get_slice().clone_request()
        term = None

        if reservation.get_term() is None:
            term = reservation.get_requested_term().clone()
        else:
            term = reservation.get_term().clone()

        rset = None

        if reservation.get_resources() is None:
            rset = ResourceSet(units=0, rtype=reservation.get_requested_type())
        else:
            rset = LocalReturn.abstract_clone_return(
                rset=reservation.get_resources())

            concrete = reservation.get_resources().get_resources()

            if concrete is not None:
                cset = concrete.clone()
                rset.set_resources(cset=cset)

        if isinstance(reservation, ABCBrokerReservation):
            client_reservation = ClientReservationFactory.create(
                rid=reservation.get_reservation_id(),
                resources=rset,
                term=term,
                slice_object=slice_obj)
            client_reservation.set_ticket_sequence_in(
                sequence=reservation.get_sequence_out())
            return client_reservation
        else:
            controller_reservation = ClientReservationFactory.create(
                rid=reservation.get_reservation_id(),
                resources=rset,
                term=term,
                slice_object=slice_obj)
            controller_reservation.set_lease_sequence_in(
                sequence=reservation.get_sequence_out())
            return controller_reservation
Ejemplo n.º 3
0
    def extract(self, *, source: ABCDelegation,
                delegation: ResourceTicket) -> ResourceSet:
        """
        Creates a new resource set using the source and the specified delegation.

        @param source source
        @param delegation delegation
        @return returns ResourceSet
        @throws Exception in case of error
        """
        extracted = ResourceSet(units=delegation.get_units(),
                                rtype=delegation.get_resource_type())

        cset = Ticket(resource_ticket=delegation,
                      plugin=self.actor.get_plugin(),
                      authority=source.get_site_proxy(),
                      delegation_id=source.get_delegation_id())

        extracted.set_resources(cset=cset)
        return extracted
 def get_request(self, term: Term, ticket: Ticket, sliver: BaseSliver):
     rset = ResourceSet(units=1, rtype=ResourceType(resource_type=sliver.resource_type.name), sliver=sliver)
     rset.set_resources(cset=ticket)
     slice_object = self.get_request_slice()
     return AuthorityReservationFactory.create(resources=rset, term=term, slice_obj=slice_object, rid=ID())