class Chef::Knife::PodnixServerCreate
Public Instance Methods
bootstrap()
click to toggle source
end¶ ↑
# File lib/chef/knife/podnix_server_create.rb, line 174 def bootstrap bootstrap = Chef::Knife::Bootstrap.new bootstrap.name_args = @po_server['ip'] bootstrap.config[:run_list] = locate_config_value(:run_list) bootstrap.config[:ssh_user] = locate_config_value(:ssh_user) bootstrap.config[:ssh_password] = locate_config_value(:password) bootstrap.config[:distro] = locate_config_value(:distro) bootstrap.config[:host_key_verify] = false bootstrap.config[:chef_node_name] = locate_config_value(:chef_node_name) || @po_server['name'] bootstrap.config[:use_sudo] = true unless bootstrap.config[:ssh_user] == 'root' bootstrap.run end
h()
click to toggle source
# File lib/chef/knife/podnix_server_create.rb, line 104 def h @highline ||= HighLine.new end
podnix_api()
click to toggle source
# File lib/chef/knife/podnix_server_create.rb, line 108 def podnix_api Podnix::API.new({:key => "#{config[:podnix_api_key]}"}) end
run()
click to toggle source
# File lib/chef/knife/podnix_server_create.rb, line 112 def run validate! unless config[:name] ui.error("A Server Name must be provided -N") exit 1 end create_hash = { :name => "#{config[:name]}", :model => "#{config[:flavor]}", :image => "#{config[:image]}", :password => "#{config[:password]}", :storage => "#{config[:storage]}" } if config[:ssd] create_hash[:ssd] = "1" end @po_server = podnix_api.add_server(create_hash) puts ui.color("Server:", :green) msg_pair("Name", config[:name]) msg_pair("Model", config[:flavor]) msg_pair("Image", config[:image]) msg_pair("Storage", config[:storage]) msg_pair("Password", config[:password]) puts ui.color("Server is being created", :green) puts ui.color("Creating Server......", :green) sleep 60 @po_start = podnix_api.start_server({:id => "#{@po_server.data[:body]['id']}"}) puts ui.color("Starting Server......", :green) sleep 60 @po_get = podnix_api.get_server({:id => "#{@po_server.data[:body]['id']}"}) print "\n#{ui.color("Waiting for instance", :magenta)}" puts("\n") @po_server = @po_get.data[:body]['data'] msg_pair("Public DNS Name", @po_server['hostname']) msg_pair("Public IP Address", @po_server['ip']) bootstrap() puts "\n" msg_pair("ID", @po_server['id']) msg_pair("Name", @po_server['name']) msg_pair("Image", @po_server['image']) msg_pair("Password", @po_server['vnc_passwd']) msg_pair("vCores", @po_server['vcores']) msg_pair("RAM", @po_server['ram']) msg_pair("Model", @po_server['model']) msg_pair("Drives", @po_server['drives']) msg_pair("Storage", @po_server['storage']) msg_pair("Run List", (config[:run_list])) #msg_pair("JSON Attributes",config[:json_attributes]) unless !config[:json_attributes] || config[:json_attributes].empty? end