Class: Furnish::Provisioner::VM
- Defined in:
- lib/furnish/provisioners/vm.rb
Overview
The VM provisioner API (which inherits from Furnish::Provisioner::API) just adds a few convenience functions and a tracking database for VM work. This makes it easy to get the data back you need and an easy, consistent way to stuff it away when you have data to store.
See the methods themselves for more information.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#vm ⇒ Object
readonly
Our database, which won’t be available until the provisioner is added to a ProvisionerGroup.
Attributes inherited from API
Instance Method Summary collapse
-
#add_vm(name, metadata) ⇒ Object
Add a vm.
-
#added_to_group ⇒ Object
Hook required by Furnish::ProvisionerGroup#run_add_hook.
-
#list_vms ⇒ Object
List the VMs.
-
#remove_vm(name) ⇒ Object
Delete a VM.
Methods inherited from API
#==, allows_recovery, allows_recovery?, configure_shutdown, configure_startup, furnish_properties, furnish_property, #hash, inherited, #initialize, #recover, #report, #shutdown, shutdown_protocol, #startup, startup_protocol, #to_s
Constructor Details
This class inherits a constructor from Furnish::Provisioner::API
Instance Attribute Details
#vm ⇒ Object (readonly)
Our database, which won’t be available until the provisioner is added to a ProvisionerGroup.
18 19 20 |
# File 'lib/furnish/provisioners/vm.rb', line 18 def vm @vm end |
Instance Method Details
#add_vm(name, metadata) ⇒ Object
Add a vm. Takes a name (String) and metadata (Hash).
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/furnish/provisioners/vm.rb', line 31 def add_vm(name, ) unless vm raise "Cannot add machine '#{name}' to ungrouped provisioner" end unless .kind_of?(Hash) raise ArgumentError, "Metadata must be a kind of Hash!" end vm[name] = end |
#added_to_group ⇒ Object
Hook required by Furnish::ProvisionerGroup#run_add_hook. See Furnish::Provisioner::API#added_to_group for more information.
24 25 26 |
# File 'lib/furnish/provisioners/vm.rb', line 24 def added_to_group @vm = Palsy::Map.new(self.class.name.gsub(/::/, '_').downcase + "_vms", furnish_group_name) end |
#list_vms ⇒ Object
List the VMs. If the provisioner is not named (a part of a Furnish::ProvisionerGroup), will return an empty array.
58 59 60 61 |
# File 'lib/furnish/provisioners/vm.rb', line 58 def list_vms return [] unless vm return vm.keys end |
#remove_vm(name) ⇒ Object
Delete a VM. Takes a name (String).
46 47 48 49 50 51 52 |
# File 'lib/furnish/provisioners/vm.rb', line 46 def remove_vm(name) unless vm raise "Cannot delete machine '#{name}' from ungrouped provisioner" end vm.delete(name) end |