knife-rackspace 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 RackspaceFlavorList < Knife
26
24
 
25
+ deps do
26
+ require 'fog'
27
+ require 'chef/json_compat'
28
+ end
29
+
27
30
  banner "knife rackspace flavor list (options)"
28
31
 
29
32
  option :rackspace_api_key,
@@ -44,12 +47,7 @@ class Chef
44
47
  :default => "auth.api.rackspacecloud.com",
45
48
  :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url }
46
49
 
47
- def h
48
- @highline ||= HighLine.new
49
- end
50
-
51
50
  def run
52
- require 'fog'
53
51
 
54
52
  connection = Fog::Compute.new(
55
53
  :provider => 'Rackspace',
@@ -58,7 +56,7 @@ class Chef
58
56
  :rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url]
59
57
  )
60
58
 
61
- flavor_list = [ h.color('ID', :bold), h.color('Name', :bold), h.color('Architecture', :bold), h.color('RAM', :bold), h.color('Disk', :bold) , h.color('Cores', :bold) ]
59
+ flavor_list = [ ui.color('ID', :bold), ui.color('Name', :bold), ui.color('Architecture', :bold), ui.color('RAM', :bold), ui.color('Disk', :bold) , ui.color('Cores', :bold) ]
62
60
  connection.flavors.sort_by(&:id).each do |flavor|
63
61
  flavor_list << flavor.id.to_s
64
62
  flavor_list << flavor.name
@@ -67,7 +65,7 @@ class Chef
67
65
  flavor_list << "#{flavor.disk.to_s} GB"
68
66
  flavor_list << flavor.cores.to_s
69
67
  end
70
- puts h.list(flavor_list, :columns_across, 6)
68
+ puts ui.list(flavor_list, :columns_across, 6)
71
69
  end
72
70
  end
73
71
  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 RackspaceImageList < Knife
26
24
 
25
+ deps do
26
+ require 'fog'
27
+ require 'chef/json_compat'
28
+ end
29
+
27
30
  banner "knife rackspace image list (options)"
28
31
 
29
32
  option :rackspace_api_key,
@@ -44,13 +47,7 @@ class Chef
44
47
  :default => "auth.api.rackspacecloud.com",
45
48
  :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url }
46
49
 
47
- def h
48
- @highline ||= HighLine.new
49
- end
50
-
51
50
  def run
52
- require 'fog'
53
-
54
51
  connection = Fog::Compute.new(
55
52
  :provider => 'Rackspace',
56
53
  :rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
@@ -58,12 +55,12 @@ class Chef
58
55
  :rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url]
59
56
  )
60
57
 
61
- image_list = [ h.color('ID', :bold), h.color('Name', :bold) ]
58
+ image_list = [ ui.color('ID', :bold), ui.color('Name', :bold) ]
62
59
  connection.images.sort_by(&:name).each do |image|
63
60
  image_list << image.id.to_s
64
61
  image_list << image.name
65
62
  end
66
- puts h.list(image_list, :columns_across, 2)
63
+ puts ui.list(image_list, :columns_across, 2)
67
64
  end
68
65
  end
69
66
  end
@@ -16,22 +16,21 @@
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
- require 'resolv'
24
20
 
25
21
  class Chef
26
22
  class Knife
27
23
  class RackspaceServerCreate < Knife
28
24
 
29
25
  deps do
26
+ require 'chef/knife/bootstrap'
30
27
  Chef::Knife::Bootstrap.load_deps
31
28
  require 'fog'
32
29
  require 'highline'
33
30
  require 'net/ssh/multi'
34
31
  require 'readline'
32
+ require 'resolv'
33
+ require 'chef/json_compat'
35
34
  end
36
35
 
37
36
  banner "knife rackspace server create (options)"
@@ -116,10 +115,6 @@ class Chef
116
115
  :proc => lambda { |o| o.split(/[\s,]+/) },
117
116
  :default => []
118
117
 
119
- def h
120
- @highline ||= HighLine.new
121
- end
122
-
123
118
  def tcp_test_ssh(hostname)
124
119
  tcp_socket = TCPSocket.new(hostname, 22)
125
120
  readable = IO.select([tcp_socket], nil, nil, 5)
@@ -140,10 +135,6 @@ class Chef
140
135
  end
141
136
 
142
137
  def run
143
- require 'fog'
144
- require 'highline'
145
- require 'net/ssh/multi'
146
- require 'readline'
147
138
 
148
139
  $stdout.sync = true
149
140
 
@@ -160,41 +151,41 @@ class Chef
160
151
  :flavor_id => Chef::Config[:knife][:flavor]
161
152
  )
162
153
 
