WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Added Xen-API support to xm shutdown.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Added Xen-API support to xm shutdown.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 Mar 2007 05:30:08 -0700
Delivery-date: Thu, 15 Mar 2007 05:29:51 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1173904077 0
# Node ID 192bee4b09a6a90f226b81e2cfc1356bf9df595e
# Parent  817647aff01f2770aa60064cac0445a2169a18b3
Added Xen-API support to xm shutdown.

Signed-off-by: Tom Wilkie <tom.wilkie@xxxxxxxxx>
---
 tools/python/xen/xm/shutdown.py |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)

diff -r 817647aff01f -r 192bee4b09a6 tools/python/xen/xm/shutdown.py
--- a/tools/python/xen/xm/shutdown.py   Wed Mar 14 14:18:51 2007 -0700
+++ b/tools/python/xen/xm/shutdown.py   Wed Mar 14 20:27:57 2007 +0000
@@ -21,7 +21,8 @@ import time
 
 from xen.xend import sxp
 from opts import *
-from main import server
+from main import server, serverType, SERVER_XEN_API, get_single_vm
+from xen.xend.XendAPIConstants import *
 
 gopts = Opts(use="""[options] [DOM]
 
@@ -49,6 +50,9 @@ gopts.opt('reboot', short='R',
           use='Shutdown and reboot.')
 
 def wait_reboot(opts, doms, rcs):
+    if serverType == SERVER_XEN_API:
+           opts.err("Cannot wait for reboot w/ XenAPI (yet)")
+
     while doms:
         alive = server.xend.domains(0)
         reboot = []
@@ -68,7 +72,12 @@ def wait_reboot(opts, doms, rcs):
 
 def wait_shutdown(opts, doms):
     while doms:
-        alive = server.xend.domains(0)
+        if serverType == SERVER_XEN_API:
+                   alive = [dom for dom in server.xenapi.VM.get_all()
+                     if server.xenapi.VM.get_power_state(dom) ==
+                     XEN_API_VM_POWER_STATE[XEN_API_VM_POWER_STATE_RUNNING]]
+        else:
+            alive = server.xend.domains(0)
         dead = []
         for d in doms:
             if d in alive: continue
@@ -82,8 +91,16 @@ def shutdown(opts, doms, mode, wait):
 def shutdown(opts, doms, mode, wait):
     rcs = {}
     for d in doms:
-        rcs[d] = server.xend.domain.getRestartCount(d)
-        server.xend.domain.shutdown(d, mode)
+               if serverType == SERVER_XEN_API:
+                       if mode == 'halt':
+                               server.xenapi.VM.clean_shutdown(d)
+                       if mode == 'reboot':
+                               server.xenapi.VM.clean_reboot(d)
+                       if mode == 'poweroff':
+                               server.xenapi.VM.clean_shutdown(d)              
                
+               else:
+                       rcs[d] = server.xend.domain.getRestartCount(d)
+                       server.xend.domain.shutdown(d, mode)
 
     if wait:
         if mode == 'reboot':
@@ -103,9 +120,13 @@ def shutdown_mode(opts):
         return 'poweroff'
 
 def main_all(opts, args):
-    doms = server.xend.domains(0)
-    dom0_name = sxp.child_value(server.xend.domain(0), 'name')
-    doms.remove(dom0_name)
+    if serverType == SERVER_XEN_API:
+        doms = [dom for dom in server.xenapi.VM.get_all()
+                if not server.xenapi.VM.get_is_control_domain(dom)]
+    else:
+        doms = server.xend.domains(0)
+        dom0_name = sxp.child_value(server.xend.domain(0), 'name')
+        doms.remove(dom0_name)
     mode = shutdown_mode(opts)  
     shutdown(opts, doms, mode, opts.vals.wait)
 
@@ -113,6 +134,8 @@ def main_dom(opts, args):
     if len(args) == 0: opts.err('No domain parameter given')
     if len(args) >  1: opts.err('No multiple domain parameters allowed')
     dom = args[0]
+    if serverType == SERVER_XEN_API:
+               dom = get_single_vm(dom)
     mode = shutdown_mode(opts)  
     shutdown(opts, [ dom ], mode, opts.vals.wait)
     

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Added Xen-API support to xm shutdown., Xen patchbot-unstable <=