Trees | Indices | Help |
---|
|
1 # -*- Mode: Python -*- 2 # vi:si:et:sw=4:sts=4:ts=4 3 4 # Flumotion - a streaming media server 5 # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L. 6 # Copyright (C) 2010,2011 Flumotion Services, S.A. 7 # All rights reserved. 8 # 9 # This file may be distributed and/or modified under the terms of 10 # the GNU Lesser General Public License version 2.1 as published by 11 # the Free Software Foundation. 12 # This file is distributed without any warranty; without even the implied 13 # warranty of merchantability or fitness for a particular purpose. 14 # See "LICENSE.LGPL" in the source distribution for more information. 15 # 16 # Headers in this file shall remain intact. 17 18 """ 19 manager commands 20 """ 21 22 import os 23 24 from twisted.spread import flavors 25 26 from flumotion.common import errors, log 27 from flumotion.monitor.nagios import util 28 29 from flumotion.admin.command import common 30 31 __version__ = "$Rev: 6562 $" 32 3335 usage = "[method-name] [arguments]" 36 summary = "invoke a method on a manager" 37 description = """Invoke a method on a manager. 38 %s 39 For a list of methods that can be invoked, see the admin's avatar class 40 in flumotion.manager.admin and its perspective_* methods. 41 42 Note that not all of them can be invoked if you have no way of passing the 43 needed arguments (for example, componentStart needs a componentState) 44 45 Examples: getConfiguration, getVersions 46 """ % common.ARGUMENTS_DESCRIPTION 4778 79 d.addCallback(cb) 80 d.addErrback(eb) 81 82 return d 83 8449 try: 50 methodName = args[0] 51 except IndexError: 52 common.errorRaise('Please specify a method name.') 53 54 if len(args) > 1: 55 args = common.parseTypedArgs(args[1], args[2:]) 56 if args is None: 57 common.errorRaise('Could not parse arguments.') 58 else: 59 args = [] 60 61 d = self.getRootCommand().medium.callRemote( 62 methodName, *args) 63 64 def cb(result): 65 import pprint 66 self.stdout.write("Invoking '%s' on manager returned:\n%s\n" % ( 67 methodName, pprint.pformat(result)))68 69 def eb(failure): 70 # FIXME 71 if failure.check(errors.NoMethodError) \ 72 or failure.check(flavors.NoSuchMethod): 73 common.errorRaise("No method '%s' on manager." % methodName) 74 elif failure.check(errors.RemoteRunError): 75 common.errorRaise(log.getFailureMessage(failure)) 76 else: 77 common.errorRaise(log.getFailureMessage(failure))86 usage = "[configuration-file]" 87 summary = "load a configuration onto the manager." 88107 108 11390 try: 91 filePath = args[0] 92 except IndexError: 93 common.errorRaise('Please specify a configuration file') 94 95 if not os.path.exists(filePath): 96 common.errorRaise("'%s' does not exist." % filePath) 97 98 d = self.getRootCommand().medium.callRemote('loadConfiguration', 99 open(filePath).read()) 100 101 def eb(failure): 102 common.errorRaise(log.getFailureMessage(failure))103 104 d.addErrback(eb) 105 106 return d
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Aug 13 06:17:24 2013 | http://epydoc.sourceforge.net |