class OSC::Reservations::Reservation

Provides a way for developers to interact with a scheduler independent reservation.

Attributes

auser[RW]

@return [String] The accounting creds user (who gets charged for unused resources).

endtime[RW]

@return [Time] The time when this reservation ends.

id[RW]

@return [String] The ID for this reservation.

nodes[RW]

@return [Array<Node>] The list of nodes reserved under this reservation.

starttime[RW]

@return [Time] The time when this reservation begins.

users[RW]

@return [Array<String>] The list of users who have access to this reservation.

Public Class Methods

new(opts) click to toggle source

@param opts [Hash] The options to create a reservation with. @option opts [String] :id The ID of the reservation. @option opts [Time] :starttime The time the reservations begins. @option opts [Time] :endtime The time the reservation ends. @option opts [Array<Node>] :nodes An array of nodes allocated for the reservation. @option opts [String] :auser The accounting user to be charged for unused CPU of reservation. @option opts [Array<String>] :users An array of users who have access to this reservation.

# File lib/osc/reservations/reservation.rb, line 31
def initialize(opts)
  @id        = opts[:id]
  @starttime = opts[:starttime]
  @endtime   = opts[:endtime]
  @nodes     = opts[:nodes]
  @auser     = opts[:auser]
  @users     = opts[:users]
end

Public Instance Methods

free_nodes() click to toggle source

List of nodes that are free to use for this reservation. @return [Array<Node>] The list of nodes free to use.

# File lib/osc/reservations/reservation.rb, line 42
def free_nodes
  nodes.select(&:free?)
end
started?() click to toggle source

Has this reservation started yet? @return [Boolean] Whether this reservation has started yet.

# File lib/osc/reservations/reservation.rb, line 48
def started?
  Time.now >= starttime
end