Revision 5f2725c1 lib/cmdlib.py

b/lib/cmdlib.py
7737 7737
                                     " have been skipped",
7738 7738
                                     errors.ECODE_INVAL)
7739 7739
        nic_ip = self.hostname1.ip
7740
        try:
7741
          self.cfg.ReserveIp(self.pnode.name, link, nic_ip, self.proc.GetECId())
7742
        except errors.ReservationError:
7743
          raise errors.OpPrereqError("IP address %s already in use"
7744
                                     " in cluster" % nic_ip,
7745
                                     errors.ECODE_NOTUNIQUE)
7746
      elif ip.lower() != constants.NIC_IP_POOL:
7740
      else:
7747 7741
        # We defer pool operations until later, so that the iallocator has
7748 7742
        # filled in the instance's node(s)
7749
        if not netutils.IPAddress.IsValid(ip):
7743
        if (ip.lower() != constants.NIC_IP_POOL and not
7744
            netutils.IPAddress.IsValid(ip)):
7750 7745
          raise errors.OpPrereqError("Invalid IP address '%s'" % ip,
7751 7746
                                     errors.ECODE_INVAL)
7752 7747
        nic_ip = ip
7753
        try:
7754
          self.cfg.ReserveIp(self.pnode.name, link, nic_ip, self.proc.GetECId())
7755
        except errors.ReservationError:
7756
          raise errors.OpPrereqError("IP address %s already in use"
7757
                                     " in cluster" % nic_ip,
7758
                                     errors.ECODE_NOTUNIQUE)
7759 7748

  
7760 7749
      # TODO: check the ip address for uniqueness
7761 7750
      if nic_mode == constants.NIC_MODE_ROUTED and not nic_ip:
......
7902 7891
    # Fill in any IPs from IP pools. This must happen here, because we need to
7903 7892
    # know the nic's primary node, as specified by the iallocator
7904 7893
    for nic in self.nics:
7905
      if nic.ip.lower() == constants.NIC_IP_POOL:
7906
        nic.ip = self.cfg.GenerateIp(self.pnode.name, nic.link,
7907
                                     self.proc.GetECId())
7908
        self.LogInfo("Chose IP %s from pool %s", nic.ip, link)
7894
      if nic.ip is not None:
7895
        link = nic.nicparams[constants.NIC_LINK]
7896
        if nic.ip.lower() == constants.NIC_IP_POOL:
7897
          nic.ip = self.cfg.GenerateIp(self.pnode.name, link,
7898
                                       self.proc.GetECId())
7899
          self.LogInfo("Chose IP %s from pool %s", nic.ip, link)
7900
        else:
7901
          try:
7902
            self.cfg.ReserveIp(self.pnode.name, link,
7903
                               nic.ip, self.proc.GetECId())
7904
          except errors.ReservationError:
7905
            raise errors.OpPrereqError("IP address %s already in use"
7906
                                       " in cluster" % nic.ip,
7907
                                       errors.ECODE_NOTUNIQUE)
7909 7908

  
7910 7909
    # mirror node verification
7911 7910
    if self.op.disk_template in constants.DTS_INT_MIRROR:

Also available in: Unified diff