def pass_authority_reservation(reservation: ABCReservationMixin,
                                   caller: AuthToken) -> ReservationAvro:
        concrete = reservation.get_resources().get_resources()
        if concrete is None:
            raise ProxyException(
                Constants.NOT_SPECIFIED_PREFIX.format("ticket"))

        avro_reservation = ReservationAvro()
        avro_reservation.slice = Translate.translate_slice_to_avro(
            slice_obj=reservation.get_slice())
        avro_reservation.term = Translate.translate_term(
            term=reservation.get_requested_term())
        avro_reservation.reservation_id = str(reservation.get_reservation_id())
        avro_reservation.sequence = reservation.get_lease_sequence_out()

        rset = Translate.translate_resource_set(
            resource_set=reservation.get_resources())

        if concrete is not None and isinstance(concrete, Ticket):
            rset.ticket = Translate.translate_ticket(ticket=concrete)

        if concrete is not None and isinstance(concrete, UnitSet):
            rset.unit_set = Translate.translate_unit_set(unit_set=concrete)

        avro_reservation.resource_set = rset

        return avro_reservation
Example #2
0
    def attach_res_properties(*, mng: ReservationMng,
                              reservation: ABCReservationMixin):
        sliver = None
        if isinstance(reservation, ABCControllerReservation):
            if reservation.is_active():
                sliver = reservation.get_leased_resources().get_sliver()
            else:
                sliver = reservation.get_resources().get_sliver()
        else:
            rset = reservation.get_resources()
            if rset is not None:
                sliver = rset.get_sliver()

        ticket = None
        rset = reservation.get_resources()

        if rset is not None:
            cs = rset.get_resources()

            if cs is not None and isinstance(cs, Ticket):
                ticket = cs.get_properties()

        mng.set_sliver(sliver=sliver)

        if isinstance(mng, TicketReservationAvro):
            mng.set_ticket_properties(ticket)

        return mng
 def assert_ticketed(self, r: ABCReservationMixin, units: int,
                     rtype: ResourceType, start: datetime, end: datetime):
     self.assertIsNotNone(r)
     self.assertFalse(r.is_failed())
     self.assertEqual(units, r.get_resources().get_units())
     self.assertEqual(rtype, r.get_resources().get_type())
     self.assertIsNotNone(r.get_term())
     self.assertEqual(start, r.get_term().get_new_start_time())
     self.assertEqual(end, r.get_term().get_end_time())
    def check_incoming_close_lease(self, request: ABCAuthorityReservation, incoming: ABCReservationMixin):
        self.assertIsNotNone(incoming)

        rset = incoming.get_resources()

        self.assertIsNotNone(rset)

        self.assertEqual(request.get_requested_units(), rset.get_units())

        uset = rset.get_resources()
        self.assertIsNotNone(uset)
        self.assertEqual(0, uset.get_units())
    def check_incoming_extend_lease(self, request: ABCAuthorityReservation, incoming: ABCReservationMixin):
        self.assertIsNotNone(incoming)
        self.assertEqual(ReservationStates.Active, incoming.get_state())
        self.assertEqual(ReservationPendingStates.None_, incoming.get_pending_state())
        rset = incoming.get_resources()
        self.assertIsNotNone(rset)
        self.assertEqual(request.get_requested_units(), rset.get_units())
        self.assertEqual(incoming.get_term(), request.get_requested_term())

        uset = rset.get_resources()
        self.assertIsNotNone(uset)
        self.assertEqual(self.TicketUnits, uset.get_units())

        u = uset.get_set().values().__iter__().__next__()
        self.assertEqual(self.my_unit, u)
    def check_incoming_lease(self, request: ABCAuthorityReservation, incoming: ABCReservationMixin):
        self.assertIsNotNone(incoming)

        rset = incoming.get_resources()

        self.assertIsNotNone(rset)

        self.assertEqual(request.get_requested_units(), rset.get_units())

        self.assertEqual(incoming.get_term(), request.get_requested_term())

        uset = rset.get_resources()
        self.assertIsNotNone(uset)
        self.assertEqual(self.TicketUnits, uset.get_units())

        u = uset.get_set().values().__iter__().__next__()
        self.my_unit = u
Example #7
0
 def absorb_res_properties(*, rsv_mng: ReservationMng,
                           res_obj: ABCReservationMixin):
     res_obj.get_resources().set_sliver(sliver=rsv_mng.get_sliver())
     return res_obj