Skip to content

Commit

Permalink
Merge pull request #41 from yast/vlan-m
Browse files Browse the repository at this point in the history
Fix wrong interface name with auto_vlan=yes (master)
  • Loading branch information
mvidner committed Sep 18, 2017
2 parents 738eafc + 4eee066 commit 5144ef5
Show file tree
Hide file tree
Showing 15 changed files with 210 additions and 139 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service_name: travis-ci
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ config.status
config.sub
configure
configure.ac
/coverage/
install-sh
/Makefile.am
/Makefile.am.common
Expand All @@ -20,6 +21,7 @@ doc/autodocs
testsuite/*.log
testsuite/*.sum
testsuite/*.test
testsuite/raw*
testsuite/tmp*
testsuite/site.exp
testsuite/config
Expand All @@ -28,3 +30,5 @@ test/*.log
test/*.trs
test-driver
package/*.tar.bz2
/doc
/.yardoc
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ services:

before_install:
- docker build -t yast-fcoe-client-image .
# list the installed packages (just for easier debugging)
- docker run --rm -it yast-fcoe-client-image rpm -qa | sort

script:
# the "yast-travis-ruby" script is included in the base yastdevel/ruby image
# see https://github.com/yast/docker-yast-ruby/blob/master/yast-travis-ruby
Expand Down
6 changes: 6 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--no-private
--markup markdown
--protected
--output-dir ./doc/autodocs
--files *.md
src/**/*.rb
6 changes: 6 additions & 0 deletions package/yast2-fcoe-client.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Sep 15 11:31:03 UTC 2017 - mvidner@suse.com

- Fix wrong interface name with auto_vlan=yes (bsc#1043419)
- 3.1.15

-------------------------------------------------------------------
Tue Jul 26 09:43:33 CEST 2016 - gs@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-fcoe-client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-fcoe-client
Version: 3.1.14
Version: 3.1.15
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
1 change: 0 additions & 1 deletion src/clients/fcoe-client_auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def main
# FCoE is possible. We can not start exactly the interface from imported
# data because the numeration of interfaces (eth0, eth1...) may differ.
Builtins.foreach(@detected_netcards) do |card|
vlan_interface = ""
fcoe_vlan_interface = ""
command = ""
output = {}
Expand Down
57 changes: 20 additions & 37 deletions src/include/fcoe-client/complex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def AdjustButtons
end

def ShowInterfaces
vlan_interface = ""
row = 0

netcards = FcoeClient.GetNetworkCards
Expand Down Expand Up @@ -314,9 +313,7 @@ def InitEditDialog(id)

# Handle
#
def HandleServicesDialog(id, event)
event = deep_copy(event)
action = Ops.get(event, "ID")
def HandleServicesDialog(_id, _event)
nil
end

Expand Down Expand Up @@ -351,6 +348,7 @@ def HandleInterfacesDialog(id, event)
card = FcoeClient.GetCurrentNetworkCard
Builtins.y2milestone("Selected card: %1", card)
dev_name = Ops.get_string(card, "dev_name", "")
vlan_interface = card.fetch("vlan_interface", "") # eg. "200"

configured_vlans = FcoeClient.IsConfigured(dev_name)

Expand All @@ -365,28 +363,22 @@ def HandleInterfacesDialog(id, event)
# text of an error popup
Popup.Error(
Builtins.sformat(
_(
"Cannot start FCoE on VLAN interface %1\n" +
_("Cannot start FCoE on VLAN interface %1\n" +
"because FCoE is already configured on\n" +
"network interface %2 itself."
),
Ops.get_string(card, "vlan_interface", ""),
dev_name
"network interface %2 itself."),
vlan_interface, dev_name
)
)
return nil
end
if Ops.get_string(card, "vlan_interface", "") == "0"
if vlan_interface == "0"
# text of an error popup
Popup.Error(
Builtins.sformat(
_(
"Cannot start FCoE on network interface %1 itself\n" +
_("Cannot start FCoE on network interface %1 itself\n" +
"because FCoE is already configured on\n" +
"VLAN interface(s) %2."
),
dev_name,
configured_vlans
"VLAN interface(s) %2."),
dev_name, configured_vlans
)
)
return nil
Expand All @@ -400,30 +392,27 @@ def HandleInterfacesDialog(id, event)
)
end

