18. モジュール説明の表示# func "func01*" call servicemodule_descriptionon https://func01.example.org:51234 running service module_description ()Allows for service control via func.
24. virtモジュールの利用例results = fc.Client("*").virt.state()for ( host, vms ) in results.iteritems(): if vms[0] == 'REMOTE_ERROR':continuefor vm in vms: ( domain, state ) = vm.split(' ')if state == 'shutdown': fc.Client(host).virt.create(domain)
25. smartモジュールの利用例info = fc.Client("*").smart.info()for(host,details) in info.iteritems(): if type(details) != list:print"%s had an error : %s" % (host,str(details)) break (rc, list_of_output) = details if rc != 0:print"Host %s may have problems" % hostprint"\n".join(list_of_output[3:])
29. モジュールコードimport func_moduleclassTest(func_module.FuncModule): version = "11.11.11" api_version = "0.0.1" description = "Just a very simple example module"defadd(self, num1, num2):returnnum1 + num2defexception(self):raiseexceptions.Exception("khhhhhhaaaaaan!!!!!!")
30. func-create-module# func-create-moduleModule Name: exampleDescription: An example module.Author: Gosuke MiyashitaEmail: gosukenator@gmail.comLeave blank to finish.Method: mymethodMethod:Your module is ready to be hacked on. Wrote out to example.py.