Revision e7d81ba0

b/lib/config.py
79 79
      self._cfg_file = cfg_file
80 80
    self._temporary_ids = set()
81 81
    self._temporary_drbds = {}
82
    self._temporary_macs = set()
82 83
    # Note: in order to prevent errors when resolving our name in
83 84
    # _DistributeConfig, we compute it here once and reuse it; it's
84 85
    # better to raise an error before starting to modify the config
......
110 111
      byte2 = random.randrange(0, 256)
111 112
      byte3 = random.randrange(0, 256)
112 113
      mac = "%s:%02x:%02x:%02x" % (prefix, byte1, byte2, byte3)
113
      if mac not in all_macs:
114
      if mac not in all_macs and mac not in self._temporary_macs:
114 115
        break
115 116
      retries -= 1
116 117
    else:
117 118
      raise errors.ConfigurationError("Can't generate unique MAC")
119
    self._temporary_macs.add(mac)
118 120
    return mac
119 121

  
120 122
  @locking.ssynchronized(_config_lock, shared=1)
......
126 128

  
127 129
    """
128 130
    all_macs = self._AllMACs()
129
    return mac in all_macs
131
    return mac in all_macs or mac in self._temporary_macs
130 132

  
131 133
  @locking.ssynchronized(_config_lock, shared=1)
132 134
  def GenerateDRBDSecret(self):
......
687 689
    self._config_data.instances[instance.name] = instance
688 690
    self._config_data.cluster.serial_no += 1
689 691
    self._UnlockedReleaseDRBDMinors(instance.name)
692
    for nic in instance.nics:
693
      self._temporary_macs.discard(nic.mac)
690 694
    self._WriteConfig()
691 695

  
692 696
  def _SetInstanceStatus(self, instance_name, status):
......
1236 1240

  
1237 1241
    if isinstance(target, objects.Instance):
1238 1242
      self._UnlockedReleaseDRBDMinors(target.name)
1243
      for nic in target.nics:
1244
        self._temporary_macs.discard(nic.mac)
1239 1245

  
1240 1246
    self._WriteConfig()

Also available in: Unified diff