knife-rackspace 0.5.6 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ .rake_tasks~
2
+ tags
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ test/tmp
7
+ test/version_tmp
8
+ tmp
9
+ pkg
10
+ *.gem
11
+ *.rbc
12
+ lib/bundler/man
13
+ spec/reports
14
+ .config
15
+ InstalledFiles
16
+ .bundle
17
+
18
+ # YARD artifacts
19
+ .yardoc
20
+ _yardoc
21
+ doc/
22
+
23
+ .DS_Store
24
+ Icon?
25
+
26
+ # Thumbnails
27
+ ._*
28
+
29
+ # Files that might appear on external disk
30
+ .Spotlight-V100
31
+ .Trashes
32
+
33
+ *.swp
34
+ *.swo
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in knife-rackspace.gemspec
4
+ gemspec
data/README.rdoc CHANGED
@@ -20,12 +20,12 @@ Depending on your system's configuration, you may need to run this command with
20
20
 
21
21
  In order to communicate with the Rackspace Cloud API you will have to tell Knife about your Username and API Key. The easiest way to accomplish this is to create some entries in your <tt>knife.rb</tt> file:
22
22
 
23
+ knife[:rackspace_username] = "Your Rackspace API username"
23
24
  knife[:rackspace_api_key] = "Your Rackspace API Key"
24
- knife[:rackspace_api_username] = "Your Rackspace API username"
25
25
 
26
26
  If your knife.rb file will be checked into a SCM system (ie readable by others) you may want to read the values from environment variables:
27
27
 
28
- knife[:rackspace_api_username] = "#{ENV['RACKSPACE_USERNAME']}"
28
+ knife[:rackspace_username] = "#{ENV['RACKSPACE_USERNAME']}"
29
29
  knife[:rackspace_api_key] = "#{ENV['RACKSPACE_API_KEY']}"
30
30
 
31
31
  You also have the option of passing your Rackspace API Username/Key into the individual knife subcommands using the <tt>-A</tt> (or <tt>--rackspace-api-username</tt>) <tt>-K</tt> (or <tt>--rackspace-api-key</tt>) command options
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Author:: Daniel DeLeo (<dan@opscode.com>)
4
+ # Copyright:: Copyright (c) 2008, 2010 Opscode, Inc.
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require 'bundler'
21
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "knife-rackspace/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "knife-rackspace"
7
+ s.version = Knife::Rackspace::VERSION
8
+ s.has_rdoc = true
9
+ s.authors = ["Adam Jacob","Seth Chisamore"]
10
+ s.email = ["adam@opscode.com","schisamo@opscode.com"]
11
+ s.homepage = "http://wiki.opscode.com/display/chef"
12
+ s.summary = "Rackspace Support for Chef's Knife Command"
13
+ s.description = s.summary
14
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.add_dependency "fog", "~> 0.8.2"
20
+ s.add_dependency "net-ssh", "~> 2.1.3"
21
+ s.add_dependency "net-ssh-multi", "~> 1.0.1"
22
+ s.require_paths = ["lib"]
23
+
24
+ end
@@ -0,0 +1,85 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife'
20
+
21
+ class Chef
22
+ class Knife
23
+ module RackspaceBase
24
+
25
+ # :nodoc:
26
+ # Would prefer to do this in a rational way, but can't be done b/c of
27
+ # Mixlib::CLI's design :(
28
+ def self.included(includer)
29
+ includer.class_eval do
30
+
31
+ deps do
32
+ require 'fog'
33
+ require 'net/ssh/multi'
34
+ require 'readline'
35
+ require 'chef/json_compat'
36
+ end
37
+
38
+ option :rackspace_api_key,
39
+ :short => "-K KEY",
40
+ :long => "--rackspace-api-key KEY",
41
+ :description => "Your rackspace API key",
42
+ :proc => Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
43
+
44
+ option :rackspace_username,
45
+ :short => "-A USERNAME",
46
+ :long => "--rackspace-username USERNAME",
47
+ :description => "Your rackspace API username",
48
+ :proc => Proc.new { |username| Chef::Config[:knife][:rackspace_username] = username }
49
+
50
+ option :rackspace_api_auth_url,
51
+ :long => "--rackspace-api-auth-url URL",
52
+ :description => "Your rackspace API auth url",
53
+ :default => "auth.api.rackspacecloud.com",
54
+ :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url }
55
+ end
56
+ end
57
+
58
+ def connection
59
+ @connection ||= begin
60
+ connection = Fog::Compute.new(
61
+ :provider => 'Rackspace',
62
+ :rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
63
+ :rackspace_username => (Chef::Config[:knife][:rackspace_username] || Chef::Config[:knife][:rackspace_api_username]),
64
+ :rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url]
65
+ )
66
+ end
67
+ end
68
+
69
+ def locate_config_value(key)
70
+ key = key.to_sym
71
+ Chef::Config[:knife][key] || config[key]
72
+ end
73
+
74
+ def public_dns_name(server)
75
+ @public_dns_name ||= begin
76
+ Resolv.getname(server.addresses["public"][0])
77
+ rescue
78
+ "#{server.addresses["public"][0].gsub('.','-')}.static.cloud-ips.com"
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+
@@ -16,47 +16,25 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife'
19
+ require 'chef/knife/rackspace_base'
20
20
 
