Class: Furnish::Provisioner::IP
- Inherits:
-
API
- Object
- API
- Furnish::Provisioner::IP
- Defined in:
- lib/furnish/provisioners/ip.rb
Overview
Static Provisioner against the Furnish::IP registry. Place this after something that yields an IP address to record it in the registry under the provisioner group’s name.
Instance Method Summary collapse
-
#initialize(args) ⇒ IP
constructor
Create the provisioner, requires :ip be passed and referring to a Furnish::IP object.
-
#ip ⇒ Object
:attr: ip.
-
#report ⇒ Object
Display the allocated addresses for this group.
-
#shutdown(args = {}) ⇒ Object
Releases the allocated addresses.
-
#startup(args = {}) ⇒ Object
Allocate the :ips set passed in to a Furnish::IP group named after the provisioning group.
Constructor Details
#initialize(args) ⇒ IP
Create the provisioner, requires :ip be passed and referring to a Furnish::IP object.
33 34 35 36 37 38 39 |
# File 'lib/furnish/provisioners/ip.rb', line 33 def initialize(args) super unless ip raise ArgumentError, "A Furnish::IP object must be provided" end end |
Instance Method Details
#ip ⇒ Object
:attr: ip
A Furnish::IP object.
18 |
# File 'lib/furnish/provisioners/ip.rb', line 18 furnish_property :ip, "A Furnish::IP registry object", Furnish::IP |
#report ⇒ Object
Display the allocated addresses for this group.
70 71 72 |
# File 'lib/furnish/provisioners/ip.rb', line 70 def report ip.group_items(furnish_group_name).to_a rescue [] end |
#shutdown(args = {}) ⇒ Object
Releases the allocated addresses.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/furnish/provisioners/ip.rb', line 56 def shutdown(args={}) if @controlled_ips ip.remove_from_group(furnish_group_name, @controlled_ips) end if ip.group_items(furnish_group_name).empty? ip.decommission_group(furnish_group_name) end return({ }) end |
#startup(args = {}) ⇒ Object
Allocate the :ips set passed in to a Furnish::IP group named after the provisioning group.
Returns the set of IP addresses in :ips.
47 48 49 50 51 |
# File 'lib/furnish/provisioners/ip.rb', line 47 def startup(args={}) @controlled_ips = args[:ips] ip.assign_group_items(furnish_group_name, @controlled_ips) return({ :ips => ip.group_items(furnish_group_name) }) end |