Module: Wakame::Rule::BasicActionSet
- Defined in:
- lib/wakame/rule.rb
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
-
#arrange_agent(svc_prop) ⇒ Object
Arrange an agent for the paticular service instance from agent pool.
- #start_instance(image_id, attr = {}) ⇒ Object
- #test_agent_candidate(svc_prop, agent) ⇒ Object
- #wait_lock ⇒ Object
Class Method Details
.deploy_configuration(service_instance) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/wakame/rule.rb', line 72 def self.deploy_configuration(service_instance) Wakame.log.debug("Begin: #{self}.deploy_configuration(#{service_instance.property.class})") begin tmpl = Wakame::Template.new(service_instance) tmpl.render_config agent = service_instance.agent src_path = tmpl.tmp_basedir.dup src_path.sub!('/$', '') if File.directory? src_path dest_path = File.("tmp/config/" + File.basename(tmpl.basedir), service_instance.agent.root_path) Util.exec("rsync -e 'ssh -i #{Wakame.config.ssh_private_key} -o \"UserKnownHostsFile #{Wakame.config.ssh_known_hosts}\"' -au #{src_path}/ root@#{agent.agent_ip}:#{dest_path}") #Util.exec("rsync -au #{src_path}/ #{dest_path}") ensure tmpl.cleanup if tmpl end Wakame.log.debug("End: #{self}.deploy_configuration(#{service_instance.property.class})") end |
Instance Method Details
#arrange_agent(svc_prop) ⇒ Object
Arrange an agent for the paticular service instance from agent pool.
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/wakame/rule.rb', line 99 def arrange_agent(svc_prop) agent = nil agent_monitor.each_online { |ag| if test_agent_candidate(svc_prop, ag) agent = ag break end } agent = agent[1] if agent agent end |
#start_instance(image_id, attr = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/wakame/rule.rb', line 50 def start_instance(image_id, attr={}) Wakame.log.debug("#{self.class} called start_instance(#{image_id})") attr[:user_data] = "node=agent\namqp_server=amqp://#{master.attr[:local_ipv4]}/" Wakame.log.debug("user_data: #{attr[:user_data]}") vm_manipulator = VmManipulator.create res = vm_manipulator.start_instance(image_id, attr) inst_id = res[:instance_id] wait_condition { | cond | cond.wait_event(Event::AgentMonitored) { |event| event.agent.attr[:instance_id] == inst_id } cond.poll(5, 100) { vm_manipulator.check_status(inst_id, :online) } } inst_id end |
#test_agent_candidate(svc_prop, agent) ⇒ Object
94 95 96 97 |
# File 'lib/wakame/rule.rb', line 94 def test_agent_candidate(svc_prop, agent) return false if agent.has_service_type?(svc_prop.class) svc_prop.vm_spec.current.satisfy?(agent) end |