knife-ec2 0.6.4 → 0.6.6.rc.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,139 @@
1
+ # License:: Apache License, Version 2.0
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+
16
+ require File.expand_path('../../spec_helper', __FILE__)
17
+ require 'fog'
18
+
19
+
20
+ describe Chef::Knife::Ec2ServerDelete do
21
+ before do
22
+ end
23
+
24
+ describe "run" do
25
+ before(:each) do
26
+ {
27
+ :image => 'image',
28
+ :aws_ssh_key_id => 'aws_ssh_key_id',
29
+ :aws_access_key_id => 'aws_access_key_id',
30
+ :aws_secret_access_key => 'aws_secret_access_key'
31
+ }.each do |key, value|
32
+ Chef::Config[:knife][key] = value
33
+ end
34
+
35
+ @ec2_server_attribs = { :id => 'i-39382318',
36
+ :flavor_id => 'm1.small',
37
+ :image_id => 'ami-47241231',
38
+ :availability_zone => 'us-west-1',
39
+ :key_name => 'my_ssh_key',
40
+ :groups => ['group1', 'group2'],
41
+ :security_group_ids => ['sg-00aa11bb'],
42
+ :dns_name => 'ec2-75.101.253.10.compute-1.amazonaws.com',
43
+ :iam_instance_profile => {},
44
+ :public_ip_address => '75.101.253.10',
45
+ :private_dns_name => 'ip-10-251-75-20.ec2.internal',
46
+ :private_ip_address => '10.251.75.20',
47
+ :root_device_type => 'not_ebs' }
48
+ @knife_ec2_delete = Chef::Knife::Ec2ServerDelete.new
49
+ @ec2_servers = double()
50
+ @knife_ec2_delete.ui.stub(:confirm)
51
+ @knife_ec2_delete.stub(:msg_pair)
52
+ @ec2_server = double(@ec2_server_attribs)
53
+ @ec2_connection = double(Fog::Compute::AWS)
54
+ @ec2_connection.stub(:servers).and_return(@ec2_servers)
55
+ @knife_ec2_delete.ui.stub(:warn)
56
+ end
57
+
58
+ it "should invoke validate!" do
59
+ knife_ec2_delete = Chef::Knife::Ec2ServerDelete.new
60
+ knife_ec2_delete.should_receive(:validate!)
61
+ knife_ec2_delete.run
62
+ end
63
+
64
+ it "should use invoke fog api to delete instance if instance id is passed" do
65
+ @ec2_servers.should_receive(:get).with('foo').and_return(@ec2_server)
66
+ Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
67
+ @knife_ec2_delete.name_args = ['foo']
68
+ @knife_ec2_delete.should_receive(:validate!)
69
+ @ec2_server.should_receive(:destroy)
70
+ @knife_ec2_delete.run
71
+ end
72
+
73
+ it "should use node_name to figure out instance id if not specified explicitly" do
74
+ @ec2_servers.should_receive(:get).with('foo').and_return(@ec2_server)
75
+ Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
76
+ @knife_ec2_delete.should_receive(:validate!)
77
+ @ec2_server.should_receive(:destroy)
78
+ @knife_ec2_delete.config[:purge] = false
79
+ @knife_ec2_delete.config[:chef_node_name] = 'baz'
80
+ double_node = double(Chef::Node)
81
+ double_node.should_receive(:attribute?).with('ec2').and_return(true)
82
+ double_node.should_receive(:[]).with('ec2').and_return('instance_id'=>'foo')
83
+ double_search = double(Chef::Search::Query)
84
+ double_search.should_receive(:search).with(:node,"name:baz").and_return([[double_node],nil,nil])
85
+ Chef::Search::Query.should_receive(:new).and_return(double_search)
86
+ @knife_ec2_delete.name_args = []
87
+ @knife_ec2_delete.run
88
+ end
89
+
90
+ describe "when --purge is passed" do
91
+ it "should use the node name if its set" do
92
+ @ec2_servers.should_receive(:get).with('foo').and_return(@ec2_server)
93
+ Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
94
+ @knife_ec2_delete.name_args = ['foo']
95
+ @knife_ec2_delete.should_receive(:validate!)
96
+ @ec2_server.should_receive(:destroy)
97
+ @knife_ec2_delete.config[:purge] = true
98
+ @knife_ec2_delete.config[:chef_node_name] = 'baz'
99
+ Chef::Node.should_receive(:load).with('baz').and_return(double(:destroy=>true))
100
+ Chef::ApiClient.should_receive(:load).with('baz').and_return(double(:destroy=>true))
101
+ @knife_ec2_delete.run
102
+ end
103
+
104
+ it "should search for the node name using the instance id when node name is not specified" do
105
+ @ec2_servers.should_receive(:get).with('i-foo').and_return(@ec2_server)
106
+ Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
107
+ @knife_ec2_delete.name_args = ['i-foo']
108
+ @knife_ec2_delete.should_receive(:validate!)
109
+ @ec2_server.should_receive(:destroy)
110
+ @knife_ec2_delete.config[:purge] = true
111
+ @knife_ec2_delete.config[:chef_node_name] = nil
112
+ double_search = double(Chef::Search::Query)
113
+ double_node = double(Chef::Node)
114
+ double_node.should_receive(:name).and_return("baz")
115
+ Chef::Node.should_receive(:load).with('baz').and_return(double(:destroy=>true))
116
+ Chef::ApiClient.should_receive(:load).with('baz').and_return(double(:destroy=>true))
117
+ double_search.should_receive(:search).with(:node,"ec2_instance_id:i-foo").and_return([[double_node],nil,nil])
118
+ Chef::Search::Query.should_receive(:new).and_return(double_search)
119
+ @knife_ec2_delete.run
120
+ end
121
+
122
+ it "should use the instance id if search does not return anything" do
123
+ @ec2_servers.should_receive(:get).with('i-foo').and_return(@ec2_server)
124
+ Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
125
+ @knife_ec2_delete.name_args = ['i-foo']
126
+ @knife_ec2_delete.should_receive(:validate!)
127
+ @ec2_server.should_receive(:destroy)
128
+ @knife_ec2_delete.config[:purge] = true
129
+ @knife_ec2_delete.config[:chef_node_name] = nil
130
+ Chef::Node.should_receive(:load).with('i-foo').and_return(double(:destroy=>true))
131
+ Chef::ApiClient.should_receive(:load).with('i-foo').and_return(double(:destroy=>true))
132
+ double_search = double(Chef::Search::Query)
133
+ double_search.should_receive(:search).with(:node,"ec2_instance_id:i-foo").and_return([[],nil,nil])
134
+ Chef::Search::Query.should_receive(:new).and_return(double_search)
135
+ @knife_ec2_delete.run
136
+ end
137
+ end
138
+ end
139
+ end
metadata CHANGED
@@ -1,129 +1,134 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: knife-ec2
3
- version: !ruby/object:Gem::Version
4
- version: 0.6.4
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1549375601
5
+ prerelease: 6
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 6
10
+ - rc
11
+ - 0
12
+ version: 0.6.6.rc.0
6
13
  platform: ruby
