OodReservations
Library that queries a cluster for active reservations of the current user.
Installation
Add this line to your application's Gemfile:
gem 'ood_reservations'And then execute:
$ bundleOr install it yourself as:
$ gem install ood_reservationsUsage
Given an OodCluster::Cluster object you can build a query object that can
query all reservations on the cluster or a specified reservation id:
# Create a query object (creates a TorqueMoab query object)
query = OodReservations::Query.build(cluster: my_torque_moab_cluster)
#=> #<OodReservations::Queries::TorqueMoab>
# Create a query object (this cluster has no scheduler to query)
query = OodReservations::Query.build(cluster: my_cluster_w_no_scheduler)
#=> nilTo query reservations:
# Query all reservations you have on that cluster
rsvs = query.reservations
#=>
#[
# #<OodReservations::Reservation>,
# #<OodReservations::Reservation>
#]
# Query for unique reservation id
my_rsv = query.reservation(id: 'my_rsv.23874')
#=> #<OodReservations::Reservation>An OodReservations::Reservation object has information about the given
reservation:
# Has this reservation started yet?
my_rsv.has_started?
#=> true
# Has this reservation ended yet?
my_rsv.has_ended?
#=> false
# Get list of users/groups that have access to this reservation
my_rsv.users.map(&:name)
#=> ["bob", "sally", "me"]
my_rsv.groups.map(&:name)
#=> ["group1", "group2"]
# List all nodes on reservation
my_rsv.nodes.map(&:id)
#=> ["n0001", "n0002"]
# List nodes that have no jobs running on them
my_rsv.free_nodes.map(&:id)
#=> ["n0002"]Contributing
- Fork it ( https://github.com/[my-github-username]/ood_reservations/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request