Skip to content

Commit

Permalink
Merge pull request #2822 from phillxnet/2819-Adapt-net-interface-dele…
Browse files Browse the repository at this point in the history
…te-to-'rockstor'-service-null-config-default

Adapt net interface delete to 'rockstor' service null config #2819
  • Loading branch information
phillxnet authored Mar 27, 2024
2 parents 792d5b7 + 5e66d4d commit dd28607
Showing 1 changed file with 18 additions and 7 deletions.
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

0 comments on commit dd28607

Please sign in to comment.