diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 3a62d29adec4cf1fde08cc823077fa9a2b1e8815..a24b407776e50dfd21e60a83796fec6fc936a6ee 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1 +1 @@ -dist_sbin_SCRIPTS = gnt-instance gnt-cluster gnt-node gnt-os gnt-backup +dist_sbin_SCRIPTS = gnt-instance gnt-cluster gnt-node gnt-os gnt-backup gnt-debug diff --git a/scripts/gnt-debug b/scripts/gnt-debug new file mode 100644 index 0000000000000000000000000000000000000000..e5700993a66b10cc03ba393d2121f68629182601 --- /dev/null +++ b/scripts/gnt-debug @@ -0,0 +1,66 @@ +#!/usr/bin/python +# + +# Copyright (C) 2006, 2007 Google Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + + +import sys +import os +import itertools +from optparse import make_option +from cStringIO import StringIO + +from ganeti.cli import * +from ganeti import opcodes +from ganeti import logger +from ganeti import constants +from ganeti import utils +from ganeti import errors + + +def Delay(opts, args): + """Sleeps for a while + + """ + delay = float(args[0]) + op = opcodes.OpTestDelay(duration=delay, + on_master=opts.on_master, + on_nodes=opts.on_nodes) + + job = opcodes.Job(op_list=[op]) + jid = SubmitJob(job) + print "Job id", jid + return 0 + + +commands = { + 'delay': (Delay, ARGS_ONE, + [DEBUG_OPT, + make_option("--no-master", dest="on_master", default=True, + action="store_false", + help="Do not sleep in the master code"), + make_option("-n", dest="on_nodes", default=[], + action="append", + help="Select nodes to sleep on"), + ], + "[opts...] <duration>", "Executes a TestDelay OpCode"), + } + + +if __name__ == '__main__': + sys.exit(GenericMain(commands))