Skip to contentSkip to conversation

Lifecycle Patches 1/7

RFC New Ewan Mellor 1 participant 1 message Jul 14, 2006

lore
Share & tools
lore
#0 lore raw

RFC 1/1 Lifecycle Patches 1/7

Xend lifecycle changes -- basic functionality.

 xend/XendDomain.py          |  287 ++++++++++++++++++++++++++++++++++----------
 xend/XendDomainInfo.py      |  203 +++++++++++++++++++++++--------
 xend/XendRoot.py            |    8 +
 xend/server/XMLRPCServer.py |    2
 xm/create.py                |    4
 xm/main.py                  |   29 +++-
 xm/new.py                   |   68 ++++++++++
 7 files changed, 485 insertions(+), 116 deletions(-)
tools/python/xen/xm/new.py new file +68 -0
Index: xen/tools/python/xen/xm/new.py
===================================================================
@@ -0,0 +1,68 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#============================================================================
+# Copyright (c) 2006 XenSource, Inc.
+#============================================================================
+
+import os
+import xmlrpclib
+
+from xen.xend import PrettyPrint
+from xen.xend import sxp
+import xen.xend.XendClient
+from xen.xend.XendClient import server
+
+from xen.xm.opts import *
+from create import *
+
+def make_domain(opts, config):
+    """Create an unstarted domain.
+
+    @param opts:   options
+    @param config: configuration
+    """
+    try:
+        server.xend.domain.new(config)
+    except xmlrpclib.Fault, ex:
+        import signal
+        if vncpid:
+            os.kill(vncpid, signal.SIGKILL)
+        if ex.faultCode == xen.xend.XendClient.ERROR_INVALID_DOMAIN:
+            err("the domain '%s' does not exist." % ex.faultString)
+        else:
+            err("%s" % ex.faultString)
+    except Exception, ex:
+        import signal
+        if vncpid:
+            os.kill(vncpid, signal.SIGKILL)
+        err(str(ex))
+
+
+def main(argv):
+    try:
+        (opts, config) = parseCommandLine(argv)
+    except StandardError, ex:
+        err(str(ex))
+
+    if not opts:
+        return
+
+    if opts.vals.dryrun:
+        PrettyPrint.prettyprint(config)
+    else:
+        make_domain(opts, config)
+        
+if __name__ == '__main__':
+    main(sys.argv)
+        
tools/python/xen/xend/XendRoot.py +8 -0
Index: xen/tools/python/xen/xend/XendRoot.py
===================================================================
@@ -96,6 +96,9 @@
 
     dom0_vcpus_default = '0'
 
+    """Default session storage path."""
+    xend_domains_path_default = '/var/lib/xend/domains'
+
     components = {}
 
     def __init__(self):
@@ -240,6 +243,11 @@
         """
         return self.get_config_value("xend-unix-path", self.xend_unix_path_default)
 
+    def get_xend_domains_path(self):
+        """ Get the path for persistent domain configuration storage
+        """
+        return self.get_config_value("xend-domains-path", self.xend_domains_path_default)
+
     def get_network_script(self):
         """@return the script used to alter the network configuration when
         Xend starts and stops, or None if no such script is specified."""
tools/python/xen/xend/XendDomain.py +227 -60

417 lines not on this page · raw message

tools/python/xen/xend/XendDomainInfo.py +153 -50

435 lines not on this page · raw message

tools/python/xen/xm/main.py +26 -3
Index: xen/tools/python/xen/xm/main.py
===================================================================
@@ -54,7 +54,11 @@
 # Strings for shorthelp
 console_help = "console <DomId>                  Attach to domain DomId's console."
 create_help =  """create [-c] <ConfigFile>
