LGTM, thanks. Note: This patch breaks compatibility with the Haskell equivalent of the OpCode NetworkDisconnect. I sent a seperate patch to fix that, which I will push together with your patches.
Cheers, Helga On Tue, Jan 29, 2013 at 9:40 AM, Dimitris Aragiorgis <[email protected]>wrote: > 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. > > Signed-off-by: Dimitris Aragiorgis <[email protected]> > --- > lib/client/gnt_network.py | 5 ++--- > lib/cmdlib.py | 10 ++++------ > lib/opcodes.py | 1 - > 3 files changed, 6 insertions(+), 10 deletions(-) > > diff --git a/lib/client/gnt_network.py b/lib/client/gnt_network.py > index b07aa7a..a51d511 100644 > --- a/lib/client/gnt_network.py > +++ b/lib/client/gnt_network.py > @@ -144,8 +144,7 @@ def DisconnectNetwork(opts, args): > # TODO: Change logic to support "--submit" > for group in groups: > op = opcodes.OpNetworkDisconnect(group_name=group, > - network_name=network, > - conflicts_check=opts.conflicts_check) > + network_name=network) > SubmitOpCode(op, opts=opts, cl=cl) > > > @@ -349,7 +348,7 @@ commands = { > "disconnect": ( > DisconnectNetwork, > [ArgNetwork(min=1, max=1), ArgGroup()], > - [NOCONFLICTSCHECK_OPT, PRIORITY_OPT], > + [PRIORITY_OPT], > "<network_name> [<node_group>...]", > "Unmap a given network from a specified node group"), > "remove": ( > diff --git a/lib/cmdlib.py b/lib/cmdlib.py > index d14bb65..5798c6f 100644 > --- a/lib/cmdlib.py > +++ b/lib/cmdlib.py > @@ -16811,9 +16811,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.cfg.GetNodeGroupInstances(self.group_uuid) > + self.needed_locks[locking.LEVEL_INSTANCE] = \ > + self.cfg.GetNodeGroupInstances(self.group_uuid) > > def BuildHooksEnv(self): > ret = { > @@ -16838,9 +16837,8 @@ class LUNetworkDisconnect(LogicalUnit): > self.connected = False > return > > - if self.op.conflicts_check: > - _NetworkConflictCheck(self, lambda nic: nic.network == > self.network_name, > - "disconnect from") > + _NetworkConflictCheck(self, lambda nic: nic.network == > self.network_name, > + "disconnect from") > > def Exec(self, feedback_fn): > if not self.connected: > diff --git a/lib/opcodes.py b/lib/opcodes.py > index 2c88363..e533310 100644 > --- a/lib/opcodes.py > +++ b/lib/opcodes.py > @@ -2143,7 +2143,6 @@ class OpNetworkDisconnect(OpCode): > OP_PARAMS = [ > _PGroupName, > _PNetworkName, > - ("conflicts_check", True, ht.TBool, "Whether to check for conflicting > IPs"), > ] > OP_RESULT = ht.TNone > > -- > 1.7.10.4 > > -- > You received this message because you are subscribed to the Google Groups > "ganeti-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > >
