Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F905133
job_template.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
Fri, Aug 29, 9:25 PM
Size
1 KB
Mime Type
text/x-ruby
Expires
Sun, Aug 31, 9:25 PM (1 h, 54 m)
Engine
blob
Format
Raw Data
Handle
252490
Attached To
rARCHIVING archiving
job_template.rb
View Options
class
JobTemplate
<
ActiveRecord
::
Base
establish_connection
Baas
::
settings
[
:local_db
]
enum
job_type
:
{
backup
:
0
,
restore
:
1
,
verify
:
2
,
admin
:
3
}
belongs_to
:host
belongs_to
:fileset
belongs_to
:schedule
validates
:name
,
:fileset_id
,
presence
:
true
validates
:schedule_id
,
presence
:
true
,
unless
:
:restore?
validates
:name
,
uniqueness
:
{
scope
:
:host
}
before_save
:set_job_type
scope
:enabled
,
->
{
where
(
enabled
:
true
)
}
# configurable
DEFAULT_OPTIONS
=
{
storage
:
:File
,
pool
:
:Default
,
messages
:
:Standard
,
priority
:
10
,
:'Write Bootstrap'
=>
'"/var/lib/bacula/%c.bsr"'
}
def
to_bacula_config_array
[
'Job {'
]
+
options_array
.
map
{
|
x
|
"
#{
x
}
"
}
+
DEFAULT_OPTIONS
.
map
{
|
k
,
v
|
"
#{
k
.
capitalize
}
=
#{
v
}
"
}
+
[
'}'
]
end
def
priority
DEFAULT_OPTIONS
[
:priority
]
end
def
enabled_human
enabled?
?
'yes'
:
'no'
end
def
schedule_human
schedule
.
present?
?
schedule
.
name
:
'-'
end
def
name_for_config
"
#{
host
.
name
}
#{
name
}
"
end
def
save_and_create_restore_job
(
location
)
if
save_status
=
save
restore_job
=
JobTemplate
.
new
(
host
:
host
,
job_type
:
:restore
,
fileset
:
fileset
,
name
:
'Restore '
+
name
,
restore_location
:
location
)
restore_job
.
save
end
save_status
end
private
# Sets the default job_type as backup
def
set_job_type
self
.
job_type
=
:backup
if
job_type
.
nil?
end
def
options_array
result
=
[
"Name =
\"
#{
name_for_config
}
\"
"
,
"FileSet =
\"
#{
fileset
.
name
}
\"
"
,
"Client =
\"
#{
host
.
name
}
\"
"
,
"Type =
\"
#{
job_type
.
capitalize
}
\"
"
]
if
restore?
result
+=
[
"Where =
\"
#{
restore_location
}
\"
"
]
else
result
+=
[
"Schedule =
\"
#{
schedule
.
name
}
\"
"
]
end
result
end
end
Event Timeline
Log In to Comment