Skip to content

Commit

Permalink
Lots of changes.
Browse files Browse the repository at this point in the history
1. Using new syntax for declaring gem dependencies.
2. -b for Load Balancer application works as intended.
  • Loading branch information
cparedes committed Apr 7, 2011
1 parent fff71c6 commit 9d12437
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/chef/knife/bluebox_server_create.rb
Expand Up @@ -16,15 +16,22 @@
# limitations under the License.
#

require 'fog'
require 'chef/knife'
require 'chef/knife/bootstrap'
require 'chef/json_compat'

class Chef
class Knife
class BlueboxServerCreate < Knife

deps do
require 'chef/knife/bootstrap'
Chef::Knife::Bootstrap.load_deps
require 'fog'
require 'socket'
require 'net/ssh/multi'
require 'readline'
require 'chef/json_compat'
end

banner "knife bluebox server create [RUN LIST...] (options)"

option :flavor,
Expand All @@ -33,7 +40,7 @@ class BlueboxServerCreate < Knife
:description => "The flavor of server",
:default => "94fd37a7-2606-47f7-84d5-9000deda52ae"

option :chef_node_name,
option :chef_node_name,
:short => "-N NAME",
:long => "--node-name NAME",
:description => "The Chef node name for your new node"
Expand Down Expand Up @@ -101,11 +108,11 @@ def run
server_args = {
:flavor_id => config[:flavor],
:image_id => config[:image],
:user => config[:username],
:username => config[:username],
:password => config[:password],
:lb_applications => config[:load_balancer]
}
server_args[:ssh_key] = Chef::Config[:knife][:ssh_key] if Chef::Config[:knife][:ssh_key]
server_args[:public_key] = Chef::Config[:knife][:ssh_key] if Chef::Config[:knife][:ssh_key]

server = bluebox.servers.new(server_args)
response = server.save
Expand All @@ -121,6 +128,7 @@ def run
puts "#{h.color("Flavor", :cyan)}: #{flavors[server.flavor_id]}"
puts "#{h.color("Image", :cyan)}: #{images[server.image_id]}"
puts "#{h.color("IP Address", :cyan)}: #{server.ips[0]['address']}"
puts "#{h.color("Load Balanced Applications", :cyan)}: #{server.lb_applications.collect { |x| x['lb_application_name'] }.join(", ")}" unless server.lb_applications.empty?

# The server was succesfully queued... Now wait for it to spin up...
print "\n#{h.color("Requesting status of #{server.hostname}\n", :magenta)}"
Expand Down

0 comments on commit 9d12437

Please sign in to comment.