163
- puts "#{h.color("Instance ID", :cyan)}: #{server.id}"
164
- puts "#{h.color("Host ID", :cyan)}: #{server.host_id}"
165
- puts "#{h.color("Name", :cyan)}: #{server.name}"
166
- puts "#{h.color("Flavor", :cyan)}: #{server.flavor.name}"
167
- puts "#{h.color("Image", :cyan)}: #{server.image.name}"
154
+ puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
155
+ puts "#{ui.color("Host ID", :cyan)}: #{server.host_id}"
156
+ puts "#{ui.color("Name", :cyan)}: #{server.name}"
157
+ puts "#{ui.color("Flavor", :cyan)}: #{server.flavor.name}"
158
+ puts "#{ui.color("Image", :cyan)}: #{server.image.name}"
168
159
 
169
- print "\n#{h.color("Waiting server", :magenta)}"
160
+ print "\n#{ui.color("Waiting server", :magenta)}"
170
161
 
171
162
  # wait for it to be ready to do stuff
172
163
  server.wait_for { print "."; ready? }
173
164
 
174
165
  puts("\n")
175
166
 
176
- puts "#{h.color("Public DNS Name", :cyan)}: #{public_dns_name(server)}"
177
- puts "#{h.color("Public IP Address", :cyan)}: #{server.addresses["public"][0]}"
178
- puts "#{h.color("Private IP Address", :cyan)}: #{server.addresses["private"][0]}"
179
- puts "#{h.color("Password", :cyan)}: #{server.password}"
167
+ puts "#{ui.color("Public DNS Name", :cyan)}: #{public_dns_name(server)}"
168
+ puts "#{ui.color("Public IP Address", :cyan)}: #{server.addresses["public"][0]}"
169
+ puts "#{ui.color("Private IP Address", :cyan)}: #{server.addresses["private"][0]}"
170
+ puts "#{ui.color("Password", :cyan)}: #{server.password}"
180
171
 
181
- print "\n#{h.color("Waiting for sshd", :magenta)}"
172
+ print "\n#{ui.color("Waiting for sshd", :magenta)}"
182
173
 
183
174
  print(".") until tcp_test_ssh(server.addresses["public"][0]) { sleep @initial_sleep_delay ||= 10; puts("done") }
184
175
 
185
176
  bootstrap_for_node(server).run
186
177
 
187
178
  puts "\n"
188
- puts "#{h.color("Instance ID", :cyan)}: #{server.id}"
189
- puts "#{h.color("Host ID", :cyan)}: #{server.host_id}"
190
- puts "#{h.color("Name", :cyan)}: #{server.name}"
191
- puts "#{h.color("Flavor", :cyan)}: #{server.flavor.name}"
192
- puts "#{h.color("Image", :cyan)}: #{server.image.name}"
193
- puts "#{h.color("Public DNS Name", :cyan)}: #{public_dns_name(server)}"
194
- puts "#{h.color("Public IP Address", :cyan)}: #{server.addresses["public"][0]}"
195
- puts "#{h.color("Private IP Address", :cyan)}: #{server.addresses["private"][0]}"
196
- puts "#{h.color("Password", :cyan)}: #{server.password}"
197
- puts "#{h.color("Run List", :cyan)}: #{config[:run_list].join(', ')}"
179
+ puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
180
+ puts "#{ui.color("Host ID", :cyan)}: #{server.host_id}"
181
+ puts "#{ui.color("Name", :cyan)}: #{server.name}"
182
+ puts "#{ui.color("Flavor", :cyan)}: #{server.flavor.name}"
183
+ puts "#{ui.color("Image", :cyan)}: #{server.image.name}"
184
+ puts "#{ui.color("Public DNS Name", :cyan)}: #{public_dns_name(server)}"
185
+ puts "#{ui.color("Public IP Address", :cyan)}: #{server.addresses["public"][0]}"
186
+ puts "#{ui.color("Private IP Address", :cyan)}: #{server.addresses["private"][0]}"
187
+ puts "#{ui.color("Password", :cyan)}: #{server.password}"
188
+ puts "#{ui.color("Run List", :cyan)}: #{config[:run_list].join(', ')}"
198
189
  end
199
190
 
200
191
  def bootstrap_for_node(server)
@@ -16,15 +16,19 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'fog'
20
19
  require 'chef/knife'
21
- require 'chef/json_compat'
22
- require 'resolv'
23
20
 
24
21
  class Chef
25
22
  class Knife
26
23
  class RackspaceServerDelete < Knife
27
-
24
+
25
+ deps do
26
+ require 'fog'
27
+ require 'chef/knife'
28
+ require 'chef/json_compat'
29
+ require 'resolv'
30
+ end
31
+
28
32
  banner "knife rackspace server delete SERVER (options)"
29
33
 
30
34
  option :rackspace_api_key,
