Class: Mt::Wall::Transport::Rsc
- Defined in:
- lib/mt/wall/transport/rsc.rb
Overview
Offline transport: renders a Plan into a RouterOS script (.rsc) instead of touching a live device. Useful for GitOps review (the rendered script is a diffable artifact) and for environments where deployment is a separate, manually approved step.
Because there is no device to read from, #fetch returns an empty current state, so a Plan against this transport is always a full render of the desired configuration. The commit-confirm hooks (arm/confirm) are no-ops: there is no live link to protect, and a nil handle signals the Reconciler to skip the health-check/confirm cycle.
Constant Summary collapse
- INTERNAL_KEYS =
Keys that are internal to the diff machinery and must never be rendered as RouterOS command arguments.
[Plan::ID_KEY].freeze
- ROS_BOOLEAN =
Boolean DIFF values are carried as the REST-style strings “true”/“false” (so desired matches the device readback). RouterOS SCRIPT syntax, however, uses the yes/no idiom — so this is the one place we translate back when WRITING a .rsc command. Applied only to exact whole-value matches (e.g. ‘disabled=true` -> `disabled=yes`); non-boolean values are untouched.
{ "true" => "yes", "false" => "no" }.freeze
Instance Method Summary collapse
-
#apply(operations) ⇒ void
Writes the operations as RouterOS CLI commands to @io.
-
#arm_auto_revert(_snapshot, timeout:) ⇒ nil
Offline render has no device to protect: no auto-revert is armed.
-
#confirm(_handle) ⇒ void
No-op: nothing was armed.
-
#fetch(_paths, managed_list_names: []) ⇒ DesiredState
No live device: current state is empty.
-
#initialize(io: $stdout) ⇒ Rsc
constructor
A new instance of Rsc.
Constructor Details
#initialize(io: $stdout) ⇒ Rsc
Returns a new instance of Rsc.
29 30 31 32 |
# File 'lib/mt/wall/transport/rsc.rb', line 29 def initialize(io: $stdout) super() @io = io end |
Instance Method Details
#apply(operations) ⇒ void
This method returns an undefined value.
Writes the operations as RouterOS CLI commands to @io. The Plan is already sorted per the apply-order invariants, so the rendered script is safe to run top-to-bottom.
45 46 47 48 49 |
# File 'lib/mt/wall/transport/rsc.rb', line 45 def apply(operations) @io.puts("# Generated by mt-wall — RouterOS script (.rsc)") operations.each { |operation| @io.puts(render(operation)) } nil end |
#arm_auto_revert(_snapshot, timeout:) ⇒ nil
Offline render has no device to protect: no auto-revert is armed. A nil handle tells the Reconciler to skip health-check/confirm.
54 55 56 |
# File 'lib/mt/wall/transport/rsc.rb', line 54 def arm_auto_revert(_snapshot, timeout:) nil end |
#confirm(_handle) ⇒ void
This method returns an undefined value.
No-op: nothing was armed.
60 |
# File 'lib/mt/wall/transport/rsc.rb', line 60 def confirm(_handle); end |
#fetch(_paths, managed_list_names: []) ⇒ DesiredState
No live device: current state is empty.
36 37 38 |
# File 'lib/mt/wall/transport/rsc.rb', line 36 def fetch(_paths, managed_list_names: []) DesiredState.new end |