knife-rackspace 0.11.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Author:: Matt Ray (<matt@opscode.com>)
4
- # Copyright:: Copyright (c) 2009-2012 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Author:: Matt Ray (<matt@chef.io>)
4
+ # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,11 +17,11 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require 'chef/knife/rackspace_base'
20
+ require "chef/knife/rackspace_base"
21
21
 
22
22
  # These two are needed for the '--purge' deletion case
23
- require 'chef/node'
24
- require 'chef/api_client'
23
+ require "chef/node"
24
+ require "chef/api_client"
25
25
 
26
26
  class Chef
27
27
  class Knife
@@ -67,8 +67,9 @@ class Chef
67
67
  msg_pair("Name", server.name)
68
68
  msg_pair("Flavor", server.flavor.name)
69
69
  msg_pair("Image", server.image.name) if server.image
70
- msg_pair("Public IP Address", ip_address(server, 'public'))
71
- msg_pair("Private IP Address", ip_address(server, 'private'))
70
+ msg_pair("Boot Image ID", server.boot_image_id) if server.boot_image_id
71
+ msg_pair("Public IP Address", ip_address(server, "public"))
72
+ msg_pair("Private IP Address", ip_address(server, "private"))
72
73
 
73
74
  puts "\n"
74
75
  confirm("Do you really want to delete this server")
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2009 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife/rackspace_base'
19
+ require "chef/knife/rackspace_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -30,34 +30,38 @@ class Chef
30
30
  $stdout.sync = true
31
31
 
32
32
  server_list = [
33
- ui.color('Instance ID', :bold),
34
- ui.color('Name', :bold),
35
- ui.color('Public IP', :bold),
36
- ui.color('Private IP', :bold),
37
- ui.color('Flavor', :bold),
38
- ui.color('Image', :bold),
39
- ui.color('State', :bold)
33
+ ui.color("Instance ID", :bold),
34
+ ui.color("Name", :bold),
35
+ ui.color("Flavor", :bold),
36
+ ui.color("Image", :bold),
37
+ ui.color("State", :bold),
40
38
  ]
39
+ if version_one?
40
+ network_list = %w{public private}
41
+ else
42
+ network_list = connection.images.sort_by(&:name).collect { |t| t.label }
43
+ end
44
+ server_list.insert(2, network_list.collect { |n| ui.color("#{n.capitalize} IP", :bold) }).flatten!
45
+ num_columns_across = server_list.length
41
46
  connection.servers.all.each do |server|
42
47
  server = connection.servers.get(server.id)
43
48
  server_list << server.id.to_s
44
49
  server_list << server.name
45
- server_list << ip_address(server, 'public')
46
- server_list << ip_address(server, 'private')
50
+ server_list += network_list.collect { |n| ip_address(server, n) }
47
51
  server_list << (server.flavor_id == nil ? "" : server.flavor_id.to_s)
48
52
  server_list << (server.image_id == nil ? "" : server.image_id.to_s)
49
53
  server_list << begin
50
54
  case server.state.downcase
51
- when 'deleted','suspended'
55
+ when "deleted", "suspended"
52
56
  ui.color(server.state.downcase, :red)
53
- when 'build','unknown'
57
+ when "build", "unknown"
54
58
  ui.color(server.state.downcase, :yellow)
55
59
  else
56
60
  ui.color(server.state.downcase, :green)
57
61
  end
58
62
  end
59
63
  end
60
- puts ui.list(server_list, :uneven_columns_across, 7)
64
+ puts ui.list(server_list, :uneven_columns_across, num_columns_across)
61
65
  end
62
66
  end
63
67
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Rackspace
3
- VERSION = '0.11.0'
4
- MAJOR, MINOR, TINY = VERSION.split('.')
3
+ VERSION = "1.0.0"
4
+ MAJOR, MINOR, TINY = VERSION.split(".")
5
5
  end
6
6
  end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
- require 'vcr'
3
- require 'ansi/code'
4
- require 'ansi/diff'
1
+ require "spec_helper"
2
+ require "vcr"
3
+ require "ansi/code"
4
+ require "ansi/diff"
5
5
 
6
6
  Chef::Config[:knife][:rackspace_api_username] = "#{ENV['OS_USERNAME']}"
7
7
  Chef::Config[:knife][:rackspace_api_key] = "#{ENV['OS_PASSWORD']}"
@@ -9,28 +9,28 @@ Chef::Config[:knife][:ssl_verify_peer] = false
9
9
  # Chef::Config[:knife][:rackspace_version] = "#{ENV['RS_VERSION']}"
10
10
 
11
11
  VCR.configure do |c|