-               [Name=Value]..       Create a domain based on Config File"""
+          [Name=Value]..            Create and start a domain based on
+                                    ConfigFile"""
+new_help =     """new [-c] <ConfigFile>
+          [Name=Value]..            Create a domain based on ConfigFile"""
+delete_help =  """delete <DomName>      Remove a persistent domain"""
 destroy_help = "destroy <DomId>                  Terminate a domain immediately"
 help_help =    "help                             Display this message"
 list_help =    "list [--long] [DomId, ...]       List information about domains"
@@ -68,6 +72,7 @@
 restore_help = "restore <File>                   Create a domain from a saved state file"
 save_help =    "save <DomId> <File>              Save domain state (and config) to file"
 shutdown_help ="shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain"
+start_help    ="start <DomId>                    Start a halted domain."
 top_help =     "top                              Monitor system and domains in real-time"
 unpause_help = "unpause <DomId>                  Unpause a paused domain"
 
@@ -135,6 +140,8 @@
 short_command_list = [
     "console",
     "create",
+    "new",
+    "delete",
     "destroy",
     "help",
     "list",
@@ -145,6 +152,7 @@
     "restore",
     "save",
     "shutdown",
+    "start",
     "top",
     "unpause",
     "vcpu-set",
@@ -153,6 +161,8 @@
 domain_commands = [
     "console",
     "create",
+    "new",
+    "delete",
     "destroy",
     "domid",
     "domname",
@@ -167,6 +177,7 @@
     "restore",
     "save",
     "shutdown",
+    "start",
     "sysrq",
     "top",
     "unpause",
@@ -274,7 +285,7 @@
 
 for command in all_commands:
     # create is handled specially
-    if (command != 'create'):
+    if (command not in ('create', 'new')):
         help[command] = commandToHelp(command)
 
 
@@ -563,7 +574,16 @@
                 "%(name)-32s %(domid)3d  %(number)4d  %(c)3s   %(s)-3s   %(cpu_time)7.1f  %(cpumap)s" %
                 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_reboot(args):
     arg_check(args, "reboot", 1, 3)
     from xen.xm import shutdown
@@ -1102,6 +1122,8 @@
     # xenstat commands
     "top": xm_top,
     # domain commands
+    "start": xm_start,
+    "delete": xm_delete,
     "destroy": xm_destroy,
     "domid": xm_domid,
     "domname": xm_domname,
@@ -1149,6 +1171,7 @@
 ## The commands supported by a separate argument parser in xend.xm.
 subcommands = [
     'create',
+    'new',    
     'migrate',
     'sysrq',
     'shutdown',
@@ -1196,7 +1219,7 @@
         "Command %s is deprecated.  Please use xm %s instead." % (old, new))
 
 def usage(cmd=None):
-    if cmd == 'create':
+    if cmd in ('create', 'new'):
         mycmd = xm_lookup_cmd(cmd)
         mycmd( ['--help'] )
         sys.exit(1)
tools/python/xen/xend/server/XMLRPCServer.py +1 -1
Index: xen/tools/python/xen/xend/server/XMLRPCServer.py
===================================================================
@@ -76,7 +76,7 @@
 
 methods = ['device_create', 'destroyDevice', 'getDeviceSxprs',
            'setMemoryTarget', 'setName', 'setVCpuCount', 'shutdown',
-           'send_sysrq', 'getVCPUInfo', 'waitForDevices']
+           'start', 'send_sysrq', 'getVCPUInfo', 'waitForDevices']
 
 exclude = ['domain_create', 'domain_restore']
 
tools/python/xen/xm/create.py +2 -2
Index: xen/tools/python/xen/xm/create.py
===================================================================
@@ -897,7 +897,7 @@
     return d
 
 
-def make_domain(opts, config):
+def make_domain_and_start(opts, config):
     """Create, build and start a domain.
 
     @param opts:   options
@@ -1118,7 +1118,7 @@
         if not create_security_check(config):
             print "Security configuration prevents domain from starting"
         else:
-            dom = make_domain(opts, config)
+            dom = make_domain_and_start(opts, config)
             if opts.vals.console_autoconnect:
                 console.execConsole(dom)
         

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel