fuel-astute/lib/astute.rb
Vladimir Sharshov (warpc) bca595a964 New version of puppet task engine
Changes:

- remove report from task engine;
- remove old logic for hangs and 'idling' statuses;
- increase code redability;
- add code docs;
- support retries in case of MClient errors for status
  and run actions;
- replace timeout raise on usual code;
- descrease waiting time for puppet run (from 120 to 10) and
  time between try (from 30 to 2);
- mcollective retry descrease from 5 to 1. Now it will use
  puppet retries if failed during network/mcollective problem
  after 1 try.

Closes-Bug: #1613396
Change-Id: I98fe3df65ef335b03eceb2c401eba12cf68ee1c8
2016-10-17 13:08:30 +03:00

121 lines
3.5 KiB
Ruby

# Copyright 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
require 'astute/ruby_removed_functions'
require 'json'
require 'yaml'
require 'logger'
require 'shellwords'
require 'active_support/all'
require 'pp'
require 'bunny'
require 'zlib'
require 'astute/ext/array'
require 'astute/ext/exception'
require 'astute/ext/deep_copy'
require 'astute/ext/hash'
require 'astute/exceptions'
require 'astute/config'
require 'astute/logparser'
require 'astute/orchestrator'
require 'astute/deployment_engine'
require 'astute/network'
require 'astute/puppetd'
require 'astute/provision'
require 'astute/deployment_engine/granular_deployment'
require 'astute/cobbler'
require 'astute/cobbler_manager'
require 'astute/image_provision'
require 'astute/dump'
require 'astute/deploy_actions'
require 'astute/nailgun_hooks'
require 'astute/puppet_task'
require 'astute/puppet_job'
require 'astute/task_manager'
require 'astute/pre_delete'
require 'astute/version'
require 'astute/server/async_logger'
require 'astute/reporter'
require 'astute/mclient'
require 'astute/context'
require 'astute/nodes_remover'
require 'astute/task'
require 'astute/task_deployment'
require 'astute/task_node'
require 'astute/task_proxy_reporter'
require 'astute/task_cluster'
require 'astute/common/reboot'
require 'astute/time_observer'
require 'fuel_deployment'
['/astute/pre_deployment_actions/*.rb',
'/astute/pre_deploy_actions/*.rb',
'/astute/pre_node_actions/*.rb',
'/astute/post_deploy_actions/*.rb',
'/astute/post_deployment_actions/*.rb',
'/astute/common_actions/*.rb',
'/astute/tasks/*.rb',
'/astute/mclients/*.rb'
].each do |path|
Dir[File.dirname(__FILE__) + path].each{ |f| require f }
end
# Server
require 'astute/server/worker'
require 'astute/server/server'
require 'astute/server/producer'
require 'astute/server/dispatcher'
require 'astute/server/reporter'
module Astute
# Library
autoload 'Node', 'astute/node'
autoload 'NodesHash', 'astute/node'
autoload 'Rsyslogd', 'astute/rsyslogd'
LogParser.autoload :ParseDeployLogs, 'astute/logparser/deployment'
LogParser.autoload :ParseProvisionLogs, 'astute/logparser/provision'
LogParser.autoload :ParseImageBuildLogs, 'astute/logparser/provision'
LogParser.autoload :Patterns, 'astute/logparser/parser_patterns'
LOG_PATH = '/var/log/astute.log'
def self.logger
unless @logger
@logger = Logger.new(LOG_PATH)
@logger.formatter = proc do |severity, datetime, progname, msg|
severity_map = {
'DEBUG' => 'DEBUG',
'INFO' => 'INFO',
'WARN' => 'WARNING',
'ERROR' => 'ERROR',
'FATAL' => 'CRITICAL'
}
"#{datetime.strftime("%Y-%m-%d %H:%M:%S")} #{severity_map[severity]} [#{Process.pid}] #{msg}\n"
end
end
@logger
end
def self.logger=(logger)
@logger = logger
Deployment::Log.logger = @logger
end
config_file = '/opt/astute/astute.conf'
Astute.config.update(YAML.load(File.read(config_file))) if File.exists?(config_file)
end