Class: ChefMetalCrowbar::CrowbarDriver
- Inherits:
-
ChefMetal::Driver
- Object
- ChefMetal::Driver
- ChefMetalCrowbar::CrowbarDriver
- Defined in:
- lib/chef_metal_crowbar/crowbar_driver.rb
Direct Known Subclasses
Constant Summary collapse
- AVAILABLE_DEPLOYMENT =
'available'
- RESERVED_DEPLOYMENT =
'reserved'
- TARGET_NODE_ROLE =
"crowbar-managed-node"
- KEY_ATTRIB =
"chef-server_admin_client_key"
Class Method Summary collapse
-
.from_url(driver_url, config) ⇒ Object
Passed in a driver_url, and a config in the format of Driver.config.
Instance Method Summary collapse
-
#allocate_machine(action_handler, machine_spec, machine_options) ⇒ Object
Acquire a machine, generally by provisioning it.
- #crowbar_api ⇒ Object
-
#initialize(driver_url, config) ⇒ CrowbarDriver
constructor
A new instance of CrowbarDriver.
- #machine_for(machine_spec, machine_options) ⇒ Object
- #ready_machine(action_handler, machine_spec, machine_options) ⇒ Object
Constructor Details
#initialize(driver_url, config) ⇒ CrowbarDriver
Returns a new instance of CrowbarDriver.
45 46 47 |
# File 'lib/chef_metal_crowbar/crowbar_driver.rb', line 45 def initialize(driver_url, config) super(driver_url, config) end |
Class Method Details
.from_url(driver_url, config) ⇒ Object
Passed in a driver_url, and a config in the format of Driver.config.
41 42 43 |
# File 'lib/chef_metal_crowbar/crowbar_driver.rb', line 41 def self.from_url(driver_url, config) CrowbarDriver.new(driver_url, config) end |
Instance Method Details
#allocate_machine(action_handler, machine_spec, machine_options) ⇒ Object
Acquire a machine, generally by provisioning it. Returns a Machine object pointing at the machine, allowing useful actions like setup, converge, execute, file and directory.
58 59 60 61 62 63 64 |
# File 'lib/chef_metal_crowbar/crowbar_driver.rb', line 58 def allocate_machine(action_handler, machine_spec, ) Core.connect # If the server does not exist, create it create_servers(action_handler, { machine_spec => }, Chef::ChefFS::Parallelizer.new(0)) machine_spec end |
#crowbar_api ⇒ Object
49 50 51 52 53 |
# File 'lib/chef_metal_crowbar/crowbar_driver.rb', line 49 def # relies on url & driver_config from Driver superclass scheme, = url.split(':', 2) Crowbar::Core.connect , driver_config end |
#machine_for(machine_spec, machine_options) ⇒ Object
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/chef_metal_crowbar/crowbar_driver.rb', line 106 def machine_for(machine_spec, ) server_id = machine_spec.location['server_id'] = { :auth_methods => ['publickey'], :keys => [ get_key('bootstrapkey') ], } transport = ChefMetal::Transport::SSHTransport.new(server_id, , {}, config) convergence_strategy = ChefMetal::ConvergenceStrategy::InstallCached.new([:convergence_options]) ChefMetal::Machine::UnixMachine.new(machine_spec, transport, convergence_strategy) end |
#ready_machine(action_handler, machine_spec, machine_options) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/chef_metal_crowbar/crowbar_driver.rb', line 87 def ready_machine(action_handler, machine_spec, ) server_id = machine_spec.location['server_id'] server = .node(server_id) if server["alive"] == 'false' action_handler.perform_action "Powering up machine #{server_id}" do .power(server_id, "on") end end if server["state"] != 0 action_handler.perform_action "wait for machine #{server_id}" do .wait_for_machine_to_have_status(server_id, 0) end end # Return the Machine object machine_for(machine_spec, ) end |