21
21
  class Chef
22
22
  class Knife
23
23
  class RackspaceFlavorList < Knife
24
24
 
25
- deps do
26
- require 'fog'
27
- require 'chef/json_compat'
28
- end
25
+ include Knife::RackspaceBase
29
26
 
30
27
  banner "knife rackspace flavor list (options)"
31
28
 
32
- option :rackspace_api_key,
33
- :short => "-K KEY",
34
- :long => "--rackspace-api-key KEY",
35
- :description => "Your rackspace API key",
36
- :proc => Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
37
-
38
- option :rackspace_api_username,
39
- :short => "-A USERNAME",
40
- :long => "--rackspace-api-username USERNAME",
41
- :description => "Your rackspace API username",
42
- :proc => Proc.new { |username| Chef::Config[:knife][:rackspace_api_username] = username }
43
-
44
- option :rackspace_api_auth_url,
45
- :long => "--rackspace-api-auth-url URL",
46
- :description => "Your rackspace API auth url",
47
- :default => "auth.api.rackspacecloud.com",
48
- :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url }
49
-
50
29
  def run
51
-
52
- connection = Fog::Compute.new(
53
- :provider => 'Rackspace',
54
- :rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
55
- :rackspace_username => Chef::Config[:knife][:rackspace_api_username] || Chef::Config[:knife][:rackspace_username],
56
- :rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url]
57
- )
58
-
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) ]
30
+ flavor_list = [
31
+ ui.color('ID', :bold),
32
+ ui.color('Name', :bold),
33
+ ui.color('Architecture', :bold),
34
+ ui.color('RAM', :bold),
35
+ ui.color('Disk', :bold),
36
+ ui.color('Cores', :bold)
37
+ ]
60
38
  connection.flavors.sort_by(&:id).each do |flavor|
61
39
  flavor_list << flavor.id.to_s
62
40
  flavor_list << flavor.name
@@ -16,50 +16,27 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife'
19
+ require 'chef/knife/rackspace_base'
20
20
 
21
21
  class Chef
22
22
  class Knife
23
23
  class RackspaceImageList < Knife
24
24
 
25
- deps do
26
- require 'fog'
27
- require 'chef/json_compat'
28
- end
25
+ include Knife::RackspaceBase
29
26
 
30
27
  banner "knife rackspace image list (options)"
31
28
 
32
- option :rackspace_api_key,
33
- :short => "-K KEY",
34
- :long => "--rackspace-api-key KEY",
35
- :description => "Your rackspace API key",
36
- :proc => Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
37
-
38
- option :rackspace_api_username,
39
- :short => "-A USERNAME",
40
- :long => "--rackspace-api-username USERNAME",
41
- :description => "Your rackspace API username",
42
- :proc => Proc.new { |username| Chef::Config[:knife][:rackspace_api_username] = username }
43
-
44
- option :rackspace_api_auth_url,
45
- :long => "--rackspace-api-auth-url URL",
46
- :description => "Your rackspace API auth url",
47
- :default => "auth.api.rackspacecloud.com",
48
- :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url }
49
-
50
29
  def run
51
- connection = Fog::Compute.new(
52
- :provider => 'Rackspace',
53
- :rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
54
- :rackspace_username => Chef::Config[:knife][:rackspace_api_username] || Chef::Config[:knife][:rackspace_username],
55
- :rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url]
56
- )
30
+ image_list = [
31
+ ui.color('ID', :bold),
32
+ ui.color('Name', :bold)
33
+ ]
57
34
 
58
- image_list = [ ui.color('ID', :bold), ui.color('Name', :bold) ]
59
35
  connection.images.sort_by(&:name).each do |image|
60
36
  image_list << image.id.to_s
61
37
  image_list << image.name
62
38
  end
39
+
63
40
  puts ui.list(image_list, :columns_across, 2)
64
41
  end
65
42
  end
@@ -22,15 +22,15 @@ class Chef
22
22
  class Knife
23
23
  class RackspaceServerCreate < Knife
