Revision 3a24c527 scripts/gnt-node

b/scripts/gnt-node
24 24

  
25 25
from ganeti.cli import *
26 26
from ganeti import opcodes
27
from ganeti import logger
28 27
from ganeti import utils
29 28
from ganeti import constants
30 29
from ganeti import errors
......
52 51
    except (errors.OpPrereqError, errors.OpExecError):
53 52
      pass
54 53
    else:
55
      logger.ToStderr("Node %s already in the cluster (as %s)"
56
                      " - please use --readd" % (args[0], output[0][0]))
54
      ToStderr("Node %s already in the cluster (as %s)"
55
               " - please use --readd", args[0], output[0][0])
57 56
      return 1
58 57

  
59
  logger.ToStderr("-- WARNING -- \n"
60
    "Performing this operation is going to replace the ssh daemon keypair\n"
61
    "on the target machine (%s) with the ones of the current one\n"
62
    "and grant full intra-cluster ssh root access to/from it\n" % node)
58
  ToStderr("-- WARNING -- \n"
59
           "Performing this operation is going to replace the ssh daemon"
60
           " keypair\n"
61
           "on the target machine (%s) with the ones of the"
62
           " current one\n"
63
           "and grant full intra-cluster ssh root access to/from it\n", node)
63 64

  
64 65
  bootstrap.SetupNodeDaemon(node, opts.ssh_key_check)
65 66

  
......
121 122
                       fields=selected_fields, unitfields=unitfields,
122 123
                       numfields=numfields, data=output)
123 124
  for line in data:
124
    logger.ToStdout(line)
125
    ToStdout(line)
125 126

  
126 127
  return 0
127 128

  
......
147 148
                               src_node)
148 149

  
149 150
  if not sinst:
150
    logger.ToStderr("No secondary instances on node %s, exiting." % src_node)
151
    ToStderr("No secondary instances on node %s, exiting.", src_node)
151 152
    return constants.EXIT_SUCCESS
152 153

  
153 154
  sinst = utils.NiceSort(sinst)
......
167 168
                                mode=constants.REPLACE_DISK_ALL,
168 169
                                disks=["sda", "sdb"])
169 170
    try:
170
      logger.ToStdout("Replacing disks for instance %s" % iname)
171
      ToStdout("Replacing disks for instance %s", iname)
171 172
      SubmitOpCode(op)
172
      logger.ToStdout("Instance %s has been relocated" % iname)
173
      ToStdout("Instance %s has been relocated", iname)
173 174
      good_cnt += 1
174 175
    except errors.GenericError, err:
175 176
      nret, msg = FormatError(err)
176 177
      retcode |= nret
177
      logger.ToStderr("Error replacing disks for instance %s: %s" %
178
                      (iname, msg))
178
      ToStderr("Error replacing disks for instance %s: %s", iname, msg)
179 179
      bad_cnt += 1
180 180

  
181 181
  if retcode == constants.EXIT_SUCCESS:
182
    logger.ToStdout("All %d instance(s) relocated successfully." % good_cnt)
182
    ToStdout("All %d instance(s) relocated successfully.", good_cnt)
183 183
  else:
184
    logger.ToStdout("There were errors during the relocation:\n"
185
                    "%d error(s) out of %d instance(s)." %
186
                    (bad_cnt, good_cnt + bad_cnt))
184
    ToStdout("There were errors during the relocation:\n"
185
             "%d error(s) out of %d instance(s).", bad_cnt, good_cnt + bad_cnt)
187 186
  return retcode
188 187

  
189 188

  
......
199 198
  node, pinst = result[0]
200 199

  
201 200
  if not pinst:
202
    logger.ToStderr("No primary instances on node %s, exiting." % node)
201
    ToStderr("No primary instances on node %s, exiting.", node)
203 202
    return 0
204 203

  
205 204
  pinst = utils.NiceSort(pinst)
......
215 214
    op = opcodes.OpFailoverInstance(instance_name=iname,
216 215
                                    ignore_consistency=opts.ignore_consistency)
217 216
    try:
218
      logger.ToStdout("Failing over instance %s" % iname)
217
      ToStdout("Failing over instance %s", iname)
219 218
      SubmitOpCode(op)
220
      logger.ToStdout("Instance %s has been failed over" % iname)
219
      ToStdout("Instance %s has been failed over", iname)
221 220
      good_cnt += 1
222 221
    except errors.GenericError, err:
223 222
      nret, msg = FormatError(err)
224 223
      retcode |= nret
225
      logger.ToStderr("Error failing over instance %s: %s" % (iname, msg))
224
      ToStderr("Error failing over instance %s: %s", iname, msg)
226 225
      bad_cnt += 1
227 226

  
228 227
  if retcode == 0:
229
    logger.ToStdout("All %d instance(s) failed over successfully." % good_cnt)
228
    ToStdout("All %d instance(s) failed over successfully.", good_cnt)
230 229
  else:
231
    logger.ToStdout("There were errors during the failover:\n"
232
                    "%d error(s) out of %d instance(s)." %
233
                    (bad_cnt, good_cnt + bad_cnt))
230
    ToStdout("There were errors during the failover:\n"
231
             "%d error(s) out of %d instance(s).", bad_cnt, good_cnt + bad_cnt)
234 232
  return retcode
235 233

  
236 234

  
......
244 242
  result = SubmitOpCode(op)
245 243

  
246 244
  for name, primary_ip, secondary_ip, pinst, sinst in result:
247
    logger.ToStdout("Node name: %s" % name)
248
    logger.ToStdout("  primary ip: %s" % primary_ip)
249
    logger.ToStdout("  secondary ip: %s" % secondary_ip)
245
    ToStdout("Node name: %s", name)
246
    ToStdout("  primary ip: %s", primary_ip)
247
    ToStdout("  secondary ip: %s", secondary_ip)
250 248
    if pinst:
251
      logger.ToStdout("  primary for instances:")
249
      ToStdout("  primary for instances:")
252 250
      for iname in pinst:
253
        logger.ToStdout("    - %s" % iname)
251
        ToStdout("    - %s", iname)
254 252
    else:
255
      logger.ToStdout("  primary for no instances")
253
      ToStdout("  primary for no instances")
256 254
    if sinst:
257
      logger.ToStdout("  secondary for instances:")
255
      ToStdout("  secondary for instances:")
258 256
      for iname in sinst:
259
        logger.ToStdout("    - %s" % iname)
257
        ToStdout("    - %s", iname)
260 258
    else:
261
      logger.ToStdout("  secondary for no instances")
259
      ToStdout("  secondary for no instances")
262 260

  
263 261
  return 0
264 262

  
......
301 299
                       numfields=numfields, data=output)
302 300

  
303 301
  for line in data:
304
    logger.ToStdout(line)
302
    ToStdout(line)
305 303

  
306 304
  return 0
307 305

  

Also available in: Unified diff