Class: Syskit::Models::ConfiguredDeployment
- Defined in:
- lib/syskit/models/configured_deployment.rb
Overview
Representation of a deployment that is configured with name mappings and spawn options
Instance Attribute Summary collapse
-
#model ⇒ Model<Syskit::Deployment>
readonly
The deployment model.
-
#name_mappings ⇒ Hash
readonly
The name mappings, e.g.
-
#process_name ⇒ String
readonly
The process name.
-
#process_server_name ⇒ String
readonly
The name of the process server this deployment should run on.
-
#spawn_options ⇒ Hash
readonly
The options that should be passed at deployment startup.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#command_line(loader: Roby.app.default_pkgconfig_loader, **options) ⇒ Object
Returns the command line information needed to start this deployment on the same machine than Syskit.
-
#each_deployed_task_model {|name, the| ... } ⇒ Object
Enumerate the tasks that are deployed by this configured deployment.
-
#each_orogen_deployed_task_context_model {|| ... } ⇒ Object
Enumerate the oroGen specification for the deployed tasks.
- #eql?(other) ⇒ Boolean
-
#filter_command_line_options(oro_logfile: nil, wait: nil, output: nil, **command_line_options) ⇒ Object
private
Filters out options that are part of the spawn options but not of the command-line generation options.
- #hash ⇒ Object
-
#initialize(process_server_name, model, name_mappings = Hash.new, process_name = model.name, spawn_options = Hash.new) ⇒ ConfiguredDeployment
constructor
A new instance of ConfiguredDeployment.
-
#new(options = Hash.new) ⇒ Syskit::Deployment
Create a new deployment task that can represent self in a plan.
-
#orogen_model ⇒ OroGen::Spec::Deployment
The oroGen model object that represents this configured deployment.
- #pretty_print(pp) ⇒ Object
Constructor Details
#initialize(process_server_name, model, name_mappings = Hash.new, process_name = model.name, spawn_options = Hash.new) ⇒ ConfiguredDeployment
Returns a new instance of ConfiguredDeployment
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/syskit/models/configured_deployment.rb', line 20 def initialize(process_server_name, model, name_mappings = Hash.new, process_name = model.name, = Hash.new) default_mappings = model.each_deployed_task_model. each_with_object(Hash.new) do |(deployed_task_name, _), result| result[deployed_task_name] = deployed_task_name end @process_server_name = process_server_name @model = model @name_mappings = default_mappings.merge(name_mappings) @process_name = process_name @spawn_options = end |
Instance Attribute Details
#model ⇒ Model<Syskit::Deployment> (readonly)
Returns the deployment model
12 13 14 |
# File 'lib/syskit/models/configured_deployment.rb', line 12 def model @model end |
#name_mappings ⇒ Hash (readonly)
Returns the name mappings, e.g. the mapping from a task name in #model to the name this task should have while running
18 19 20 |
# File 'lib/syskit/models/configured_deployment.rb', line 18 def name_mappings @name_mappings end |
#process_name ⇒ String (readonly)
Returns the process name
10 11 12 |
# File 'lib/syskit/models/configured_deployment.rb', line 10 def process_name @process_name end |
#process_server_name ⇒ String (readonly)
Returns the name of the process server this deployment should run on
8 9 10 |
# File 'lib/syskit/models/configured_deployment.rb', line 8 def process_server_name @process_server_name end |
#spawn_options ⇒ Hash (readonly)
Returns the options that should be passed at deployment startup
15 16 17 |
# File 'lib/syskit/models/configured_deployment.rb', line 15 def @spawn_options end |
Instance Method Details
#==(other) ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/syskit/models/configured_deployment.rb', line 114 def ==(other) return if !other.kind_of?(ConfiguredDeployment) return process_server_name == other.process_server_name && process_name == other.process_name && model == other.model && == other. && name_mappings == other.name_mappings end |
#command_line(loader: Roby.app.default_pkgconfig_loader, **options) ⇒ Object
Returns the command line information needed to start this deployment on the same machine than Syskit
45 46 47 48 49 |
# File 'lib/syskit/models/configured_deployment.rb', line 45 def command_line(loader: Roby.app.default_pkgconfig_loader, **) model.command_line(process_name, name_mappings, loader: loader, **()) end |
#each_deployed_task_model {|name, the| ... } ⇒ Object
Enumerate the tasks that are deployed by this configured deployment
Unlike #each_orogen_deployed_task_context_model, it enumerates the Syskit task context model
79 80 81 82 83 84 |
# File 'lib/syskit/models/configured_deployment.rb', line 79 def each_deployed_task_model return enum_for(__method__) if !block_given? model.each_deployed_task_model do |name, model| yield(name_mappings[name], model) end end |
#each_orogen_deployed_task_context_model {|| ... } ⇒ Object
Enumerate the oroGen specification for the deployed tasks
89 90 91 92 93 94 95 96 |
# File 'lib/syskit/models/configured_deployment.rb', line 89 def each_orogen_deployed_task_context_model return enum_for(__method__) if !block_given? model.each_orogen_deployed_task_context_model do |deployed_task| task = deployed_task.dup task.name = name_mappings[task.name] || task.name yield(task) end end |
#eql?(other) ⇒ Boolean
127 |
# File 'lib/syskit/models/configured_deployment.rb', line 127 def eql?(other); self == other end |
#filter_command_line_options(oro_logfile: nil, wait: nil, output: nil, **command_line_options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters out options that are part of the spawn options but not of the command-line generation options
37 38 39 40 |
# File 'lib/syskit/models/configured_deployment.rb', line 37 def (oro_logfile: nil, wait: nil, output: nil, **) return end |
#hash ⇒ Object
123 124 125 |
# File 'lib/syskit/models/configured_deployment.rb', line 123 def hash [process_name, model].hash end |
#new(options = Hash.new) ⇒ Syskit::Deployment
Create a new deployment task that can represent self in a plan
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/syskit/models/configured_deployment.rb', line 102 def new( = Hash.new) = .merge( process_name: process_name, name_mappings: name_mappings, spawn_options: , on: process_server_name) .delete(:working_directory) .delete(:output) .delete(:wait) model.new() end |
#orogen_model ⇒ OroGen::Spec::Deployment
The oroGen model object that represents this configured deployment
It differs from model.orogen_model in that the #name_mappings are applied
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/syskit/models/configured_deployment.rb', line 57 def orogen_model if @orogen_model return @orogen_model end @orogen_model = model.orogen_model.dup orogen_model.task_activities.map! do |activity| activity = activity.dup activity.name = name_mappings[activity.name] || activity.name activity end @orogen_model end |
#pretty_print(pp) ⇒ Object
129 130 131 132 133 134 135 136 137 |
# File 'lib/syskit/models/configured_deployment.rb', line 129 def pretty_print(pp) pp.text "deployment #{model.orogen_model.name} with the following tasks" pp.nest(2) do each_orogen_deployed_task_context_model do |task| pp.breakable task.pretty_print(pp) end end end |