Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F462353
schedule.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, May 18, 9:43 PM
Size
897 B
Mime Type
text/x-ruby
Expires
Tue, May 20, 9:43 PM (20 h, 54 m)
Engine
blob
Format
Raw Data
Handle
220495
Attached To
rARCHIVING archiving
schedule.rb
View Options
class
Schedule
<
ActiveRecord
::
Base
DEFAULT_RUNS
=
[
'Level=Full 1st sun at '
,
'Level=Differential 2nd-5th sun at '
,
'Level=Incremental mon-sat at '
]
attr_accessor
:runtime
serialize
:runs
,
JSON
belongs_to
:host
validates
:name
,
:runs
,
presence
:
true
validates
:name
,
uniqueness
:
{
scope
:
:host
}
before_validation
:set_runs
,
if
:
Proc
.
new
{
|
s
|
s
.
runtime
.
present?
}
def
to_bacula_config_array
[
'Schedule {'
]
+
[
" Name =
\"
#{
name_for_config
}
\"
"
]
+
runs
.
map
{
|
r
|
" Run =
#{
r
}
"
}
+
[
'}'
]
end
def
name_for_config
[
host
.
name
,
name
].
join
(
' '
)
end
private
def
set_runs
if
valid_runtime?
self
.
runs
=
DEFAULT_RUNS
.
map
{
|
r
|
r
+
runtime
}
else
self
.
errors
.
add
(
:runtime
,
:not_valid_24h_time
)
false
end
end
def
valid_runtime?
runtime
&&
runtime
[
/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/
]
end
end
Event Timeline
Log In to Comment