ia64/xen-unstable

changeset 14528:8b0be0ddc223

Make xm save / restore talk XenAPI; add save / restore to VM class.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Ewan Mellor <ewan@xensource.com>
date Fri Mar 23 10:59:49 2007 +0000 (2007-03-23)
parents fd0b109501af
children 5dfa9b09b07c
files tools/python/xen/xend/XendAPI.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Fri Mar 23 10:46:39 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Fri Mar 23 10:59:49 2007 +0000
     1.3 @@ -1095,9 +1095,11 @@ class XendAPI(object):
     1.4                    ('remove_from_platform', None),
     1.5                    ('add_to_other_config', None),
     1.6                    ('remove_from_other_config', None),
     1.7 +                  ('save', None),
     1.8                    ('send_trigger', None)]
     1.9      
    1.10      VM_funcs  = [('create', 'VM'),
    1.11 +                 ('restore', None),
    1.12                   ('get_by_name_label', 'Set(VM)')]
    1.13  
    1.14      # parameters required for _create()
    1.15 @@ -1584,7 +1586,18 @@ class XendAPI(object):
    1.16          xeninfo = xendom.get_vm_by_uuid(vm_ref)
    1.17          xendom.domain_send_trigger(xeninfo.getDomid(), trigger, vcpu)
    1.18          return xen_api_success_void()
    1.19 -        
    1.20 +
    1.21 +    def VM_save(self, _, vm_ref, dest, checkpoint):
    1.22 +        xendom = XendDomain.instance()
    1.23 +        xeninfo = xendom.get_vm_by_uuid(vm_ref)
    1.24 +        xendom.domain_save(xeninfo.getDomid(), dest, checkpoint)
    1.25 +        return xen_api_success_void()
    1.26 +
    1.27 +    def VM_restore(self, _, src, paused):
    1.28 +        xendom = XendDomain.instance()
    1.29 +        xendom.domain_restore(src, bool(paused))
    1.30 +        return xen_api_success_void()
    1.31 +
    1.32  
    1.33      # Xen API: Class VM_metrics
    1.34      # ----------------------------------------------------------------
     2.1 --- a/tools/python/xen/xm/main.py	Fri Mar 23 10:46:39 2007 +0000
     2.2 +++ b/tools/python/xen/xm/main.py	Fri Mar 23 10:59:49 2007 +0000
     2.3 @@ -637,14 +637,18 @@ def xm_shell(args):
     2.4  #########################################################################
     2.5  
     2.6  def xm_save(args):
     2.7 +
     2.8      arg_check(args, "save", 2, 3)
     2.9 -
    2.10 +    
    2.11      try:
    2.12          (options, params) = getopt.gnu_getopt(args, 'c', ['checkpoint'])
    2.13      except getopt.GetoptError, opterr:
    2.14          err(opterr)
    2.15          sys.exit(1)
    2.16  
    2.17 +    dom = params[0]
    2.18 +    savefile = params[1]
    2.19 +
    2.20      checkpoint = False
    2.21      for (k, v) in options:
    2.22          if k in ['-c', '--checkpoint']:
    2.23 @@ -655,19 +659,22 @@ def xm_save(args):
    2.24          usage('save')
    2.25          sys.exit(1)
    2.26  
    2.27 -    try:
    2.28 -        dominfo = parse_doms_info(server.xend.domain(params[0]))
    2.29 -    except xmlrpclib.Fault, ex:
    2.30 -        raise ex
    2.31 -    
    2.32 -    domid = dominfo['domid']
    2.33 -    savefile = os.path.abspath(params[1])
    2.34 +    savefile = os.path.abspath(savefile)
    2.35  
    2.36      if not os.access(os.path.dirname(savefile), os.W_OK):
    2.37          err("xm save: Unable to create file %s" % savefile)
    2.38          sys.exit(1)
    2.39 +        
    2.40 +    if serverType == SERVER_XEN_API:       
    2.41 +        server.xenapi.VM.save(get_single_vm(dom), savefile, checkpoint)
    2.42 +    else:
    2.43 +        try:
    2.44 +            dominfo = parse_doms_info(server.xend.domain(dom))
    2.45 +        except xmlrpclib.Fault, ex:
    2.46 +            raise ex
    2.47      
    2.48 -    server.xend.domain.save(domid, savefile, checkpoint)
    2.49 +        domid = dominfo['domid']
    2.50 +        server.xend.domain.save(domid, savefile, checkpoint)
    2.51      
    2.52  def xm_restore(args):
    2.53      arg_check(args, "restore", 1, 2)
    2.54 @@ -693,7 +700,10 @@ def xm_restore(args):
    2.55          err("xm restore: Unable to read file %s" % savefile)
    2.56          sys.exit(1)
    2.57  
    2.58 -    server.xend.domain.restore(savefile, paused)
    2.59 +    if serverType == SERVER_XEN_API:
    2.60 +        server.xenapi.VM.restore(savefile, paused)
    2.61 +    else:
    2.62 +        server.xend.domain.restore(savefile, paused)
    2.63  
    2.64  
    2.65  def getDomains(domain_names, state, full = 0):