direct-io.hg

changeset 8288:231686596796

Move xm destroy handling out of crufty destroy.py and into main.py, where it
can share the better argument parsing.

Closes bug #443.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Thu Dec 08 14:30:15 2005 +0000 (2005-12-08)
parents fa1a93f3a322
children 76bff6c996b0
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/destroy.py	Thu Dec 08 14:28:53 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,41 +0,0 @@
     1.4 -#============================================================================
     1.5 -# This library is free software; you can redistribute it and/or
     1.6 -# modify it under the terms of version 2.1 of the GNU Lesser General Public
     1.7 -# License as published by the Free Software Foundation.
     1.8 -#
     1.9 -# This library is distributed in the hope that it will be useful,
    1.10 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.11 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.12 -# Lesser General Public License for more details.
    1.13 -#
    1.14 -# You should have received a copy of the GNU Lesser General Public
    1.15 -# License along with this library; if not, write to the Free Software
    1.16 -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.17 -#============================================================================
    1.18 -# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
    1.19 -#============================================================================
    1.20 -
    1.21 -"""Destroy a domain.
    1.22 -"""
    1.23 -
    1.24 -from xen.xend.XendClient import server
    1.25 -from xen.xm.opts import *
    1.26 -
    1.27 -gopts = Opts(use="""[DOM]
    1.28 -
    1.29 -Destroy a domain.
    1.30 -""")
    1.31 -
    1.32 -gopts.opt('help', short='h',
    1.33 -         fn=set_true, default=0,
    1.34 -         use="Print this help.")
    1.35 -
    1.36 -def main(argv):
    1.37 -    opts = gopts
    1.38 -    args = opts.parse(argv)
    1.39 -    if opts.vals.help:
    1.40 -        opts.usage()
    1.41 -        return
    1.42 -    if len(args) < 1: opts.err('Missing domain')
    1.43 -    dom = args[0]
    1.44 -    server.xend_domain_destroy(dom)
     2.1 --- a/tools/python/xen/xm/main.py	Thu Dec 08 14:28:53 2005 +0000
     2.2 +++ b/tools/python/xen/xm/main.py	Thu Dec 08 14:30:15 2005 +0000
     2.3 @@ -577,6 +577,13 @@ def xm_vcpu_set(args):
     2.4      from xen.xend.XendClient import server
     2.5      server.xend_domain_set_vcpus(args[0], int(args[1]))
     2.6  
     2.7 +
     2.8 +def xm_destroy(args):
     2.9 +    arg_check(args, "destroy", 1)
    2.10 +    from xen.xend.XendClient import server
    2.11 +    server.xend_domain_destroy(args[0])
    2.12 +
    2.13 +
    2.14  def xm_domid(args):
    2.15      arg_check(args, "domid", 1)
    2.16  
    2.17 @@ -783,6 +790,7 @@ commands = {
    2.18      # xenstat commands
    2.19      "top": xm_top,
    2.20      # domain commands
    2.21 +    "destroy": xm_destroy,
    2.22      "domid": xm_domid,
    2.23      "domname": xm_domname,
    2.24      "rename": xm_rename,
    2.25 @@ -825,7 +833,6 @@ commands = {
    2.26  ## The commands supported by a separate argument parser in xend.xm.
    2.27  subcommands = [
    2.28      'create',
    2.29 -    'destroy',
    2.30      'migrate',
    2.31      'sysrq',
    2.32      'shutdown'