24
24
 
25
+ include Knife::RackspaceBase
26
+
25
27
  deps do
26
- require 'chef/knife/bootstrap'
27
- Chef::Knife::Bootstrap.load_deps
28
28
  require 'fog'
29
- require 'highline'
30
29
  require 'net/ssh/multi'
31
30
  require 'readline'
32
- require 'resolv'
33
31
  require 'chef/json_compat'
32
+ require 'chef/knife/bootstrap'
33
+ Chef::Knife::Bootstrap.load_deps
34
34
  end
35
35
 
36
36
  banner "knife rackspace server create (options)"
@@ -69,23 +69,10 @@ class Chef
69
69
  :long => "--ssh-password PASSWORD",
70
70
  :description => "The ssh password"
71
71
 
72
- option :rackspace_api_key,
73
- :short => "-K KEY",
74
- :long => "--rackspace-api-key KEY",
75
- :description => "Your rackspace API key",
76
- :proc => Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
77
-
78
- option :rackspace_api_username,
79
- :short => "-A USERNAME",
80
- :long => "--rackspace-api-username USERNAME",
81
- :description => "Your rackspace API username",
82
- :proc => Proc.new { |username| Chef::Config[:knife][:rackspace_api_username] = username }
83
-
84
- option :rackspace_api_auth_url,
85
- :long => "--rackspace-api-auth-url URL",
86
- :description => "Your rackspace API auth url; default is 'auth.api.rackspacecloud.com'",
87
- :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url },
88
- :default => "auth.api.rackspacecloud.com"
72
+ option :identity_file,
73
+ :short => "-i IDENTITY_FILE",
74
+ :long => "--identity-file IDENTITY_FILE",
75
+ :description => "The SSH identity file used for authentication"
89
76
 
90
77
  option :prerelease,
91
78
  :long => "--prerelease",
@@ -103,11 +90,6 @@ class Chef
103
90
  :proc => Proc.new { |d| Chef::Config[:knife][:distro] = d },
104
91
  :default => "ubuntu10.04-gems"
105
92
 
106
- option :use_sudo,
107
- :long => "--sudo",
108
- :description => "Execute the bootstrap via sudo",
109
- :boolean => false
110
-
111
93
  option :template_file,
112
94
  :long => "--template-file TEMPLATE",
113
95
  :description => "Full path to location of template to use",
@@ -121,6 +103,13 @@ class Chef
121
103
  :proc => lambda { |o| o.split(/[\s,]+/) },
122
104
  :default => []
123
105
 
106
+ option :rackspace_metadata,
107
+ :short => "-M JSON",
108
+ :long => "--rackspace-metadata JSON",
109
+ :description => "JSON string version of metadata hash to be supplied with the server create call",
110
+ :proc => Proc.new { |m| Chef::Config[:knife][:rackspace_metadata] = JSON.parse(m) },
111
+ :default => ""
112
+
124
113
  def tcp_test_ssh(hostname)
125
114
  tcp_socket = TCPSocket.new(hostname, 22)
126
115
  readable = IO.select([tcp_socket], nil, nil, 5)
@@ -148,13 +137,6 @@ class Chef
148
137
  def run
149
138
  $stdout.sync = true
150
139
 
151
- connection = Fog::Compute.new(
152
- :provider => 'Rackspace',
153
- :rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
154
- :rackspace_username => Chef::Config[:knife][:rackspace_api_username] || Chef::Config[:knife][:rackspace_username],
155
- :rackspace_auth_url => locate_config_value(:rackspace_api_auth_url)
156
- )
157
-
158
140
  unless Chef::Config[:knife][:image]
159
141
  ui.error("You have not provided a valid image value. Please note the short option for this value recently changed from '-i' to '-I'.")
160
142
  exit 1
@@ -163,7 +145,8 @@ class Chef
163
145
  server = connection.servers.create(
164
146
  :name => config[:server_name],
165
147
  :image_id => Chef::Config[:knife][:image],
166
- :flavor_id => locate_config_value(:flavor)
148
+ :flavor_id => locate_config_value(:flavor),
149
+ :metadata => Chef::Config[:knife][:rackspace_metadata]
167
150
  )
168
151
 
169
152
  puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
@@ -171,6 +154,7 @@ class Chef
171
154
  puts "#{ui.color("Name", :cyan)}: #{server.name}"
172
155
  puts "#{ui.color("Flavor", :cyan)}: #{server.flavor.name}"
173
156
  puts "#{ui.color("Image", :cyan)}: #{server.image.name}"
157
+ puts "#{ui.color("Metadata", :cyan)}: #{server.metadata}"
174
158
 
