Revision e0e916fe

b/daemons/ganeti-masterd
402 402
  return until
403 403

  
404 404

  
405
@rpc.RunWithRPC
405 406
def CheckAgreement():
406 407
  """Check the agreement on who is the master.
407 408

  
......
462 463
  return result
463 464

  
464 465

  
465
def CheckAgreementWithRpc():
466
  rpc.Init()
467
  try:
468
    return CheckAgreement()
469
  finally:
470
    rpc.Shutdown()
471

  
472

  
473 466
def CheckMasterd(options, args):
474 467
  """Initial checks whether to run or exit with a failure.
475 468

  
......
509 502

  
510 503
  # CheckAgreement uses RPC and threads, hence it needs to be run in a separate
511 504
  # process before we call utils.Daemonize in the current process.
512
  if not utils.RunInSeparateProcess(CheckAgreementWithRpc):
505
  if not utils.RunInSeparateProcess(CheckAgreement):
513 506
    sys.exit(constants.EXIT_FAILURE)
514 507

  
515 508

  
b/lib/cli.py
1192 1192
    return [os_name]
1193 1193

  
1194 1194

  
1195
def UsesRPC(fn):
1196
  def wrapper(*args, **kwargs):
1197
    rpc.Init()
1198
    try:
1199
      return fn(*args, **kwargs)
1200
    finally:
1201
      rpc.Shutdown()
1202
  return wrapper
1195
UsesRPC = rpc.RunWithRPC
1203 1196

  
1204 1197

  
1205 1198
def AskUser(text, choices=None):
b/lib/rpc.py
151 151
  return decorator
152 152

  
153 153

  
154
def RunWithRPC(fn):
155
  """RPC-wrapper decorator.
156

  
157
  When applied to a function, it runs it with the RPC system
158
  initialized, and it shutsdown the system afterwards. This means the
159
  function must be called without RPC being initialized.
160

  
161
  """
162
  def wrapper(*args, **kwargs):
163
    Init()
164
    try:
165
      return fn(*args, **kwargs)
166
    finally:
167
      Shutdown()
168
  return wrapper
169

  
170

  
154 171
class RpcResult(object):
155 172
  """RPC Result class.
156 173

  

Also available in: Unified diff