Skip to content

Commit

Permalink
neutron-l3-ha-service: fixed hound issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AbelNavarro committed Oct 4, 2017
1 parent 7e35fcb commit 2b32cb4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions chef/cookbooks/neutron/files/default/neutron-l3-ha-service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.log
@logger
end

def self.set_file(file_path)
def self.file=(file_path)
@logger = Logger.new(file_path, "daily") unless file_path.nil?
end
end
Expand All @@ -39,7 +39,7 @@ def main
service_options = ServiceOptions.load ARGV[0]
ha_functions = HAFunctions.new(service_options)
error_counter = ErrorCounter.new service_options.max_errors_tolerated
HAToolLog.set_file(service_options.log_file)
HAToolLog.file = service_options.log_file

while true
status = ha_functions.check_l3_agents
Expand Down Expand Up @@ -242,25 +242,25 @@ class ServiceOptions
attr_reader :max_errors_tolerated
attr_reader :log_file

def initialize(status_timeout, router_migration_timeout, hatool_options, sleep_time, max_errors_tolerated, log_file)
@status_timeout = status_timeout
@router_migration_timeout = router_migration_timeout
@hatool = hatool_options
@seconds_to_sleep_between_checks = sleep_time
@max_errors_tolerated = max_errors_tolerated
@log_file = log_file
def initialize(params = {})
@status_timeout = params.fetch(:status_timeout)
@router_migration_timeout = params.fetch(:router_migration_timeout)
@hatool = params.fetch(:hatool_options)
@seconds_to_sleep_between_checks = params.fetch(:sleep_time)
@max_errors_tolerated = params.fetch(:max_errors_tolerated)
@log_file = params.fetch(:log_file)
end

def self.load(path)
File.open path do |file|
data = YAML.load file.read
ServiceOptions.new(
TimeoutOptions.from_hash(data["timeouts"]["status"]),
TimeoutOptions.from_hash(data["timeouts"]["router_migration"]),
HAToolOptions.from_hash(data["hatool"]),
data["seconds_to_sleep_between_checks"].to_i,
data["max_errors_tolerated"].to_i,
data["log_file"]
status_timeout: TimeoutOptions.from_hash(data["timeouts"]["status"]),
router_migration_timeout: TimeoutOptions.from_hash(data["timeouts"]["router_migration"]),
hatool_options: HAToolOptions.from_hash(data["hatool"]),
sleep_time: data["seconds_to_sleep_between_checks"].to_i,
max_errors_tolerated: data["max_errors_tolerated"].to_i,
log_file: data["log_file"]
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/neutron_l3_ha_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def sleep_workaround_for_subprocess
end
end

def make_config(tmpdir, log_file=nil)
def make_config(tmpdir, log_file = nil)
config = {
"timeouts" => {
"status" => {
Expand All @@ -546,7 +546,7 @@ def make_config(tmpdir, log_file=nil)
"max_errors_tolerated" => "10"
}

config.update({"log_file" => log_file}) unless log_file.nil?
config.update("log_file" => log_file) unless log_file.nil?

tmpdir.write_file "settings.yml", config.to_yaml
end
Expand Down

0 comments on commit 2b32cb4

Please sign in to comment.