mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
IfcfgUtil: Remediate connection_seems_active() for controller
For the active bonding/bridge connection, when all the port connection profiles are brought down firstly, then the operstate of the controller device will change into "down" automatically, which denotes missing the carrier for the controller device. However, the connection for the controller device should still be considered as active as long as there is any valid IP address configured. Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
parent
f2bd21cd79
commit
5d167549f3
1 changed files with 21 additions and 3 deletions
|
|
@ -659,7 +659,7 @@ class IfcfgUtil:
|
|||
text_file.write(h)
|
||||
|
||||
@classmethod
|
||||
def connection_seems_active(cls, name):
|
||||
def connection_seems_active(cls, name, run_env):
|
||||
# we don't know whether a ifcfg file is currently active,
|
||||
# and we also don't know which.
|
||||
#
|
||||
|
|
@ -683,7 +683,25 @@ class IfcfgUtil:
|
|||
return None
|
||||
|
||||
if i_content.strip() != "up":
|
||||
return False
|
||||
# For the active bonding/bridge connection, when all the port connection
|
||||
# profiles are brought down firstly, then the operstate of the controller
|
||||
# device will change into "down" automatically, which denotes missing the
|
||||
# carrier for the controller device. However, the connection for the
|
||||
# controller device stays active in such a situation.
|
||||
try:
|
||||
_unused_, out, _ignored_ = run_env.run_command(
|
||||
["ip", "address", "show", content["DEVICE"]],
|
||||
"utf-8",
|
||||
)
|
||||
except Exception:
|
||||
return None
|
||||
if "inet" in out:
|
||||
if out.count("inet") == 1 and "inet6 fe80" in out:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
|
@ -2614,7 +2632,7 @@ class Cmd_initscripts(Cmd):
|
|||
)
|
||||
return
|
||||
|
||||
is_active = IfcfgUtil.connection_seems_active(name)
|
||||
is_active = IfcfgUtil.connection_seems_active(name, self.run_env)
|
||||
is_modified = self.connection_modified_earlier(idx)
|
||||
force_state_change = self.connection_force_state_change(connection)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue