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
8ac0b81b
Verified
Commit
8ac0b81b
authored
3 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Work towards WDS clients
parent
2f775ea0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/concerns/foreman_wds/host_extensions.rb
+1
-4
1 addition, 4 deletions
app/models/concerns/foreman_wds/host_extensions.rb
app/models/wds_server.rb
+30
-7
30 additions, 7 deletions
app/models/wds_server.rb
with
31 additions
and
11 deletions
app/models/concerns/foreman_wds/host_extensions.rb
+
1
−
4
View file @
8ac0b81b
...
...
@@ -103,7 +103,7 @@ module ForemanWds
raise
NotImplementedError
,
'Not implemented yet'
return
unless
wds?
client
=
wds_server
.
client
(
self
)
||
wds_server
.
creat
e_client
(
self
)
client
=
wds_server
.
ensur
e_client
(
self
)
Rails
.
logger
.
info
client
true
...
...
@@ -116,9 +116,6 @@ module ForemanWds
raise
NotImplementedError
,
'Not implemented yet'
return
unless
wds?
client
=
wds_server
.
client
(
self
)
return
unless
client
wds_server
.
delete_client
(
self
)
true
rescue
ScriptError
,
StandardError
=>
ex
...
...
This diff is collapsed.
Click to expand it.
app/models/wds_server.rb
+
30
−
7
View file @
8ac0b81b
...
...
@@ -183,21 +183,36 @@ class WdsServer < ApplicationRecord
end
def
ensure_unattend
(
host
)
iface
=
host
&
.
provision_interface
raise
'No provisioning interface available'
unless
iface
raise
NotImplementedException
,
'TODO: Not implemented yet'
# TODO: render template, send as heredoc
template
=
host
.
operatingsystem
.
provisioning_templates
.
find
{
|
t
|
t
.
template_kind
.
name
==
'wds_unattend'
}
unless
template
logger
.
warn
'No WDS Unattend template specified, falling back to provision template'
template
||=
host
.
operatingsystem
.
provisioning_templates
.
find
{
|
t
|
t
.
template_kind
.
name
==
'provision'
}
end
raise
'No provisioning template available'
unless
template
template_data
=
host
.
render_template
template:
template
connection
.
shell
(
:powershell
)
do
|
sh
|
file_path
=
unattend_file
(
host
)
sh
.
run
(
"$unattend_render = @'
\n
#{
template_data
}
\n
'@"
)
sh
.
run
(
"New-Item -Path '
#{
file_path
}
' -ItemType 'file' -Value $unattend_render"
)
source_image
=
host
.
wds_facet
.
install_image
target_image
=
target_image_for
(
host
)
# TODO: render template, send as heredoc
# sh.run("$unattend_render = @'\n#{unattend_template}\n'@")
# sh.run("New-Item -Path '#{unattend_file(host)}' -ItemType 'file' -Value $unattend_render")
if
SETTINGS
[
:wds_unattend_group
]
raise
NotImplementedException
,
'TODO: Not implemented yet'
# New-WdsInstallImageGroup -Name #{SETTINGS[:wds_unattend_group]}
# Export-WdsInstallImage -ImageGroup <Group> ...
# Import-WdsInstallImage -ImageGroup #{SETTINGS[:wds_unattend_group]} -UnattendFile '#{
unattend_file(host)
}' -OverwriteUnattend ...
# Import-WdsInstallImage -ImageGroup #{SETTINGS[:wds_unattend_group]} -UnattendFile '#{
file_path
}' -OverwriteUnattend ...
else
source_image
=
host
.
wds_facet
.
install_image
sh
.
run
(
"Copy-WdsInstallImage -ImageGroup '
#{
source_image
.
image_group
}
' -FileName '
#{
source_image
.
file_name
}
' -ImageName '
#{
source_image
.
image_name
}
' -NewFileName '
#{
target_image
.
file_name
}
' -NewImageName '
#{
target_image
.
image_name
}
'"
)
sh
.
run
(
"Set-WdsInstallImage -ImageGroup '
#{
target_image
.
image_group
}
' -FileName '
#{
target_image
.
file_name
}
' -ImageName '
#{
target_image
.
image_name
}
' -DisplayOrder 99999 -UnattendFile '
#{
unattend_file
(
host
)
}
' -OverwriteUnattend"
)
sh
.
run
(
"Set-WdsInstallImage -ImageGroup '
#{
target_image
.
image_group
}
' -FileName '
#{
target_image
.
file_name
}
' -ImageName '
#{
target_image
.
image_name
}
' -DisplayOrder 99999 -UnattendFile '
#{
file_path
}
' -OverwriteUnattend"
)
end
end
end
...
...
@@ -211,6 +226,14 @@ class WdsServer < ApplicationRecord
end
.
errcode
.
zero?
end
def
ensure_client
(
host
)
raise
NotImplementedException
,
'TODO: Not implemented yet'
end
def
delete_client
(
host
)
raise
NotImplementedException
,
'TODO: Not implemented yet'
end
def
images
(
type
,
name
=
nil
)
raise
ArgumentError
,
'Type must be :boot or :install'
unless
%i[boot install]
.
include?
type
...
...
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