Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load config file from OXIDIZED_HOME env var location. #2479

Merged
5 commits merged into from
Mar 8, 2022
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
2 changes: 1 addition & 1 deletion lib/oxidized/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Config
Sleep = 1

def self.load(cmd_opts = {})
asetus = Asetus.new(name: 'oxidized', load: false, key_to_s: true)
asetus = Asetus.new(name: 'oxidized', load: false, key_to_s: true, usrdir: Oxidized::Config::Root)
Oxidized.asetus = asetus

asetus.default.username = 'username'
Expand Down
31 changes: 16 additions & 15 deletions lib/oxidized/input/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,13 @@ def make_ssh_opts
ssh_opts[:auth_methods] = auth_methods
Oxidized.logger.debug "AUTH METHODS::#{auth_methods}"

proxy_host = vars(:ssh_proxy)
if ( defined?(proxy_host) && !proxy_host.nil? && !proxy_host.empty? )
proxy_command = "ssh "
proxy_command += "-o StrictHostKeyChecking=no " unless secure
if (proxy_port = vars(:ssh_proxy_port))
proxy_command += "-p #{proxy_port} "
end
proxy_command += "#{proxy_host} -W [%h]:%p"
proxy = Net::SSH::Proxy::Command.new(proxy_command)
ssh_opts[:proxy] = proxy
end
ssh_opts[:proxy] = make_ssh_proxy_command(vars(:ssh_proxy), vars(:ssh_proxy_port), secure) if vars(:ssh_proxy)

ssh_opts[:keys] = [vars(:ssh_keys)].flatten if vars(:ssh_keys)
ssh_opts[:kex] = vars(:ssh_kex).split(/,\s*/) if vars(:ssh_kex)
ssh_opts[:keys] = [vars(:ssh_keys)].flatten if vars(:ssh_keys)
ssh_opts[:kex] = vars(:ssh_kex).split(/,\s*/) if vars(:ssh_kex)
ssh_opts[:encryption] = vars(:ssh_encryption).split(/,\s*/) if vars(:ssh_encryption)
ssh_opts[:host_key] = vars(:ssh_host_key).split(/,\s*/) if vars(:ssh_host_key)
ssh_opts[:hmac] = vars(:ssh_hmac).split(/,\s*/) if vars(:ssh_hmac)
ssh_opts[:host_key] = vars(:ssh_host_key).split(/,\s*/) if vars(:ssh_host_key)
ssh_opts[:hmac] = vars(:ssh_hmac).split(/,\s*/) if vars(:ssh_hmac)

if Oxidized.config.input.debug?
ssh_opts[:logger] = Oxidized.logger
Expand All @@ -159,5 +149,16 @@ def make_ssh_opts

ssh_opts
end

def make_ssh_proxy_command(proxy_host, proxy_port, secure)
return nil unless !proxy_host.nil? && !proxy_host.empty?

proxy_command = "ssh "
proxy_command += "-o StrictHostKeyChecking=no " unless secure
proxy_command += "-p #{proxy_port} " if proxy_port
proxy_command += "#{proxy_host} -W [%h]:%p"
proxy = Net::SSH::Proxy::Command.new(proxy_command)
proxy
end
end
end
2 changes: 1 addition & 1 deletion lib/oxidized/model/enterasys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Enterasys < Oxidized::Model

prompt /^.+\w\((su|rw)\)->\s?$/

comment '!'
comment '!'

# Handle paging
expect /^--More--.*$/ do |data, re|
Expand Down
2 changes: 1 addition & 1 deletion lib/oxidized/model/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def xmlcomment(str)
# with '- '
data = ''
str.each_line do |line|
data << '<!-- ' << str.gsub(/-(?=-)/, '- ').chomp << " -->\n"
data << '<!-- ' << line.gsub(/-(?=-)/, '- ').chomp << " -->\n"
end
data
end
Expand Down