7
- authors:
14
+ authors:
8
15
  - Adam Jacob
9
16
  - Seth Chisamore
10
17
  autorequire:
11
18
  bindir: bin
12
19
  cert_chain: []
13
- date: 2013-04-15 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
20
+
21
+ date: 2013-10-28 00:00:00 Z
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
16
24
  name: fog
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: '1.6'
23
- type: :runtime
24
25
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
+ requirement: &id001 !ruby/object:Gem::Requirement
26
27
  none: false
27
- requirements:
28
+ requirements:
28
29
  - - ~>
29
- - !ruby/object:Gem::Version
30
- version: '1.6'
31
- - !ruby/object:Gem::Dependency
30
+ - !ruby/object:Gem::Version
31
+ hash: 43
32
+ segments:
33
+ - 1
34
+ - 15
35
+ - 0
36
+ version: 1.15.0
37
+ type: :runtime
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
32
40
  name: chef
33
- requirement: !ruby/object:Gem::Requirement
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
34
43
  none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 35
48
+ segments:
49
+ - 0
50
+ - 10
51
+ - 10
38
52
  version: 0.10.10
39
53
  type: :runtime
54
+ version_requirements: *id002
55
+ - !ruby/object:Gem::Dependency
56
+ name: knife-windows
40
57
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
58
+ requirement: &id003 !ruby/object:Gem::Requirement
42
59
  none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: 0.10.10
