Class: RsMule::RunExecutable
- Inherits:
-
Object
- Object
- RsMule::RunExecutable
- Defined in:
- lib/rs-mule/run_executable.rb
Instance Attribute Summary collapse
-
#right_api_client ⇒ Object
Returns the value of attribute right_api_client.
Instance Method Summary collapse
-
#initialize(right_api_client) ⇒ RunExecutable
constructor
Initializes a new RunExecutable.
-
#run_executable(tags, executable, options = {}) ⇒ Object
Runs a RightScript or Chef Recipe on all instances which have all of the specified tags.
Constructor Details
#initialize(right_api_client) ⇒ RunExecutable
Initializes a new RunExecutable
29 30 31 |
# File 'lib/rs-mule/run_executable.rb', line 29 def initialize(right_api_client) @right_api_client = right_api_client end |
Instance Attribute Details
#right_api_client ⇒ Object
Returns the value of attribute right_api_client.
23 24 25 |
# File 'lib/rs-mule/run_executable.rb', line 23 def right_api_client @right_api_client end |
Instance Method Details
#run_executable(tags, executable, options = {}) ⇒ Object
Runs a RightScript or Chef Recipe on all instances which have all of the specified tags.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/rs-mule/run_executable.rb', line 61 def run_executable(, executable, ={}) = { :executable_type => "auto", :right_script_revision => "latest", :tag_match_strategy => "all", :inputs => {}, :update_inputs => [] }.merge() execute_params = {} = [] unless .is_a?(Array) [:update_inputs] = [[:update_inputs]] unless [:update_inputs].is_a?(Array) case [:executable_type] when "right_script_href" execute_params[:right_script_href] = executable when "right_script_name" scripts = find_right_script_lineage_by_name(executable) execute_params[:right_script_href] = right_script_revision_from_lineage(scripts, [:right_script_revision]).href when "recipe_name" execute_params[:recipe_name] = executable when "auto" is_recipe = executable =~ /.*::.*/ is_href = executable =~ /^\/api\/right_scripts\/[a-zA-Z0-9]*/ if is_recipe execute_params[:recipe_name] = executable else if is_href execute_params[:right_script_href] = executable else scripts = find_right_script_lineage_by_name(executable) execute_params[:right_script_href] = right_script_revision_from_lineage(scripts, [:right_script_revision]).href end end else raise ArgumentError.new("Unknown executable_type (#{options[:executable_type]})") end if [:inputs].length > 0 execute_params[:inputs] = [:inputs] end resources_by_tag = @right_api_client..by_tag( :resource_type => "instances", :tags => , :match_all => [:tag_match_strategy] == "all" ? "true" : "false" ) resources_by_tag.each do |res| instance = @right_api_client.resource(res.links.first["href"]) instance.run_executable(execute_params) [:update_inputs].each do |update_type| update_inputs(instance, [:inputs], update_type) end end end |