ia64/xen-unstable

changeset 12092:2bc0831859cb

[XM] Add commands to implement lifecycle commands via the XM XMLRPC interface.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Oct 05 17:29:19 2006 +0100 (2006-10-05)
parents aab988d497ea
children edb546bbfff0
files tools/python/xen/xm/create.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/create.py	Thu Oct 05 17:29:19 2006 +0100
     1.2 +++ b/tools/python/xen/xm/create.py	Thu Oct 05 17:29:19 2006 +0100
     1.3 @@ -439,6 +439,21 @@ gopts.var('uuid', val='',
     1.4            addresses for virtual network interfaces.  This must be a unique 
     1.5            value across the entire cluster.""")
     1.6  
     1.7 +gopts.var('autostart', val='no|yes',
     1.8 +          fn=set_bool, default=0,
     1.9 +          use="Should the start VM automatically when Xend starts.")
    1.10 +
    1.11 +gopts.var('autostop', val='no|yes',
    1.12 +          fn=set_bool, default=0,
    1.13 +          use="Should stop VM automatically when Xend stops.")
    1.14 +
    1.15 +gopts.var('on_xend_stop', val='shtudown|suspend',
    1.16 +          fn=set_value, default="shutdown",
    1.17 +          use="""Behaviour when Xend stops and autostop is on:
    1.18 +          - shutdown:       Domain is shutdown;
    1.19 +          - suspend:        Domain is suspended;
    1.20 +          """)
    1.21 +
    1.22  def err(msg):
    1.23      """Print an error to stderr and exit.
    1.24      """
    1.25 @@ -668,8 +683,9 @@ def make_config(vals):
    1.26                  config.append([n, v])
    1.27  
    1.28      map(add_conf, ['name', 'memory', 'maxmem', 'shadow_memory',
    1.29 -                   'restart', 'on_poweroff', 'on_reboot', 'on_crash',
    1.30 -                   'vcpus', 'features'])
    1.31 +                   'restart', 'on_poweroff',
    1.32 +                   'on_reboot', 'on_crash', 'vcpus', 'features',
    1.33 +                   'autostart', 'autostop', 'on_xend_stop'])
    1.34  
    1.35      if vals.uuid is not None:
    1.36          config.append(['uuid', vals.uuid])
     2.1 --- a/tools/python/xen/xm/main.py	Thu Oct 05 17:29:19 2006 +0100
     2.2 +++ b/tools/python/xen/xm/main.py	Thu Oct 05 17:29:19 2006 +0100
     2.3 @@ -92,6 +92,15 @@ SUBCOMMAND_HELP = {
     2.4      'unpause'     : ('<Domain>', 'Unpause a paused domain.'),
     2.5      'uptime'      : ('[-s] <Domain>', 'Print uptime for a domain.'),
     2.6  
     2.7 +    # Life cycle xm commands
     2.8 +    'new'         : ('<ConfigFile> [options] [vars]',
     2.9 +                     'Adds a domain to Xend domain management'),
    2.10 +    'delete'      : ('<DomainName>',
    2.11 +                     'Remove a domain from Xend domain management.'),
    2.12 +    'start'       : ('<DomainName>', 'Start a Xend managed domain'),
    2.13 +    'resume'      : ('<DomainName>', 'Resume a Xend managed domain'),
    2.14 +    'suspend'     : ('<DomainName>', 'Suspend a Xend maanged domain'),
    2.15 +
    2.16      # less used commands
    2.17  
    2.18      'dmesg'       : ('[-c|--clear]',
    2.19 @@ -194,6 +203,8 @@ SUBCOMMAND_OPTIONS = {
    2.20  common_commands = [
    2.21      "console",
    2.22      "create",
    2.23 +    "new",
    2.24 +    "delete",
    2.25      "destroy",
    2.26      "dump-core",
    2.27      "help",
    2.28 @@ -203,8 +214,11 @@ common_commands = [
    2.29      "pause",
    2.30      "reboot",
    2.31      "restore",
    2.32 +    "resume",
    2.33      "save",
    2.34      "shutdown",
    2.35 +    "start",
    2.36 +    "suspend",
    2.37      "top",
    2.38      "unpause",
    2.39      "uptime",
    2.40 @@ -214,6 +228,8 @@ common_commands = [
    2.41  domain_commands = [
    2.42      "console",
    2.43      "create",
    2.44 +    "new",
    2.45 +    "delete",
    2.46      "destroy",
    2.47      "domid",
    2.48      "domname",
    2.49 @@ -226,8 +242,11 @@ domain_commands = [
    2.50      "reboot",
    2.51      "rename",
    2.52      "restore",
    2.53 +    "resume",
    2.54      "save",
    2.55      "shutdown",
    2.56 +    "start",
    2.57 +    "suspend",
    2.58      "sysrq",
    2.59      "top",
    2.60      "unpause",
    2.61 @@ -678,6 +697,26 @@ def xm_vcpu_list(args):
    2.62  
    2.63              print format % locals()
    2.64  
    2.65 +def xm_start(args):
    2.66 +    arg_check(args, "start", 1)
    2.67 +    dom = args[0]
    2.68 +    server.xend.domain.start(dom)
    2.69 +
    2.70 +def xm_delete(args):
    2.71 +    arg_check(args, "delete", 1)
    2.72 +    dom = args[0]
    2.73 +    server.xend.domain.delete(dom)
    2.74 +
    2.75 +def xm_suspend(args):
    2.76 +    arg_check(args, "suspend", 1)
    2.77 +    dom = args[0]
    2.78 +    server.xend.domain.suspend(dom)
    2.79 +
    2.80 +def xm_resume(args):
    2.81 +    arg_check(args, "resume", 1)
    2.82 +    dom = args[0]
    2.83 +    server.xend.domain.resume(dom)
    2.84 +    
    2.85  def xm_reboot(args):
    2.86      arg_check(args, "reboot", 1, 3)
    2.87      from xen.xm import shutdown
    2.88 @@ -1318,6 +1357,7 @@ commands = {
    2.89      # xenstat commands
    2.90      "top": xm_top,
    2.91      # domain commands
    2.92 +    "delete": xm_delete,
    2.93      "destroy": xm_destroy,
    2.94      "domid": xm_domid,
    2.95      "domname": xm_domname,
    2.96 @@ -1327,8 +1367,10 @@ commands = {
    2.97      "restore": xm_restore,
    2.98      "save": xm_save,
    2.99      "shutdown": xm_shutdown,
   2.100 +    "start": xm_start,
   2.101      "sysrq": xm_sysrq,
   2.102      "uptime": xm_uptime,
   2.103 +    "suspend": xm_suspend,
   2.104      "list": xm_list,
   2.105      # memory commands
   2.106      "mem-max": xm_mem_max,
   2.107 @@ -1368,13 +1410,14 @@ commands = {
   2.108  ## The commands supported by a separate argument parser in xend.xm.
   2.109  IMPORTED_COMMANDS = [
   2.110      'create',
   2.111 +    'new',    
   2.112      'migrate',
   2.113      'labels',
   2.114 -    'addlabel',
   2.115      'cfgbootpolicy',
   2.116      'makepolicy',
   2.117      'loadpolicy',
   2.118 -    'dumppolicy',
   2.119 +    'dumppolicy',        
   2.120 +    'addlabel',
   2.121      'rmlabel',
   2.122      'getlabel',
   2.123      'dry-run',