original_docstring: 
          Attempt to transition a slice to a new state
          @param operation slice operation
          @param reservations reservations
          @return Slice State
          @throws Exception in case of error
          
docstring: Attempt to transition a slice to a new state
  @param operation slice operation
  @param reservations reservations
  @return Slice State
  @throws Exception in case of error
docstring_tokens: Attempt to transition a slice to a new state @param operation slice operation @param reservations reservations @return Slice State @throws Exception in case of error
code: def transition_slice(self, *, operation: SliceOperation, reservations: ReservationSet) -> Tuple[bool, SliceState]:
          """
          Attempt to transition a slice to a new state
          @param operation slice operation
          @param reservations reservations
          @return Slice State
          @throws Exception in case of error
          """
          state_changed = False
          prev_state = self.state
          if self.state not in operation.valid_from_states:
              raise SliceException(f"Operation: {operation} cannot transition from state {self.state}")
  
          if operation.command == SliceCommand.Create:
              self.state = SliceState.Configuring
  
          elif operation.command == SliceCommand.Modify:
              self.state = SliceState.Configuring
  
          elif operation.command == SliceCommand.Delete:
              if self.state != SliceState.Dead:
                  self.state = SliceState.Closing
  
          elif operation.command == SliceCommand.Reevaluate:
              if reservations is None or reservations.size() == 0:
                  return state_changed, self.state
  
              bins = StateBins()
              for r in reservations.values():
                  bins.add(s=r.get_state())
  
              if self.state == SliceState.Nascent or self.state == SliceState.Configuring:
                  if not bins.has_state_other_than(ReservationStates.Active, ReservationStates.Closed):
                      self.state = SliceState.StableOK
  
                  if (not bins.has_state_other_than(ReservationStates.Active, ReservationStates.Failed,
                                                    ReservationStates.Closed)) and \
                          bins.has_state(s=ReservationStates.Failed):
                      self.state = SliceState.StableError
  
                  if not bins.has_state_other_than(ReservationStates.Closed, ReservationStates.CloseWait,
                                                   ReservationStates.Failed):
                      self.state = SliceState.Closing
  
              elif self.state == SliceState.StableError or self.state == SliceState.StableOK:
                  if not bins.has_state_other_than(ReservationStates.Closed, ReservationStates.CloseWait,
                                                   ReservationStates.Failed):
                      self.state = SliceState.Dead
  
                  if not bins.has_state_other_than(ReservationStates.Closed, ReservationStates.CloseWait,
                                                   ReservationPendingStates.Closing, ReservationStates.Failed):
                      self.state = SliceState.Closing
  
              elif self.state == SliceState.Closing and not bins.has_state_other_than(ReservationStates.CloseWait,
                                                                                      ReservationStates.Closed,
                                                                                      ReservationStates.Failed):
                  self.state = SliceState.Dead
          if prev_state != self.state:
              state_changed = True
  
          return state_changed, self.state
code_tokens: def transition_slice ( self , * , operation : SliceOperation , reservations : ReservationSet ) -> Tuple [ bool , SliceState ] : state_changed = False prev_state = self . state if self . state not in operation . valid_from_states : raise SliceException ( f"Operation: {operation} cannot transition from state {self.state}" ) if operation . command == SliceCommand . Create : self . state = SliceState . Configuring elif operation . command == SliceCommand . Modify : self . state = SliceState . Configuring elif operation . command == SliceCommand . Delete : if self . state != SliceState . Dead : self . state = SliceState . Closing elif operation . command == SliceCommand . Reevaluate : if reservations is None or reservations . size ( ) == 0 : return state_changed , self . state bins = StateBins ( ) for r in reservations . values ( ) : bins . add ( s = r . get_state ( ) ) if self . state == SliceState . Nascent or self . state == SliceState . Configuring : if not bins . has_state_other_than ( ReservationStates . Active , ReservationStates . Closed ) : self . state = SliceState . StableOK if ( not bins . has_state_other_than ( ReservationStates . Active , ReservationStates . Failed , ReservationStates . Closed ) ) and bins . has_state ( s = ReservationStates . Failed ) : self . state = SliceState . StableError if not bins . has_state_other_than ( ReservationStates . Closed , ReservationStates . CloseWait , ReservationStates . Failed ) : self . state = SliceState . Closing elif self . state == SliceState . StableError or self . state == SliceState . StableOK : if not bins . has_state_other_than ( ReservationStates . Closed , ReservationStates . CloseWait , ReservationStates . Failed ) : self . state = SliceState . Dead if not bins . has_state_other_than ( ReservationStates . Closed , ReservationStates . CloseWait , ReservationPendingStates . Closing , ReservationStates . Failed ) : self . state = SliceState . Closing elif self . state == SliceState . Closing and not bins . has_state_other_than ( ReservationStates . CloseWait , ReservationStates . Closed , ReservationStates . Failed ) : self . state = SliceState . Dead if prev_state != self . state : state_changed = True return state_changed , self . state
short_docstring: Attempt to transition a slice to a new state
  @param operation slice operation
  @param reservations reservations
  @return Slice State
  @throws Exception in case of error
short_docstring_tokens: Attempt to transition a slice to a new state @param operation slice operation @param reservations reservations @return Slice State @throws Exception in case of error
comment: """
          Attempt to transition a slice to a new state
          @param operation slice operation
          @param reservations reservations
          @return Slice State
          @throws Exception in case of error
          """