47
- - !ruby/object:Gem::Dependency
48
- name: rspec-core
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :development
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 19
64
+ segments:
65
+ - 0
66
+ - 5
67
+ - 12
68
+ version: 0.5.12
69
+ type: :runtime
70
+ version_requirements: *id003
71
+ - !ruby/object:Gem::Dependency
72
+ name: rspec
56
73
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- - !ruby/object:Gem::Dependency
64
- name: rspec-expectations
65
- requirement: !ruby/object:Gem::Requirement
74
+ requirement: &id004 !ruby/object:Gem::Requirement
66
75
  none: false
67
- requirements:
68
- - - ! '>='
69
- - !ruby/object:Gem::Version
70
- version: '0'
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ hash: 31
80
+ segments:
81
+ - 2
82
+ - 14
83
+ version: "2.14"
71
84
  type: :development
85
+ version_requirements: *id004
86
+ - !ruby/object:Gem::Dependency
87
+ name: rake
72
88
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ! '>='
77
- - !ruby/object:Gem::Version
78
- version: '0'
79
- - !ruby/object:Gem::Dependency
80
- name: rspec-mocks
81
- requirement: !ruby/object:Gem::Requirement
89
+ requirement: &id005 !ruby/object:Gem::Requirement
82
90
  none: false
83
- requirements:
84
- - - ! '>='
85
- - !ruby/object:Gem::Version
86
- version: '0'
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ hash: 33
95
+ segments:
96
+ - 10
97
+ - 1
98
+ version: "10.1"
87
99
  type: :development
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: sdoc
88
103
  prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
104
+ requirement: &id006 !ruby/object:Gem::Requirement
90
105
  none: false
91
- requirements:
92
- - - ! '>='
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
- - !ruby/object:Gem::Dependency
96
- name: rspec_junit_formatter
97
- requirement: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ! '>='
101
- - !ruby/object:Gem::Version
102
- version: '0'
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ hash: 13
110
+ segments:
111
+ - 0
112
+ - 3
113
+ version: "0.3"
103
114
  type: :development
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- description: EC2 Support for Chef's Knife Command
112
- email:
115
+ version_requirements: *id006
116
+ description: EC2 Support for Chef\'s Knife Command
117
+ email:
113
118
  - adam@opscode.com
114
119
  - schisamo@opscode.com
115
120
  executables: []
121
+
116
122
  extensions: []
117
- extra_rdoc_files:
118
- - README.rdoc
119
- - LICENSE
120
- files:
123
+
124
+ extra_rdoc_files: []
125
+
126
+ files:
121
127
  - .gitignore
122
- - .rspec
128
+ - .travis.yml
123
129
  - Gemfile
124
- - Gemfile.lock
125
130
  - LICENSE
126
- - README.rdoc
131
+ - README.md
127
132
  - Rakefile
128
133
  - knife-ec2.gemspec
129
134
  - lib/chef/knife/ec2_base.rb
@@ -135,31 +140,42 @@ files:
135
140
  - lib/knife-ec2/version.rb
136
141
  - spec/spec_helper.rb
137
142
  - spec/unit/ec2_server_create_spec.rb
138
- homepage: http://wiki.opscode.com/display/chef
139
- licenses: []
143
+ - spec/unit/ec2_server_delete_spec.rb
144
+ homepage: https://github.com/opscode/knife-ec2
145
+ licenses:
146
+ - Apache 2.0
140
147
  post_install_message:
141
148
  rdoc_options: []
142
- require_paths:
149
+
150
+ require_paths:
143
151
  - lib
144
- required_ruby_version: !ruby/object:Gem::Requirement
152
+ required_ruby_version: !ruby/object:Gem::Requirement
145
153
  none: false
146
- requirements:
147
- - - ! '>='
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
- required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 3
158
+ segments:
159
+ - 0
160
+ version: "0"
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
162
  none: false
152
- requirements:
153
- - - ! '>='
154
- - !ruby/object:Gem::Version
155
- version: '0'
163
+ requirements:
164
+ - - ">"
165
+ - !ruby/object:Gem::Version
166
+ hash: 25
167
+ segments:
168
+ - 1
169
+ - 3
170
+ - 1
171
+ version: 1.3.1
156
172
  requirements: []
