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 Fluendo, S.L. (www.fluendo.com). 6 # All rights reserved. 7 8 # This file may be distributed and/or modified under the terms of 9 # the GNU General Public License version 2 as published by 10 # the Free Software Foundation. 11 # This file is distributed without any warranty; without even the implied 12 # warranty of merchantability or fitness for a particular purpose. 13 # See "LICENSE.GPL" in the source distribution for more information. 14 15 # Licensees having purchased or holding a valid Flumotion Advanced 16 # Streaming Server license may use this file in accordance with the 17 # Flumotion Advanced Streaming Server Commercial License Agreement. 18 # See "LICENSE.Flumotion" in the source distribution for more information. 19 20 # Headers in this file shall remain intact. 21 22 """ 23 manager commands 24 """ 25 26 import os 27 28 from twisted.spread import flavors 29 from twisted.python import failure 30 31 from flumotion.common import errors, log 32 from flumotion.monitor.nagios import util 33 34 from flumotion.admin.command import common 35 36 __version__ = "$Rev: 6562 $" 37 3840 usage = "[method-name] [arguments]" 41 summary = "invoke a method on a manager" 42 description = """Invoke a method on a manager. 43 %s 44 For a list of methods that can be invoked, see the admin's avatar class 45 in flumotion.manager.admin and its perspective_* methods. 46 47 Note that not all of them can be invoked if you have no way of passing the 48 needed arguments (for example, componentStart needs a componentState) 49 50 Examples: getConfiguration, getVersions 51 """ % common.ARGUMENTS_DESCRIPTION 5283 84 d.addCallback(cb) 85 d.addErrback(eb) 86 87 return d 88 8954 try: 55 methodName = args[0] 56 except IndexError: 57 common.errorRaise('Please specify a method name.') 58 59 if len(args) > 1: 60 args = common.parseTypedArgs(args[1], args[2:]) 61 if args is None: 62 common.errorRaise('Could not parse arguments.') 63 else: 64 args = [] 65 66 d = self.getRootCommand().medium.callRemote( 67 methodName, *args) 68 69 def cb(result): 70 import pprint 71 self.stdout.write("Invoking '%s' on manager returned:\n%s\n" % ( 72 methodName, pprint.pformat(result)))73 74 def eb(failure): 75 # FIXME 76 if failure.check(errors.NoMethodError) \ 77 or failure.check(flavors.NoSuchMethod): 78 common.errorRaise("No method '%s' on manager." % methodName) 79 elif failure.check(errors.RemoteRunError): 80 common.errorRaise(log.getFailureMessage(failure)) 81 else: 82 common.errorRaise(log.getFailureMessage(failure))91 usage = "[configuration-file]" 92 summary = "load a configuration onto the manager." 93112 113 11895 try: 96 filePath = args[0] 97 except IndexError: 98 common.errorRaise('Please specify a configuration file') 99 100 if not os.path.exists(filePath): 101 common.errorRaise("'%s' does not exist." % filePath) 102 103 d = self.getRootCommand().medium.callRemote('loadConfiguration', 104 open(filePath).read()) 105 106 def eb(failure): 107 common.errorRaise(log.getFailureMessage(failure))108 109 d.addErrback(eb) 110 111 return d
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Jul 9 00:07:22 2010 | http://epydoc.sourceforge.net |