2012/12/5 Dimitris Aragiorgis <[email protected]>:
> Use GetNetwork() only when having already aquired the lock,
> i.e. in CheckPrereq().
>
> In LUNetworkConnect/Disconnect do not include Network info in Hooks
> environment, so that network locking can be avoided if conflicts
> are not checked.
>
> Invoke _CheckNodeGroupInstances() only in case of conflicts check,
> because otherwise owned instances are None, which results to an error.
LGTM, thanks! I will push with the interdiff below. Please also add
locking to _NetworkQuery. It is not used in most cases, but callers
can request locking to be used.
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -15778,7 +15778,8 @@ class LUNetworkRemove(LogicalUnit):
self.network_uuid = self.cfg.LookupNetwork(self.op.network_name)
if not self.network_uuid:
- raise errors.OpPrereqError("Network %s not found" % self.op.network_name,
+ raise errors.OpPrereqError(("Network '%s' not found" %
+ self.op.network_name),
errors.ECODE_INVAL)
self.share_locks[locking.LEVEL_NODEGROUP] = 1
@@ -15795,18 +15796,17 @@ class LUNetworkRemove(LogicalUnit):
cluster.
"""
-
# Verify that the network is not conncted.
node_groups = [group.name
for group in self.cfg.GetAllNodeGroupsInfo().values()
- if self.network_uuid in group.networks.keys()]
+ if self.network_uuid in group.networks]
if node_groups:
- self.LogWarning("Nework '%s' is connected to the following"
- " node groups: %s" % (self.op.network_name,
- utils.CommaJoin(utils.NiceSort(node_groups))))
- raise errors.OpPrereqError("Network still connected",
- errors.ECODE_STATE)
+ self.LogWarning("Network '%s' is connected to the following"
+ " node groups: %s" %
+ (self.op.network_name,
+ utils.CommaJoin(utils.NiceSort(node_groups))))
+ raise errors.OpPrereqError("Network still connected", errors.ECODE_STATE)
def BuildHooksEnv(self):
"""Build hooks env.
@@ -15851,9 +15851,10 @@ class LUNetworkSetParams(LogicalUnit):
def ExpandNames(self):
self.network_uuid = self.cfg.LookupNetwork(self.op.network_name)
if self.network_uuid is None:
- raise errors.OpPrereqError("Could not retrieve network '%s' (UUID: %s)" %
- (self.op.network_name, self.network_uuid),
+ raise errors.OpPrereqError(("Network '%s' not found" %
+ self.op.network_name),
errors.ECODE_INVAL)
+
self.needed_locks = {
locking.LEVEL_NETWORK: [self.network_uuid],
}
Michael