Revision 1dacbb06

b/lib/cmdlib.py
16110 16110
    return (nodes, nodes)
16111 16111

  
16112 16112
  def CheckPrereq(self):
16113
    owned_instances = frozenset(self.owned_locks(locking.LEVEL_INSTANCE))
16114
    owned_groups = frozenset(self.owned_locks(locking.LEVEL_NODEGROUP))
16115

  
16116
    assert self.group_uuid in owned_groups
16117

  
16118
    # Check if locked instances are still correct
16119
    _CheckNodeGroupInstances(self.cfg, self.group_uuid, owned_instances)
16120

  
16113 16121
    l = lambda value: utils.CommaJoin("%s: %s/%s" % (i[0], i[1], i[2])
16114 16122
                                      for i in value)
16115 16123

  
......
16128 16136
      self.connected = True
16129 16137
      return
16130 16138

  
16131
    pool = network.AddressPool(self.network)
16132 16139
    if self.op.conflicts_check:
16133
      groupinstances = []
16134
      for n in self.cfg.GetNodeGroupInstances(self.group_uuid):
16135
        groupinstances.append(self.cfg.GetInstanceInfo(n))
16136
      instances = [(instance.name, idx, nic.ip)
16137
                   for instance in groupinstances
16138
                   for idx, nic in enumerate(instance.nics)
16139
                   if (not nic.network and pool.Contains(nic.ip))]
16140
      if instances:
16140
      pool = network.AddressPool(self.network)
16141
      conflicting_instances = []
16142

  
16143
      for (_, instance) in self.cfg.GetMultiInstanceInfo(owned_instances):
16144
        for idx, nic in enumerate(instance.nics):
16145
          if pool.Contains(nic.ip):
16146
            conflicting_instances.append((instance.name, idx, nic.ip))
16147

  
16148
      if conflicting_instances:
16141 16149
        self.LogWarning("Following occurences use IPs from network %s"
16142 16150
                        " that is about to connect to nodegroup %s: %s" %
16143 16151
                        (self.network_name, self.group.name,
16144
                        l(instances)))
16152
                        l(conflicting_instances)))
16145 16153
        raise errors.OpPrereqError("Conflicting IPs found."
16146 16154
                                   " Please remove/modify"
16147 16155
                                   " corresponding NICs",
......
16192 16200
      # been acquired
16193 16201
      if self.op.conflicts_check:
16194 16202
        self.needed_locks[locking.LEVEL_INSTANCE] = \
16195
            self.cfg.GetNodeGroupInstances(self.group_uuid)
16203
          self.cfg.GetNodeGroupInstances(self.group_uuid)
16196 16204

  
16197 16205
  def BuildHooksEnv(self):
16198 16206
    ret = {
......
16206 16214
    return (nodes, nodes)
16207 16215

  
16208 16216
  def CheckPrereq(self):
16217
    owned_instances = frozenset(self.owned_locks(locking.LEVEL_INSTANCE))
16218
    owned_groups = frozenset(self.owned_locks(locking.LEVEL_NODEGROUP))
16219

  
16220
    assert self.group_uuid in owned_groups
16221

  
16222
    # Check if locked instances are still correct
16223
    _CheckNodeGroupInstances(self.cfg, self.group_uuid, owned_instances)
16224

  
16209 16225
    l = lambda value: utils.CommaJoin("%s: %s/%s" % (i[0], i[1], i[2])
16210 16226
                                      for i in value)
16211 16227

  
......
16217 16233
      return
16218 16234

  
16219 16235
    if self.op.conflicts_check:
16220
      groupinstances = []
16221
      for n in self.cfg.GetNodeGroupInstances(self.group_uuid):
16222
        groupinstances.append(self.cfg.GetInstanceInfo(n))
16223
      instances = [(instance.name, idx, nic.ip)
16224
                   for instance in groupinstances
16225
                   for idx, nic in enumerate(instance.nics)
16226
                   if nic.network == self.network_name]
16227
      if instances:
16236
      conflicting_instances = []
16237

  
16238
      for (_, instance) in self.cfg.GetMultiInstanceInfo(owned_instances):
16239
        for idx, nic in enumerate(instance.nics):
16240
          if nic.network == self.network_name:
16241
            conflicting_instances.append((instance.name, idx, nic.ip))
16242

  
16243
      if conflicting_instances:
16228 16244
        self.LogWarning("Following occurences use IPs from network %s"
16229 16245
                           " that is about to disconnected from the nodegroup"
16230 16246
                           " %s: %s" %
16231 16247
                           (self.network_name, self.group.name,
16232
                            l(instances)))
16248
                            l(conflicting_instances)))
16233 16249
        raise errors.OpPrereqError("Conflicting IPs."
16234 16250
                                   " Please remove/modify"
16235 16251
                                   " corresponding NICS",

Also available in: Unified diff