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.
31 32 33 34 |
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb', line 31 def initialize(config) @config = config @ui ||= Chef::Knife::UI.new(STDOUT, STDERR, STDIN, {}) end |
Instance Method Details
#bootstrap ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb', line 36 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
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb', line 61 def create_bootstrap_distribution if @config[:image_os_type] == "windows" || @config[:image_os_type] == "linux" Chef::Knife::Cloud::BootstrapDistribution.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
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrapper.rb', line 48 def create_bootstrap_protocol if @config[:connection_protocol].nil? || @config[:connection_protocol] == "ssh" SshBootstrapProtocol.new(@config) elsif @config[:connection_protocol] == "winrm" WinrmBootstrapProtocol.new(@config) else # raise an exception, invalid bootstrap protocol. = "Invalid bootstrap protocol." ui.fatal() raise CloudExceptions::BootstrapError, end end |