73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/construqt/flavour/mikrotik/flavour_mikrotik.rb', line 73
def scheduler_hack(host, iface)
return [] unless iface.interfaces.find{|iface| iface.class.kind_of? self.class }
system_script_schema = {
"name" => Schema.identifier.key.required,
"source" => Schema.source.required
}
host.result.render_mikrotik(system_script_schema, {
"no_auto_disable" => true,
"name" => "disable-#{iface.name}",
"source" => <<SRC
/interface bonding disable [ find name=#{iface.name} ]
/system scheduler enable [ find name=enable-#{iface.name} ]
SRC
}, "system", "script")
or_condition = "(" + iface.interfaces.map{|iface| "name=#{iface.name}"}.join(" or ") + ")"
host.result.render_mikrotik(system_script_schema, {
"no_auto_disable" => true,
"name" => "enable-#{iface.name}",
"source" => <<SRC
:local run [ /interface bonding find running=yes and #{or_condition}]
:if ($run!="") do={
/interface bonding enable [find name=sw12]
/system schedule disable [ find name=enable-sw12 ]
}
SRC
}, "system", "script")
system_scheduler_script = {
"name" => Schema.identifier.key.required,
"on-event" => Schema.identifier.required,
"start-time" => Schema.identifier.null,
"interval" => Schema.interval.null,
"disabled" => Schema.boolean.default(false)
}
host.result.render_mikrotik(system_scheduler_script, {
"name" => "disable-#{iface.name}",
"on-event" => "disable-#{iface.name}",
"start-time" => "startup"
}, "system", "scheduler")
host.result.render_mikrotik(system_scheduler_script, {
"name" => "enable-#{iface.name}",
"on-event" => "enable-#{iface.name}",
"interval" => "00:00:10",
"disabled" => true
}, "system", "scheduler")
end
|