175
159
  print "\n#{ui.color("Waiting server", :magenta)}"
176
160
 
@@ -196,6 +180,7 @@ class Chef
196
180
  puts "#{ui.color("Name", :cyan)}: #{server.name}"
197
181
  puts "#{ui.color("Flavor", :cyan)}: #{server.flavor.name}"
198
182
  puts "#{ui.color("Image", :cyan)}: #{server.image.name}"
183
+ puts "#{ui.color("Metadata", :cyan)}: #{server.metadata}"
199
184
  puts "#{ui.color("Public DNS Name", :cyan)}: #{public_dns_name(server)}"
200
185
  puts "#{ui.color("Public IP Address", :cyan)}: #{server.addresses["public"][0]}"
201
186
  puts "#{ui.color("Private IP Address", :cyan)}: #{server.addresses["private"][0]}"
@@ -216,24 +201,12 @@ class Chef
216
201
  bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
217
202
  bootstrap.config[:distro] = locate_config_value(:distro)
218
203
  # bootstrap will run as root...sudo (by default) also messes up Ohai on CentOS boxes
219
- bootstrap.config[:use_sudo] = config[:use_sudo]
204
+ bootstrap.config[:use_sudo] = true unless config[:ssh_user] == 'root'
220
205
  bootstrap.config[:template_file] = locate_config_value(:template_file)
221
206
  bootstrap.config[:environment] = config[:environment]
222
207
  bootstrap
223
208
  end
224
209
 
225
- def locate_config_value(key)
226
- key = key.to_sym
227
- Chef::Config[:knife][key] || config[key]
228
- end
229
-
230
- def public_dns_name(server)
231
- @public_dns_name ||= begin
232
- Resolv.getname(server.addresses["public"][0])
233
- rescue
234
- "#{server.addresses["public"][0].gsub('.','-')}.static.cloud-ips.com"
235
- end
236
- end
237
210
  end
238
211
  end
239
212
  end
@@ -16,76 +16,41 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife'
19
+ require 'chef/knife/rackspace_base'
20
20
 
21
21
  class Chef
22
22
  class Knife
23
23
  class RackspaceServerDelete < Knife
24
-
25
- deps do
26
- require 'fog'
27
- require 'chef/knife'
28
- require 'chef/json_compat'
29
- require 'resolv'
30
- end
31
-
32
- banner "knife rackspace server delete SERVER_ID (options)"
33
-
34
- option :rackspace_api_key,
35
- :short => "-K KEY",
36
- :long => "--rackspace-api-key KEY",
37
- :description => "Your rackspace API key",
38
- :proc => Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
39
24
 
40
- option :rackspace_api_username,
41
- :short => "-A USERNAME",
42
- :long => "--rackspace-api-username USERNAME",
43
- :description => "Your rackspace API username",
44
- :proc => Proc.new { |username| Chef::Config[:knife][:rackspace_api_username] = username }
25
+ include Knife::RackspaceBase
45
26
 
46
- option :rackspace_api_auth_url,
47
- :long => "--rackspace-api-auth-url URL",
48
- :description => "Your rackspace API auth url",
49
- :default => "auth.api.rackspacecloud.com",
50
- :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url }
27
+ banner "knife rackspace server delete SERVER_ID [SERVER_ID] (options)"
51
28
 
52
29
  def run
53
- require 'fog'
54
- require 'highline'
55
- require 'net/ssh/multi'
56
- require 'readline'
57
-
58
- connection = Fog::Compute.new(
59
- :provider => 'Rackspace',
60
- :rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
61
- :rackspace_username => Chef::Config[:knife][:rackspace_api_username] || Chef::Config[:knife][:rackspace_username],
62
- :rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url]
63
- )
30
+ @name_args.each do |instance_id|
31
+
32
+ server = connection.servers.get(instance_id)
64
33
 
65
- server = connection.servers.get(@name_args[0])
34
+ msg("Instance ID", server.id.to_s)
35
+ msg("Host ID", server.host_id)
36
+ msg("Name", server.name)
37
+ msg("Flavor", server.flavor.name)
38
+ msg("Image", server.image.name)
39
+ msg("Public DNS Name", server.addresses["public"][0])
40
+ msg("Private IP Address", server.addresses["private"][0])
66
41
 
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]}"
42
+ puts "\n"
43
+ confirm("Do you really want to delete this server")
75
44
 
76
- puts "\n"
77
- confirm("Do you really want to delete this server")
45
+ server.destroy
78
46
 
79
- server.destroy
80
-
81
- ui.warn("Deleted server #{server.id} named #{server.name}")
47
+ ui.warn("Deleted server #{server.id} named #{server.name}")
48
+ end
82
49
  end
