Revision 82e12743

b/lib/cmdlib.py
2331 2331

  
2332 2332
    if self.op.drained is not None:
2333 2333
      node.drained = self.op.drained
2334
      result.append(("drained", str(self.op.drained)))
2334 2335
      if self.op.drained == True:
2335 2336
        if node.master_candidate:
2336 2337
          node.master_candidate = False
b/scripts/gnt-node
73 73
  cl = GetClient()
74 74
  dns_data = utils.HostInfo(args[0])
75 75
  node = dns_data.name
76

  
77
  if not opts.readd:
78
    try:
79
      output = cl.QueryNodes(names=[node], fields=['name'], use_locking=True)
80
    except (errors.OpPrereqError, errors.OpExecError):
81
      pass
82
    else:
76
  readd = opts.readd
77

  
78
  try:
79
    output = cl.QueryNodes(names=[node], fields=['name', 'sip'],
80
                           use_locking=True)
81
    node_exists, sip = output[0]
82
  except (errors.OpPrereqError, errors.OpExecError):
83
    node_exists = ""
84
    sip = None
85

  
86
  if readd:
87
    if not node_exists:
88
      ToStderr("Node %s not in the cluster"
89
               " - please retry without '--readd'", node)
90
      return 1
91
  else:
92
    if node_exists:
83 93
      ToStderr("Node %s already in the cluster (as %s)"
84
               " - please use --readd", args[0], output[0][0])
94
               " - please retry with '--readd'", node, node_exists)
85 95
      return 1
96
    sip = opts.secondary_ip
86 97

  
87 98
  # read the cluster name from the master
88 99
  output = cl.QueryConfigValues(['cluster_name'])
89 100
  cluster_name = output[0]
90 101

  
91
  ToStderr("-- WARNING -- \n"
92
           "Performing this operation is going to replace the ssh daemon"
93
           " keypair\n"
94
           "on the target machine (%s) with the ones of the"
95
           " current one\n"
96
           "and grant full intra-cluster ssh root access to/from it\n", node)
102
  if readd:
103
    # clear the offline and drain flags on the node
104
    ToStdout("Resetting the 'offline' and 'drained' flags due to re-add")
105
    op = opcodes.OpSetNodeParams(node_name=node, force=True,
106
                                 offline=False, drained=False)
107

  
108
    result = SubmitOpCode(op, cl=cl)
109
    if result:
110
      ToStdout("Modified:")
111
      for param, data in result:
112
        ToStdout(" - %-5s -> %s", param, data)
113
  else:
114
    ToStderr("-- WARNING -- \n"
115
             "Performing this operation is going to replace the ssh daemon"
116
             " keypair\n"
117
             "on the target machine (%s) with the ones of the"
118
             " current one\n"
119
             "and grant full intra-cluster ssh root access to/from it\n", node)
97 120

  
98 121
  bootstrap.SetupNodeDaemon(cluster_name, node, opts.ssh_key_check)
99 122

  
100
  op = opcodes.OpAddNode(node_name=args[0], secondary_ip=opts.secondary_ip,
123
  op = opcodes.OpAddNode(node_name=args[0], secondary_ip=sip,
101 124
                         readd=opts.readd)
102 125
  SubmitOpCode(op)
103 126

  

Also available in: Unified diff