Class: Chef::Knife::ServerBootstrapOpenstack

Inherits:
Chef::Knife
  • Object
show all
Includes:
ServerBootstrapBase
Defined in:
lib/chef/knife/server_bootstrap_openstack.rb

Overview

Provisions an OpenStack instance and sets up an Open Source Chef Server.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ServerBootstrapBase

included

Class Method Details

.wrapped_plugin_classObject



31
32
33
# File 'lib/chef/knife/server_bootstrap_openstack.rb', line 31

def self.wrapped_plugin_class
  Chef::Knife::Cloud::OpenstackServerCreate
end

Instance Method Details

#openstack_bootstrapObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/chef/knife/server_bootstrap_openstack.rb', line 70

def openstack_bootstrap
  ENV["WEBUI_PASSWORD"] = config_val(:webui_password)
  ENV["AMQP_PASSWORD"] = config_val(:amqp_password)
  ENV["NO_TEST"] = "1" if config[:no_test]
  bootstrap = wrapped_plugin_class.new
  wrapped_plugin_class.options.keys.each do |attr|
    val = config_val(attr)
    next if val.nil?

    bootstrap.config[attr] = val
  end
  bootstrap.config[:distro] = bootstrap_distro
  bootstrap
end

#openstack_connectionObject



85
86
87
88
89
90
91
92
93
94
# File 'lib/chef/knife/server_bootstrap_openstack.rb', line 85

def openstack_connection
  @openstack_connection ||= Fog::Compute.new(
    :provider => :openstack,
    :openstack_username => config_val(:openstack_username),
    :openstack_password => config_val(:openstack_password),
    :openstack_auth_url => config_val(:openstack_auth_url),
    :openstack_tenant => config_val(:openstack_tenant),
    :openstack_region => config_val(:openstack_region)
  )
end

#runObject



62
63
64
65
66
67
68
# File 'lib/chef/knife/server_bootstrap_openstack.rb', line 62

def run
  super
  openstack_bootstrap.run
  fetch_validation_key
  create_root_client
  install_client_key
end

#server_ip_addressObject



96
97
98
99
100
101
102
# File 'lib/chef/knife/server_bootstrap_openstack.rb', line 96

def server_ip_address
  server = openstack_connection.servers.find do |s|
    s.status == 1 && s.name == config_val(:openstack_node_name)
  end

  server && server.public_ip_address
end

#wrapped_plugin_classObject



35
36
37
# File 'lib/chef/knife/server_bootstrap_openstack.rb', line 35

def wrapped_plugin_class
  self.class.wrapped_plugin_class
end