knife-windows 0.5.14 → 0.5.15
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -4
- data/.rspec +3 -3
- data/.travis.yml +6 -6
- data/CHANGELOG +14 -14
- data/Gemfile +11 -11
- data/LICENSE +201 -201
- data/README.rdoc +140 -140
- data/Rakefile +16 -16
- data/features/knife_help.feature +20 -20
- data/features/support/env.rb +5 -5
- data/knife-windows.gemspec +24 -24
- data/lib/chef/knife/bootstrap/windows-chef-client-msi.erb +222 -211
- data/lib/chef/knife/bootstrap/windows-shell.erb +68 -68
- data/lib/chef/knife/bootstrap_windows_base.rb +196 -196
- data/lib/chef/knife/bootstrap_windows_ssh.rb +93 -93
- data/lib/chef/knife/bootstrap_windows_winrm.rb +62 -62
- data/lib/chef/knife/core/windows_bootstrap_context.rb +177 -177
- data/lib/chef/knife/windows_helper.rb +34 -34
- data/lib/chef/knife/winrm.rb +286 -286
- data/lib/chef/knife/winrm_base.rb +99 -98
- data/lib/knife-windows/version.rb +6 -6
- data/spec/functional/bootstrap_download_spec.rb +120 -120
- data/spec/spec_helper.rb +63 -63
- data/spec/unit/knife/bootstrap_template_spec.rb +91 -91
- data/spec/unit/knife/winrm_spec.rb +82 -82
- metadata +12 -12
data/spec/spec_helper.rb
CHANGED
@@ -1,63 +1,63 @@
|
|
1
|
-
|
2
|
-
# Author:: Adam Edwards (<adamed@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2012 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
|
15
|
-
# implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
def windows?
|
21
|
-
!!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
|
22
|
-
end
|
23
|
-
|
24
|
-
require_relative '../lib/chef/knife/core/windows_bootstrap_context'
|
25
|
-
require_relative '../lib/chef/knife/bootstrap_windows_winrm'
|
26
|
-
|
27
|
-
if windows?
|
28
|
-
require 'ruby-wmi'
|
29
|
-
end
|
30
|
-
|
31
|
-
def windows2012?
|
32
|
-
is_win2k12 = false
|
33
|
-
|
34
|
-
if windows?
|
35
|
-
this_operating_system = WMI::Win32_OperatingSystem.find(:first)
|
36
|
-
os_version = this_operating_system.send('Version')
|
37
|
-
|
38
|
-
# The operating system version is a string in the following form
|
39
|
-
# that can be split into components based on the '.' delimiter:
|
40
|
-
# MajorVersionNumber.MinorVersionNumber.BuildNumber
|
41
|
-
os_version_components = os_version.split('.')
|
42
|
-
|
43
|
-
if os_version_components.length < 2
|
44
|
-
raise 'WMI returned a Windows version from Win32_OperatingSystem.Version ' +
|
45
|
-
'with an unexpected format. The Windows version could not be determined.'
|
46
|
-
end
|
47
|
-
|
48
|
-
# Windows 6.2 is Windows Server 2012, so test the major and
|
49
|
-
# minor version components
|
50
|
-
is_win2k12 = os_version_components[0] == '6' && os_version_components[1] == '2'
|
51
|
-
end
|
52
|
-
|
53
|
-
is_win2k12
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
RSpec.configure do |config|
|
58
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
59
|
-
|
60
|
-
config.filter_run_excluding :windows_only => true unless windows?
|
61
|
-
config.filter_run_excluding :windows_2012_only => true unless windows2012?
|
62
|
-
end
|
63
|
-
|
1
|
+
|
2
|
+
# Author:: Adam Edwards (<adamed@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 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
|
15
|
+
# implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
def windows?
|
21
|
+
!!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
|
22
|
+
end
|
23
|
+
|
24
|
+
require_relative '../lib/chef/knife/core/windows_bootstrap_context'
|
25
|
+
require_relative '../lib/chef/knife/bootstrap_windows_winrm'
|
26
|
+
|
27
|
+
if windows?
|
28
|
+
require 'ruby-wmi'
|
29
|
+
end
|
30
|
+
|
31
|
+
def windows2012?
|
32
|
+
is_win2k12 = false
|
33
|
+
|
34
|
+
if windows?
|
35
|
+
this_operating_system = WMI::Win32_OperatingSystem.find(:first)
|
36
|
+
os_version = this_operating_system.send('Version')
|
37
|
+
|
38
|
+
# The operating system version is a string in the following form
|
39
|
+
# that can be split into components based on the '.' delimiter:
|
40
|
+
# MajorVersionNumber.MinorVersionNumber.BuildNumber
|
41
|
+
os_version_components = os_version.split('.')
|
42
|
+
|
43
|
+
if os_version_components.length < 2
|
44
|
+
raise 'WMI returned a Windows version from Win32_OperatingSystem.Version ' +
|
45
|
+
'with an unexpected format. The Windows version could not be determined.'
|
46
|
+
end
|
47
|
+
|
48
|
+
# Windows 6.2 is Windows Server 2012, so test the major and
|
49
|
+
# minor version components
|
50
|
+
is_win2k12 = os_version_components[0] == '6' && os_version_components[1] == '2'
|
51
|
+
end
|
52
|
+
|
53
|
+
is_win2k12
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
RSpec.configure do |config|
|
58
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
59
|
+
|
60
|
+
config.filter_run_excluding :windows_only => true unless windows?
|
61
|
+
config.filter_run_excluding :windows_2012_only => true unless windows2012?
|
62
|
+
end
|
63
|
+
|
@@ -1,91 +1,91 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Chirag Jog (<chirag@clogeny.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Chirag Jog
|
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
|
-
TEMPLATE_FILE = File.expand_path(File.dirname(__FILE__)) + "/../../../lib/chef/knife/bootstrap/windows-chef-client-msi.erb"
|
20
|
-
|
21
|
-
require 'spec_helper'
|
22
|
-
|
23
|
-
describe "While Windows Bootstrapping" do
|
24
|
-
context "the default Windows bootstrapping template" do
|
25
|
-
bootstrap = Chef::Knife::BootstrapWindowsWinrm.new
|
26
|
-
bootstrap.config[:template_file] = TEMPLATE_FILE
|
27
|
-
|
28
|
-
template = bootstrap.load_template
|
29
|
-
template_file_lines = template.split('\n')
|
30
|
-
it "should download Platform specific MSI" do
|
31
|
-
download_url=template_file_lines.find {|l| l.include?("url=")}
|
32
|
-
download_url.include?("%MACHINE_OS%") && download_url.include?("%MACHINE_ARCH%")
|
33
|
-
end
|
34
|
-
it "should download specific version of MSI if supplied" do
|
35
|
-
download_url_ext= template_file_lines.find {|l| l.include?("url +=")}
|
36
|
-
download_url_ext.include?("[:bootstrap_version]")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe Chef::Knife::BootstrapWindowsWinrm do
|
42
|
-
before(:all) do
|
43
|
-
@original_config = Chef::Config.hash_dup
|
44
|
-
@original_knife_config = Chef::Config[:knife].dup
|
45
|
-
end
|
46
|
-
|
47
|
-
after(:all) do
|
48
|
-
Chef::Config.configuration = @original_config
|
49
|
-
Chef::Config[:knife] = @original_knife_config
|
50
|
-
end
|
51
|
-
|
52
|
-
before(:each) do
|
53
|
-
Chef::Log.logger = Logger.new(StringIO.new)
|
54
|
-
@knife = Chef::Knife::BootstrapWindowsWinrm.new
|
55
|
-
# Merge default settings in.
|
56
|
-
@knife.merge_configs
|
57
|
-
@knife.config[:template_file] = TEMPLATE_FILE
|
58
|
-
@stdout = StringIO.new
|
59
|
-
@knife.ui.stub(:stdout).and_return(@stdout)
|
60
|
-
@stderr = StringIO.new
|
61
|
-
@knife.ui.stub(:stderr).and_return(@stderr)
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "specifying no_proxy with various entries" do
|
65
|
-
subject(:knife) { described_class.new }
|
66
|
-
let(:options){ ["--bootstrap-proxy", "", "--bootstrap-no-proxy", setting] }
|
67
|
-
let(:template_file) { TEMPLATE_FILE }
|
68
|
-
let(:rendered_template) do
|
69
|
-
knife.instance_variable_set("@template_file", template_file)
|
70
|
-
knife.parse_options(options)
|
71
|
-
# Avoid referencing a validation keyfile we won't find during #render_template
|
72
|
-
template_string = knife.read_template.gsub(/^.*[Vv]alidation_key.*$/, '')
|
73
|
-
knife.render_template(template_string)
|
74
|
-
end
|
75
|
-
|
76
|
-
context "via --bootstrap-no-proxy" do
|
77
|
-
let(:setting) { "api.opscode.com" }
|
78
|
-
|
79
|
-
it "renders the client.rb with a single FQDN no_proxy entry" do
|
80
|
-
rendered_template.should match(%r{.*no_proxy\s*\"api.opscode.com\".*})
|
81
|
-
end
|
82
|
-
end
|
83
|
-
context "via --bootstrap-no-proxy multiple" do
|
84
|
-
let(:setting) { "api.opscode.com,172.16.10.*" }
|
85
|
-
|
86
|
-
it "renders the client.rb with comma-separated FQDN and wildcard IP address no_proxy entries" do
|
87
|
-
rendered_template.should match(%r{.*no_proxy\s*"api.opscode.com,172.16.10.\*".*})
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Chirag Jog (<chirag@clogeny.com>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Chirag Jog
|
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
|
+
TEMPLATE_FILE = File.expand_path(File.dirname(__FILE__)) + "/../../../lib/chef/knife/bootstrap/windows-chef-client-msi.erb"
|
20
|
+
|
21
|
+
require 'spec_helper'
|
22
|
+
|
23
|
+
describe "While Windows Bootstrapping" do
|
24
|
+
context "the default Windows bootstrapping template" do
|
25
|
+
bootstrap = Chef::Knife::BootstrapWindowsWinrm.new
|
26
|
+
bootstrap.config[:template_file] = TEMPLATE_FILE
|
27
|
+
|
28
|
+
template = bootstrap.load_template
|
29
|
+
template_file_lines = template.split('\n')
|
30
|
+
it "should download Platform specific MSI" do
|
31
|
+
download_url=template_file_lines.find {|l| l.include?("url=")}
|
32
|
+
download_url.include?("%MACHINE_OS%") && download_url.include?("%MACHINE_ARCH%")
|
33
|
+
end
|
34
|
+
it "should download specific version of MSI if supplied" do
|
35
|
+
download_url_ext= template_file_lines.find {|l| l.include?("url +=")}
|
36
|
+
download_url_ext.include?("[:bootstrap_version]")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe Chef::Knife::BootstrapWindowsWinrm do
|
42
|
+
before(:all) do
|
43
|
+
@original_config = Chef::Config.hash_dup
|
44
|
+
@original_knife_config = Chef::Config[:knife].dup
|
45
|
+
end
|
46
|
+
|
47
|
+
after(:all) do
|
48
|
+
Chef::Config.configuration = @original_config
|
49
|
+
Chef::Config[:knife] = @original_knife_config
|
50
|
+
end
|
51
|
+
|
52
|
+
before(:each) do
|
53
|
+
Chef::Log.logger = Logger.new(StringIO.new)
|
54
|
+
@knife = Chef::Knife::BootstrapWindowsWinrm.new
|
55
|
+
# Merge default settings in.
|
56
|
+
@knife.merge_configs
|
57
|
+
@knife.config[:template_file] = TEMPLATE_FILE
|
58
|
+
@stdout = StringIO.new
|
59
|
+
@knife.ui.stub(:stdout).and_return(@stdout)
|
60
|
+
@stderr = StringIO.new
|
61
|
+
@knife.ui.stub(:stderr).and_return(@stderr)
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "specifying no_proxy with various entries" do
|
65
|
+
subject(:knife) { described_class.new }
|
66
|
+
let(:options){ ["--bootstrap-proxy", "", "--bootstrap-no-proxy", setting] }
|
67
|
+
let(:template_file) { TEMPLATE_FILE }
|
68
|
+
let(:rendered_template) do
|
69
|
+
knife.instance_variable_set("@template_file", template_file)
|
70
|
+
knife.parse_options(options)
|
71
|
+
# Avoid referencing a validation keyfile we won't find during #render_template
|
72
|
+
template_string = knife.read_template.gsub(/^.*[Vv]alidation_key.*$/, '')
|
73
|
+
knife.render_template(template_string)
|
74
|
+
end
|
75
|
+
|
76
|
+
context "via --bootstrap-no-proxy" do
|
77
|
+
let(:setting) { "api.opscode.com" }
|
78
|
+
|
79
|
+
it "renders the client.rb with a single FQDN no_proxy entry" do
|
80
|
+
rendered_template.should match(%r{.*no_proxy\s*\"api.opscode.com\".*})
|
81
|
+
end
|
82
|
+
end
|
83
|
+
context "via --bootstrap-no-proxy multiple" do
|
84
|
+
let(:setting) { "api.opscode.com,172.16.10.*" }
|
85
|
+
|
86
|
+
it "renders the client.rb with comma-separated FQDN and wildcard IP address no_proxy entries" do
|
87
|
+
rendered_template.should match(%r{.*no_proxy\s*"api.opscode.com,172.16.10.\*".*})
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -1,82 +1,82 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Bryan McLellan <btm@opscode.com>
|
3
|
-
# Copyright:: Copyright (c) 2013 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 'spec_helper'
|
20
|
-
|
21
|
-
Chef::Knife::Winrm.load_deps
|
22
|
-
|
23
|
-
describe Chef::Knife::Winrm do
|
24
|
-
before(:all) do
|
25
|
-
@original_config = Chef::Config.hash_dup
|
26
|
-
@original_knife_config = Chef::Config[:knife].dup
|
27
|
-
end
|
28
|
-
|
29
|
-
after(:all) do
|
30
|
-
Chef::Config.configuration = @original_config
|
31
|
-
Chef::Config[:knife] = @original_knife_config
|
32
|
-
end
|
33
|
-
|
34
|
-
before do
|
35
|
-
@knife = Chef::Knife::Winrm.new
|
36
|
-
@knife.config[:attribute] = "fqdn"
|
37
|
-
@node_foo = Chef::Node.new
|
38
|
-
@node_foo.automatic_attrs[:fqdn] = "foo.example.org"
|
39
|
-
@node_foo.automatic_attrs[:ipaddress] = "10.0.0.1"
|
40
|
-
@node_bar = Chef::Node.new
|
41
|
-
@node_bar.automatic_attrs[:fqdn] = "bar.example.org"
|
42
|
-
@node_bar.automatic_attrs[:ipaddress] = "10.0.0.2"
|
43
|
-
@node_bar.automatic_attrs[:ec2][:public_hostname] = "somewhere.com"
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "#configure_session" do
|
47
|
-
before do
|
48
|
-
@query =
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when there are some hosts found but they do not have an attribute to connect with" do
|
52
|
-
before do
|
53
|
-
@knife.config[:manual] = false
|
54
|
-
@query.stub
|
55
|
-
@node_foo.automatic_attrs[:fqdn] = nil
|
56
|
-
@node_bar.automatic_attrs[:fqdn] = nil
|
57
|
-
Chef::Search::Query.stub
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should raise a specific error (KNIFE-222)" do
|
61
|
-
@knife.ui.should_receive(:fatal).with(/does not have the required attribute/)
|
62
|
-
@knife.should_receive(:exit).with(10)
|
63
|
-
@knife.configure_session
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "when there are nested attributes" do
|
68
|
-
before do
|
69
|
-
@knife.config[:manual] = false
|
70
|
-
@query.stub
|
71
|
-
Chef::Search::Query.stub
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should use nested attributes (KNIFE-276)" do
|
75
|
-
@knife.config[:attribute] = "ec2.public_hostname"
|
76
|
-
@knife.stub
|
77
|
-
@knife.configure_session
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan <btm@opscode.com>
|
3
|
+
# Copyright:: Copyright (c) 2013 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 'spec_helper'
|
20
|
+
|
21
|
+
Chef::Knife::Winrm.load_deps
|
22
|
+
|
23
|
+
describe Chef::Knife::Winrm do
|
24
|
+
before(:all) do
|
25
|
+
@original_config = Chef::Config.hash_dup
|
26
|
+
@original_knife_config = Chef::Config[:knife].dup
|
27
|
+
end
|
28
|
+
|
29
|
+
after(:all) do
|
30
|
+
Chef::Config.configuration = @original_config
|
31
|
+
Chef::Config[:knife] = @original_knife_config
|
32
|
+
end
|
33
|
+
|
34
|
+
before do
|
35
|
+
@knife = Chef::Knife::Winrm.new
|
36
|
+
@knife.config[:attribute] = "fqdn"
|
37
|
+
@node_foo = Chef::Node.new
|
38
|
+
@node_foo.automatic_attrs[:fqdn] = "foo.example.org"
|
39
|
+
@node_foo.automatic_attrs[:ipaddress] = "10.0.0.1"
|
40
|
+
@node_bar = Chef::Node.new
|
41
|
+
@node_bar.automatic_attrs[:fqdn] = "bar.example.org"
|
42
|
+
@node_bar.automatic_attrs[:ipaddress] = "10.0.0.2"
|
43
|
+
@node_bar.automatic_attrs[:ec2][:public_hostname] = "somewhere.com"
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#configure_session" do
|
47
|
+
before do
|
48
|
+
@query = double("Chef::Search::Query")
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when there are some hosts found but they do not have an attribute to connect with" do
|
52
|
+
before do
|
53
|
+
@knife.config[:manual] = false
|
54
|
+
@query.stub(:search).and_return([[@node_foo, @node_bar]])
|
55
|
+
@node_foo.automatic_attrs[:fqdn] = nil
|
56
|
+
@node_bar.automatic_attrs[:fqdn] = nil
|
57
|
+
Chef::Search::Query.stub(:new).and_return(@query)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should raise a specific error (KNIFE-222)" do
|
61
|
+
@knife.ui.should_receive(:fatal).with(/does not have the required attribute/)
|
62
|
+
@knife.should_receive(:exit).with(10)
|
63
|
+
@knife.configure_session
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when there are nested attributes" do
|
68
|
+
before do
|
69
|
+
@knife.config[:manual] = false
|
70
|
+
@query.stub(:search).and_return([[@node_foo, @node_bar]])
|
71
|
+
Chef::Search::Query.stub(:new).and_return(@query)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should use nested attributes (KNIFE-276)" do
|
75
|
+
@knife.config[:attribute] = "ec2.public_hostname"
|
76
|
+
@knife.stub(:session_from_list)
|
77
|
+
@knife.configure_session
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|