Revision b43dcc5a lib/cmdlib.py

b/lib/cmdlib.py
3675 3675

  
3676 3676
  def CheckArguments(self):
3677 3677
    # validate/normalize the node name
3678
    self.op.node_name = netutils.Hostname.GetNormalizedName(self.op.node_name)
3678
    self.hostname = netutils.GetHostname(name=self.op.node_name,
3679
                                         family=self.cfg.GetPrimaryIPFamily())
3680
    self.op.node_name = self.hostname.name
3679 3681

  
3680 3682
  def BuildHooksEnv(self):
3681 3683
    """Build hooks env.
......
3704 3706
    Any errors are signaled by raising errors.OpPrereqError.
3705 3707

  
3706 3708
    """
3707
    hostname = netutils.GetHostname(name=self.op.node_name)
3708
    node = hostname.name
3709 3709
    cfg = self.cfg
3710

  
3710
    hostname = self.hostname
3711
    node = hostname.name
3711 3712
    primary_ip = self.op.primary_ip = hostname.ip
3712 3713
    if self.op.secondary_ip is None:
3713 3714
      self.op.secondary_ip = primary_ip
3714
    if not netutils.IP4Address.IsValid(self.op.secondary_ip):
3715
      raise errors.OpPrereqError("Invalid secondary IP given",
3716
                                 errors.ECODE_INVAL)
3715

  
3717 3716
    secondary_ip = self.op.secondary_ip
3717
    if not netutils.IP4Address.IsValid(secondary_ip):
3718
      raise errors.OpPrereqError("Secondary IP (%s) needs to be a valid IPv4"
3719
                                 " address" % secondary_ip, errors.ECODE_INVAL)
3718 3720

  
3719 3721
    node_list = cfg.GetNodeList()
3720 3722
    if not self.op.readd and node in node_list:
......
3846 3848
    # Add node to our /etc/hosts, and add key to known_hosts
3847 3849
    if self.cfg.GetClusterInfo().modify_etc_hosts:
3848 3850
      # FIXME: this should be done via an rpc call to node daemon
3849
      utils.AddHostToEtcHosts(new_node.name)
3851
      utils.AddHostToEtcHosts(self.hostname)
3850 3852

  
3851 3853
    if new_node.secondary_ip != new_node.primary_ip:
3852 3854
      result = self.rpc.call_node_has_ip_address(new_node.name,

Also available in: Unified diff