Class: Chef::Knife::Cloud::Bootstrapper
- Inherits:
-
Object
- Object
- Chef::Knife::Cloud::Bootstrapper
- Defined in:
- lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #create_bootstrap_distribution ⇒ Object
- #create_bootstrap_protocol ⇒ Object
-
#initialize(config) ⇒ Bootstrapper
constructor
A new instance of Bootstrapper.
Constructor Details
#initialize(config) ⇒ Bootstrapper
Returns a new instance of Bootstrapper.
32 33 34 35 |
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb', line 32 def initialize(config) @config = config @ui ||= Chef::Knife::UI.new(STDOUT, STDERR, STDIN, {}) end |
Instance Method Details
#bootstrap ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb', line 37 def bootstrap # uses BootstrapDistribution and BootstrapProtocol to perform bootstrap @protocol = create_bootstrap_protocol @distribution = create_bootstrap_distribution begin @protocol.send_bootstrap_command rescue Net::SSH::AuthenticationFailed => e = "Authentication Failed during bootstrapping. #{e.}." raise CloudExceptions::BootstrapError, end end |
#create_bootstrap_distribution ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb', line 62 def create_bootstrap_distribution if @config[:image_os_type] == 'windows' Chef::Knife::Cloud::WindowsDistribution.new(@config) elsif @config[:image_os_type] == 'linux' Chef::Knife::Cloud::UnixDistribution.new(@config) else # raise an exception, invalid bootstrap distribution. = "Invalid bootstrap distribution. image_os_type should be either windows or linux." ui.fatal() raise CloudExceptions::BootstrapError, end end |
#create_bootstrap_protocol ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb', line 49 def create_bootstrap_protocol if @config[:bootstrap_protocol].nil? or @config[:bootstrap_protocol] == 'ssh' SshBootstrapProtocol.new(@config) elsif @config[:bootstrap_protocol] == 'winrm' WinrmBootstrapProtocol.new(@config) else # raise an exception, invalid bootstrap protocol. = "Invalid bootstrap protocol." ui.fatal() raise CloudExceptions::BootstrapError, end end |