knife-bluebox 0.5.7 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,10 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'fog'
|
20
|
-
require 'highline'
|
21
19
|
require 'chef/knife'
|
22
|
-
require 'chef/json_compat'
|
23
20
|
|
24
21
|
class Chef
|
25
22
|
class Knife
|
@@ -38,8 +35,7 @@ class Chef
|
|
38
35
|
end
|
39
36
|
|
40
37
|
def run
|
41
|
-
bluebox = Fog::Compute.new(
|
42
|
-
:provider => 'Bluebox',
|
38
|
+
bluebox = Fog::Compute::Bluebox.new(
|
43
39
|
:bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
|
44
40
|
:bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
|
45
41
|
)
|
@@ -23,14 +23,13 @@ class Chef
|
|
23
23
|
class BlueboxServerCreate < Knife
|
24
24
|
|
25
25
|
deps do
|
26
|
-
require 'chef/knife/bootstrap'
|
27
|
-
Chef::Knife::Bootstrap.load_deps
|
28
26
|
require 'fog'
|
29
|
-
require 'socket'
|
30
|
-
require 'net/ssh/multi'
|
31
27
|
require 'readline'
|
32
28
|
require 'highline'
|
29
|
+
require 'net/ssh/multi'
|
33
30
|
require 'chef/json_compat'
|
31
|
+
require 'chef/knife/bootstrap'
|
32
|
+
Chef::Knife::Bootstrap.load_deps
|
34
33
|
end
|
35
34
|
|
36
35
|
banner "knife bluebox server create [RUN LIST...] (options)"
|
@@ -50,7 +49,7 @@ class Chef
|
|
50
49
|
:short => "-i IMAGE",
|
51
50
|
:long => "--image IMAGE",
|
52
51
|
:description => "The image of the server",
|
53
|
-
:default => "
|
52
|
+
:default => "a8f05200-7638-47d1-8282-2474ef57c4c3"
|
54
53
|
|
55
54
|
option :username,
|
56
55
|
:short => "-U KEY",
|
@@ -64,10 +63,10 @@ class Chef
|
|
64
63
|
:description => "User password on new server.",
|
65
64
|
:default => ""
|
66
65
|
|
67
|
-
option :
|
68
|
-
:long => "--bootstrap
|
66
|
+
option :disable_bootstrap,
|
67
|
+
:long => "--disable-bootstrap",
|
69
68
|
:description => "Disables the bootstrapping process.",
|
70
|
-
:
|
69
|
+
:boolean => true
|
71
70
|
|
72
71
|
option :distro,
|
73
72
|
:short => "-d DISTRO",
|
@@ -95,14 +94,17 @@ class Chef
|
|
95
94
|
end
|
96
95
|
|
97
96
|
def run
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
97
|
+
$stdout.sync = true
|
98
|
+
|
99
|
+
if Chef::Config[:knife][:identity_file].nil? && config[:identity_file].nil?
|
100
|
+
ui.error('You have not provided a SSH identity file. This is required to create a Blue Box server.')
|
101
|
+
exit 1
|
102
|
+
elsif Chef::Config[:knife][:identity_file]
|
103
|
+
public_key = File.read(Chef::Config[:knife][:identity_file]).chomp
|
104
|
+
else public_key = File.read(config[:identity_file]).chomp
|
105
|
+
end
|
106
|
+
|
107
|
+
bluebox = Fog::Compute::Bluebox.new(
|
106
108
|
:bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
|
107
109
|
:bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
|
108
110
|
)
|
@@ -111,18 +113,18 @@ class Chef
|
|
111
113
|
images = bluebox.images.inject({}) { |h,i| h[i.id] = i.description; h }
|
112
114
|
|
113
115
|
puts "#{h.color("Deploying a new Blue Box Block...", :green)}\n\n"
|
114
|
-
|
115
|
-
|
116
|
-
:
|
117
|
-
:
|
116
|
+
|
117
|
+
server = bluebox.servers.new(
|
118
|
+
:flavor_id => Chef::Config[:knife][:flavor] || config[:flavor],
|
119
|
+
:image_id => Chef::Config[:knife][:image] || config[:image],
|
120
|
+
:hostname => config[:chef_node_name],
|
121
|
+
:username => Chef::Config[:knife][:username] || config[:username],
|
118
122
|
:password => config[:password],
|
119
|
-
:
|
120
|
-
|
121
|
-
|
123
|
+
:public_key => public_key,
|
124
|
+
:lb_applications => Chef::Config[:knife][:load_balancer] || config[:load_balancer]
|
125
|
+
)
|
122
126
|
|
123
|
-
server = bluebox.servers.new(server_args)
|
124
127
|
response = server.save
|
125
|
-
$stdout.sync = true
|
126
128
|
|
127
129
|
# Wait for the server to start
|
128
130
|
begin
|
@@ -141,7 +143,7 @@ class Chef
|
|
141
143
|
|
142
144
|
# Define a timeout and ensure the block starts up in the specified amount of time:
|
143
145
|
# ready? will raise Fog::Bluebox::Compute::BlockInstantiationError if block creation fails.
|
144
|
-
unless server.wait_for(
|
146
|
+
unless server.wait_for(config[:block_startup_timeout]){ print "."; STDOUT.flush; ready? }
|
145
147
|
|
146
148
|
# The server wasn't started in specified timeout ... Send a destroy call to make sure it doesn't spin up on us later.
|
147
149
|
server.destroy
|
@@ -151,9 +153,9 @@ class Chef
|
|
151
153
|
print "\n\n#{h.color("BBG Server startup succesful. Accessible at #{server.hostname}\n", :green)}"
|
152
154
|
|
153
155
|
# Make sure we should be bootstrapping.
|
154
|
-
|
155
|
-
puts "\n\n#{h.color("Boostrapping disabled per command line inputs. Exiting here.
|
156
|
-
|
156
|
+
if config[:disable_bootstrap]
|
157
|
+
puts "\n\n#{h.color("Boostrapping disabled per command line inputs. Exiting here.", :green)}"
|
158
|
+
exit 0
|
157
159
|
end
|
158
160
|
|
159
161
|
# Bootstrap away!
|
@@ -164,9 +166,7 @@ class Chef
|
|
164
166
|
bootstrap = Chef::Knife::Bootstrap.new
|
165
167
|
bootstrap.name_args = [ server.ips[0]['address'] ]
|
166
168
|
bootstrap.config[:run_list] = @name_args
|
167
|
-
|
168
|
-
bootstrap.config[:password] = password
|
169
|
-
end
|
169
|
+
bootstrap.config[:password] = password unless config[:password].blank?
|
170
170
|
bootstrap.config[:ssh_user] = config[:username]
|
171
171
|
bootstrap.config[:identity_file] = config[:identity_file]
|
172
172
|
bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.hostname
|
@@ -36,9 +36,8 @@ class Chef
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def run
|
39
|
-
bluebox = Fog::Compute.new(
|
40
|
-
:
|
41
|
-
:bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
|
39
|
+
bluebox = Fog::Compute::Bluebox.new(
|
40
|
+
:bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
|
42
41
|
:bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
|
43
42
|
)
|
44
43
|
|
@@ -46,8 +45,8 @@ class Chef
|
|
46
45
|
servers = bluebox.servers.inject({}) { |h,f| h[f.hostname] = f.id; h }
|
47
46
|
|
48
47
|
unless servers.has_key?(@name_args[0])
|
49
|
-
|
50
|
-
|
48
|
+
ui.error("Can't find a block named #{@name_args[0]}")
|
49
|
+
exit 1
|
51
50
|
end
|
52
51
|
|
53
52
|
confirm(h.color("Do you really want to delete block UUID #{servers[@name_args[0]]} with hostname #{@name_args[0]}", :green))
|
@@ -55,10 +54,13 @@ class Chef
|
|
55
54
|
begin
|
56
55
|
response = bluebox.destroy_block(servers[@name_args[0]])
|
57
56
|
if response.status == 200
|
58
|
-
|
57
|
+
puts "\n\n#{h.color("Successfully destroyed #{@name_args[0]}", :green)}"
|
58
|
+
else
|
59
|
+
puts "\n\n#{h.color("There was a problem destroying #{@name_args[0]}. Please check Box Panel.", :red)}"
|
60
|
+
exit 1
|
59
61
|
end
|
60
62
|
rescue Excon::Errors::UnprocessableEntity
|
61
|
-
|
63
|
+
puts "\n\n#{h.color("There was a problem destroying #{@name_args[0]}. Please check Box Panel.", :red)}"
|
62
64
|
end
|
63
65
|
end
|
64
66
|
end
|
@@ -16,11 +16,7 @@
|
|
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
|
@@ -40,9 +36,8 @@ class Chef
|
|
40
36
|
end
|
41
37
|
|
42
38
|
def run
|
43
|
-
bluebox = Fog::Compute.new(
|
44
|
-
:
|
45
|
-
:bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
|
39
|
+
bluebox = Fog::Compute::Bluebox.new(
|
40
|
+
:bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
|
46
41
|
:bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
|
47
42
|
)
|
48
43
|
|
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-bluebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
-
|
8
|
+
- Lee Huffman
|
9
|
+
- Jesse Proudman
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
+
date: 2012-02-09 00:00:00.000000000Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: chef
|
16
|
-
requirement: &
|
17
|
+
requirement: &2156276420 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
@@ -21,10 +22,10 @@ dependencies:
|
|
21
22
|
version: 0.9.14
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
+
version_requirements: *2156276420
|
25
26
|
- !ruby/object:Gem::Dependency
|
26
27
|
name: fog
|
27
|
-
requirement: &
|
28
|
+
requirement: &2156275740 !ruby/object:Gem::Requirement
|
28
29
|
none: false
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
@@ -32,9 +33,9 @@ dependencies:
|
|
32
33
|
version: 1.1.2
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
description:
|
37
|
-
email:
|
36
|
+
version_requirements: *2156275740
|
37
|
+
description: Blue Box support for Chef's Knife command
|
38
|
+
email: support@bluebox.net
|
38
39
|
executables: []
|
39
40
|
extensions: []
|
40
41
|
extra_rdoc_files:
|
@@ -71,5 +72,5 @@ rubyforge_project:
|
|
71
72
|
rubygems_version: 1.8.6
|
72
73
|
signing_key:
|
73
74
|
specification_version: 3
|
74
|
-
summary:
|
75
|
+
summary: Blue Box support for Chef's Knife command
|
75
76
|
test_files: []
|