-
Notifications
You must be signed in to change notification settings - Fork 33
Fixes #20987 - Update installation media in KCH #534
Fixes #20987 - Update installation media in KCH #534
Conversation
Issues: #20987 |
katello/katello-change-hostname
Outdated
@@ -263,6 +263,13 @@ unless @foreman_proxy_content | |||
# Incorrect error message is piped to /dev/null, can be removed when http://projects.theforeman.org/issues/18186 is fixed | |||
# For the same reason, we accept exit code 65 here. | |||
hammer_cmd("capsule update --id #{proxy_id} --url https://#{@new_hostname}:9090 --new-name #{@new_hostname} 2> /dev/null", [0, 65]) | |||
|
|||
STDOUT.puts "Updating installation media paths" | |||
installation_media_ids = hammer_cmd("medium list | grep #{old_hostname} | awk '{ print $1 }'").split("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs @old_hostname
everywhere :)
katello/katello-change-hostname
Outdated
|
||
STDOUT.puts "Updating installation media paths" | ||
installation_media_ids = hammer_cmd("medium list | grep #{old_hostname} | awk '{ print $1 }'").split("\n") | ||
installation_media_paths = hammer_cmd("medium list | grep #{old_hostname} | awk '{ print $5 }'").split("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hammer medium list
will shorten the path if it is too long. e.g.:
9 | Default_Organization/Library/Red_Hat_Server/Red_Hat_Enterprise_Linux_7_Server... | http://sat.example.com/pulp/repos/Default_Organization/Library/con...
If you use that output to update the path, save the shortened path, instead of the real one, breaking it :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like this might be fixing it:
old_mediums = JSON.parse(hammer_cmd("--output json medium list --search #{@old_hostname}"))
old_mediums.each do |medium|
new_path = medium['Path'].sub(@old_hostname, @new_hostname)
hammer_cmd("medium update --id #{medium['Id']} --path #{new_path}")
end
(untested)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose the following (tested) patch on top of this PR:
--- a/katello-packaging/katello/katello-change-hostname
+++ b/katello-packaging/katello/katello-change-hostname
@@ -6,6 +6,7 @@ require "rubygems"
require 'yaml'
require 'shellwords'
require "json"
+require 'uri'
raise 'Must run as root' unless Process.uid == 0
@@ -275,10 +276,12 @@ unless @foreman_proxy_content
hammer_cmd("capsule update --id #{proxy_id} --url https://#{@new_hostname}:9090 --new-name #{@new_hostname} 2> /dev/null", [0, 65])
STDOUT.puts "Updating installation media paths"
- installation_media_ids = hammer_cmd("medium list | grep #{@old_hostname} | awk '{ print $1 }'").split("\n")
- installation_media_paths = hammer_cmd("medium list | grep #{@old_hostname} | awk '{ print $5 }'").split("\n")
- installation_media_ids.zip(installation_media_paths).each do |id, path|
- hammer_cmd("medium update --id #{id} --path #{path.sub! @old_hostname, @new_hostname}")
+ old_media = JSON.parse(hammer_cmd("--output json medium list --search #{@old_hostname}"))
+ old_media.each do |medium|
+ new_path = URI.parse(medium['Path'])
+ new_path.host = @new_hostname
+ new_path = new_path.to_s
+ hammer_cmd("medium update --id #{medium['Id']} --path #{new_path}")
end
end
d3709fe
to
5e08a2c
Compare
This was removed at some point, but we should keep it around for upgraded users. (It was removed because we no longer create install media for new kickstart repos that you sync)
5e08a2c
to
b89d699
Compare
Before hnc
hostname change w/o error and then the capsules were updated:
|
c'est si ne pas un ACK I would ACK that, but half of the code is mine, so it's probably not a soo good idea ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This was removed at some point, but we should keep it around for
upgraded users. (It was removed because we no longer create
install media for new kickstart repos that you sync)