12
- c.cassette_library_dir = 'spec/cassettes'
12
+ c.cassette_library_dir = "spec/cassettes"
13
13
  c.hook_into :excon
14
14
  c.configure_rspec_metadata!
15
15
 
16
16
  # Sensitive data
17
- c.filter_sensitive_data('_RAX_USERNAME_') { Chef::Config[:knife][:rackspace_api_username] }
18
- c.filter_sensitive_data('_RAX_PASSWORD_') { Chef::Config[:knife][:rackspace_api_key] }
19
- c.filter_sensitive_data('_CDN-TENANT-NAME_') { ENV['RS_CDN_TENANT_NAME'] }
20
- c.filter_sensitive_data('000000') { ENV['RS_TENANT_ID'] }
17
+ c.filter_sensitive_data("_RAX_USERNAME_") { Chef::Config[:knife][:rackspace_api_username] }
18
+ c.filter_sensitive_data("_RAX_PASSWORD_") { Chef::Config[:knife][:rackspace_api_key] }
19
+ c.filter_sensitive_data("_CDN-TENANT-NAME_") { ENV["RS_CDN_TENANT_NAME"] }
20
+ c.filter_sensitive_data("000000") { ENV["RS_TENANT_ID"] }
21
21
 
22
22
  c.before_record do |interaction|
23
23
  # Sensitive data
24
- filter_headers(interaction, /X-\w*-Token/, '_ONE-TIME-TOKEN_')
24
+ filter_headers(interaction, /X-\w*-Token/, "_ONE-TIME-TOKEN_")
25
25
 
26
26
  # Transient data (trying to avoid unnecessary cassette churn)
27
- filter_headers(interaction, 'X-Compute-Request-Id', '_COMPUTE-REQUEST-ID_')
28
- filter_headers(interaction, 'X-Varnish', '_VARNISH-REQUEST-ID_')
27
+ filter_headers(interaction, "X-Compute-Request-Id", "_COMPUTE-REQUEST-ID_")
28
+ filter_headers(interaction, "X-Varnish", "_VARNISH-REQUEST-ID_")
29
29
 
30
30
  # Throw away build state - just makes server.wait_for loops really long during replay
31
31
  begin
32
32
  json = JSON.parse(interaction.response.body)
33
- if json['server']['status'] == 'BUILD'
33
+ if json["server"]["status"] == "BUILD"
34
34
  # Ignoring interaction because server is in BUILD state
35
35
  interaction.ignore!
36
36
  end
@@ -38,21 +38,21 @@ VCR.configure do |c|
38
38
  end
39
39
  end
40
40
 
41
- c.before_playback do | interaction |
42
- interaction.filter!('_TENANT-ID_', '0000000')
41
+ c.before_playback do |interaction|
42
+ interaction.filter!("_TENANT-ID_", "0000000")
43
43
  end
44
44
 
45
45
  c.default_cassette_options = {
46
46
  # :record => :none,
47
47
  # Ignores cache busting parameters.
48
- :match_requests_on => [:host, :path]
48
+ :match_requests_on => [:host, :path],
49
49
  }
50
- c.default_cassette_options.merge!({:record => :all}) if ENV['INTEGRATION_TESTS'] == 'live'
50
+ c.default_cassette_options.merge!({ :record => :all }) if ENV["INTEGRATION_TESTS"] == "live"
51
51
  end
52
52
 
53
53
  def filter_headers(interaction, pattern, placeholder)
54
- [interaction.request.headers, interaction.response.headers].each do | headers |
55
- sensitive_tokens = headers.select{|key| key.to_s.match(pattern)}
54
+ [interaction.request.headers, interaction.response.headers].each do |headers|
55
+ sensitive_tokens = headers.select { |key| key.to_s.match(pattern) }
56
56
  sensitive_tokens.each do |key, value|
57
57
  headers[key] = placeholder
58
58
  end
@@ -67,8 +67,8 @@ end
67
67
 
68
68
  def clean_output(output)
69
69
  output = ANSI.unansi(output)
70
- output.gsub!(/\s+$/,'')
71
- output.gsub!("\e[0G", '')
70
+ output.gsub!(/\s+$/, "")
71
+ output.gsub!("\e[0G", "")
72
72
  output
73
73
  end
74
74
 
@@ -77,7 +77,7 @@ RSpec::Matchers.define :match_output do |expected_output|
77
77
  clean_output(actual_output) == expected_output.strip
78
78
  end
79
79
  # Nice when it works, but has ANSI::Diff has some bugs that prevent it from showing any output
80
- failure_message_for_should do |actual_output|
80
+ failure_message do |actual_output|
81
81
  buffer = StringIO.new
82
82
  buffer.puts clean_output(actual_output)
