ifcfg-rh: write DEVICE only once

The plugin already writes DEVICE in write_connection_setting(), there
is no need to write it again elsewhere.
This commit is contained in:
Beniamino Galvani
2017-09-06 18:10:15 +02:00
parent 18f53a8b30
commit e89ed9b51e
4 changed files with 4 additions and 40 deletions

View File

@@ -1192,19 +1192,11 @@ static gboolean
write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error)
{ {
NMSettingVlan *s_vlan; NMSettingVlan *s_vlan;
NMSettingConnection *s_con;
char *tmp; char *tmp;
guint32 vlan_flags = 0; guint32 vlan_flags = 0;
gsize s_buf_len; gsize s_buf_len;
char s_buf[50], *s_buf_ptr; char s_buf[50], *s_buf_ptr;
s_con = nm_connection_get_setting_connection (connection);
if (!s_con) {
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing connection setting");
return FALSE;
}
s_vlan = nm_connection_get_setting_vlan (connection); s_vlan = nm_connection_get_setting_vlan (connection);
if (!s_vlan) { if (!s_vlan) {
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
@@ -1214,9 +1206,8 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired,
svSetValueStr (ifcfg, "VLAN", "yes"); svSetValueStr (ifcfg, "VLAN", "yes");
svSetValueStr (ifcfg, "TYPE", TYPE_VLAN); svSetValueStr (ifcfg, "TYPE", TYPE_VLAN);
svSetValueStr (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con));
svSetValueStr (ifcfg, "PHYSDEV", nm_setting_vlan_get_parent (s_vlan)); svSetValueStr (ifcfg, "PHYSDEV", nm_setting_vlan_get_parent (s_vlan));
svSetValueInt64 (ifcfg, "VLAN_ID", nm_setting_vlan_get_id(s_vlan)); svSetValueInt64 (ifcfg, "VLAN_ID", nm_setting_vlan_get_id (s_vlan));
vlan_flags = nm_setting_vlan_get_flags (s_vlan); vlan_flags = nm_setting_vlan_get_flags (s_vlan);
svSetValueBoolean (ifcfg, "REORDER_HDR", NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)); svSetValueBoolean (ifcfg, "REORDER_HDR", NM_FLAGS_HAS (vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS));
@@ -1254,7 +1245,6 @@ static gboolean
write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error)
{ {
NMSettingBond *s_bond; NMSettingBond *s_bond;
const char *iface;
guint32 i, num_opts; guint32 i, num_opts;
s_bond = nm_connection_get_setting_bond (connection); s_bond = nm_connection_get_setting_bond (connection);
@@ -1264,14 +1254,6 @@ write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wir
return FALSE; return FALSE;
} }
iface = nm_connection_get_interface_name (connection);
if (!iface) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing interface name");
return FALSE;
}
svSetValueStr (ifcfg, "DEVICE", iface);
svUnsetValue (ifcfg, "BONDING_OPTS"); svUnsetValue (ifcfg, "BONDING_OPTS");
num_opts = nm_setting_bond_get_num_options (s_bond); num_opts = nm_setting_bond_get_num_options (s_bond);
@@ -1308,7 +1290,6 @@ static gboolean
write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error) write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, GError **error)
{ {
NMSettingTeam *s_team; NMSettingTeam *s_team;
const char *iface;
const char *config; const char *config;
s_team = nm_connection_get_setting_team (connection); s_team = nm_connection_get_setting_team (connection);
@@ -1318,14 +1299,6 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired,
return FALSE; return FALSE;
} }
iface = nm_connection_get_interface_name (connection);
if (!iface) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing interface name");
return FALSE;
}
svSetValueStr (ifcfg, "DEVICE", iface);
config = nm_setting_team_get_config (s_team); config = nm_setting_team_get_config (s_team);
svSetValueStr (ifcfg, "TEAM_CONFIG", config); svSetValueStr (ifcfg, "TEAM_CONFIG", config);
@@ -1372,7 +1345,6 @@ static gboolean
write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
{ {
NMSettingBridge *s_bridge; NMSettingBridge *s_bridge;
const char *iface;
guint32 i; guint32 i;
gboolean b; gboolean b;
GString *opts; GString *opts;
@@ -1385,14 +1357,6 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error
return FALSE; return FALSE;
} }
iface = nm_connection_get_interface_name (connection);
if (!iface) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing interface name");
return FALSE;
}
svSetValueStr (ifcfg, "DEVICE", iface);
svUnsetValue (ifcfg, "BRIDGING_OPTS"); svUnsetValue (ifcfg, "BRIDGING_OPTS");
svSetValueBoolean (ifcfg, "STP", FALSE); svSetValueBoolean (ifcfg, "STP", FALSE);
svUnsetValue (ifcfg, "DELAY"); svUnsetValue (ifcfg, "DELAY");

View File

@@ -1,4 +1,3 @@
DEVICE=bond0
BONDING_OPTS=mode=balance-rr BONDING_OPTS=mode=balance-rr
TYPE=Bond TYPE=Bond
BONDING_MASTER=yes BONDING_MASTER=yes
@@ -13,4 +12,5 @@ IPV4_FAILURE_FATAL=no
IPV6INIT=no IPV6INIT=no
NAME="Test Write Bond Main" NAME="Test Write Bond Main"
UUID=${UUID} UUID=${UUID}
DEVICE=bond0
ONBOOT=yes ONBOOT=yes

View File

@@ -1,6 +1,5 @@
VLAN=yes VLAN=yes
TYPE=Vlan TYPE=Vlan
DEVICE=vlan43
PHYSDEV=eth9 PHYSDEV=eth9
VLAN_ID=43 VLAN_ID=43
REORDER_HDR=yes REORDER_HDR=yes
@@ -19,4 +18,5 @@ IPV4_FAILURE_FATAL=no
IPV6INIT=no IPV6INIT=no
NAME="Vlan test-vlan-interface" NAME="Vlan test-vlan-interface"
UUID=${UUID} UUID=${UUID}
DEVICE=vlan43
ONBOOT=yes ONBOOT=yes

View File

@@ -1,5 +1,4 @@
VLAN=yes VLAN=yes
DEVICE=enp31s0f1-142
PHYSDEV=enp31s0f1 PHYSDEV=enp31s0f1
VLAN_ID=142 VLAN_ID=142
REORDER_HDR=yes REORDER_HDR=yes
@@ -7,6 +6,7 @@ GVRP=no
MVRP=no MVRP=no
NAME=team-slave-enp31s0f1-142 NAME=team-slave-enp31s0f1-142
UUID=74f435bb-ede4-415a-9d48-f580b60eba04 UUID=74f435bb-ede4-415a-9d48-f580b60eba04
DEVICE=enp31s0f1-142
ONBOOT=no ONBOOT=no
TEAM_MASTER=team142 TEAM_MASTER=team142
DEVICETYPE=TeamPort DEVICETYPE=TeamPort