Skip to content

Commit

Permalink
Merge pull request #59 from ancorgs/fix_finish_client
Browse files Browse the repository at this point in the history
Use correct VLAN interface name in the finish client
  • Loading branch information
ancorgs committed Feb 20, 2020
2 parents 8e153e1 + 515befa commit c0ba9c8
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 149 deletions.
8 changes: 8 additions & 0 deletions package/yast2-fcoe-client.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Feb 20 13:09:42 UTC 2020 - Ancor Gonzalez Sosa <ancor@suse.com>

- Use the correct file names when copying the configuration of the
FCoE VLANs to the target system at the end of installation
(related to bsc#1163343).
- 4.2.2

-------------------------------------------------------------------
Mon Aug 26 09:37:36 CEST 2019 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-fcoe-client.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-fcoe-client
Version: 4.2.1
Version: 4.2.2
Release: 0
Summary: YaST2 - Configuration of Fibre Channel over Ethernet
Group: System/YaST
Expand Down
63 changes: 29 additions & 34 deletions src/clients/fcoe-client_finish.rb
Expand Up @@ -87,40 +87,35 @@ def main
Builtins.y2milestone("Nothing to do")
end

Builtins.foreach(@netcards) do |card|
command = ""
file_name = ""
if Ops.get_string(card, "fcoe_vlan", "") != FcoeClient.NOT_AVAILABLE &&
Ops.get_string(card, "fcoe_vlan", "") != FcoeClient.NOT_CONFIGURED
# FCoE VLAN interface is configured -> start services
@start_services = true

# copy sysconfig files
file_name = Builtins.sformat(
"/etc/sysconfig/network/ifcfg-%1.%2",
Ops.get_string(card, "dev_name", ""),
Ops.get_string(card, "vlan_interface", "")
)
command = Builtins.sformat(
"/usr/bin/cp -a %1 %2/etc/sysconfig/network",
file_name.shellescape,
Installation.destdir.shellescape
)
Builtins.y2milestone("Executing command: %1", command)
WFM.Execute(path(".local.bash"), command)

file_name = Builtins.sformat(
"/etc/sysconfig/network/ifcfg-%1",
Ops.get_string(card, "dev_name", "")
)
command = Builtins.sformat(
"/usr/bin/cp -a %1 %2/etc/sysconfig/network",
file_name.shellescape,
Installation.destdir.shellescape
)
Builtins.y2milestone("Executing command: %1", command)
WFM.Execute(path(".local.bash"), command)
end
@netcards.each do |card|
iface_name = FcoeClient.fcoe_vlan(card)
next if iface_name.nil?

# FCoE VLAN interface is configured -> start services
@start_services = true

# copy sysconfig files
file_name = "/etc/sysconfig/network/ifcfg-#{iface_name}"

command = Builtins.sformat(
"/usr/bin/cp -a %1 %2/etc/sysconfig/network",
file_name.shellescape,
Installation.destdir.shellescape
)
Builtins.y2milestone("Executing command: %1", command)
WFM.Execute(path(".local.bash"), command)

file_name = Builtins.sformat(
"/etc/sysconfig/network/ifcfg-%1",
Ops.get_string(card, "dev_name", "")
)
command = Builtins.sformat(
"/usr/bin/cp -a %1 %2/etc/sysconfig/network",
file_name.shellescape,
Installation.destdir.shellescape
)
Builtins.y2milestone("Executing command: %1", command)
WFM.Execute(path(".local.bash"), command)
end

if @start_services
Expand Down
223 changes: 120 additions & 103 deletions src/modules/FcoeClient.rb
Expand Up @@ -46,7 +46,7 @@ class Interface < Hash
# @!method [](k)
# I am not sure when the keys are present/absent :-/
# @option k [String] 'fcoe_vlan'
# "eth1.500" or "not configured" or "not available"
# "eth1.500-fcoe" or "not configured" or "not available"
# @option k [String] 'vlan_interface'
# "500", or "0" for no VLAN used; yes, the name is nonsense, should be "vid"
# @option k [String] 'dev_name' "eth1"
Expand Down Expand Up @@ -952,9 +952,7 @@ def IsConfigured(device_name)
interfaces = GetNetworkCards()

Builtins.foreach(interfaces) do |interface|
if device_name == Ops.get_string(interface, "dev_name", "") &&
Ops.get_string(interface, "fcoe_vlan", "") != @NOT_CONFIGURED &&
Ops.get_string(interface, "fcoe_vlan", "") != @NOT_AVAILABLE
if device_name == interface.fetch("dev_name", "") && fcoe_vlan?(interface)
configured_vlans = Builtins.add(
configured_vlans,
Ops.get_string(interface, "vlan_interface", "")
Expand Down Expand Up @@ -1235,35 +1233,34 @@ def WriteSysconfigFiles
netcards = GetNetworkCards()
success = true

Builtins.foreach(netcards) do |card|
fcoe_vlan = card.fetch("fcoe_vlan", "")
if fcoe_vlan != @NOT_AVAILABLE &&
fcoe_vlan != @NOT_CONFIGURED
# write ifcfg-<if>.>VLAN> only if VLAN was created (not for VLAN = 0 which means
# FCoE is started on the network interface itself)
dev_name = card.fetch("dev_name", "")
vid = card.fetch("vlan_interface", "")
if vid != "0"
Builtins.y2milestone("Writing /etc/sysconfig/network/ifcfg-%1", fcoe_vlan)
vifcfg_path = path(".network.value") + fcoe_vlan
# write /etc/sysconfig/network/ifcfg-<fcoe-vlan-interface>, e.g. ifcfg-eth3.200
SCR.Write(vifcfg_path + "BOOTPROTO", "static")
SCR.Write(vifcfg_path + "STARTMODE", "nfsroot")
SCR.Write(vifcfg_path + "ETHERDEVICE", dev_name)
SCR.Write(vifcfg_path + "USERCONTROL", "no")
SCR.Write(vifcfg_path + "VLAN_ID", vid)
end
ifcfg_file = "/etc/sysconfig/network/ifcfg-#{dev_name}"
Builtins.y2milestone("Writing %1", ifcfg_file)

# write /etc/sysconfig/network/ifcfg-<interface> (underlying interface), e.g. ifcfg-eth3
ifcfg_path = path(".network.value") + dev_name
SCR.Write(ifcfg_path + "STARTMODE", "nfsroot")
# don't overwrite BOOTPROTO !!!
if !FileUtils.Exists(ifcfg_file)
SCR.Write(ifcfg_path + "BOOTPROTO", "static")
SCR.Write(ifcfg_path + "NAME", card.fetch("device", ""))
end
netcards.each do |card|
fcoe_vlan = fcoe_vlan(card)
# write ifcfg-<if>.<VLAN> only if VLAN was created (not for VLAN = 0 which means
# FCoE is started on the network interface itself)
next if fcoe_vlan.nil?

dev_name = card.fetch("dev_name", "")
vid = card.fetch("vlan_interface", "")
if vid != "0"
Builtins.y2milestone("Writing /etc/sysconfig/network/ifcfg-%1", fcoe_vlan)
vifcfg_path = path(".network.value") + fcoe_vlan
# write /etc/sysconfig/network/ifcfg-<fcoe-vlan-interface>, e.g. ifcfg-eth3.200
SCR.Write(vifcfg_path + "BOOTPROTO", "static")
SCR.Write(vifcfg_path + "STARTMODE", "nfsroot")
SCR.Write(vifcfg_path + "ETHERDEVICE", dev_name)
SCR.Write(vifcfg_path + "USERCONTROL", "no")
SCR.Write(vifcfg_path + "VLAN_ID", vid)
end
ifcfg_file = "/etc/sysconfig/network/ifcfg-#{dev_name}"
Builtins.y2milestone("Writing %1", ifcfg_file)

# write /etc/sysconfig/network/ifcfg-<interface> (underlying interface), e.g. ifcfg-eth3
ifcfg_path = path(".network.value") + dev_name
SCR.Write(ifcfg_path + "STARTMODE", "nfsroot")
# don't overwrite BOOTPROTO !!!
if !FileUtils.Exists(ifcfg_file)
SCR.Write(ifcfg_path + "BOOTPROTO", "static")
SCR.Write(ifcfg_path + "NAME", card.fetch("device", ""))
end
end
# This is very important- it flushes the cache, and stores the configuration on the disk
Expand All @@ -1282,90 +1279,86 @@ def WriteCfgFiles

success = false

Builtins.foreach(netcards) do |card|
if Ops.get_string(card, "fcoe_vlan", "") != @NOT_AVAILABLE &&
Ops.get_string(card, "fcoe_vlan", "") != @NOT_CONFIGURED
command = ""
output = {}

Builtins.y2milestone(
"Writing /etc/fcoe/cfg-%1",
Ops.get_string(card, "cfg_device", "")
)
success = SCR.Write(
netcards.each do |card|
next unless fcoe_vlan?(card)

Builtins.y2milestone(
"Writing /etc/fcoe/cfg-%1",
Ops.get_string(card, "cfg_device", "")
)
success = SCR.Write(
Ops.add(
Ops.add(
Ops.add(
path(".fcoe.cfg-ethx.value"),
Ops.get_string(card, "cfg_device", "")
),
"FCOE_ENABLE"
path(".fcoe.cfg-ethx.value"),
Ops.get_string(card, "cfg_device", "")
),
"FCOE_ENABLE"
),
Ops.get_string(card, "fcoe_enable", "no")
)
if !success
Builtins.y2error(
"Writing FCOE_ENABLE=%1 failed",
Ops.get_string(card, "fcoe_enable", "no")
)
if !success
Builtins.y2error(
"Writing FCOE_ENABLE=%1 failed",
Ops.get_string(card, "fcoe_enable", "no")
)
end
success = SCR.Write(
end
success = SCR.Write(
Ops.add(
Ops.add(
Ops.add(
path(".fcoe.cfg-ethx.value"),
Ops.get_string(card, "cfg_device", "")
),
"DCB_REQUIRED"
path(".fcoe.cfg-ethx.value"),
Ops.get_string(card, "cfg_device", "")
),
"DCB_REQUIRED"
),
Ops.get_string(card, "dcb_required", "no")
)
if !success
Builtins.y2error(
"Writing DCB_REQUIRED=%1 failed",
Ops.get_string(card, "dcb_required", "no")
)
if !success
Builtins.y2error(
"Writing DCB_REQUIRED=%1 failed",
Ops.get_string(card, "dcb_required", "no")
)
end
success = SCR.Write(
end
success = SCR.Write(
Ops.add(
Ops.add(
Ops.add(
path(".fcoe.cfg-ethx.value"),
Ops.get_string(card, "cfg_device", "")
),
"AUTO_VLAN"
path(".fcoe.cfg-ethx.value"),
Ops.get_string(card, "cfg_device", "")
),
"AUTO_VLAN"
),
Ops.get_string(card, "auto_vlan", "no")
)
if !success
Builtins.y2error(
"Writing AUTO_VLAN=%1 failed",
Ops.get_string(card, "auto_vlan", "no")
)
if !success
Builtins.y2error(
"Writing AUTO_VLAN=%1 failed",
Ops.get_string(card, "auto_vlan", "no")
)
end
if Ops.get_string(card, "dcb_required", "no") == "yes"
# enable DCB on the interface
command = Builtins.sformat(
"/usr/sbin/dcbtool sc %1 dcb on",
Ops.get_string(card, "dev_name", "").shellescape
)
Builtins.y2milestone("Executing command: %1", command)
output = SCR.Execute(path(".target.bash_output"), command)
Builtins.y2milestone("Output: %1", output)
if Ops.get_integer(output, "exit", 255) != 0
# only warning, not necessarily an error
Builtins.y2warning("Command: %1 failed", command)
end
if Ops.get_string(card, "dcb_required", "no") == "yes"
# enable DCB on the interface
command = Builtins.sformat(
"/usr/sbin/dcbtool sc %1 dcb on",
Ops.get_string(card, "dev_name", "").shellescape
)
Builtins.y2milestone("Executing command: %1", command)
output = SCR.Execute(path(".target.bash_output"), command)
Builtins.y2milestone("Output: %1", output)
if Ops.get_integer(output, "exit", 255) != 0
# only warning, not necessarily an error
Builtins.y2warning("Command: %1 failed", command)
end
# enable App:FCoE on the interface
command = Builtins.sformat(
"/usr/sbin/dcbtool sc %1 app:0 e:1 a:1 w:1",
Ops.get_string(card, "dev_name", "").shellescape
)
Builtins.y2milestone("Executing command: %1", command)
# enable App:FCoE on the interface
command = Builtins.sformat(
"/usr/sbin/dcbtool sc %1 app:0 e:1 a:1 w:1",
Ops.get_string(card, "dev_name", "").shellescape
)
Builtins.y2milestone("Executing command: %1", command)

output = SCR.Execute(path(".target.bash_output"), command)
Builtins.y2milestone("Output: %1", output)
if Ops.get_integer(output, "exit", 255) != 0
# only warning, not necessarily an error
Builtins.y2warning("Command: %1 failed", command)
end
output = SCR.Execute(path(".target.bash_output"), command)
Builtins.y2milestone("Output: %1", output)
if Ops.get_integer(output, "exit", 255) != 0
# only warning, not necessarily an error
Builtins.y2warning("Command: %1 failed", command)
end
end
end
Expand Down Expand Up @@ -1690,6 +1683,30 @@ def AutoPackages
{ "install" => [FcoeClientClass::FCOE_PKG_NAME], "remove" => [] }
end

# Name of the network interface configured as FCoE VLAN for the given
# network card, if any
#
# @param card [Hash] a hash with all the information about a network interface
# @return [String, nil] nil if no FCoE VLAN is configured for the given interface
def fcoe_vlan(card)
fcoe_vlan = card["fcoe_vlan"]
# It should never contain a nil or an empty string, but better safe than sorry
return nil if fcoe_vlan.nil? || fcoe_vlan.empty?
return nil if fcoe_vlan == @NOT_AVAILABLE || fcoe_vlan == @NOT_CONFIGURED

fcoe_vlan
end

# Whether a FCoE VLAN is configured for the given network card
#
# @see #fcoe_vlan
#
# @param card [Hash] a hash with all the information about a network interface
# @return [Boolean]
def fcoe_vlan?(card)
!!fcoe_vlan(card)
end

publish :function => :Modified, :type => "boolean ()"
publish :function => :FcoeClient, :type => "void ()"
publish :function => :Abort, :type => "boolean ()"
Expand Down

0 comments on commit c0ba9c8

Please sign in to comment.