Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1145 from yast/write_nm_changes
Write NetworkManager config files
- Loading branch information
Showing
8 changed files
with
304 additions
and
9 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
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
38 changes: 38 additions & 0 deletions
38
src/lib/y2network/network_manager/connection_config_writers/vlan.rb
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,38 @@ | ||
# Copyright (c) [2021] 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/network_manager/connection_config_writers/base" | ||
|
||
module Y2Network | ||
module NetworkManager | ||
module ConnectionConfigWriters | ||
# This class is responsible for writing the information from a ConnectionConfig::Vlan | ||
# object to the underlying system. | ||
class Vlan < Base | ||
# @see Y2Network::ConnectionConfigWriters::Base#update_file | ||
# @param conn [Y2Network::ConnectionConfig::Vlan] Configuration to write | ||
def update_file(conn) | ||
file.vlan["id"] = conn.vlan_id | ||
file.vlan["parent"] = conn.parent_device | ||
file.vlan["type"] = "vlan" | ||
end | ||
end | ||
end | ||
end | ||
end |
83 changes: 83 additions & 0 deletions
83
src/lib/y2network/network_manager/connection_config_writers/wireless.rb
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,83 @@ | ||
# Copyright (c) [2021] 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/network_manager/connection_config_writers/base" | ||
|
||
module Y2Network | ||
module NetworkManager | ||
module ConnectionConfigWriters | ||
# This class is responsible for writing the information from a ConnectionConfig::Wireless | ||
# object to the underlying system. | ||
class Wireless < Base | ||
MODE = { "ad-hoc" => "ad-hoc", "master" => "ap", "managed" => "infrastructure" }.freeze | ||
|
||
# @see Y2Network::ConnectionConfigWriters::Base#update_file | ||
def update_file(conn) | ||
file.connection["type"] = "wifi" | ||
file.wifi["ssid"] = conn.essid unless conn.essid.to_s.empty? | ||
file.wifi["mode"] = MODE[conn.mode] | ||
file.wifi["channel"] = con.channel if conn.channel | ||
|
||
write_auth_settings(conn) | ||
end | ||
|
||
# Writes autentication settings for WPA-EAP networks | ||
# | ||
# @param _conn [Y2Network::ConnectionConfig::Base] Configuration to write | ||
def write_eap_auth_settings(_conn) | ||
# FIXME: incomplete | ||
file.wifi_security["key-mgmt"] = "wpa-eap" | ||
# wrong section name | ||
# | ||
# file.802_1x["eap"] = conn.eap_mode | ||
# file.802_1x["phase2-auth"] = conn.eap_auth | ||
end | ||
|
||
# Writes authentication settings | ||
# | ||
# This method relies in `write_*_auth_settings` methods. | ||
# | ||
# | ||
# @param conn [Y2Network::ConnectionConfig::Base] Configuration to write | ||
# | ||
# @see #write_eap_auth_settings | ||
# @see #write_psk_auth_settings | ||
# @see #write_shared_auth_settings | ||
def write_auth_settings(conn) | ||
meth = "write_#{conn.auth_mode}_auth_settings".to_sym | ||
send(meth, conn) if respond_to?(meth, true) | ||
end | ||
|
||
# Writes autentication settings for WPA-PSK networks | ||
# | ||
# @param conn [Y2Network::ConnectionConfig::Base] Configuration to write | ||
def write_psk_auth_settings(conn) | ||
file.wifi_security["auth-alg"] = "open" | ||
file.wifi_security["key-mgmt"] = "wpa-psk" | ||
file.wifi_security["psk"] = conn.wpa_psk | ||
end | ||
|
||
# Writes autentication settings for WEP networks | ||
# | ||
# @param _conn [Y2Network::ConnectionConfig::Base] Configuration to write | ||
def write_shared_auth_settings(_conn); end | ||
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
Oops, something went wrong.