Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt net interface delete to 'rockstor' service null config #2819 #2822

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/rockstor/storageadmin/views/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,21 +554,32 @@ def delete(self, request, id):
dnet_disconnect(c, brco.docker_name)
dnet_remove(network=brco.docker_name)
else:
restricted = False
restricted: bool = False
unknown_restricted: bool = False
try:
so = Service.objects.get(name="rockstor")
config = json.loads(so.config)
if config["network_interface"] == nco.name:
restricted = True
if so.config is None:
unknown_restricted = True
else:
config = json.loads(so.config)
if config["network_interface"] == nco.name:
restricted = True
except Exception as e:
logger.exception(e)
if restricted:
e_msg = (
"This connection ({}) is designated for "
"management and cannot be deleted. If you really "
f"This connection ({nco.name}) is designated for "
"management/Web-UI and cannot be deleted. If you really "
"need to delete it, change the Rockstor service "
"configuration and try again."
).format(nco.name)
)
handle_exception(Exception(e_msg), request)
if unknown_restricted:
e_msg = (
"No connection is yet designated for management/Web-UI. "
"To avoid inadvertently deleting the Web-UI network connection, "
"first configure the Rockstor service's 'Network Interface'."
)
handle_exception(Exception(e_msg), request)
self._delete_connection(nco)
return Response()
Expand Down