173
+
157
174
  rubyforge_project:
158
- rubygems_version: 1.8.23
175
+ rubygems_version: 1.8.10
159
176
  signing_key:
160
177
  specification_version: 3
161
- summary: EC2 Support for Chef's Knife Command
162
- test_files:
163
- - spec/spec_helper.rb
164
- - spec/unit/ec2_server_create_spec.rb
165
- has_rdoc: true
178
+ summary: EC2 Support for Chef\'s Knife Command
179
+ test_files: []
180
+
181
+ has_rdoc:
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- -fs
@@ -1,104 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- knife-ec2 (0.5.14)
5
- chef (>= 0.10.10)
6
- fog (~> 1.3)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- builder (3.0.0)
12
- bunny (0.8.0)
13
- chef (10.12.0)
14
- bunny (>= 0.6.0)
15
- erubis
16
- highline (>= 1.6.9)
17
- json (>= 1.4.4, <= 1.6.1)
18
- mixlib-authentication (>= 1.1.0)
19
- mixlib-cli (>= 1.1.0)
20
- mixlib-config (>= 1.1.2)
21
- mixlib-log (>= 1.3.0)
22
- mixlib-shellout
23
- moneta
24
- net-ssh (~> 2.2.2)
25
- net-ssh-multi (~> 1.1.0)
26
- ohai (>= 0.6.0)
27
- rest-client (>= 1.0.4, < 1.7.0)
28
- treetop (~> 1.4.9)
29
- uuidtools
30
- yajl-ruby (~> 1.1)
31
- diff-lcs (1.1.3)
32
- erubis (2.7.0)
33
- excon (0.14.3)
34
- fog (1.4.0)
35
- builder
36
- excon (~> 0.14.0)
37
- formatador (~> 0.2.0)
38
- mime-types
39
- multi_json (~> 1.0)
40
- net-scp (~> 1.0.4)
41
- net-ssh (>= 2.1.3)
42
- nokogiri (~> 1.5.0)
43
- ruby-hmac
44
- formatador (0.2.3)
45
- highline (1.6.13)
46
- ipaddress (0.8.0)
47
- json (1.6.1)
48
- mime-types (1.19)
49
- mixlib-authentication (1.1.4)
50
- mixlib-log
51
- mixlib-cli (1.2.2)
52
- mixlib-config (1.1.2)
53
- mixlib-log (1.4.1)
54
- mixlib-shellout (1.0.0)
55
- moneta (0.6.0)
56
- multi_json (1.3.6)
57
- net-scp (1.0.4)
58
- net-ssh (>= 1.99.1)
59
- net-ssh (2.2.2)
60
- net-ssh-gateway (1.1.0)
61
- net-ssh (>= 1.99.1)
62
- net-ssh-multi (1.1)
63
- net-ssh (>= 2.1.4)
64
- net-ssh-gateway (>= 0.99.0)
65
- nokogiri (1.5.5)
66
- ohai (6.14.0)
67
- ipaddress
68
- mixlib-cli
69
- mixlib-config
70
- mixlib-log
71
- systemu
72
- yajl-ruby
73
- polyglot (0.3.3)
74
- rest-client (1.6.7)
75
- mime-types (>= 1.16)
76
- rspec (2.7.0)
77
- rspec-core (~> 2.7.0)
78
- rspec-expectations (~> 2.7.0)
79
- rspec-mocks (~> 2.7.0)
80
- rspec-core (2.7.1)
81
- rspec-expectations (2.7.0)
82
- diff-lcs (~> 1.1.2)
83
- rspec-mocks (2.7.0)
84
- rspec_junit_formatter (0.1.1)
85
- builder
86
- rspec (~> 2.0)
87
- ruby-hmac (0.4.0)
88
- systemu (2.5.2)
89
- treetop (1.4.10)
90
- polyglot
91
- polyglot (>= 0.3.1)
92
- uuidtools (2.1.3)
93
- yajl-ruby (1.1.0)
94
-
95
- PLATFORMS
96
- ruby
97
-
98
- DEPENDENCIES
99
- knife-ec2!
100
- rspec (~> 2.7.0)
101
- rspec-core
102
- rspec-expectations
103
- rspec-mocks
104
- rspec_junit_formatter