Exception: Syskit::MissingDeployments

Inherits:
SpecError show all
Defined in:
lib/syskit/exceptions.rb

Overview

Exception raised at the end of #resolve if some tasks do not have a deployed equivalent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tasks_with_candidates) ⇒ MissingDeployments

Initializes this exception by providing a mapping from tasks that have no deployments to the deployment candidates

Parameters:



497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/syskit/exceptions.rb', line 497

def initialize(tasks_with_candidates)
    @tasks = Hash.new
    tasks_with_candidates.each do |task, candidates|
        parents = task.dependency_context
        candidates = candidates.map do |process_server_name, deployment, task_name, existing|
            existing ||= Array.new
            existing = existing.map do |task|
                [task, task.dependency_context]
            end
            [process_server_name, deployment, task_name, existing]
        end

        @tasks[task] = [parents, candidates, task.deployment_hints]
    end
end

Instance Attribute Details

#tasksObject (readonly)

The tasks that are not deployed, as a hash from the actual task to a set of [role_set, parent_task] pairs

This is computed in #initialize as the dependency structure will probably change afterwards



491
492
493
# File 'lib/syskit/exceptions.rb', line 491

def tasks
  @tasks
end

Instance Method Details

#pretty_print(pp) ⇒ Object



513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/syskit/exceptions.rb', line 513

def pretty_print(pp)
    pp.text "cannot deploy the following tasks"
    tasks.each do |task, (parents, possible_deployments)|
        pp.breakable
        pp.text "#{task} (#{task.orogen_model.name})"
        pp.nest(2) do
            pp.breakable
            pp.seplist(parents) do |parent_task|
                role, parent_task = parent_task
                pp.text "child #{role} of #{parent_task}"
            end
        end
    end

    tasks.each do |task, (_parents, possible_deployments, deployment_hints)|
        has_free_deployment = possible_deployments.any? { |_, _, existing| existing.empty? }
        pp.breakable
        if has_free_deployment
            pp.text "#{task}: multiple possible deployments, choose one with #prefer_deployed_tasks(deployed_task_name)"
            if !deployment_hints.empty?
                deployment_hints.each do |hint|
                    pp.text "  current hints: #{deployment_hints.map(&:to_s).join(", ")}"
                end
            end
        elsif possible_deployments.empty?
            pp.text "#{task}: no deployments available"
        else
            pp.text "#{task}: some deployments exist, but they are already used in this network"
        end

        pp.nest(2) do
            possible_deployments.each do |configured_deployment, task_name, existing|
                pp.breakable
                pp.text "task #{task_name} from deployment #{configured_deployment.orogen_model.name} defined in #{configured_deployment.orogen_model.project.name} on #{configured_deployment.process_server_name}"
                pp.nest(2) do
                    existing.each do |task, parents|
                        pp.breakable
                        msg = parents.map do |parent_task|
                            role, parent_task = *parent_task
                            "child #{role} of #{parent_task}"
                        end
                        pp.text "already used by #{task}: #{msg.join(", ")}"
                    end
                end
            end
        end
    end
end