Skip to content

Commit

Permalink
Changes based on CR
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Feb 15, 2019
1 parent bd6e37d commit 1366899
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 15 additions & 2 deletions src/modules/LanItems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,18 @@ def GetDeviceNames(items)
items.map { |itemId| GetDeviceName(itemId) }.reject(&:empty?)
end

# Return the actual name of the current {LanItem}
#
# @return [String] the actual name for the current device
def current_name
renamed?(@current) ? renamed_to(@current) : GetDeviceName(@current)
current_name_for?(@current)
end

# Return the current device names
#
# @ return [Array<String>]
def current_device_names
GetNetcardInterfaces().map { |i| renamed?(i) ? renamed_to(i) : GetDeviceName(i) }.reject(&:empty?)
GetNetcardInterfaces().map { |i| current_name_for?(i) }.reject(&:empty?)
end

# Returns device name for current lan item (see LanItems::current)
Expand Down Expand Up @@ -2647,6 +2653,13 @@ def enslaved?(ifcfg_name)

private

# Return the current name of the {LanItem} given
#
# @param item_id [Integer] a key for {#Items}
def current_name_for?(item_id)
renamed?(item_id) ? renamed_to(item_id) : GetDeviceName(item_id)
end

# Checks if given lladdr can be written into ifcfg
#
# @param lladdr [String] logical link address, usually MAC address in case
Expand Down
4 changes: 0 additions & 4 deletions test/lib/network/edit_nic_name_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
require "yast"
require "network/edit_nic_name"

current_name = "spec0".freeze
new_name = "new1".freeze
existing_new_name = "existing_new_name".freeze

Yast.import "LanItems"

describe Yast::EditNicName do
Expand Down

0 comments on commit 1366899

Please sign in to comment.