Skip to content

Commit

Permalink
Merge 8d6fd9e into 1a2ab8a
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Aug 1, 2019
2 parents 1a2ab8a + 8d6fd9e commit 4c9ac10
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/y2network/connection_config/base.rb
Expand Up @@ -53,6 +53,8 @@ class Base
attr_accessor :startmode
# @return [String] Connection's description (e.g., "Ethernet Card 0")
attr_accessor :description
# @return [String] Link layer address
attr_accessor :lladdress

# Constructor
def initialize
Expand Down
28 changes: 28 additions & 0 deletions src/lib/y2network/connection_config/qeth.rb
@@ -0,0 +1,28 @@
# 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 "y2network/connection_config/base"

module Y2Network
module ConnectionConfig
# Configuration for qeth connections
class Qeth < Base
end
end
end
Expand Up @@ -51,6 +51,7 @@ def connection_config
conn.ip = all_ips.find { |i| i.id.empty? }
conn.ip_aliases = all_ips.reject { |i| i.id.empty? }
conn.name = file.interface
conn.lladdress = file.lladdr
conn.startmode = Startmode.create(file.startmode || "manual")
conn.startmode.priority = file.ifplugd_priority if conn.startmode.name == "ifplugd"
update_connection_config(conn)
Expand Down
31 changes: 31 additions & 0 deletions src/lib/y2network/sysconfig/connection_config_readers/qeth.rb
@@ -0,0 +1,31 @@
# 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 "y2network/sysconfig/connection_config_readers/ethernet"

module Y2Network
module Sysconfig
module ConnectionConfigReaders
# This class is able to build a ConnectionConfig::Qeth object given a
# Sysconfig::InterfaceFile object.
class Qeth < Ethernet
end
end
end
end
Expand Up @@ -42,6 +42,7 @@ def initialize(file)
def write(conn)
file.bootproto = conn.bootproto.name
file.name = conn.description
file.lladdr = conn.lladdress
file.startmode = conn.startmode.to_s
file.ifplugd_priority = conn.startmode.priority if conn.startmode.name == "ifplugd"
add_ips(conn)
Expand Down
31 changes: 31 additions & 0 deletions src/lib/y2network/sysconfig/connection_config_writers/qeth.rb
@@ -0,0 +1,31 @@
# 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 "y2network/sysconfig/connection_config_writers/ethernet"

module Y2Network
module Sysconfig
module ConnectionConfigWriters
# This class is responsible for writing the information from a ConnectionConfig::Qeth
# object to the underlying system.
class Qeth < Ethernet
end
end
end
end
4 changes: 4 additions & 0 deletions src/lib/y2network/sysconfig/interface_file.rb
Expand Up @@ -177,6 +177,10 @@ def variable_name(param_name)
# @return [Hash] Netmasks
define_collection_variable(:netmask)

# !@attribute [r] lladdr
# @return [String] Link layer address
define_variable(:lladdr)

# !@attribute [r] wireless_key_length
# @return [Integer] Length in bits for all keys used
define_variable(:wireless_key_length, :integer)
Expand Down
4 changes: 4 additions & 0 deletions test/data/scr_read/etc/sysconfig/network/ifcfg-eth5
@@ -0,0 +1,4 @@
STARTMODE='auto'
BOOTPROTO='static'
IPADDR='192.168.50.1/24'
LLADDR='00:06:29:55:2A:01'
30 changes: 30 additions & 0 deletions test/y2network/connection_config/qeth_test.rb
@@ -0,0 +1,30 @@
# 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 "y2network/connection_config/qeth"
require "y2network/interface_type"

describe Y2Network::ConnectionConfig::Qeth do
describe "#type" do
it "returns 'qeth'" do
expect(subject.type).to eq(Y2Network::InterfaceType::QETH)
end
end
end
49 changes: 49 additions & 0 deletions test/y2network/sysconfig/connection_config_readers/qeth_test.rb
@@ -0,0 +1,49 @@
# 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 "y2network/sysconfig/connection_config_readers/qeth"
require "y2network/sysconfig/interface_file"
require "y2network/boot_protocol"

describe Y2Network::Sysconfig::ConnectionConfigReaders::Qeth do
subject(:handler) { described_class.new(file) }

let(:scr_root) { File.join(DATA_PATH, "scr_read") }

around do |example|
change_scr_root(scr_root, &example)
end

let(:interface_name) { "eth5" }

let(:file) do
Y2Network::Sysconfig::InterfaceFile.find(interface_name).tap(&:load)
end

describe "#connection_config" do
it "returns a qeth connection config object" do
qeth = handler.connection_config
expect(qeth.type).to eql(Y2Network::InterfaceType::QETH)
expect(qeth.interface).to eq("eth5")
expect(qeth.ip.address).to eq(Y2Network::IPAddress.from_string("192.168.50.1/24"))
expect(qeth.bootproto).to eq(Y2Network::BootProtocol::STATIC)
end
end
end
53 changes: 53 additions & 0 deletions test/y2network/sysconfig/connection_config_writers/qeth_test.rb
@@ -0,0 +1,53 @@
# 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 "y2network/sysconfig/connection_config_writers/qeth"
require "y2network/startmode"
require "y2network/boot_protocol"
require "y2network/connection_config/qeth"
require "y2network/connection_config/ip_config"

describe Y2Network::Sysconfig::ConnectionConfigWriters::Qeth do
subject(:handler) { described_class.new(file) }

let(:conn) do
Y2Network::ConnectionConfig::Qeth.new.tap do |c|
c.name = "eth6"
c.interface = "eth6"
c.bootproto = Y2Network::BootProtocol::STATIC
c.lladdress = "00:06:29:55:2A:04"
c.startmode = Y2Network::Startmode.create("auto")
end
end

let(:file) { Y2Network::Sysconfig::InterfaceFile.new(conn.name) }

describe "#write" do
it "writes common properties" do
handler.write(conn)
expect(file).to have_attributes(
bootproto: "static",
startmode: "auto",
lladdr: "00:06:29:55:2A:04"
)
end
end
end

0 comments on commit 4c9ac10

Please sign in to comment.