def extend_lease(self, *, reservation: ABCControllerReservation = None, rset: ReservationSet = None): if reservation is not None and rset is not None: raise ControllerException( "Invalid Arguments: reservation and rset can not be both not None" ) if reservation is None and rset is None: raise ControllerException( "Invalid Arguments: reservation and rset can not be both None") if reservation is not None: self.extend_lease_reservation(reservation=reservation) if rset is not None: for r in rset.values(): try: if isinstance(r, ABCControllerReservation): self.extend_lease_reservation(reservation=r) else: self.logger.warning( "Reservation #{} cannot extendLease".format( r.get_reservation_id())) except Exception as e: self.logger.error( "Could not extend_lease for #{} e={}".format( r.get_reservation_id(), e))
def demand(self, *, rid: ID): if rid is None: raise ControllerException("Invalid argument") reservation = self.get_reservation(rid=rid) if reservation is None: raise ControllerException("Unknown reservation {}".format(rid)) self.policy.demand(reservation=reservation) reservation.set_policy(policy=self.policy)
def modify(self, *, reservation_id: ID, modify_properties: dict): if reservation_id is None or modify_properties is None: self.logger.error( "modifyProperties argument is null or non-existing reservation" ) rc = None try: rc = self.get_reservation(rid=reservation_id) except Exception as e: self.logger.error("Could not find reservation #{} e: {}".format( reservation_id, e)) if rc is None: raise ControllerException( "Unknown reservation: {}".format(reservation_id)) if rc.get_resources() is not None: # TODO print("TODO") else: self.logger.warning( "There are no approved resources for {}, no modify properties will be added" .format(reservation_id)) if not self.recovered: self.modifying_lease.add(reservation=rc) else: self.wrapper.modify_lease(reservation=rc)
def reclaim_delegation_client(self, *, delegation_id: str = None, slice_object: ABCSlice = None, broker: ABCBrokerProxy = None, id_token: str = None) -> ABCDelegation: raise ControllerException("Not implemented")
def update_ticket(self, *, reservation: ABCReservationMixin, update_data, caller: AuthToken): if not self.is_recovered() or self.is_stopped(): raise ControllerException("This actor cannot receive calls") self.wrapper.update_ticket(reservation=reservation, update_data=update_data, caller=caller)
def revisit(self, *, reservation: ABCReservationMixin): super().revisit(reservation=reservation) if reservation.get_state() == ReservationStates.Nascent: self.calendar.add_pending(reservation=reservation) elif reservation.get_state() == ReservationStates.Ticketed: if reservation.get_pending_state( ) == ReservationPendingStates.None_: if reservation.is_pending_recover(): self.calendar.add_pending(reservation=reservation) else: self.calendar.add_redeeming( reservation=reservation, cycle=self.get_redeem(reservation=reservation)) self.calendar.add_holdings( reservation=reservation, start=reservation.get_term().get_new_start_time(), end=reservation.get_term().get_end_time()) self.calendar.add_closing(reservation=reservation, cycle=self.get_close( reservation=reservation, term=reservation.get_term())) if reservation.is_renewable( ) and reservation.get_renew_time() != 0: # Scheduling renewal is a bit tricky, since it may # involve communication with the upstream broker. # However, in some recovery cases, typical in one # container deployment, the broker and the service # manager will be recovering at the same time. In # this case the query may fail and we will have to # fail the reservation. # Our approach here is as follows: we cache the # renew time in the reservation class and persist # it in the database. When we recover, we will # check the renewTime field of the reservation if # it is non-zero, we will use it, otherwise we will # schedule the renew after we get the lease back # from the authority. self.calendar.add_renewing( reservation=reservation, cycle=reservation.get_renew_time()) elif reservation.get_pending_state( ) == ReservationPendingStates.Redeeming: raise ControllerException(Constants.INVALID_RECOVERY_STATE) elif reservation.get_state() == ReservationStates.Active: if reservation.get_pending_state( ) == ReservationPendingStates.None_: # pending list if reservation.is_pending_recover(): self.calendar.add_pending(reservation=reservation) # renewing if reservation.is_renewable(): self.calendar.add_renewing( reservation=reservation, cycle=reservation.get_renew_time()) # holdings self.calendar.add_holdings( reservation=reservation, start=reservation.get_term().get_new_start_time(), end=reservation.get_term().get_end_time()) # closing self.calendar.add_closing( reservation=reservation, cycle=self.get_close(reservation=reservation, term=reservation.get_lease_term())) elif reservation.get_pending_state( ) == ReservationPendingStates.ExtendingTicket: raise ControllerException(Constants.INVALID_RECOVERY_STATE) elif reservation.get_state() == ReservationStates.ActiveTicketed: if reservation.get_pending_state( ) == ReservationPendingStates.None_: if reservation.is_pending_recover(): self.calendar.add_pending(reservation=reservation) else: self.calendar.add_redeeming( reservation=reservation, cycle=self.get_redeem(reservation=reservation)) # holdings self.calendar.add_holdings( reservation=reservation, start=reservation.get_term().get_new_start_time(), end=reservation.get_term().get_end_time()) # closing self.calendar.add_closing( reservation=reservation, cycle=self.get_close(reservation=reservation, term=reservation.get_lease_term())) # renewing if reservation.is_renewable(): self.calendar.add_renewing( reservation=reservation, cycle=reservation.get_renew_time()) elif reservation.get_pending_state( ) == ReservationPendingStates.ExtendingLease: raise ControllerException(Constants.INVALID_RECOVERY_STATE)
def update_delegation(self, *, delegation: ABCDelegation, update_data, caller: AuthToken): raise ControllerException("Not supported in controller")