Class: Naginata::CLI::RemoteAbstract
- Inherits:
-
Object
- Object
- Naginata::CLI::RemoteAbstract
show all
- Defined in:
- lib/naginata/cli/remote_abstract.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of RemoteAbstract.
7
8
9
|
# File 'lib/naginata/cli/remote_abstract.rb', line 7
def initialize(options = {})
@options = options
end
|
Instance Method Details
47
48
49
50
51
52
53
|
# File 'lib/naginata/cli/remote_abstract.rb', line 47
def configure_backend
if @options[:dry_run]
require 'sshkit/backends/printer'
::Naginata::Configuration.env.set(:sshkit_backend, SSHKit::Backend::Printer)
end
::Naginata::Configuration.env.configure_backend
end
|
#execute ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/naginata/cli/remote_abstract.rb', line 11
def execute
set_custom_naginatafile
load_configuration
set_log_level
set_nagios_filter
configure_backend
load_remote_objects
run
end
|
#load_configuration ⇒ Object
#load_remote_objects ⇒ Object
55
56
57
|
# File 'lib/naginata/cli/remote_abstract.rb', line 55
def load_remote_objects
Loader.load_remote_objects(@options)
end
|
#run ⇒ Object
59
60
61
|
# File 'lib/naginata/cli/remote_abstract.rb', line 59
def run
raise NotImplementedError, 'Called abstract method'
end
|
#set_custom_naginatafile ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/naginata/cli/remote_abstract.rb', line 21
def set_custom_naginatafile
if custom_path = @options[:naginatafile] || ENV['NAGINATAFILE']
custom_path = File.expand_path(custom_path)
raise NaginatafileNotFound, "Could not locate Naginatafile" unless File.file?(custom_path)
::Naginata::Configuration.env.set(:naginatafile, custom_path)
end
end
|
#set_log_level ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/naginata/cli/remote_abstract.rb', line 29
def set_log_level
if @options[:debug]
::Naginata::Configuration.env.set(:log_level, :debug)
elsif @options[:verbose]
::Naginata::Configuration.env.set(:log_level, :info)
end
end
|
#set_nagios_filter ⇒ Object
37
38
39
40
41
|
# File 'lib/naginata/cli/remote_abstract.rb', line 37
def set_nagios_filter
if @options[:nagios]
::Naginata::Configuration.env.add_filter(:nagios_server, @options[:nagios])
end
end
|