Class: Chef::Knife::Cloud::BootstrapProtocol

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb

Direct Known Subclasses

SshBootstrapProtocol, WinrmBootstrapProtocol

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#locate_config_value, #msg_pair

Constructor Details

#initialize(config) ⇒ BootstrapProtocol

Returns a new instance of BootstrapProtocol.



32
33
34
35
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 32

def initialize(config)
  @config = config
  @ui ||= Chef::Knife::UI.new(STDOUT, STDERR, STDIN, {})
end

Instance Attribute Details

#bootstrapObject

Returns the value of attribute bootstrap.



29
30
31
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 29

def bootstrap
  @bootstrap
end

#configObject (readonly)

Returns the value of attribute config.



30
31
32
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 30

def config
  @config
end

#initial_sleep_delayObject

Returns the value of attribute initial_sleep_delay.



29
30
31
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 29

def initial_sleep_delay
  @initial_sleep_delay
end

#uiObject

Returns the value of attribute ui.



29
30
31
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 29

def ui
  @ui
end

Instance Method Details

#init_bootstrap_optionsObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 47

def init_bootstrap_options
  # set the command bootstrap options.
  bootstrap.name_args = locate_config_value(:bootstrap_ip_address)
  bootstrap.config[:chef_node_name] = locate_config_value(:chef_node_name)
  bootstrap.config[:run_list] = locate_config_value(:run_list)
  bootstrap.config[:prerelease] = locate_config_value(:prerelease)
  bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
  bootstrap.config[:distro] = locate_config_value(:distro)
  bootstrap.config[:bootstrap_proxy] = locate_config_value(:bootstrap_proxy)
  bootstrap.config[:environment] = locate_config_value(:environment)
  # see chef/knife/bootstrap.rb #warn_chef_config_secret_key.
  bootstrap.config[:encrypted_data_bag_secret] = locate_config_value(:encrypted_data_bag_secret)
  bootstrap.config[:encrypted_data_bag_secret_file] = locate_config_value(:encrypted_data_bag_secret_file)
  bootstrap.config[:first_boot_attributes] = locate_config_value(:first_boot_attributes)
  bootstrap.config[:secret] = locate_config_value(:secret)
  bootstrap.config[:secret_file] = locate_config_value(:secret_file)
  bootstrap.config[:template_file] =  locate_config_value(:template_file)
end

#send_bootstrap_commandObject



41
42
43
44
45
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 41

def send_bootstrap_command
  wait_for_server_ready
  init_bootstrap_options
  @bootstrap.run
end

#wait_for_server_readyObject

Raises:

  • (Chef::Exceptions::Override)


37
38
39
# File 'lib/chef/knife/cloud/chefbootstrap/bootstrap_protocol.rb', line 37

def wait_for_server_ready
  raise Chef::Exceptions::Override, "You must override wait_for_server_ready in #{self.to_s}"
end