Skip to content

Commit

Permalink
{ssh|vnc} AY installation with renaming supported. bnc#944349
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Nov 15, 2015
1 parent 042245e commit eace0ca
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
55 changes: 52 additions & 3 deletions src/clients/save_network.rb
Expand Up @@ -47,6 +47,8 @@ def main
Yast.import "Mode"
Yast.import "Arch"
Yast.import "Storage"
Yast.import "LanItems"
Yast.import "Profile"

Yast.include self, "network/routines.rb"
Yast.include self, "network/complex.rb"
Expand Down Expand Up @@ -188,14 +190,14 @@ def copy_udev_rules
log.info("File #{udev_rules_destdir} exists")
end

if !FileUtils.Exists(net_destfile)
if !Mode.update
log.info("Copying #{net_srcfile} to the installed system ")
WFM.Execute(
path(".local.bash"),
"/bin/cp -p '#{udev_rules_srcdir}/#{net_srcfile}' '#{net_destfile}'"
)
else
log.info("Not copying file #{net_destfile} - it already exists")
log.info("Not copying file #{net_destfile} - update mode")
end

nil
Expand All @@ -211,7 +213,8 @@ def copy_from_instsys
new_SCR = WFM.SCROpen("chroot=/:scr", false)
WFM.SCRSetDefault(new_SCR)

# --------------------------------------------------------------
ay_mode_configuration if Mode.autoinst

# Copy DHCP client cache so that we can request the same IP (#43974).
WFM.Execute(
path(".local.bash"),
Expand Down Expand Up @@ -262,6 +265,52 @@ def configure_target
nil
end

# Applies part of AY configuration at the end of first stage
#
# Intended mainly for steps which cannot be done in AY's second stage
#
# FIXME: Currently used only for applying udev rules during network
# installations (ssh, vnc, ...). It was introduced as a quick fix for
# bnc#944349, so it is currently limited only on {ssh|vnc} installations.
# Once properly analyzed and tested then starting of whole network second
# stage can be moved here.
def ay_mode_configuration
# TODO: run only when in {ssh|vnc} mode of AY
# TODO: support for changing udev rule option (mac <-> busid)

ay_profile = Profile.current

log.info("Applying udev rules according AY profile")

return if ay_profile.nil? || ay_profile.empty?
return if ay_profile["networking"].nil? || ay_profile["networking"].empty?

udev_rules = ay_profile["networking"]["net-udev"]
log.info("- udev rules: #{udev_rules}")

return if udev_rules.nil? || udev_rules.empty?

LanItems.Read

udev_rules.each do |rule|
name_to = rule["name"]
key = rule["value"].upcase
# currently we're interrested only on those interfaces which are already
# configured - such interfaces cannot be restarted during second stage
matching_item = LanItems.Items.find { |_, i| i["hwinfo"]["busid"].upcase == key || i["hwinfo"]["mac"].upcase == key }
next if !matching_item

name_from = matching_item[1]["ifcfg"]

log.info("- renaming <#{name_from}> -> <#{name_to}>")

LanItems.FindAndSelect(name_from)
LanItems.rename(name_to)
end

LanItems.write
end

# this replaces bash script create_interface
def save_network
log.info("starting save_network")
Expand Down
4 changes: 2 additions & 2 deletions src/modules/LanItems.rb
Expand Up @@ -645,7 +645,7 @@ def WriteUdevItemsRules
# - remove it completely
# removing is less error prone when tracking name changes, so it was chosen.
item_udev_net = RemoveKeyFromUdevRule(item_udev_net, "KERNEL")
SetLinkDown(dev_name)
SetLinkDown(dev_name) if !Mode.autoinst

@force_restart = true
end
Expand Down Expand Up @@ -736,7 +736,7 @@ def write
SetItemName(item_id, renamed_to(item_id))
end

LanItems.WriteUdevRules if !Mode.autoinst && LanUdevAuto.AllowUdevModify
LanItems.WriteUdevRules if LanUdevAuto.AllowUdevModify

# FIXME: hack: no "netcard" filter as biosdevname names it diferently (bnc#712232)
NetworkInterfaces.Write("")
Expand Down

0 comments on commit eace0ca

Please sign in to comment.