ia64/xen-unstable

changeset 1770:1331621fe269

bitkeeper revision 1.1076 (40f3f7b4Cj4P09-PODiTO2MMFlKicw)

Add device create and device destroy for an existing domain.
author mjw@wray-m-3.hpl.hp.com
date Tue Jul 13 14:54:44 2004 +0000 (2004-07-13)
parents 1858589ab205
children 524a61d40438
files tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xend/server/blkif.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/python/xen/xend/XendClient.py	Tue Jul 13 12:44:25 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendClient.py	Tue Jul 13 14:54:44 2004 +0000
     1.3 @@ -316,6 +316,17 @@ class Xend:
     1.4                          {'op'       : 'vbd',
     1.5                           'vbd'      : vbd })
     1.6  
     1.7 +    def xend_domain_device_create(self, id, config):
     1.8 +        return xend_call(self.domainurl(id),
     1.9 +                         {'op'      : 'device_create',
    1.10 +                          'config'  : fileof(config) })
    1.11 +
    1.12 +    def xend_domain_device_destroy(self, id, type, idx):
    1.13 +        return xend_call(self.domainurl(id),
    1.14 +                         {'op'      : 'device_destroy',
    1.15 +                          'type'    : type,
    1.16 +                          'index'   : idx })
    1.17 +
    1.18      def xend_consoles(self):
    1.19          return xend_get(self.consoleurl())
    1.20  
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Tue Jul 13 12:44:25 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Jul 13 14:54:44 2004 +0000
     2.3 @@ -320,6 +320,7 @@ class XendDomain:
     2.4          @param config: configuration
     2.5          @return: deferred
     2.6          """
     2.7 +        print 'domain_configure>', id, config
     2.8          dom = int(id)
     2.9          dominfo = self.domain_get(dom)
    2.10          if not dominfo:
    2.11 @@ -498,9 +499,12 @@ class XendDomain:
    2.12          """
    2.13          # Need a cancel too?
    2.14          # Don't forget to cancel restart for it.
    2.15 +        print 'domain_migrate>', id, dst
    2.16          dom = int(id)
    2.17          xmigrate = XendMigrate.instance()
    2.18 -        return xmigrate.migrate_begin(dom, dst)
    2.19 +        val = xmigrate.migrate_begin(dom, dst)
    2.20 +        print 'domain_migrate<', val
    2.21 +        return val
    2.22  
    2.23      def domain_save(self, id, dst, progress=0):
    2.24          """Start saving a domain to file.
    2.25 @@ -561,6 +565,21 @@ class XendDomain:
    2.26          dom = int(dom)
    2.27          return xc.atropos_domain_get(dom)
    2.28  
    2.29 +    def domain_device_create(self, dom, devconfig):
    2.30 +        dom = int(dom)
    2.31 +        dominfo = self.domain_get(dom)
    2.32 +        if not dominfo:
    2.33 +            raise ValueError("invalid domain:" + str(dom))
    2.34 +        return dominfo.device_create(devconfig)
    2.35 +    
    2.36 +
    2.37 +    def domain_device_destroy(self, dom, type, idx):
    2.38 +        dom = int(dom)
    2.39 +        dominfo = self.domain_get(dom)
    2.40 +        if not dominfo:
    2.41 +            raise ValueError("invalid domain:" + str(dom))
    2.42 +        return dominfo.device_destroy(type, idx)
    2.43 +
    2.44      def domain_devtype_ls(self, dom, type):
    2.45          """Get list of device indexes for a domain.
    2.46  
     3.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Tue Jul 13 12:44:25 2004 +0000
     3.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Tue Jul 13 14:54:44 2004 +0000
     3.3 @@ -75,23 +75,49 @@ class SrvDomain(SrvDir):
     3.4                      [['dom', 'int'],
     3.5                       ['destination', 'str']])
     3.6          deferred = fn(req.args, {'dom': self.dom.id})
     3.7 +        print 'op_migrate>', deferred
     3.8          deferred.addCallback(self._op_migrate_cb, req)
     3.9          deferred.addErrback(self._op_migrate_err, req)
    3.10          return deferred
    3.11  
    3.12      def _op_migrate_cb(self, info, req):
    3.13 +        print '_op_migrate_cb>', info, req
    3.14          #req.setResponseCode(http.ACCEPTED)
    3.15          host = info.dst_host
    3.16          port = info.dst_port
    3.17          dom  = info.dst_dom
    3.18          url = "http://%s:%d/xend/domain/%d" % (host, port, dom)
    3.19          req.setHeader("Location", url)
    3.20 +        print '_op_migrate_cb> url=', url
    3.21          return url
    3.22  
    3.23      def _op_migrate_err(self, err, req):
    3.24 +        print '_op_migrate_err>', err, req
    3.25          req.setResponseCode(http.BAD_REQUEST, "Error: "+ str(err))
    3.26          return str(err)
    3.27 -        
    3.28 +
    3.29 +    def op_device_create(self, op, req):
    3.30 +        fn = FormFn(self.xd.domain_device_create,
    3.31 +                    [['dom', 'int'],
    3.32 +                     ['config', 'sxpr']])
    3.33 +        try:
    3.34 +            d = fn(req.args, {'dom': self.dom.id})
    3.35 +            d.addErrback(self._op_device_create_err, req)
    3.36 +            return d
    3.37 +        except ValueError, ex:
    3.38 +            return ['err', str(ex)]
    3.39 +
    3.40 +    def _op_device_create_err(self, err, req):
    3.41 +        return ['err', str(err)]
    3.42 +
    3.43 +    def op_device_destroy(self, op, req):
    3.44 +        fn = FormFn(self.xd.domain_device_destroy,
    3.45 +                    [['dom', 'int'],
    3.46 +                     ['type', 'str'],
    3.47 +                     ['index', 'int']])
    3.48 +        val = fn(req.args, {'dom': self.dom.id})
    3.49 +        return val
    3.50 +                
    3.51      def op_pincpu(self, op, req):
    3.52          fn = FormFn(self.xd.domain_pincpu,
    3.53                      [['dom', 'int'],
     4.1 --- a/tools/python/xen/xend/server/blkif.py	Tue Jul 13 12:44:25 2004 +0000
     4.2 +++ b/tools/python/xen/xend/server/blkif.py	Tue Jul 13 14:54:44 2004 +0000
     4.3 @@ -236,7 +236,6 @@ class BlkDev(controller.Dev):
     4.4          return val
     4.5  
     4.6      def destroy(self):
     4.7 -        PrettyPrint.prettyprint(self.sxpr())
     4.8          self.controller.send_be_vbd_destroy(self.vdev)
     4.9          
    4.10  class BlkifController(controller.Controller):
     5.1 --- a/tools/python/xen/xm/create.py	Tue Jul 13 12:44:25 2004 +0000
     5.2 +++ b/tools/python/xen/xm/create.py	Tue Jul 13 14:54:44 2004 +0000
     5.3 @@ -246,7 +246,7 @@ def randomMAC():
     5.4              random.randint(0x00, 0x7f),
     5.5              random.randint(0x00, 0xff),
     5.6              random.randint(0x00, 0xff) ]
     5.7 -    return ':'.join(map(lambda x: "%x" % x, mac))
     5.8 +    return ':'.join(map(lambda x: "%02x" % x, mac))
     5.9  
    5.10  def configure_vifs(config_devs, vals):
    5.11      """Create the config for virtual network interfaces.