-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an InterfaceNaming widget to hide the renaming details
- Loading branch information
Showing
5 changed files
with
108 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright (c) [2019] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "cwm/custom_widget" | ||
require "y2network/widgets/udev_rules" | ||
require "y2network/widgets/interface_name" | ||
|
||
module Y2Network | ||
module Widgets | ||
# Widget to handle interface naming, including udev based renames. | ||
class InterfaceNaming < ::CWM::CustomWidget | ||
# Constructor | ||
# | ||
# @param [Y2Network::InterfaceConfigBuilder] Interface configuration builder object | ||
def initialize(builder) | ||
@builder = builder | ||
end | ||
|
||
# @see CWM::CustomWidget#contents | ||
def contents | ||
VBox(widget) | ||
end | ||
|
||
private | ||
|
||
def udev_based_rename? | ||
hardware = @builder.interface.hardware | ||
return false unless hardware | ||
!!(hardware.mac || hardware.busid) | ||
end | ||
|
||
# Internal widget | ||
# | ||
# It uses an internal widget to handle the rename depending on whether | ||
# udev based renames are needed or not. | ||
def widget | ||
@widget ||= udev_based_rename? ? UdevRules.new(@builder) : InterfaceName.new(@builder) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) [2019] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require_relative "../../test_helper" | ||
require "cwm/rspec" | ||
|
||
require "y2network/widgets/interface_naming" | ||
require "y2network/interface_config_builder" | ||
require "y2network/physical_interface" | ||
|
||
describe Y2Network::Widgets::InterfaceNaming do | ||
subject(:widget) { described_class.new(builder) } | ||
|
||
let(:builder) do | ||
instance_double( | ||
Y2Network::InterfaceConfigBuilder, | ||
interface: interface | ||
) | ||
end | ||
|
||
let(:interface) { instance_double(Y2Network::PhysicalInterface, hardware: nil) } | ||
|
||
include_examples "CWM::CustomWidget" | ||
describe "#contents" | ||
describe "#store" | ||
end |