Revision b33e986b lib/cli.py

b/lib/cli.py
35 35
from ganeti import constants
36 36
from ganeti import opcodes
37 37
from ganeti import luxi
38
from ganeti import ssconf
38 39

  
39 40
from optparse import (OptionParser, make_option, TitledHelpFormatter,
40 41
                      Option, OptionValueError)
......
377 378

  
378 379
  """
379 380
  if cl is None:
380
    cl = luxi.Client()
381
    cl = GetClient()
381 382

  
382 383
  job_id = cl.SubmitJob([op])
383 384

  
......
414 415

  
415 416
def GetClient():
416 417
  # TODO: Cache object?
417
  return luxi.Client()
418
  try:
419
    client = luxi.Client()
420
  except luxi.NoMasterError:
421
    master, myself = ssconf.GetMasterAndMyself()
422
    if master != myself:
423
      raise errors.OpPrereqError("This is not the master node, please connect"
424
                                 " to node '%s' and rerun the command" %
425
                                 master)
426
    else:
427
      raise
428
  return client
418 429

  
419 430

  
420 431
def FormatError(err):

Also available in: Unified diff