knife-openstack 0.5.0 → 0.5.1
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.
- data/knife-openstack.gemspec +0 -2
- data/lib/chef/knife/openstack_flavor_list.rb +14 -10
- data/lib/chef/knife/openstack_image_list.rb +14 -10
- data/lib/chef/knife/openstack_server_create.rb +33 -35
- data/lib/chef/knife/openstack_server_delete.rb +9 -12
- data/lib/chef/knife/openstack_server_list.rb +15 -17
- data/lib/knife-openstack/version.rb +1 -1
- metadata +8 -30
data/knife-openstack.gemspec
CHANGED
@@ -19,9 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "chef", ">= 0.9.14"
|
23
22
|
s.add_dependency "fog", "~> 0.6.0"
|
24
23
|
s.add_dependency "net-ssh", "~> 2.1.3"
|
25
24
|
s.add_dependency "net-ssh-multi", "~> 1.0.1"
|
26
|
-
s.add_dependency "highline", "~> 1.6.1"
|
27
25
|
end
|
@@ -16,14 +16,17 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'fog'
|
20
19
|
require 'chef/knife'
|
21
|
-
require 'chef/json_compat'
|
22
20
|
|
23
21
|
class Chef
|
24
22
|
class Knife
|
25
23
|
class OpenstackFlavorList < Knife
|
26
24
|
|
25
|
+
deps do
|
26
|
+
require 'fog'
|
27
|
+
require 'chef/json_compat'
|
28
|
+
end
|
29
|
+
|
27
30
|
banner "knife openstack flavor list (options)"
|
28
31
|
|
29
32
|
option :openstack_access_key_id,
|
@@ -48,13 +51,7 @@ class Chef
|
|
48
51
|
:description => "Your OpenStack region",
|
49
52
|
:proc => Proc.new { |region| Chef::Config[:knife][:region] = region }
|
50
53
|
|
51
|
-
def h
|
52
|
-
@highline ||= HighLine.new
|
53
|
-
end
|
54
|
-
|
55
54
|
def run
|
56
|
-
require 'fog'
|
57
|
-
|
58
55
|
connection = Fog::Compute.new(
|
59
56
|
:provider => 'AWS',
|
60
57
|
:aws_access_key_id => Chef::Config[:knife][:openstack_access_key_id],
|
@@ -63,7 +60,14 @@ class Chef
|
|
63
60
|
:region => Chef::Config[:knife][:region] || config[:region]
|
64
61
|
)
|
65
62
|
|
66
|
-
flavor_list = [
|
63
|
+
flavor_list = [
|
64
|
+
ui.color('ID', :bold),
|
65
|
+
ui.color('Name', :bold),
|
66
|
+
ui.color('Architecture', :bold),
|
67
|
+
ui.color('RAM', :bold),
|
68
|
+
ui.color('Disk', :bold),
|
69
|
+
ui.color('Cores', :bold)
|
70
|
+
]
|
67
71
|
connection.flavors.sort_by(&:id).each do |flavor|
|
68
72
|
flavor_list << flavor.id.to_s
|
69
73
|
flavor_list << flavor.name
|
@@ -72,7 +76,7 @@ class Chef
|
|
72
76
|
flavor_list << "#{flavor.disk.to_s} GB"
|
73
77
|
flavor_list << flavor.cores.to_s
|
74
78
|
end
|
75
|
-
puts
|
79
|
+
puts ui.list(flavor_list, :columns_across, 6)
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -16,14 +16,17 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'fog'
|
20
19
|
require 'chef/knife'
|
21
|
-
require 'chef/json_compat'
|
22
20
|
|
23
21
|
class Chef
|
24
22
|
class Knife
|
25
23
|
class OpenstackImageList < Knife
|
26
24
|
|
25
|
+
deps do
|
26
|
+
require 'fog'
|
27
|
+
require 'chef/json_compat'
|
28
|
+
end
|
29
|
+
|
27
30
|
banner "knife openstack image list (options)"
|
28
31
|
|
29
32
|
option :openstack_access_key_id,
|
@@ -48,13 +51,7 @@ class Chef
|
|
48
51
|
:description => "Your OpenStack region",
|
49
52
|
:proc => Proc.new { |region| Chef::Config[:knife][:region] = region }
|
50
53
|
|
51
|
-
def h
|
52
|
-
@highline ||= HighLine.new
|
53
|
-
end
|
54
|
-
|
55
54
|
def run
|
56
|
-
require 'fog'
|
57
|
-
|
58
55
|
connection = Fog::Compute.new(
|
59
56
|
:provider => 'AWS',
|
60
57
|
:aws_access_key_id => Chef::Config[:knife][:openstack_access_key_id],
|
@@ -63,7 +60,14 @@ class Chef
|
|
63
60
|
:region => Chef::Config[:knife][:region] || config[:region]
|
64
61
|
)
|
65
62
|
|
66
|
-
image_list = [
|
63
|
+
image_list = [
|
64
|
+
ui.color('ID', :bold),
|
65
|
+
ui.color('Kernel ID', :bold),
|
66
|
+
ui.color('Architecture', :bold),
|
67
|
+
ui.color('Root Store', :bold),
|
68
|
+
ui.color('Name', :bold),
|
69
|
+
ui.color('Location', :bold)
|
70
|
+
]
|
67
71
|
connection.images.sort_by(&:name).each do |image|
|
68
72
|
image_list << image.id.to_s
|
69
73
|
image_list << image.kernel_id.to_s
|
@@ -72,7 +76,7 @@ class Chef
|
|
72
76
|
image_list << image.name
|
73
77
|
image_list << image.location
|
74
78
|
end
|
75
|
-
puts
|
79
|
+
puts ui.list(image_list, :columns_across, 6)
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -16,16 +16,22 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'fog'
|
20
|
-
require 'socket'
|
21
19
|
require 'chef/knife'
|
22
|
-
require 'chef/knife/bootstrap'
|
23
|
-
require 'chef/json_compat'
|
24
20
|
|
25
21
|
class Chef
|
26
22
|
class Knife
|
27
23
|
class OpenstackServerCreate < Knife
|
28
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 'chef/json_compat'
|
33
|
+
end
|
34
|
+
|
29
35
|
banner "knife openstack server create (options)"
|
30
36
|
|
31
37
|
attr_accessor :initial_sleep_delay
|
@@ -134,10 +140,6 @@ class Chef
|
|
134
140
|
:boolean => true,
|
135
141
|
:default => false
|
136
142
|
|
137
|
-
def h
|
138
|
-
@highline ||= HighLine.new
|
139
|
-
end
|
140
|
-
|
141
143
|
def tcp_test_ssh(hostname)
|
142
144
|
tcp_socket = TCPSocket.new(hostname, 22)
|
143
145
|
readable = IO.select([tcp_socket], nil, nil, 5)
|
@@ -158,10 +160,6 @@ class Chef
|
|
158
160
|
end
|
159
161
|
|
160
162
|
def run
|
161
|
-
require 'fog'
|
162
|
-
require 'highline'
|
163
|
-
require 'net/ssh/multi'
|
164
|
-
require 'readline'
|
165
163
|
|
166
164
|
$stdout.sync = true
|
167
165
|
|
@@ -211,14 +209,14 @@ class Chef
|
|
211
209
|
end
|
212
210
|
server = connection.servers.create(server_def)
|
213
211
|
|
214
|
-
puts "#{
|
215
|
-
puts "#{
|
216
|
-
puts "#{
|
217
|
-
puts "#{
|
218
|
-
puts "#{
|
219
|
-
puts "#{
|
212
|
+
puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
|
213
|
+
puts "#{ui.color("Flavor", :cyan)}: #{server.flavor_id}"
|
214
|
+
puts "#{ui.color("Image", :cyan)}: #{server.image_id}"
|
215
|
+
puts "#{ui.color("Availability Zone", :cyan)}: #{server.availability_zone}"
|
216
|
+
puts "#{ui.color("Security Groups", :cyan)}: #{server.groups.join(", ")}"
|
217
|
+
puts "#{ui.color("SSH Key", :cyan)}: #{server.key_name}"
|
220
218
|
|
221
|
-
print "\n#{
|
219
|
+
print "\n#{ui.color("Waiting for server", :magenta)}"
|
222
220
|
|
223
221
|
display_name = server.dns_name
|
224
222
|
|
@@ -227,12 +225,12 @@ class Chef
|
|
227
225
|
|
228
226
|
puts("\n")
|
229
227
|
|
230
|
-
puts "#{
|
231
|
-
puts "#{
|
232
|
-
puts "#{
|
233
|
-
puts "#{
|
228
|
+
puts "#{ui.color("Public DNS Name", :cyan)}: #{server.dns_name}"
|
229
|
+
puts "#{ui.color("Public IP Address", :cyan)}: #{server.ip_address}"
|
230
|
+
puts "#{ui.color("Private DNS Name", :cyan)}: #{server.private_dns_name}"
|
231
|
+
puts "#{ui.color("Private IP Address", :cyan)}: #{server.private_ip_address}"
|
234
232
|
|
235
|
-
print "\n#{
|
233
|
+
print "\n#{ui.color("Waiting for sshd", :magenta)}"
|
236
234
|
|
237
235
|
print(".") until tcp_test_ssh(display_name) {
|
238
236
|
sleep @initial_sleep_delay ||= 10
|
@@ -242,17 +240,17 @@ class Chef
|
|
242
240
|
bootstrap_for_node(server).run
|
243
241
|
|
244
242
|
puts "\n"
|
245
|
-
puts "#{
|
246
|
-
puts "#{
|
247
|
-
puts "#{
|
248
|
-
puts "#{
|
249
|
-
puts "#{
|
250
|
-
puts "#{
|
251
|
-
puts "#{
|
252
|
-
puts "#{
|
253
|
-
puts "#{
|
254
|
-
puts "#{
|
255
|
-
puts "#{
|
243
|
+
puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
|
244
|
+
puts "#{ui.color("Flavor", :cyan)}: #{server.flavor_id}"
|
245
|
+
puts "#{ui.color("Image", :cyan)}: #{server.image_id}"
|
246
|
+
puts "#{ui.color("Availability Zone", :cyan)}: #{server.availability_zone}"
|
247
|
+
puts "#{ui.color("Security Groups", :cyan)}: #{server.groups.join(", ")}"
|
248
|
+
puts "#{ui.color("Public DNS Name", :cyan)}: #{server.dns_name}"
|
249
|
+
puts "#{ui.color("Public IP Address", :cyan)}: #{server.ip_address}"
|
250
|
+
puts "#{ui.color("Private DNS Name", :cyan)}: #{server.private_dns_name}"
|
251
|
+
puts "#{ui.color("SSH Key", :cyan)}: #{server.key_name}"
|
252
|
+
puts "#{ui.color("Private IP Address", :cyan)}: #{server.private_ip_address}"
|
253
|
+
puts "#{ui.color("Run List", :cyan)}: #{config[:run_list].join(', ')}"
|
256
254
|
end
|
257
255
|
|
258
256
|
def bootstrap_for_node(server)
|
@@ -17,12 +17,18 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'chef/knife'
|
20
|
-
require 'chef/json_compat'
|
21
20
|
|
22
21
|
class Chef
|
23
22
|
class Knife
|
24
23
|
class OpenstackServerDelete < Knife
|
25
24
|
|
25
|
+
deps do
|
26
|
+
require 'fog'
|
27
|
+
require 'net/ssh/multi'
|
28
|
+
require 'readline'
|
29
|
+
require 'chef/json_compat'
|
30
|
+
end
|
31
|
+
|
26
32
|
banner "knife openstack server delete SERVER [SERVER] (options)"
|
27
33
|
|
28
34
|
option :openstack_access_key_id,
|
@@ -47,16 +53,7 @@ class Chef
|
|
47
53
|
:description => "Your OpenStack region",
|
48
54
|
:proc => Proc.new { |region| Chef::Config[:knife][:region] = region }
|
49
55
|
|
50
|
-
def h
|
51
|
-
@highline ||= HighLine.new
|
52
|
-
end
|
53
|
-
|
54
56
|
def run
|
55
|
-
require 'fog'
|
56
|
-
require 'highline'
|
57
|
-
require 'net/ssh/multi'
|
58
|
-
require 'readline'
|
59
|
-
|
60
57
|
connection = Fog::Compute.new(
|
61
58
|
:provider => 'AWS',
|
62
59
|
:aws_access_key_id => Chef::Config[:knife][:openstack_access_key_id],
|
@@ -84,13 +81,13 @@ class Chef
|
|
84
81
|
|
85
82
|
server.destroy
|
86
83
|
|
87
|
-
|
84
|
+
ui.warn("Deleted server #{server.id}")
|
88
85
|
end
|
89
86
|
end
|
90
87
|
|
91
88
|
def msg(label, value)
|
92
89
|
if value && !value.empty?
|
93
|
-
puts "#{
|
90
|
+
puts "#{ui.color(label, :cyan)}: #{value}"
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
@@ -17,12 +17,18 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'chef/knife'
|
20
|
-
require 'chef/json_compat'
|
21
20
|
|
22
21
|
class Chef
|
23
22
|
class Knife
|
24
23
|
class OpenstackServerList < Knife
|
25
24
|
|
25
|
+
deps do
|
26
|
+
require 'fog'
|
27
|
+
require 'net/ssh/multi'
|
28
|
+
require 'readline'
|
29
|
+
require 'chef/json_compat'
|
30
|
+
end
|
31
|
+
|
26
32
|
banner "knife openstack server list (options)"
|
27
33
|
|
28
34
|
option :openstack_access_key_id,
|
@@ -47,15 +53,7 @@ class Chef
|
|
47
53
|
:description => "Your OpenStack region",
|
48
54
|
:proc => Proc.new { |region| Chef::Config[:knife][:region] = region }
|
49
55
|
|
50
|
-
def h
|
51
|
-
@highline ||= HighLine.new
|
52
|
-
end
|
53
|
-
|
54
56
|
def run
|
55
|
-
require 'fog'
|
56
|
-
require 'highline'
|
57
|
-
require 'net/ssh/multi'
|
58
|
-
require 'readline'
|
59
57
|
|
60
58
|
$stdout.sync = true
|
61
59
|
|
@@ -68,13 +66,13 @@ class Chef
|
|
68
66
|
)
|
69
67
|
|
70
68
|
server_list = [
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
ui.color('Instance ID', :bold),
|
70
|
+
ui.color('Public IP', :bold),
|
71
|
+
ui.color('Private IP', :bold),
|
72
|
+
ui.color('Flavor', :bold),
|
73
|
+
ui.color('Image', :bold),
|
74
|
+
ui.color('Security Groups', :bold),
|
75
|
+
ui.color('State', :bold)
|
78
76
|
]
|
79
77
|
connection.servers.all.each do |server|
|
80
78
|
server_list << server.id.to_s
|
@@ -85,7 +83,7 @@ class Chef
|
|
85
83
|
server_list << server.groups.join(", ")
|
86
84
|
server_list << server.state
|
87
85
|
end
|
88
|
-
puts
|
86
|
+
puts ui.list(server_list, :columns_across, 7)
|
89
87
|
|
90
88
|
end
|
91
89
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: knife-openstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Seth Chisamore
|
@@ -10,64 +10,42 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-04-05 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: chef
|
18
|
-
prerelease: false
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
|
-
requirements:
|
22
|
-
- - ">="
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 0.9.14
|
25
|
-
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
16
|
- !ruby/object:Gem::Dependency
|
28
17
|
name: fog
|
29
18
|
prerelease: false
|
30
|
-
requirement: &
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
31
20
|
none: false
|
32
21
|
requirements:
|
33
22
|
- - ~>
|
34
23
|
- !ruby/object:Gem::Version
|
35
24
|
version: 0.6.0
|
36
25
|
type: :runtime
|
37
|
-
version_requirements: *
|
26
|
+
version_requirements: *id001
|
38
27
|
- !ruby/object:Gem::Dependency
|
39
28
|
name: net-ssh
|
40
29
|
prerelease: false
|
41
|
-
requirement: &
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
31
|
none: false
|
43
32
|
requirements:
|
44
33
|
- - ~>
|
45
34
|
- !ruby/object:Gem::Version
|
46
35
|
version: 2.1.3
|
47
36
|
type: :runtime
|
48
|
-
version_requirements: *
|
37
|
+
version_requirements: *id002
|
49
38
|
- !ruby/object:Gem::Dependency
|
50
39
|
name: net-ssh-multi
|
51
40
|
prerelease: false
|
52
|
-
requirement: &
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
42
|
none: false
|
54
43
|
requirements:
|
55
44
|
- - ~>
|
56
45
|
- !ruby/object:Gem::Version
|
57
46
|
version: 1.0.1
|
58
47
|
type: :runtime
|
59
|
-
version_requirements: *
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: highline
|
62
|
-
prerelease: false
|
63
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 1.6.1
|
69
|
-
type: :runtime
|
70
|
-
version_requirements: *id005
|
48
|
+
version_requirements: *id003
|
71
49
|
description: OpenStack Compute Support for Chef's Knife Command
|
72
50
|
email:
|
73
51
|
- schisamo@opscode.com
|