ia64/xen-unstable

changeset 14850:d51b3bc40ca5

Add VM.migrate to XenAPI, add support to XM

signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Tom Wilkie <tom.wilkie@gmail.com>
date Fri Apr 13 13:55:10 2007 +0100 (2007-04-13)
parents 5f6b31335cda
children 76f9a8e730ea
files tools/python/xen/xend/XendAPI.py tools/python/xen/xm/migrate.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Fri Apr 13 12:30:04 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Fri Apr 13 13:55:10 2007 +0100
     1.3 @@ -1304,6 +1304,7 @@ class XendAPI(object):
     1.4                    ('set_memory_dynamic_max_live', None),
     1.5                    ('set_memory_dynamic_min_live', None),
     1.6                    ('send_trigger', None),
     1.7 +                  ('migrate', None),
     1.8                    ('destroy', None)]
     1.9      
    1.10      VM_funcs  = [('create', 'VM'),
    1.11 @@ -1823,6 +1824,17 @@ class XendAPI(object):
    1.12          xendom.domain_send_trigger(xeninfo.getDomid(), trigger, vcpu)
    1.13          return xen_api_success_void()
    1.14  
    1.15 +    def VM_migrate(self, _, vm_ref, destination_url, live, other_config):
    1.16 +        xendom = XendDomain.instance()
    1.17 +        xeninfo = xendom.get_vm_by_uuid(vm_ref)
    1.18 +
    1.19 +        resource = other_config.get("resource", 0)
    1.20 +        port = other_config.get("port", 0)
    1.21 +        
    1.22 +        xendom.domain_migrate(xeninfo.getDomid(), destination_url,
    1.23 +                              bool(live), resource, port)
    1.24 +        return xen_api_success_void()
    1.25 +
    1.26      def VM_save(self, _, vm_ref, dest, checkpoint):
    1.27          xendom = XendDomain.instance()
    1.28          xeninfo = xendom.get_vm_by_uuid(vm_ref)
     2.1 --- a/tools/python/xen/xm/migrate.py	Fri Apr 13 12:30:04 2007 +0100
     2.2 +++ b/tools/python/xen/xm/migrate.py	Fri Apr 13 13:55:10 2007 +0100
     2.3 @@ -23,7 +23,7 @@ import sys
     2.4  
     2.5  from xen.xm.opts import *
     2.6  
     2.7 -from main import server
     2.8 +from main import server, serverType, get_single_vm, SERVER_XEN_API
     2.9  
    2.10  gopts = Opts(use="""[options] DOM HOST
    2.11  
    2.12 @@ -60,5 +60,16 @@ def main(argv):
    2.13  
    2.14      dom = args[0]
    2.15      dst = args[1]
    2.16 -    server.xend.domain.migrate(dom, dst, opts.vals.live, opts.vals.resource,
    2.17 -                               opts.vals.port)
    2.18 +
    2.19 +    if serverType == SERVER_XEN_API:
    2.20 +        vm_ref = get_single_vm(dom)
    2.21 +        other_config = {
    2.22 +            "port":     opts.vals.port,
    2.23 +            "resource": opts.vals.resource
    2.24 +            }
    2.25 +        server.xenapi.VM.migrate(vm_ref, dst, bool(opts.vals.live),
    2.26 +                                 other_config)
    2.27 +    else:
    2.28 +        server.xend.domain.migrate(dom, dst, opts.vals.live,
    2.29 +                                   opts.vals.resource,
    2.30 +                                   opts.vals.port)