Class: OSC::Reservations::Reservation

Inherits:
Object
  • Object
show all
Defined in:
lib/osc/reservations/reservation.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Reservation

Returns a new instance of Reservation.

Parameters:

  • opts (Hash)

    The options to create a reservation with.

Options Hash (opts):

  • :id (String)

    The ID of the reservation.

  • :starttime (Time)

    The time the reservations begins.

  • :endtime (Time)

    The time the reservation ends.

  • :nodes (Array<Node>)

    An array of nodes allocated for the reservation.

  • :auser (String)

    The accounting user to be charged for unused CPU of reservation.

  • :users (Array<String>)

    An array of users who have access to this reservation.



31
32
33
34
35
36
37
38
# 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

Instance Attribute Details

#auserString

Returns The accounting creds user (who gets charged for unused resources).

Returns:

  • (String)

    The accounting creds user (who gets charged for unused resources).



19
20
21
# File 'lib/osc/reservations/reservation.rb', line 19

def auser
  @auser
end

#endtimeTime

Returns The time when this reservation ends.

Returns:

  • (Time)

    The time when this reservation ends.



13
14
15
# File 'lib/osc/reservations/reservation.rb', line 13

def endtime
  @endtime
end

#idString

Returns The ID for this reservation.

Returns:

  • (String)

    The ID for this reservation.



7
8
9
# File 'lib/osc/reservations/reservation.rb', line 7

def id
  @id
end

#nodesArray<Node>

Returns The list of nodes reserved under this reservation.

Returns:

  • (Array<Node>)

    The list of nodes reserved under this reservation.



16
17
18
# File 'lib/osc/reservations/reservation.rb', line 16

def nodes
  @nodes
end

#starttimeTime

Returns The time when this reservation begins.

Returns:

  • (Time)

    The time when this reservation begins.



10
11
12
# File 'lib/osc/reservations/reservation.rb', line 10

def starttime
  @starttime
end

#usersArray<String>

Returns The list of users who have access to this reservation.

Returns:

  • (Array<String>)

    The list of users who have access to this reservation.



22
23
24
# File 'lib/osc/reservations/reservation.rb', line 22

def users
  @users
end

Instance Method Details

#free_nodesArray<Node>

List of nodes that are free to use for this reservation.

Returns:

  • (Array<Node>)

    The list of nodes free to use.



42
43
44
# File 'lib/osc/reservations/reservation.rb', line 42

def free_nodes
  nodes.select(&:free?)
end

#started?Boolean

Has this reservation started yet?

Returns:

  • (Boolean)

    Whether this reservation has started yet.



48
49
50
# File 'lib/osc/reservations/reservation.rb', line 48

def started?
  Time.now >= starttime
end