mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-29 01:49:19 +00:00
Check for predictable network interface names in bridge check function, and always return a status message with the outcome of the check. Issue #1191
This commit is contained in:
parent
5a6d12c075
commit
51f1e7eae7
@ -651,10 +651,12 @@ def attach_device():
|
||||
if param:
|
||||
params.update({item.replace(PARAM_PREFIX, ""): param})
|
||||
|
||||
return_message = "Attached %(device_type)s to SCSI ID %(id_number)s LUN %(unit_number)s"
|
||||
if "interface" in params.keys():
|
||||
bridge_status = is_bridge_configured(params["interface"])
|
||||
if not bridge_status["status"]:
|
||||
return response(error=True, message=bridge_status["msg"])
|
||||
return_message = return_message + " - " + bridge_status["msg"]
|
||||
|
||||
kwargs = {
|
||||
"unit": int(unit),
|
||||
@ -672,7 +674,7 @@ def attach_device():
|
||||
if process["status"]:
|
||||
return response(
|
||||
message=_(
|
||||
"Attached %(device_type)s to SCSI ID %(id_number)s LUN %(unit_number)s",
|
||||
return_message,
|
||||
device_type=get_device_name(device_type),
|
||||
id_number=scsi_id,
|
||||
unit_number=unit,
|
||||
|
@ -274,24 +274,34 @@ def is_bridge_configured(interface):
|
||||
PATH_IPTV4 = "/etc/iptables/rules.v4"
|
||||
PATH_DHCPCD = "/etc/dhcpcd.conf"
|
||||
PATH_BRIDGE = "/etc/network/interfaces.d/piscsi_bridge"
|
||||
return_msg = _("Configure the network bridge for %(interface)s first: ", interface=interface)
|
||||
to_configure = []
|
||||
sys_cmd = SysCmds()
|
||||
if interface.startswith("wlan"):
|
||||
if interface.startswith("wlan") or interface.startswith("wlx"):
|
||||
return_msg = _("Wireless network bridge enabled for %(interface)s", interface=interface)
|
||||
if not sys_cmd.introspect_file(PATH_SYSCTL, r"^net\.ipv4\.ip_forward=1$"):
|
||||
to_configure.append("IPv4 forwarding")
|
||||
if not Path(PATH_IPTV4).is_file():
|
||||
to_configure.append("NAT")
|
||||
else:
|
||||
elif interface.startswith("eth") or interface.startswith("enx"):
|
||||
return_msg = _("Wired network bridge enabled for %(interface)s", interface=interface)
|
||||
if not sys_cmd.introspect_file(PATH_DHCPCD, r"^denyinterfaces " + interface + r"$"):
|
||||
to_configure.append(PATH_DHCPCD)
|
||||
if not Path(PATH_BRIDGE).is_file():
|
||||
to_configure.append(PATH_BRIDGE)
|
||||
else:
|
||||
return_msg = _(
|
||||
"Unable to detect if %(interface)s is Ethernet or WiFi. "
|
||||
"Make sure that the correct network bridge is configured.",
|
||||
interface=interface,
|
||||
)
|
||||
|
||||
if to_configure:
|
||||
return_msg = _(
|
||||
"Configure the network bridge for %(interface)s first: ", interface=interface
|
||||
)
|
||||
return {"status": False, "msg": return_msg + ", ".join(to_configure)}
|
||||
|
||||
return {"status": True, "msg": ""}
|
||||
return {"status": True, "msg": return_msg}
|
||||
|
||||
|
||||
def is_safe_path(file_name):
|
||||
|
Loading…
Reference in New Issue
Block a user