knife-bluebox 0.5.0 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
- = Knife BlueBox
2
- This is the official Opscode Knife plugin for BlueBox[http://www.bluebox.new].
3
- This plugin gives knife the ability to create, bootstrap, and manage BlueBox
1
+ = Knife Blue Box
2
+ This is the official Opscode Knife plugin for {Blue Box}[http://www.bluebox.net].
3
+ This plugin gives knife the ability to create, bootstrap, and manage Blue Box
4
4
  servers.
5
5
 
6
6
  == Installation
@@ -25,6 +25,12 @@ class Chef
25
25
  class Knife
26
26
  class BlueboxImagesList < Knife
27
27
 
28
+ deps do
29
+ require 'fog'
30
+ require 'highline'
31
+ require 'chef/json_compat'
32
+ end
33
+
28
34
  banner "knife bluebox images list"
29
35
 
30
36
  def highline
@@ -32,7 +38,8 @@ class Chef
32
38
  end
33
39
 
34
40
  def run
35
- bluebox = Fog::Bluebox::Compute.new(
41
+ bluebox = Fog::Compute.new(
42
+ :provider => 'Bluebox',
36
43
  :bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
37
44
  :bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
38
45
  )
@@ -16,15 +16,23 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'fog'
20
19
  require 'chef/knife'
21
- require 'chef/knife/bootstrap'
22
- require 'chef/json_compat'
23
20
 
24
21
  class Chef
25
22
  class Knife
26
23
  class BlueboxServerCreate < Knife
27
24
 
25
+ deps do
26
+ require 'chef/knife/bootstrap'
27
+ Chef::Knife::Bootstrap.load_deps
28
+ require 'fog'
29
+ require 'socket'
30
+ require 'net/ssh/multi'
31
+ require 'readline'
32
+ require 'highline'
33
+ require 'chef/json_compat'
34
+ end
35
+
28
36
  banner "knife bluebox server create [RUN LIST...] (options)"
29
37
 
30
38
  option :flavor,
@@ -33,6 +41,11 @@ class Chef
33
41
  :description => "The flavor of server",
34
42
  :default => "94fd37a7-2606-47f7-84d5-9000deda52ae"
35
43
 
44
+ option :chef_node_name,
45
+ :short => "-N NAME",
46
+ :long => "--node-name NAME",
47
+ :description => "The Chef node name for your new node"
48
+
36
49
  option :image,
37
50
  :short => "-i IMAGE",
38
51
  :long => "--image IMAGE",
@@ -56,6 +69,27 @@ class Chef
56
69
  :description => "Disables the bootstrapping process.",
57
70
  :default => true
58
71
 
72
+ option :distro,
73
+ :short => "-d DISTRO",
74
+ :long => "--distro DISTRO",
75
+ :description => "Bootstrap a distro using a template",
76
+ :default => "ubuntu10.04-gems"
77
+
78
+ option :identity_file,
79
+ :short => "-I IDENTITY_FILE",
80
+ :long => "--identity-file IDENTITY_FILE",
81
+ :description => "The SSH identity file used for authentication"
82
+
83
+ option :load_balancer,
84
+ :short => "-b LB",
85
+ :long => "--load_balancer LB",
86
+ :description => "Adds server to the specified load balanced application."
87
+
88
+ option :block_startup_timeout,
89
+ :long => "--block_startup_timeout TIME",
90
+ :description => "Amount of time fog should wait before aborting server deployment.",
91
+ :default => 10 * 60
92
+
59
93
  def h
60
94
  @highline ||= HighLine.new
61
95
  end
@@ -67,22 +101,24 @@ class Chef
67
101
  require 'readline'
68
102
  require 'erb'
69
103
 
70
- bluebox = Fog::Bluebox::Compute.new(
104
+ bluebox = Fog::Compute.new(
105
+ :provider => 'Bluebox',
71
106
  :bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
72
107
  :bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
73
108
  )
74
109
 
75
- flavors = bluebox.flavors.inject({}) { |h,f| h[f.id] = f.description; h }
110
+ flavors = bluebox.flavors.inject({}) { |h,f| h[f.id] = f.description; h }
76
111
  images = bluebox.images.inject({}) { |h,i| h[i.id] = i.description; h }
77
112
 
78
113
  puts "#{h.color("Deploying a new Blue Box Block...", :green)}\n\n"
79
114
  server_args = {
80
115
  :flavor_id => config[:flavor],
81
116
  :image_id => config[:image],
82
- :user => config[:username],
83
- :password => config[:password]
117
+ :username => config[:username],
118
+ :password => config[:password],
119
+ :lb_applications => config[:load_balancer]
84
120
  }
85
- server_args[:ssh_key] = Chef::Config[:knife][:ssh_key] if Chef::Config[:knife][:ssh_key]
121
+ server_args[:public_key] = Chef::Config[:knife][:ssh_key] if Chef::Config[:knife][:ssh_key]
86
122
 
87
123
  server = bluebox.servers.new(server_args)
88
124
  response = server.save
@@ -92,23 +128,24 @@ class Chef
92
128
  begin
93
129
 
94
130
  # Make sure we could properly queue the server for creation on BBG.
95
- raise Fog::Bluebox::BlockInstantiationError if server.status != "queued"
131
+ raise Fog::Compute::Bluebox::BlockInstantiationError if server.state != "queued"
96
132
  puts "#{h.color("Hostname", :cyan)}: #{server.hostname}"
97
- puts "#{h.color("Server Status", :cyan)}: #{server.status.capitalize}"
133
+ puts "#{h.color("Server Status", :cyan)}: #{server.state.capitalize}"
98
134
  puts "#{h.color("Flavor", :cyan)}: #{flavors[server.flavor_id]}"
99
135
  puts "#{h.color("Image", :cyan)}: #{images[server.image_id]}"
100
136
  puts "#{h.color("IP Address", :cyan)}: #{server.ips[0]['address']}"
137
+ puts "#{h.color("Load Balanced Applications", :cyan)}: #{server.lb_applications.collect { |x| x['lb_application_name'] }.join(", ")}" unless server.lb_applications.empty?
101
138
 
102
139
  # The server was succesfully queued... Now wait for it to spin up...
103
140
  print "\n#{h.color("Requesting status of #{server.hostname}\n", :magenta)}"
104
141
 
105
- # Allow for 5 minutes to time out...
106
- # ready? will raise Fog::Bluebox::BlockInstantiationError if block creation fails.
107
- unless server.wait_for( 5 * 60 ){ print "."; STDOUT.flush; ready? }
142
+ # Define a timeout and ensure the block starts up in the specified amount of time:
143
+ # ready? will raise Fog::Bluebox::Compute::BlockInstantiationError if block creation fails.
144
+ unless server.wait_for( config[:block_startup_timeout] ){ print "."; STDOUT.flush; ready? }
108
145
 
109
- # The server wasn't started in 5 minutes... Send a destroy call to make sure it doesn't spin up on us later...
146
+ # The server wasn't started in specified timeout ... Send a destroy call to make sure it doesn't spin up on us later.
110
147
  server.destroy
111
- raise Fog::Bluebox::BlockInstantiationError, "BBG server not available after 5 minutes"
148
+ raise Fog::Compute::Bluebox::BlockInstantiationError, "BBG server not available after #{config[:block_startup_timeout]} seconds."
112
149
 
113
150
  else
114
151
  print "\n\n#{h.color("BBG Server startup succesful. Accessible at #{server.hostname}\n", :green)}"
@@ -134,6 +171,7 @@ class Chef
134
171
  bootstrap.config[:identity_file] = config[:identity_file]
135
172
  bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.hostname
136
173
  bootstrap.config[:use_sudo] = true
174
+ bootstrap.config[:distro] = config[:distro]
137
175
  bootstrap.run
138
176
  rescue Errno::ECONNREFUSED
139
177
  puts h.color("Connection refused on SSH, retrying - CTRL-C to abort")
@@ -147,7 +185,7 @@ class Chef
147
185
 
148
186
  end
149
187
 
150
- rescue Fog::Bluebox::BlockInstantiationError => e
188
+ rescue Fog::Compute::Bluebox::BlockInstantiationError => e
151
189
 
152
190
  puts "\n\n#{h.color("Encountered error starting up BBG block. Auto destroy called. Please try again.", :red)}"
153
191
 
@@ -16,24 +16,28 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'fog'
20
- require 'highline'
21
- require 'readline'
22
19
  require 'chef/knife'
23
- require 'chef/json_compat'
24
20
 
25
21
  class Chef
26
22
  class Knife
27
23
  class BlueboxServerDelete < Knife
28
24
 
25
+ deps do
26
+ require 'fog'
27
+ require 'highline'
28
+ require 'readline'
29
+ require 'chef/json_compat'
30
+ end
31
+
29
32
  banner "knife bluebox server delete BLOCK-HOSTNAME"
30
33
 
31
- def h
34
+ def h
32
35
  @highline ||= HighLine.new
33
36
  end
34
37
 
35
38
  def run
36
- bluebox = Fog::Bluebox::Compute.new(
39
+ bluebox = Fog::Compute.new(
40
+ :provider => 'Bluebox',
37
41
  :bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
38
42
  :bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
39
43
  )
@@ -26,6 +26,13 @@ class Chef
26
26
  class Knife
27
27
  class BlueboxServerList < Knife
28
28
 
29
+ deps do
30
+ require 'fog'
31
+ require 'highline'
32
+ require 'readline'
33
+ require 'chef/json_compat'
34
+ end
35
+
29
36
  banner "knife bluebox server list (options)"
30
37
 
31
38
  def h
@@ -33,7 +40,8 @@ class Chef
33
40
  end
34
41
 
35
42
  def run
36
- bluebox = Fog::Bluebox::Compute.new(
43
+ bluebox = Fog::Compute.new(
44
+ :provider => 'Bluebox',
37
45
  :bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
38
46
  :bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
39
47
  )
@@ -1,3 +1,3 @@
1
1
  module KnifeBlueBox
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.7"
3
3
  end
metadata CHANGED
@@ -1,50 +1,46 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: knife-bluebox
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.7
4
5
  prerelease:
5
- version: 0.5.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Adam Jacob
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-03-29 00:00:00 -07:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: chef
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2156629200 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
24
21
  version: 0.9.14
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: fog
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2156629200
25
+ - !ruby/object:Gem::Dependency
26
+ name: fog
27
+ requirement: &2156628360 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
29
+ requirements:
33
30
  - - ~>
34
- - !ruby/object:Gem::Version
35
- version: 0.6.0
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.2
36
33
  type: :runtime
37
- version_requirements: *id002
34
+ prerelease: false
35
+ version_requirements: *2156628360
38
36
  description: BlueBox Support for Chef's Knife Command
39
37
  email: adam@opscode.com
40
38
  executables: []
41
-
42
39
  extensions: []
43
-
44
- extra_rdoc_files:
40
+ extra_rdoc_files:
45
41
  - README.rdoc
46
42
  - LICENSE
47
- files:
43
+ files:
48
44
  - LICENSE
49
45
  - README.rdoc
50
46
  - lib/chef/knife/bluebox_images_list.rb
@@ -52,33 +48,28 @@ files:
52
48
  - lib/chef/knife/bluebox_server_delete.rb
53
49
  - lib/chef/knife/bluebox_server_list.rb
54
50
  - lib/knife-bluebox/version.rb
55
- has_rdoc: true
56
51
  homepage: http://wiki.opscode.com/display/chef
57
52
  licenses: []
58
-
59
53
  post_install_message:
60
54
  rdoc_options: []
61
-
62
- require_paths:
55
+ require_paths:
63
56
  - lib
64
- required_ruby_version: !ruby/object:Gem::Requirement
57
+ required_ruby_version: !ruby/object:Gem::Requirement
65
58
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: "0"
70
- required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
64
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: "0"
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
76
69
  requirements: []
77
-
78
70
  rubyforge_project:
79
- rubygems_version: 1.6.2
71
+ rubygems_version: 1.8.6
80
72
  signing_key:
81
73
  specification_version: 3
82
74
  summary: BlueBox Support for Chef's Knife Command
83
75
  test_files: []
84
-