Class: Bcome::Orchestrator::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/orchestrator/loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(machines) ⇒ Loader

Returns a new instance of Loader.



4
5
6
7
8
9
10
# File 'lib/orchestrator/loader.rb', line 4

def initialize(machines)
  config_path = "#{Dir.pwd}/bcome/config/orchestration"
  @recipes_path = "#{config_path}/command_recipes.yml"
  @machine_targets_path = "#{config_path}/node_target_selectors.yml"
  @direct_commands_path = "#{config_path}/direct_command_sets.yml"
  @machines = machines
end

Instance Method Details

#direct_commandsObject



20
21
22
# File 'lib/orchestrator/loader.rb', line 20

def direct_commands
  @direct_commands ||= ::Bcome::Orchestrator::Factory.create_direct_commands_from_json(do_load_direct_commands)
end

#do_load_direct_commandsObject



28
29
30
# File 'lib/orchestrator/loader.rb', line 28

def do_load_direct_commands
  return json_from_file(@direct_commands_path)
end

#do_load_machine_targetsObject



32
33
34
# File 'lib/orchestrator/loader.rb', line 32

def do_load_machine_targets
  return json_from_file(@machine_targets_path)
end

#do_load_recipesObject



24
25
26
# File 'lib/orchestrator/loader.rb', line 24

def do_load_recipes
  return json_from_file(@recipes_path)
end

#json_from_file(file_path) ⇒ Object



36
37
38
39
40
# File 'lib/orchestrator/loader.rb', line 36

def json_from_file(file_path)
  raise "Cannot load file #{file_path}" unless File.exist?(file_path)
  file_contents = File.read(file_path)
  return  YAML.load(file_contents)
end

#node_targetsObject



16
17
18
# File 'lib/orchestrator/loader.rb', line 16

def node_targets
  @node_targets ||= ::Bcome::Orchestrator::Factory.create_node_targets_from_json(do_load_machine_targets, @machines)
end

#recipesObject



12
13
14
# File 'lib/orchestrator/loader.rb', line 12

def recipes
  @recipes ||= ::Bcome::Orchestrator::Factory.create_recipes_from_json(do_load_recipes, node_targets, @machines, direct_commands)
end