command = Builtins.sformat("fipvlan -c -s %1", dev_name)
if card["auto_vlan"] == "yes" || vlan_interface == "0"
command = "fipvlan -c -s -f '-fcoe' #{dev_name}"
else
command = "fipvlan -c -s #{dev_name}"
end

output = {}
fcoe_vlan_interface = ""
status_map = {}

ifcfg_file = Builtins.sformat(
"/etc/sysconfig/network/ifcfg-%1.%2",
dev_name,
Ops.get_string(card, "vlan_interface", "")
)
ifcfg_file = "/etc/sysconfig/network/ifcfg-#{dev_name}.#{vlan_interface}"

# headline of a popup: creating and starting Fibre Channel over Ethernet
ret = Popup.YesNoHeadline(
_("Creating and Starting FCoE on Detected VLAN Device"),
# question to the user: really create and start FCoE
Builtins.sformat(
_(
"Do you really want to create a FCoE network\n" +
_("Do you really want to create a FCoE network\n" +
"interface for discovered VLAN interface %1\n" +
"on %2 and start the FCoE initiator?"
),
Ops.get_string(card, "vlan_interface", ""),
dev_name
"on %2 and start the FCoE initiator?"),
vlan_interface, dev_name
)
)
if ret == true
Expand All @@ -450,11 +439,7 @@ def HandleInterfacesDialog(id, event)
# if /etc/sysconfig/network/ifcfg-<if>.<vlan> already exists
# call 'ifup' for the interface (creates /proc/net/vlan/<if>.<vlan>)
if FileUtils.Exists(ifcfg_file)
cmd_ifup = Builtins.sformat(
"ifup %1.%2",
dev_name,
Ops.get_string(card, "vlan_interface", "")
)
cmd_ifup = Builtins.sformat("ifup %1.%2", dev_name, vlan_interface)
Builtins.y2milestone("Executing command: %1", cmd_ifup)
output = Convert.to_map(
SCR.Execute(path(".target.bash_output"), cmd_ifup)
Expand Down Expand Up @@ -774,9 +759,7 @@ def HandleInterfacesDialog(id, event)
nil
end

def HandleConfigurationDialog(id, event)
event = deep_copy(event)
action = Ops.get(event, "ID")
def HandleConfigurationDialog(_id, _event)
nil
end

Expand Down
145 changes: 47 additions & 98 deletions src/modules/FcoeClient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ class FcoeClientClass < Module

FCOE_PKG_NAME = "fcoe-utils"

# Used by FcoeClientClass to keep data about an individual network interface
# (Not a real class; documents the structure of a Hash)
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"
# @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"
# @option k [String] 'auto_vlan' "yes" or "no"
# @option k [String] 'mac_addr' "00:11:22:33:44:55"
# @option k [String] 'fcoe_enable' "yes" or "no"
# @option k [String] 'dcb_required' "yes" or "no"
# @option k [String] 'dcb_capable' "yes" or "no"
# @option k [String] 'cfg_device' "eth1.500" or "" ???
# @option k [Boolean] 'fcoe_flag' fcoe offload
# @option k [Boolean] 'iscsi_flag' scsi offload
# @option k [Boolean] 'storage_only'
end

def main
Yast.import "UI"
textdomain "fcoe-client"
Expand Down Expand Up @@ -369,6 +390,7 @@ def GetNetworkCards
end

# Get currently selected network card
# @return [Interface]
def GetCurrentNetworkCard
Ops.get(@network_interfaces, @current_card, {})
end
Expand Down Expand Up @@ -673,7 +695,6 @@ def CreateFcoeConfig(vlan_device_name, netcard)
#
def GetFcoeStatus(vlan_device_name, device_name)
status_map = {}
content = ""
file_name = ""
device = vlan_device_name

Expand Down Expand Up @@ -934,7 +955,8 @@ def ServiceStatus
#
# Check whether there are configured FCoE VLANs for the given network interface
# Return list of configured VLANs
#
# @param device_name [String] "eth1"
# @return [Array<String>] ["200", "300"]
def IsConfigured(device_name)
configured_vlans = []
interfaces = GetNetworkCards()
Expand All @@ -952,9 +974,9 @@ def IsConfigured(device_name)
deep_copy(configured_vlans)
end

#
# Detect network interface cards (hardware probe)
#
# @return [Array<Hash>] .probe.netcard output
# (except the items without dev_name)
def ProbeNetcards
if !TestMode()
netcards = Convert.convert(
Expand Down Expand Up @@ -1012,7 +1034,8 @@ def ProbeNetcards
# eth3 08:00:... Gigabit... 200 eth3.200 yes/no yes/no yes/no yes/no eth3.200
#
# Get the network cards and check Fcoe status
#
# @param netcards [Array<Hash>] .probe.netcard output
# @return [Array<Interface>]
def DetectNetworkCards(netcards)
return [] if netcards == nil

Expand Down Expand Up @@ -1223,107 +1246,33 @@ def WriteSysconfigFiles
success = true

Builtins.foreach(netcards) do |card|
if Ops.get_string(card, "fcoe_vlan", "") != @NOT_AVAILABLE &&
Ops.get_string(card, "fcoe_vlan", "") != @NOT_CONFIGURED
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)
if Ops.get_string(card, "vlan_interface", "") != "0"
Builtins.y2milestone(
"Writing /etc/sysconfig/network/ifcfg-%1",
Ops.get_string(card, "fcoe_vlan", "")
)
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(
Ops.add(
Ops.add(
path(".network.value"),
Ops.get_string(card, "fcoe_vlan", "")
),
"BOOTPROTO"
),
"static"
)
SCR.Write(
Ops.add(
Ops.add(
path(".network.value"),
Ops.get_string(card, "fcoe_vlan", "")
),
"STARTMODE"
),
"nfsroot"
)
SCR.Write(
Ops.add(
Ops.add(
path(".network.value"),
Ops.get_string(card, "fcoe_vlan", "")
),
"ETHERDEVICE"
),
Ops.get_string(card, "dev_name", "")
)
SCR.Write(
Ops.add(
Ops.add(
path(".network.value"),
Ops.get_string(card, "fcoe_vlan", "")
),
"USERCONTROL"
),
"no"
)
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 = Builtins.sformat(
"/etc/sysconfig/network/ifcfg-%1",
Ops.get_string(card, "dev_name", "")
)
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(
Ops.add(
Ops.add(
path(".network.value"),
Ops.get_string(card, "dev_name", "")
),
"BOOTPROTO"
),
"static"
)
SCR.Write(
Ops.add(
Ops.add(
path(".network.value"),
Ops.get_string(card, "dev_name", "")
),
"STARTMODE"
),
"nfsroot"
)
SCR.Write(
Ops.add(
Ops.add(
path(".network.value"),
Ops.get_string(card, "dev_name", "")
),
"NAME"
),
Ops.get_string(card, "device", "")
)
else
# don't overwrite BOOTPROTO !!!
SCR.Write(
Ops.add(
Ops.add(
path(".network.value"),
Ops.get_string(card, "dev_name", "")
),
"STARTMODE"
),
"nfsroot"
)
SCR.Write(ifcfg_path + "BOOTPROTO", "static")
SCR.Write(ifcfg_path + "NAME", card.fetch("device", ""))
end
end
end
Expand Down
Loading

0 comments on commit 5144ef5

Please sign in to comment.