83
83
  buffer.puts
@@ -87,18 +87,18 @@ RSpec::Matchers.define :match_output do |expected_output|
87
87
  # ANSI::Diff.new(output, expected_output)
88
88
  end
89
89
  description do
90
- 'Compare actual and expected output, ignoring ansi color and trailing whitespace'
90
+ "Compare actual and expected output, ignoring ansi color and trailing whitespace"
91
91
  end
92
92
  end
93
93
 
94
94
  def server_list
95
- stdout, stderr, status = knife_capture('rackspace server list')
95
+ stdout, stderr, status = knife_capture("rackspace server list")
96
96
  status == 0 ? stdout : stderr
97
97
  end
98
98
 
99
99
  def capture_instance_data(stdout, labels = {})
100
100
  result = {}
101
- labels.each do | key, label |
101
+ labels.each do |key, label|
102
102
  result[key] = clean_output(stdout).match(/^#{label}: (.*)$/)[1]
103
103
  end
104
104
  result
@@ -106,8 +106,8 @@ end
106
106
 
107
107
  # Ideally this belongs in knife-dsl, but it causes a scoping conflict with knife.rb.
108
108
  # See https://github.com/chef-workflow/knife-dsl/issues/2
109
- def knife_capture(command, args=[], input=nil)
110
- null = Gem.win_platform? ? File.open('NUL:', 'r') : File.open('/dev/null', 'r')
109
+ def knife_capture(command, args = [], input = nil)
110
+ null = Gem.win_platform? ? File.open("NUL:", "r") : File.open("/dev/null", "r")
111
111
 
112
112
  if defined? Pry
113
113
  Pry.config.input = STDIN
@@ -118,9 +118,9 @@ def knife_capture(command, args=[], input=nil)
118
118
  $VERBOSE = nil
119
119
  old_stderr, old_stdout, old_stdin = $stderr, $stdout, $stdin
120
120
 
121
- $stderr = StringIO.new('', 'r+')
122
- $stdout = StringIO.new('', 'r+')
123
- $stdin = input ? StringIO.new(input, 'r') : null
121
+ $stderr = StringIO.new("", "r+")
122
+ $stdout = StringIO.new("", "r+")
123
+ $stdin = input ? StringIO.new(input, "r") : null
124
124
  $VERBOSE = warn
125
125
 
126
126
  status = Chef::Knife::DSL::Support.run_knife(command, args)
@@ -1,3 +1,3 @@
1
- $:.unshift File.expand_path('../../lib', __FILE__)
2
- require 'chef/knife/bootstrap'
3
- require 'chef/knife/rackspace_base'
1
+ $:.unshift File.expand_path("../../lib", __FILE__)
2
+ require "chef/knife/bootstrap"
3
+ require "chef/knife/rackspace_base"
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- require 'chef/knife/rackspace_base'
4
- require 'chef/knife'
3
+ require "chef/knife/rackspace_base"
4
+ require "chef/knife"
5
5
 
6
6
  class RackspaceBaseTester < Chef::Knife
7
7
  include Chef::Knife::RackspaceBase
@@ -15,7 +15,7 @@ describe "auth_endpoint" do
15
15
  Chef::Config[:knife][:rackspace_auth_url] = test_url
16
16
  Chef::Config[:knife][:rackspace_region] = :ord
17
17
 
18
- tester.auth_endpoint.should == test_url
18
+ expect(tester.auth_endpoint).to eq(test_url)
19
19
  end
20
20
 
21
21
  [:dfw, :ord, :syd].each do |region|
@@ -24,15 +24,15 @@ describe "auth_endpoint" do
24
24
  Chef::Config[:knife][:rackspace_auth_url] = nil
25
25
  Chef::Config[:knife][:rackspace_region] = region
26
26
 
27
- tester.auth_endpoint.should == ::Fog::Rackspace::US_AUTH_ENDPOINT
27
+ expect(tester.auth_endpoint).to eq(::Fog::Rackspace::US_AUTH_ENDPOINT)
28
28
  end
29
29
  end
30
30
 
31
31
  it "should pick the UK end point if the region is :lon" do
32
32
  tester = RackspaceBaseTester.new
33
33
  Chef::Config[:knife][:rackspace_auth_url] = nil
34
- Chef::Config[:knife][:rackspace_region] = 'lon'
34
+ Chef::Config[:knife][:rackspace_region] = "lon"
35
35
 
36
- tester.auth_endpoint.should == ::Fog::Rackspace::UK_AUTH_ENDPOINT
36
+ expect(tester.auth_endpoint).to eq(::Fog::Rackspace::UK_AUTH_ENDPOINT)
37
37
  end
38
- end
38
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-rackspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
@@ -12,120 +12,50 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-09-08 00:00:00.000000000 Z
15
+ date: 2016-11-16 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: knife-windows
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ! '>='
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - ! '>='
28
+ - - ">="
29
29
  - !ruby/object:Gem::Version
30
30
  version: '0'
31
31
  - !ruby/object:Gem::Dependency
32
- name: fog
32
+ name: fog-rackspace
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - ! '>='
35
+ - - ">="
36
36
  - !ruby/object:Gem::Version
37
- version: '1.24'
37
+ version: '0.1'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - ! '>='
42
+ - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: '1.24'
44
+ version: '0.1'
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: chef
47
47
  requirement: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - ! '>='
49
+ - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: 0.10.10
51
+ version: '12.0'
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - ! '>='
56
+ - - ">="
57
57
  - !ruby/object:Gem::Version
58
- version: 0.10.10
59
- - !ruby/object:Gem::Dependency
60
- name: knife-dsl
61
- requirement: !ruby/object:Gem::Requirement
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: '0'
66
- type: :development
67
- prerelease: false
68
- version_requirements: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - ! '>='
71
- - !ruby/object:Gem::Version
72
- version: '0'
73
- - !ruby/object:Gem::Dependency
74
- name: rspec
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- type: :development
81
- prerelease: false
82
- version_requirements: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - ! '>='
85
- - !ruby/object:Gem::Version
86
- version: '0'
87
- - !ruby/object:Gem::Dependency
88
- name: vcr
89
- requirement: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- type: :development
95
- prerelease: false
96
- version_requirements: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - ! '>='
99
- - !ruby/object:Gem::Version
100
- version: '0'
101
- - !ruby/object:Gem::Dependency
102
- name: ansi
103
- requirement: !ruby/object:Gem::Requirement
104
- requirements:
105
- - - ! '>='
106
- - !ruby/object:Gem::Version
107
- version: '0'
108
- type: :development
109
- prerelease: false
110
- version_requirements: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - ! '>='
113
- - !ruby/object:Gem::Version
114
- version: '0'
115
- - !ruby/object:Gem::Dependency
116
- name: rake
117
- requirement: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - ! '>='
120
- - !ruby/object:Gem::Version
121
- version: '0'
122
- type: :development
123
- prerelease: false
124
- version_requirements: !ruby/object:Gem::Requirement
125
- requirements:
126
- - - ! '>='
127
- - !ruby/object:Gem::Version
128
- version: '0'
58
+ version: '12.0'
129
59
  description: Rackspace Support for Chef's Knife Command
130
60
  email:
131
61
  - adam@chef.io
@@ -135,16 +65,17 @@ email:
135
65
  executables: []
136
66
  extensions: []
137
67
  extra_rdoc_files:
138
- - README.rdoc
68
+ - README.md
139
69
  - LICENSE
140
70
  files:
141
- - .chef/knife.rb
142
- - .gitignore
143
- - .travis.yml
71
+ - ".chef/knife.rb"
72
+ - ".github/ISSUE_TEMPLATE.md"
73
+ - ".gitignore"
74
+ - ".travis.yml"
144
75
  - CHANGELOG.md
145
76
  - Gemfile
146
77
  - LICENSE
147
- - README.rdoc
78
+ - README.md
148
79
  - Rakefile
149
80
  - knife-rackspace.gemspec
150
81
  - lib/chef/knife/rackspace_base.rb
@@ -165,7 +96,7 @@ files:
165
96
  - spec/integration_spec_helper.rb
166
97
  - spec/spec_helper.rb
167
98
  - spec/unit/rackspace_base_spec.rb
168
- homepage: https://docs.chef.io/plugin_knife_rackspace.html
99
+ homepage: https://github.com/chef/knife-rackspace
169
100
  licenses: []
170
101
  metadata: {}
171
102
  post_install_message:
@@ -174,17 +105,17 @@ require_paths:
174
105
  - lib
175
106
  required_ruby_version: !ruby/object:Gem::Requirement
176
107
  requirements:
177
- - - ! '>='
108
+ - - ">="
178
109
  - !ruby/object:Gem::Version
179
- version: '0'
110
+ version: 2.2.2
180
111
  required_rubygems_version: !ruby/object:Gem::Requirement
181
112
  requirements:
182
- - - ! '>='
113
+ - - ">="
183
114
  - !ruby/object:Gem::Version
184
115
  version: '0'
185
116
  requirements: []
186
117
  rubyforge_project:
187
- rubygems_version: 2.4.5
118
+ rubygems_version: 2.4.8
188
119
  signing_key:
189
120
  specification_version: 4
190
121
  summary: Rackspace Support for Chef's Knife Command