direct-io.hg

changeset 11584:92bfc59726a4

[XM] Move 'xm sysrq' into main.py

* There's not need for sysrq to be in its own file.
* Bonus advantage: can use arg_check rather than gopts for argument
validation.

Signed-off-by: Alastair Tse <atse@xensource.com>
author atse@norwich.uk.xensource.com
date Fri Sep 22 16:32:30 2006 +0100 (2006-09-22)
parents e6388ec26a97
children 3499b3271e5f cdd03c7ec8d3
files tools/python/xen/xm/main.py tools/python/xen/xm/sysrq.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Fri Sep 22 16:20:36 2006 +0100
     1.2 +++ b/tools/python/xen/xm/main.py	Fri Sep 22 16:32:30 2006 +0100
     1.3 @@ -1010,6 +1010,12 @@ def xm_uptime(args):
     1.4  
     1.5          print upstring
     1.6  
     1.7 +def xm_sysrq(args):
     1.8 +    arg_check(args, "sysrq", 2)
     1.9 +    dom = args[0]
    1.10 +    req = args[1]
    1.11 +    server.xend.domain.send_sysrq(dom, req)    
    1.12 +
    1.13  def xm_top(args):
    1.14      arg_check(args, "top", 0)
    1.15  
    1.16 @@ -1318,6 +1324,7 @@ commands = {
    1.17      "restore": xm_restore,
    1.18      "save": xm_save,
    1.19      "shutdown": xm_shutdown,
    1.20 +    "sysrq": xm_sysrq,
    1.21      "uptime": xm_uptime,
    1.22      "list": xm_list,
    1.23      # memory commands
    1.24 @@ -1359,7 +1366,6 @@ commands = {
    1.25  IMPORTED_COMMANDS = [
    1.26      'create',
    1.27      'migrate',
    1.28 -    'sysrq',
    1.29      'labels',
    1.30      'addlabel',
    1.31      'cfgbootpolicy',
     2.1 --- a/tools/python/xen/xm/sysrq.py	Fri Sep 22 16:20:36 2006 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,30 +0,0 @@
     2.4 -# (C) Matthew Bloch <matthew@bytemark.co.uk> 2004
     2.5 -# Copyright (C) 2005 XenSource Ltd
     2.6 -
     2.7 -"""Domain sysrq.
     2.8 -"""
     2.9 -
    2.10 -from xen.xend.XendClient import server
    2.11 -from xen.xm.opts import *
    2.12 -
    2.13 -gopts = Opts(use="""[DOM] [letter]
    2.14 -
    2.15 -Sends a Linux sysrq to a domain.
    2.16 -""")
    2.17 -
    2.18 -gopts.opt('help', short='h',
    2.19 -         fn=set_true, default=0,
    2.20 -         use="Print this help.")
    2.21 -
    2.22 -def main(argv):
    2.23 -    opts = gopts
    2.24 -    args = opts.parse(argv)
    2.25 -
    2.26 -    if len(args) < 1:
    2.27 -        raise OptionError('Missing domain argument')
    2.28 -    if len(args) < 2:
    2.29 -        raise OptionError('Missing sysrq character')
    2.30 -
    2.31 -    dom = args[0]
    2.32 -    req = ord(args[1][0])
    2.33 -    server.xend.domain.send_sysrq(dom, req)