OSC::Reservations
Ruby library that queries OSC systems for active batch reservations of the current user.
Installation
Add this line to your application's Gemfile:
gem 'osc-reservations'
And then execute:
$ bundle install
Usage
Currently only OSC::Reservations::Query
is implemented, meaning you can query
for available reservations or for a single reservation. At this time you are
unable to submit a reservation to the system. Also it should be noted that the
OSC scheduler is set up to display only the reservations owned by the current
running user. Viewing reservations that the current user does not have access
to is impossible at this time.
Simple Example (Oakley)
This library has a set of OSC clusters pre-programmed into it. Querying a reservation of the Oakley cluster is as simple as
q = OSC::Reservations::Query.oakley
q.reservations
This will return an array of immutable Reservation
objects containing the
relevant information for each reservation allocated to the user. The structure
of such objects are detailed in the corresponding yardoc pages.
Advance Example
This library comes with a list of adapters to communicate with your
corresponding batch scheduler. As of writing this the only adapter implemented
is the Adapters::OSCMoab
adapter. It provides an interface to OSC's Moab
batch scheduler.
Once you have chosen your desired adapter, you will need to define a Batch
server object that the library will connect to when requesting/submitting the
reservations. Certain adapters may have further requirements on the Batch
object (e.g., Adapters::OSCMoab
requires a mrsvctl
property on the Batch
object).
A full implementation would look like
adapter = OSC::Reservations::Adapters::OSCMoab.new
batch = OSC::Reservations::Batch.new(
oak-batch.osc.edu,
mrsvctl: 'LD_LIBRARY_PATH=/usr/local/moab-6.1.11/lib /usr/local/moab-6.1.11/bin/mrsvctl'
)
q = OSC::Reservations::Query.new adapter, batch
q.reservations
Configure your own Batch Schedulers
Currently the library will read from a defined configuration YAML file located
at conf/batch.yml
. An example entry may look like
oakley:
adapter: 'OSC::Reservations::Adapters::OSCMoab'
server: 'oak-batch.osc.edu'
mrsvctl: 'LD_LIBRARY_PATH=/usr/local/moab-6.1.11/lib /usr/local/moab-6.1.11/bin/mrsvctl'
The Query
object will then use these entries when defining its methods. For
example, a developer can access this oakley
batch scheduler through
q = OSC::Reservations::Query.oakley
To predefine your own batch schedulers you will need to make a local YAML file with the necessary properties. Then you would be able to access and use this YAML file as shown below.
OSC::Reservations.batch_config_path = "/path/to/config.yml"
q = OSC::Reservations::Query.my_batch
q.reservations
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Test your changes (
rake test
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request