Ejemplo n.º 1
0
    def update_ticket_wrapper(self, reservation: ReservationClient,
                              rtype: ResourceType, units: int, ticket: Ticket,
                              term: Term):
        if reservation.state == ReservationStates.Nascent:
            reservation.resources = reservation.get_approved_resources(
            ).abstract_clone()
            reservation.resources.units = units
            reservation.resources.type = rtype
            reservation.resources.set_resources(cset=ticket)

            reservation.previous_ticket_term = None
            reservation.previous_term = None
            reservation.term = term.clone()
            reservation.ticket_term = reservation.term

            reservation.transition(prefix="ticket",
                                   state=ReservationStates.Ticketed,
                                   pending=ReservationPendingStates.None_)
        else:
            reservation.resources.units = units
            reservation.resources.type = rtype
            reservation.resources.resources.change(concrete_set=ticket,
                                                   configure=False)

            reservation.previous_term = reservation.term
            reservation.previous_ticket_term = reservation.ticket_term
            reservation.term = term.clone()
            reservation.ticket_term = reservation.term

            reservation.transition(prefix="extendticket",
                                   state=ReservationStates.ActiveTicketed,
                                   pending=ReservationPendingStates.None_)
Ejemplo n.º 2
0
    def update_lease_wrapper(self, reservation: ReservationClient,
                             rtype: ResourceType, units: int,
                             cs: ABCConcreteSet, term: Term):
        if reservation.state == ReservationStates.Ticketed:
            reservation.leased_resources = reservation.resources.abstract_clone(
            )
            reservation.leased_resources.units = units
            reservation.leased_resources.type = rtype
            reservation.leased_resources.set_resources(cset=cs)

            reservation.previous_lease_term = None
            reservation.previous_term = reservation.term
            reservation.lease_term = term.clone()
            reservation.term = reservation.lease_term

            reservation.transition(prefix="redeem",
                                   state=ReservationStates.Active,
                                   pending=ReservationPendingStates.None_)
        else:
            reservation.leased_resources.units = units
            reservation.leased_resources.type = rtype
            reservation.leased_resources.resources.change(concrete_set=cs,
                                                          configure=False)

            reservation.previous_lease_term = reservation.requested_term
            reservation.previous_term = reservation.term
            reservation.lease_term = term.clone()
            reservation.term = reservation.lease_term

            reservation.transition(prefix="redeem",
                                   state=ReservationStates.Active,
                                   pending=ReservationPendingStates.None_)