Revision 79829d23 lib/cmdlib.py

b/lib/cmdlib.py
5996 5996
                        " without using re-add. Please make sure the node"
5997 5997
                        " is healthy!")
5998 5998

  
5999
    # When changing the secondary ip, verify if this is a single-homed to
6000
    # multi-homed transition or vice versa, and apply the relevant
6001
    # restrictions.
5999 6002
    if self.op.secondary_ip:
6000 6003
      # Ok even without locking, because this can't be changed by any LU
6001 6004
      master = self.cfg.GetNodeInfo(self.cfg.GetMasterNode())
6002 6005
      master_singlehomed = master.secondary_ip == master.primary_ip
6003
      if master_singlehomed and self.op.secondary_ip:
6004
        raise errors.OpPrereqError("Cannot change the secondary ip on a single"
6005
                                   " homed cluster", errors.ECODE_INVAL)
6006
      if master_singlehomed and self.op.secondary_ip != node.primary_ip:
6007
        if self.op.force and node.name == master.name:
6008
          self.LogWarning("Transitioning from single-homed to multi-homed"
6009
                          " cluster. All nodes will require a secondary ip.")
6010
        else:
6011
          raise errors.OpPrereqError("Changing the secondary ip on a"
6012
                                     " single-homed cluster requires the"
6013
                                     " --force option to be passed, and the"
6014
                                     " target node to be the master",
6015
                                     errors.ECODE_INVAL)
6016
      elif not master_singlehomed and self.op.secondary_ip == node.primary_ip:
6017
        if self.op.force and node.name == master.name:
6018
          self.LogWarning("Transitioning from multi-homed to single-homed"
6019
                          " cluster. Secondary IPs will have to be removed.")
6020
        else:
6021
          raise errors.OpPrereqError("Cannot set the secondary IP to be the"
6022
                                     " same as the primary IP on a multi-homed"
6023
                                     " cluster, unless the --force option is"
6024
                                     " passed, and the target node is the"
6025
                                     " master", errors.ECODE_INVAL)
6006 6026

  
6007 6027
      assert not (frozenset(affected_instances) -
6008 6028
                  self.owned_locks(locking.LEVEL_INSTANCE))

Also available in: Unified diff