@@ -45,10 +49,6 @@ class Chef
45
49
  :default => "auth.api.rackspacecloud.com",
46
50
  :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url }
47
51
 
48
- def h
49
- @highline ||= HighLine.new
50
- end
51
-
52
52
  def run
53
53
  require 'fog'
54
54
  require 'highline'
@@ -64,21 +64,21 @@ class Chef
64
64
 
65
65
  server = connection.servers.get(@name_args[0])
66
66
 
67
- puts "#{h.color("Instance ID", :cyan)}: #{server.id}"
68
- puts "#{h.color("Host ID", :cyan)}: #{server.host_id}"
69
- puts "#{h.color("Name", :cyan)}: #{server.name}"
70
- puts "#{h.color("Flavor", :cyan)}: #{server.flavor.name}"
71
- puts "#{h.color("Image", :cyan)}: #{server.image.name}"
72
- puts "#{h.color("Public DNS Name", :cyan)}: #{public_dns_name(server)}"
73
- puts "#{h.color("Public IP Address", :cyan)}: #{server.addresses["public"][0]}"
74
- puts "#{h.color("Private IP Address", :cyan)}: #{server.addresses["private"][0]}"
67
+ puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
68
+ puts "#{ui.color("Host ID", :cyan)}: #{server.host_id}"
69
+ puts "#{ui.color("Name", :cyan)}: #{server.name}"
70
+ puts "#{ui.color("Flavor", :cyan)}: #{server.flavor.name}"
71
+ puts "#{ui.color("Image", :cyan)}: #{server.image.name}"
72
+ puts "#{ui.color("Public DNS Name", :cyan)}: #{public_dns_name(server)}"
73
+ puts "#{ui.color("Public IP Address", :cyan)}: #{server.addresses["public"][0]}"
74
+ puts "#{ui.color("Private IP Address", :cyan)}: #{server.addresses["private"][0]}"
75
75
 
76
76
  puts "\n"
77
77
  confirm("Do you really want to delete this server")
78
78
 
79
79
  server.destroy
80
80
 
81
- Chef::Log.warn("Deleted server #{server.id} named #{server.name}")
81
+ ui.warn("Deleted server #{server.id} named #{server.name}")
82
82
  end
83
83
 
84
84
  def public_dns_name(server)
@@ -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 RackspaceServerList < Knife
26
24
 
25
+ deps do
26
+ require 'fog'
27
+ require 'chef/json_compat'
28
+ end
29
+
27
30
  banner "knife rackspace server list (options)"
28
31
 
29
32
  option :rackspace_api_key,
@@ -44,16 +47,9 @@ class Chef
44
47
  :default => "auth.api.rackspacecloud.com",
45
48
  :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url }
46
49
 
47
- def h
48
- @highline ||= HighLine.new
49
- end
50
-
51
50
  def run
52
- require 'fog'
53
- require 'highline'
54
- require 'net/ssh/multi'
55
- require 'readline'
56
-
51
+ $stdout.sync = true
52
+
57
53
  connection = Fog::Compute.new(
58
54
  :provider => 'Rackspace',
59
55
  :rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
@@ -61,7 +57,15 @@ class Chef
61
57
  :rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url]
62
58
  )
63
59
 
64
- server_list = [ h.color('ID', :bold), h.color('Name', :bold), h.color('Public IP', :bold), h.color('Private IP', :bold), h.color('Flavor', :bold), h.color('Image', :bold), h.color('State', :bold) ]
60
+ server_list = [
61
+ ui.color('ID', :bold),
62
+ ui.color('Name', :bold),
63
+ ui.color('Public IP', :bold),
64
+ ui.color('Private IP', :bold),
65
+ ui.color('Flavor', :bold),
66
+ ui.color('Image', :bold),
67
+ ui.color('State', :bold)
68
+ ]
65
69
  connection.servers.all.each do |server|
66
70
  server_list << server.id.to_s
67
71
  server_list << server.name
@@ -71,7 +75,7 @@ class Chef
71
75
  server_list << server.image.name
72
76
  server_list << server.status.downcase
73
77
  end
74
- puts h.list(server_list, :columns_across, 7)
78
+ puts ui.list(server_list, :columns_across, 7)
75
79
 
76
80
  end
77
81
  end
@@ -1,3 +1,3 @@
1
1
  module KnifeRackspace
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: knife-rackspace
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.1
5
+ version: 0.5.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Adam Jacob
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-04 00:00:00 -04:00
13
+ date: 2011-04-05 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -57,17 +57,6 @@ dependencies:
57
57
  version: 1.0.1
58
58
  type: :runtime
59
59
  version_requirements: *id004
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
71
60
  description: Rackspace Support for Chef's Knife Command
72
61
  email: adam@opscode.com
73
62
  executables: []