modules/mu/deploy.rb in cloud-mu-3.1.6 vs modules/mu/deploy.rb in cloud-mu-3.2.0

- old
+ new

@@ -155,10 +155,11 @@ end } _shortclass, _cfg_name, _cfg_plural, classname = MU::Cloud.getResourceNames(data[:cfg_plural]) @main_config[data[:cfg_plural]].each { |resource| resource["#MU_CLOUDCLASS"] = classname +# resource["#MU_CLOUDCLASS"] = MU::Cloud.resourceClass(resource['cloud'], data[:cfg_plural]) } setThreadDependencies(@main_config[data[:cfg_plural]]) end } end @@ -263,11 +264,11 @@ parent_thread_id = Thread.current.object_id # Run cloud provider-specific deploy meta-artifact creation (ssh keys, # resource groups, etc) @mommacat.cloudsUsed.each { |cloud| - cloudclass = Object.const_get("MU").const_get("Cloud").const_get(cloud) + cloudclass = MU::Cloud.cloudClass(cloud) cloudclass.initDeploy(@mommacat) } # Kick off threads to create each of our new servers. @my_threads << Thread.new { @@ -552,46 +553,45 @@ # siblings will exist for dependency checking before we start). @dependency_threads["#{name}_create"]=["mu_create_container"] @dependency_threads["#{name}_groom"]=["#{name}_create", "mu_groom_container"] MU.log "Setting dependencies for #{name}", MU::DEBUG, details: resource["dependencies"] - if resource["dependencies"] != nil then + if !resource["dependencies"].nil? then resource["dependencies"].each { |dependency| - parent_class = nil - MU::Cloud.resource_types.each_pair { |res_class, attrs| - if attrs[:cfg_name] == dependency['type'] or - attrs[:cfg_plural] == dependency['type'] - parent_class = Object.const_get("MU").const_get("Cloud").const_get(res_class) - break - end - } + parent_class = MU::Cloud.loadBaseType(dependency['type']) parent_type = parent_class.cfg_name # our groom thread will always need to wait on our parent's create parent = parent_type+"_"+dependency["name"]+"_create" addDependentThread(parent, "#{name}_groom") # should our creation thread also wait on our parent's create? - if !resource["no_create_wait"] and + if !dependency["no_create_wait"] and (resource["#MU_CLOUDCLASS"].waits_on_parent_completion or dependency['phase'] == "create" or - (parent_class.deps_wait_on_my_creation and parent_type != res_type)) + parent_class.deps_wait_on_my_creation) addDependentThread(parent, "#{name}_create") end # how about our groom thread waiting on our parents' grooms? if (dependency['phase'] == "groom" or resource["#MU_CLOUDCLASS"].waits_on_parent_completion) and parent_class.instance_methods(false).include?(:groom) parent = parent_type+"_"+dependency["name"]+"_groom" addDependentThread(parent, "#{name}_groom") - if (parent_class.deps_wait_on_my_creation and parent_type != res_type) or resource["#MU_CLOUDCLASS"].waits_on_parent_completion or dependency['phase'] == "groom" + if !dependency["no_create_wait"] and ( + parent_class.deps_wait_on_my_creation or + resource["#MU_CLOUDCLASS"].waits_on_parent_completion or + dependency['phase'] == "groom" + ) addDependentThread(parent, "#{name}_create") end end } end + MU.log "Thread dependencies #{res_type}[#{name}]", MU::DEBUG, details: { "create" => @dependency_threads["#{name}_create"], "groom" => @dependency_threads["#{name}_groom"] } + @dependency_threads["#{name}_groom"]=["#{name}_create", "mu_groom_container"] } end ######################################################################### # Kick off a thread to create a resource. @@ -649,11 +649,12 @@ end begin run_this_method = myservice['#MUOBJECT'].method(mode) rescue StandardError => e MU::MommaCat.unlockAll - @main_thread.raise MuError, "Error invoking #{myservice["#MU_CLOUDCLASS"]}.#{mode} for #{myservice['name']} (#{e.inspect})", e.backtrace - raise e + @main_thread.raise MuError, "Error invoking #{myservice["#MUOBJECT"].class.name}.#{mode} for #{myservice['name']} (#{e.inspect})", e.backtrace + return +# raise e end begin MU.log "Checking whether to run #{myservice['#MUOBJECT']}.#{mode} (updating: #{@updating})", MU::DEBUG if !@updating or mode != "create" myservice = run_this_method.call