Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def execution_interface
get_interface_by_flag(:execution)
end

def remote_execution_proxies(provider)
def remote_execution_proxies(provider, authorized = true)
proxies = {}
proxies[:subnet] = execution_interface.subnet.remote_execution_proxies.with_features(provider) if execution_interface && execution_interface.subnet
proxies[:fallback] = smart_proxies.with_features(provider) if Setting[:remote_execution_fallback_proxy]
Expand All @@ -50,14 +50,15 @@ def remote_execution_proxies(provider)
proxy_scope = ::SmartProxy
end

proxies[:global] = proxy_scope.authorized.with_features(provider)
proxy_scope = proxy_scope.authorized if authorized
proxies[:global] = proxy_scope.with_features(provider)
end

proxies
end

def remote_execution_ssh_keys
remote_execution_proxies('SSH').values.flatten.uniq.map { |proxy| proxy.pubkey }.compact.uniq
remote_execution_proxies('SSH', false).values.flatten.uniq.map { |proxy| proxy.pubkey }.compact.uniq
end

def drop_execution_interface_cache
Expand Down
11 changes: 11 additions & 0 deletions test/unit/concerns/host_extensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
it 'has ssh keys in the parameters' do
host.remote_execution_ssh_keys.must_include sshkey
end

it 'has ssh keys in the parameters even when no user specified' do
# this is a case, when using the helper in provisioning templates
FactoryGirl.create(:smart_proxy, :ssh) do |proxy|
proxy.organizations << host.organization
proxy.locations << host.location
end
host.interfaces.first.subnet.remote_execution_proxies.clear
User.current = nil
host.remote_execution_ssh_keys.must_include sshkey
end
end

context 'host has multiple nics' do
Expand Down