Commit 37a978e7 authored by Helga Velroyen's avatar Helga Velroyen Committed by Guido Trotter
Browse files

Force conflicts check in LUNetworkDisconnect

Until now if one disconnects a network with --no-conflicts-check
and then remove it, there is a possibility to leave instances with NICs
referencing non-existing networks. This causes network queries,
instance removal and modification to fail.

This patch allows a network to be disconnected from a nodegroup,
only if instances residing in the nodegroup do not have NICs attached
to the network. Otherwise OpPrereqError is raised. The
--no-conflicts-check option is removed from the gnt-network disconnect
command as well.

This is a cherry-pick of commit 6bb939a2

Signed-off-by: default avatarDimitris Aragiorgis <>
Reviewed-by: default avatarHelga Velroyen <>
Reviewed-by: default avatarMichele Tartara <>
parent becf9d5c
......@@ -143,8 +143,7 @@ def DisconnectNetwork(opts, args):
# TODO: Change logic to support "--submit"
for group in groups:
op = opcodes.OpNetworkDisconnect(group_name=group,
SubmitOpCode(op, opts=opts, cl=cl)
......@@ -344,7 +343,7 @@ commands = {
"disconnect": (
[ArgNetwork(min=1, max=1), ArgGroup()],
"<network_name> [<node_group>...]",
"Unmap a given network from a specified node group"),
"remove": (
......@@ -16790,9 +16790,8 @@ class LUNetworkDisconnect(LogicalUnit):
# Lock instances optimistically, needs verification once group lock has
# been acquired
if self.op.conflicts_check:
self.needed_locks[locking.LEVEL_INSTANCE] = \
self.needed_locks[locking.LEVEL_INSTANCE] = \
def BuildHooksEnv(self):
ret = {
......@@ -16817,9 +16816,8 @@ class LUNetworkDisconnect(LogicalUnit):
self.connected = False
if self.op.conflicts_check:
_NetworkConflictCheck(self, lambda nic: == self.network_name,
"disconnect from")
_NetworkConflictCheck(self, lambda nic: == self.network_name,
"disconnect from")
def Exec(self, feedback_fn):
if not self.connected:
......@@ -2138,7 +2138,6 @@ class OpNetworkDisconnect(OpCode):
("conflicts_check", True, ht.TBool, "Whether to check for conflicting IPs"),
OP_RESULT = ht.TNone
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment