Revision e7c6e02b lib/cmdlib.py

b/lib/cmdlib.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2006, 2007 Google Inc.
4
# Copyright (C) 2006, 2007, 2008 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
1641 1641
    if not utils.IsValidIP(secondary_ip):
1642 1642
      raise errors.OpPrereqError("Invalid secondary IP given")
1643 1643
    self.op.secondary_ip = secondary_ip
1644

  
1644 1645
    node_list = cfg.GetNodeList()
1645
    if node in node_list:
1646
      raise errors.OpPrereqError("Node %s is already in the configuration"
1647
                                 % node)
1646
    if not self.op.readd and node in node_list:
1647
      raise errors.OpPrereqError("Node %s is already in the configuration" %
1648
                                 node)
1649
    elif self.op.readd and node not in node_list:
1650
      raise errors.OpPrereqError("Node %s is not in the configuration" % node)
1648 1651

  
1649 1652
    for existing_node_name in node_list:
1650 1653
      existing_node = cfg.GetNodeInfo(existing_node_name)
1654

  
1655
      if self.op.readd and node == existing_node_name:
1656
        if (existing_node.primary_ip != primary_ip or
1657
            existing_node.secondary_ip != secondary_ip):
1658
          raise errors.OpPrereqError("Readded node doesn't have the same IP"
1659
                                     " address configuration as before")
1660
        continue
1661

  
1651 1662
      if (existing_node.primary_ip == primary_ip or
1652 1663
          existing_node.secondary_ip == primary_ip or
1653 1664
          existing_node.primary_ip == secondary_ip or
......
1810 1821
      if not self.ssh.CopyFileToNode(node, fname):
1811 1822
        logger.Error("could not copy file %s to node %s" % (fname, node))
1812 1823

  
1813
    logger.Info("adding node %s to cluster.conf" % node)
1814
    self.cfg.AddNode(new_node)
1824
    if not self.op.readd:
1825
      logger.Info("adding node %s to cluster.conf" % node)
1826
      self.cfg.AddNode(new_node)
1815 1827

  
1816 1828

  
1817 1829
class LUMasterFailover(LogicalUnit):

Also available in: Unified diff