Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
foreman_wds
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LiU IT - Infrastructure
foreman_wds
Commits
595f5989
Verified
Commit
595f5989
authored
4 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Add CSR render endpoint, to ease use in unattend
parent
19f8ee17
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/concerns/foreman_wds/unattended_controller_extensions.rb
+38
-17
38 additions, 17 deletions
.../concerns/foreman_wds/unattended_controller_extensions.rb
with
38 additions
and
17 deletions
app/controllers/concerns/foreman_wds/unattended_controller_extensions.rb
+
38
−
17
View file @
595f5989
module
ForemanWds
module
UnattendedControllerExtensions
def
host_template
return
super
unless
params
[
:kind
]
==
'wds_localboot'
begin
iface
=
@host
.
provision_interface
# Deploy regular DHCP and local boot TFTP
@host
.
provision_method
=
'build'
@host
.
build
=
false
iface
.
send
:rebuild_tftp
iface
.
send
:rebuild_dhcp
render
inline:
"Success. Local boot template was deployed successfully.
\n
"
rescue
StandardError
=>
e
message
=
format
(
'Failed to set local boot template: %{error}'
,
error:
e
)
logger
.
error
message
render
text:
message
,
status: :error
,
content_type:
'text/plain'
end
return
wds_render_csr
if
params
[
:kind
]
==
'csr_attributes.yaml'
return
wds_deploy_localboot
if
params
[
:kind
]
==
'wds_localboot'
super
end
def
load_template_vars
super
unless
params
[
:kind
]
==
'wds_localboot'
end
private
def
wds_render_csr
return
render
(
:plain
=>
'Host not in build mode'
)
unless
@host
and
@host
.
build?
template
=
ProvisioningTemplate
.
find_by_name
(
'csr_attributes.yaml'
)
content
=
@host
.
render_template
template:
template
raise
Foreman
::
Exception
.
new
(
N_
(
"Template '%s' didn't render correctly"
),
template
.
name
)
unless
content
render
plain:
content
end
def
wds_deploy_localboot
return
render
(
:plain
=>
'Host not in build mode'
)
unless
@host
and
@host
.
build?
iface
=
@host
.
provision_interface
# Deploy regular DHCP and local boot TFTP
@host
.
provision_method
=
'build'
@host
.
build
=
false
iface
.
send
:rebuild_tftp
iface
.
send
:rebuild_dhcp
render
inline:
"Success. Local boot template was deployed successfully.
\n
"
rescue
StandardError
=>
e
message
=
format
(
'Failed to set local boot template: %{error}'
,
error:
e
)
logger
.
error
message
render
text:
message
,
status: :error
,
content_type:
'text/plain'
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment