Skip to content

Commit

Permalink
Merge 74cb2cd into ab4d7b5
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Aug 1, 2019
2 parents ab4d7b5 + 74cb2cd commit 5cee825
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/lib/y2network/connection_config/hsi.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 hsi connections
class Hsi < Base
end
end
end
2 changes: 1 addition & 1 deletion src/lib/y2network/interface_type.rb
Expand Up @@ -131,7 +131,7 @@ def method_missing(method_name, *arguments, &block)
# LAN-Channel-Station (LCS) network devices. S390 specific.
LCS = new(N_("LCS"), "lcs")
# HiperSockets s390 network device
HIPERSOCKETS = new(N_("HiperSockets"), "hsi")
HSI = new(N_("HSI"), "hsi")
# FICON-attached direct access storage devices. s390 specific
FICON = new(N_("FICON"), "ficon")
end
Expand Down
31 changes: 31 additions & 0 deletions src/lib/y2network/sysconfig/connection_config_readers/hsi.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::Hsi object given a
# Sysconfig::InterfaceFile object.
class Hsi < Ethernet
end
end
end
end
31 changes: 31 additions & 0 deletions src/lib/y2network/sysconfig/connection_config_writers/hsi.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::Hsi object to the underlying system.
class Hsi < Ethernet
end
end
end
end
3 changes: 3 additions & 0 deletions test/data/scr_read/etc/sysconfig/network/ifcfg-hsi0
@@ -0,0 +1,3 @@
STARTMODE='auto'
BOOTPROTO='static'
IPADDR='192.168.100.10/24'
30 changes: 30 additions & 0 deletions test/y2network/connection_config/hsi_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/hsi"
require "y2network/interface_type"

describe Y2Network::ConnectionConfig::Hsi do
describe "#type" do
it "returns 'hsi'" do
expect(subject.type).to eq(Y2Network::InterfaceType::HSI)
end
end
end
49 changes: 49 additions & 0 deletions test/y2network/sysconfig/connection_config_readers/hsi_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/hsi"
require "y2network/sysconfig/interface_file"
require "y2network/boot_protocol"

describe Y2Network::Sysconfig::ConnectionConfigReaders::Hsi 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) { "hsi0" }

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

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

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

let(:conn) do
Y2Network::ConnectionConfig::Hsi.new.tap do |c|
c.name = "hsi1"
c.interface = "hsi1"
c.bootproto = Y2Network::BootProtocol::DHCP
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: "dhcp",
startmode: "auto"
)
end
end
end
Expand Up @@ -23,7 +23,6 @@
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) }
Expand Down

0 comments on commit 5cee825

Please sign in to comment.