[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [XM] Add commands to implement lifecycle commands via the XM XMLRPC interface.



# HG changeset patch
# User Alastair Tse <atse@xxxxxxxxxxxxx>
# Node ID 2bc0831859cba6d559310643a9181d94e6ace857
# Parent  aab988d497eadd058087c615a3882ebec56770bb
[XM] Add commands to implement lifecycle commands via the XM XMLRPC interface.

Signed-off-by: Alastair Tse <atse@xxxxxxxxxxxxx>
---
 tools/python/xen/xm/create.py |   20 ++++++++++++++++-
 tools/python/xen/xm/main.py   |   47 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 4 deletions(-)

diff -r aab988d497ea -r 2bc0831859cb tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Thu Oct 05 17:29:19 2006 +0100
+++ b/tools/python/xen/xm/create.py     Thu Oct 05 17:29:19 2006 +0100
@@ -438,6 +438,21 @@ gopts.var('uuid', val='',
           will be randomly generated if this option is not set, just like MAC 
           addresses for virtual network interfaces.  This must be a unique 
           value across the entire cluster.""")
+
+gopts.var('autostart', val='no|yes',
+          fn=set_bool, default=0,
+          use="Should the start VM automatically when Xend starts.")
+
+gopts.var('autostop', val='no|yes',
+          fn=set_bool, default=0,
+          use="Should stop VM automatically when Xend stops.")
+
+gopts.var('on_xend_stop', val='shtudown|suspend',
+          fn=set_value, default="shutdown",
+          use="""Behaviour when Xend stops and autostop is on:
+          - shutdown:       Domain is shutdown;
+          - suspend:        Domain is suspended;
+          """)
 
 def err(msg):
     """Print an error to stderr and exit.
@@ -668,8 +683,9 @@ def make_config(vals):
                 config.append([n, v])
 
     map(add_conf, ['name', 'memory', 'maxmem', 'shadow_memory',
-                   'restart', 'on_poweroff', 'on_reboot', 'on_crash',
-                   'vcpus', 'features'])
+                   'restart', 'on_poweroff',
+                   'on_reboot', 'on_crash', 'vcpus', 'features',
+                   'autostart', 'autostop', 'on_xend_stop'])
 
     if vals.uuid is not None:
         config.append(['uuid', vals.uuid])
diff -r aab988d497ea -r 2bc0831859cb tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu Oct 05 17:29:19 2006 +0100
+++ b/tools/python/xen/xm/main.py       Thu Oct 05 17:29:19 2006 +0100
@@ -91,6 +91,15 @@ SUBCOMMAND_HELP = {
     'top'         : ('', 'Monitor a host and the domains in real time.'),
     'unpause'     : ('<Domain>', 'Unpause a paused domain.'),
     'uptime'      : ('[-s] <Domain>', 'Print uptime for a domain.'),
+
+    # Life cycle xm commands
+    'new'         : ('<ConfigFile> [options] [vars]',
+                     'Adds a domain to Xend domain management'),
+    'delete'      : ('<DomainName>',
+                     'Remove a domain from Xend domain management.'),
+    'start'       : ('<DomainName>', 'Start a Xend managed domain'),
+    'resume'      : ('<DomainName>', 'Resume a Xend managed domain'),
+    'suspend'     : ('<DomainName>', 'Suspend a Xend maanged domain'),
 
     # less used commands
 
@@ -194,6 +203,8 @@ common_commands = [
 common_commands = [
     "console",
     "create",
+    "new",
+    "delete",
     "destroy",
     "dump-core",
     "help",
@@ -203,8 +214,11 @@ common_commands = [
     "pause",
     "reboot",
     "restore",
+    "resume",
     "save",
     "shutdown",
+    "start",
+    "suspend",
     "top",
     "unpause",
     "uptime",
@@ -214,6 +228,8 @@ domain_commands = [
 domain_commands = [
     "console",
     "create",
+    "new",
+    "delete",
     "destroy",
     "domid",
     "domname",
@@ -226,8 +242,11 @@ domain_commands = [
     "reboot",
     "rename",
     "restore",
+    "resume",
     "save",
     "shutdown",
+    "start",
+    "suspend",
     "sysrq",
     "top",
     "unpause",
@@ -678,6 +697,26 @@ def xm_vcpu_list(args):
 
             print format % locals()
 
+def xm_start(args):
+    arg_check(args, "start", 1)
+    dom = args[0]
+    server.xend.domain.start(dom)
+
+def xm_delete(args):
+    arg_check(args, "delete", 1)
+    dom = args[0]
+    server.xend.domain.delete(dom)
+
+def xm_suspend(args):
+    arg_check(args, "suspend", 1)
+    dom = args[0]
+    server.xend.domain.suspend(dom)
+
+def xm_resume(args):
+    arg_check(args, "resume", 1)
+    dom = args[0]
+    server.xend.domain.resume(dom)
+    
 def xm_reboot(args):
     arg_check(args, "reboot", 1, 3)
     from xen.xm import shutdown
@@ -1318,6 +1357,7 @@ commands = {
     # xenstat commands
     "top": xm_top,
     # domain commands
+    "delete": xm_delete,
     "destroy": xm_destroy,
     "domid": xm_domid,
     "domname": xm_domname,
@@ -1327,8 +1367,10 @@ commands = {
     "restore": xm_restore,
     "save": xm_save,
     "shutdown": xm_shutdown,
+    "start": xm_start,
     "sysrq": xm_sysrq,
     "uptime": xm_uptime,
+    "suspend": xm_suspend,
     "list": xm_list,
     # memory commands
     "mem-max": xm_mem_max,
@@ -1368,13 +1410,14 @@ commands = {
 ## The commands supported by a separate argument parser in xend.xm.
 IMPORTED_COMMANDS = [
     'create',
+    'new',    
     'migrate',
     'labels',
-    'addlabel',
     'cfgbootpolicy',
     'makepolicy',
     'loadpolicy',
-    'dumppolicy',
+    'dumppolicy',        
+    'addlabel',
     'rmlabel',
     'getlabel',
     'dry-run',

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.