83
50
 
84
- def public_dns_name(server)
85
- @public_dns_name ||= begin
86
- Resolv.getname(server.addresses["public"][0])
87
- rescue
88
- "#{server.addresses["public"][0].gsub('.','-')}.static.cloud-ips.com"
51
+ def msg(label, value)
52
+ if value && !value.empty?
53
+ puts "#{ui.color(label, :cyan)}: #{value}"
89
54
  end
90
55
  end
91
56
  end
@@ -16,46 +16,18 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife'
19
+ require 'chef/knife/rackspace_base'
20
20
 
21
21
  class Chef
22
22
  class Knife
23
23
  class RackspaceServerList < Knife
24
24
 
25
- deps do
26
- require 'fog'
27
- require 'chef/json_compat'
28
- end
25
+ include Knife::RackspaceBase
29
26
 
30
27
  banner "knife rackspace server list (options)"
31
28
 
32
- option :rackspace_api_key,
33
- :short => "-K KEY",
34
- :long => "--rackspace-api-key KEY",
35
- :description => "Your rackspace API key",
36
- :proc => Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
37
-
38
- option :rackspace_api_username,
39
- :short => "-A USERNAME",
40
- :long => "--rackspace-api-username USERNAME",
41
- :description => "Your rackspace API username",
42
- :proc => Proc.new { |username| Chef::Config[:knife][:rackspace_api_username] = username }
43
-
44
- option :rackspace_api_auth_url,
45
- :long => "--rackspace-api-auth-url URL",
46
- :description => "Your rackspace API auth url; default is 'auth.api.rackspacecloud.com'",
47
- :default => "auth.api.rackspacecloud.com",
48
- :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_api_auth_url] = url }
49
-
50
29
  def run
51
30
  $stdout.sync = true
52
-
53
- connection = Fog::Compute.new(
54
- :provider => 'Rackspace',
55
- :rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
56
- :rackspace_username => Chef::Config[:knife][:rackspace_api_username] || Chef::Config[:knife][:rackspace_username],
57
- :rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url]
58
- )
59
31
 
60
32
  server_list = [
61
33
  ui.color('Instance ID', :bold),
@@ -73,7 +45,16 @@ class Chef
73
45
  server_list << (server.flavor_id == nil ? "" : server.flavor_id.to_s)
74
46
  server_list << (server.image_id == nil ? "" : server.image_id.to_s)
75
47
  server_list << server.name
76
- server_list << (server.state == nil ? "" : server.state.downcase)
48
+ server_list << begin
49
+ case server.state.downcase
50
+ when 'deleted','suspended'
51
+ ui.color(server.state.downcase, :red)
52
+ when 'build'
53
+ ui.color(server.state.downcase, :yellow)
54
+ else
55
+ ui.color(server.state.downcase, :green)
56
+ end
57
+ end
77
58
  end
78
59
  puts ui.list(server_list, :columns_across, 7)
79
60
 
@@ -1,3 +1,6 @@
1
- module KnifeRackspace
2
- VERSION = "0.5.6"
1
+ module Knife
2
+ module Rackspace
3
+ VERSION = "0.5.8"
4
+ MAJOR, MINOR, TINY = VERSION.split('.')
5
+ end
3
6
  end
metadata CHANGED
@@ -2,15 +2,16 @@
2
2
  name: knife-rackspace
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.6
5
+ version: 0.5.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Adam Jacob
9
+ - Seth Chisamore
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
13
 
13
- date: 2011-06-23 00:00:00 -04:00
14
+ date: 2011-07-23 00:00:00 -04:00
14
15
  default_executable:
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
@@ -47,7 +48,9 @@ dependencies:
47
48
  type: :runtime
48
49
  version_requirements: *id003
49
50
  description: Rackspace Support for Chef's Knife Command
50
- email: adam@opscode.com
51
+ email:
52
+ - adam@opscode.com
53
+ - schisamo@opscode.com
51
54
  executables: []
52
55
 
53
56
  extensions: []
@@ -56,8 +59,13 @@ extra_rdoc_files:
56
59
  - README.rdoc
57
60
  - LICENSE
58
61
  files:
62
+ - .gitignore
63
+ - Gemfile
59
64
  - LICENSE
60
65
  - README.rdoc
66
+ - Rakefile
67
+ - knife-rackspace.gemspec
68
+ - lib/chef/knife/rackspace_base.rb
61
69
  - lib/chef/knife/rackspace_flavor_list.rb
62
70
  - lib/chef/knife/rackspace_image_list.rb
63
71
  - lib/chef/knife/rackspace_server_create.rb