class DTK::Client::Operation::Module::Install::DependentModules::ComponentDependencyTree
Constants
- BaseRoute
Attributes
cache[R]
module_ref[R]
Public Class Methods
create(module_ref, children_module_refs, print_helper)
click to toggle source
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 40 def self.create(module_ref, children_module_refs, print_helper) new(module_ref, :children_module_refs => children_module_refs, :print_helper => print_helper).recursively_add_children! end
new(module_ref, opts = {})
click to toggle source
opts can have keys:
:children_module_refs :cached :print_helper
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 31 def initialize(module_ref, opts = {}) @module_ref = module_ref @cache = opts[:cache] || Cache.new @print_helper = opts[:print_helper] @children = children_from_module_refs(opts[:children_module_refs] || [], @cache) @first_level_added = !opts[:children_module_refs].nil? end
Public Instance Methods
print_helper()
click to toggle source
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 63 def print_helper @print_helper || raise(Error, "Unexepected that @print_helper is nil") end
recursively_add_children!()
click to toggle source
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 44 def recursively_add_children! unless @first_level_added raise Error, "Unexpected that @children is not empty" unless @children.empty? @children = children_from_module_refs(get_children_module_refs, @cache) @first_level_added = true end @children.each { |child| child.recursively_add_children! } self end
resolve_conflicts_and_versions(opts = {})
click to toggle source
resolves conflicts and returns an array of unified module_refs
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 56 def resolve_conflicts_and_versions(opts = {}) # TODO: currently module refs al nailed as opposed to version contraints; when there are # version contraints; this methdo will take care of them ResolveModules.resolve_conflicts(self, opts) end
Private Instance Methods
children_from_module_refs(module_refs, cache)
click to toggle source
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 69 def children_from_module_refs(module_refs, cache) module_refs.map { |module_ref| self.class.new(module_ref, cache: cache) } end
convert_to_module_refs_array(module_dependencies_response)
click to toggle source
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 110 def convert_to_module_refs_array(module_dependencies_response) response = module_dependencies_response #alias ret = [] return ret unless response # processing warning messages, :missing_module_components and :required_modules process_if_warnings(response) if missing_modules = response.data(:missing_module_components) ret += missing_modules.map { |ref_hash| create_module_ref(ref_hash, :module_installed => false) } end if required_modules = response.data(:required_modules) ret += required_modules.map { |ref_hash| create_module_ref(ref_hash, :module_installed => true) } end ret end
create_module_ref(ref_hash, opts = {})
click to toggle source
opts can have keys:
:module_installed
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 139 def create_module_ref(ref_hash, opts = {}) module_ref_hash = { :namespace => ref_hash['namespace'], :module_name => ref_hash['name'], :version => ref_hash['version'] } module_ref_hash.merge!(:module_installed => opts[:module_installed]) if opts.has_key?(:module_installed) Install::ModuleRef.new(module_ref_hash) end
get_children_module_refs()
click to toggle source
returns module refs array or raises error
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 74 def get_children_module_refs @cache.lookup_dependencies?(@module_ref) || get_children_module_refs_aux end
get_children_module_refs_aux()
click to toggle source
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 78 def get_children_module_refs_aux response = nil begin hash = { :module_name => module_name, :namespace => namespace, :rsa_pub_key => SSHUtil.rsa_pub_key_content, :version? => version } response = rest_get "#{BaseRoute}/module_dependencies", QueryStringHash.new(hash) rescue Error::ServerNotOkResponse => e # temp fix for issue when dependent module is imported from puppet forge if errors = e.response && e.response['errors'] response = nil if errors.first.include?('not found') else raise e end end dependencies = convert_to_module_refs_array(response) # to avoid cases where dependency can have itself as dependency (stack level too deep) we remove it from dependencies # think we will not need this when we have unified module (instead of component and service modules) if @module_ref.is_base_module? matching = dependencies.find{ |dep| (dep.module_name == module_name) && (dep.namespace == namespace) && (dep.version == version) } dependencies.delete(matching) end @cache.add!(@module_ref, dependencies) dependencies end
process_if_warnings(module_dependencies_response)
click to toggle source
# File lib/client/operation/module/install/dependent_modules/component_dependency_tree.rb, line 129 def process_if_warnings(module_dependencies_response) are_there_warnings = RemoteDependency.check_permission_warnings(module_dependencies_response) are_there_warnings ||= RemoteDependency.print_dependency_warnings(module_dependencies_response, nil, :ignore_permission_warnings => true) if are_there_warnings raise Install::TerminateInstall unless Console.prompt_yes_no("Do you still want to proceed with install?", :add_options => true) end end