Revision 4331f6cd lib/cli.py

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

  
40 41
from optparse import (OptionParser, make_option, TitledHelpFormatter,
41 42
                      Option, OptionValueError)
......
51 52
           "JobSubmittedException", "FormatTimestamp", "ParseTimespec",
52 53
           "ValidateBeParams",
53 54
           "ToStderr", "ToStdout",
55
           "UsesRPC",
54 56
           ]
55 57

  
56 58

  
......
424 426
      raise errors.ParameterError("Invalid number of VCPUs")
425 427

  
426 428

  
429
def UsesRPC(fn):
430
  def wrapper(*args, **kwargs):
431
    rpc.Init()
432
    try:
433
      return fn(*args, **kwargs)
434
    finally:
435
      rpc.Shutdown()
436
  return wrapper
437

  
438

  
427 439
def AskUser(text, choices=None):
428 440
  """Ask the user a question.
429 441

  

Also available in: Unified diff