Skip to content

david-caro/foreman_reserve

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foreman_reserve

<img src=“https://badge.fury.io/rb/foreman_reserve.png” alt=“Gem Version” />

This gem will added a route to the API to return the name of available host(s)

Installation:

You have to make sure that the gem is available to foreman, to do that the recommended way is to add a new file to $FOREMAN_DIR/bundler.d named foreman_reserve.rb with the next content:

  • You can use the git code to get the latest:

gem 'foreman_reserve', :git => "https://github.com/david-caro/foreman_reserve.git"
  • Or the gem from rubygems:

gem 'foreman_reserve'

After that you’ll need to create the bundle for foreman, as foreman user run from the $FOREMAN_DIR:

>$ bunde --deploy

Foreman 1.1

In order to work, the foreman application must be the following two lines commented out.

config/routes.rb

# match '*a', :to => 'errors#routing'

config/routes/v1.rb

# match '*other', :to => 'home#route_error'

Usage

To make a host ‘reservable’, you need to make sure it has a parameter named RESERVED, When this parameter is added it should be set to ‘false’. This parameter will be used to store the current reservation status, you can safely add the parameter to a hostgroup for the host to inherit from.

To return 1 host:

>$ curl -u admin:secret -H 'accept:application/json' http://0.0.0.0:3000/api/hosts_reserve

To return multiple hosts, pass a parameter called ‘amount’

>$ curl -u admin:secret -H 'accept:application/json' http://0.0.0.0:3000/api/hosts_reserve?amount=3

Filter using a specific query: (name ~ virt%)

>$ curl -u admin:secret -H 'accept:application/json' 'http://0.0.0.0:3000/api/hosts_reserve?query=name%20~%20virt%25'

Release a specific host:

>$ curl -u admin:secret -H 'accept:application/json' 'http://0.0.0.0:3000/api/hosts_release?host_name=myreservedhost'

Release a group of hosts using a query: (name ~ virt%)

>$ curl -u admin:secret -H 'accept:application/json' 'http://0.0.0.0:3000/api/hosts_reserve?query=name%20~%20virt%25'

foreman-python

In order to use from python, there’s a python module that already includes this plugin calls, you can find it on pypi or on github:

Contributing to foreman_reserve

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.

  • Fork the project.

  • Start a feature/bugfix branch.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2013 Joseph Mitchell Magen and David Caro. See LICENSE.txt for further details.

About

foreman_reserve

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%