bitkeeper revision 1.1076 (40f3f7b4Cj4P09-PODiTO2MMFlKicw)

Add device create and device destroy for an existing domain.
This commit is contained in:
mjw@wray-m-3.hpl.hp.com committed 2004-07-13 14:54:44 +00:00
1 parent 634b06df4c
commit 9a1fac5ff3
5 files changed
+59 -4

No files matched your search

+11
View File
@@ -316,6 +316,17 @@ class Xend:
{'op' : 'vbd',
'vbd' : vbd })
def xend_domain_device_create(self, id, config):
return xend_call(self.domainurl(id),
{'op' : 'device_create',
'config' : fileof(config) })
def xend_domain_device_destroy(self, id, type, idx):
return xend_call(self.domainurl(id),
{'op' : 'device_destroy',
'type' : type,
'index' : idx })
def xend_consoles(self):
return xend_get(self.consoleurl())
+20 -1
View File
@@ -320,6 +320,7 @@ class XendDomain:
@param config: configuration
@return: deferred
"""
print 'domain_configure>', id, config
dom = int(id)
dominfo = self.domain_get(dom)
if not dominfo:
@@ -498,9 +499,12 @@ class XendDomain:
"""
# Need a cancel too?
# Don't forget to cancel restart for it.
print 'domain_migrate>', id, dst
dom = int(id)
xmigrate = XendMigrate.instance()
return xmigrate.migrate_begin(dom, dst)
val = xmigrate.migrate_begin(dom, dst)
print 'domain_migrate<', val
return val
def domain_save(self, id, dst, progress=0):
"""Start saving a domain to file.
@@ -561,6 +565,21 @@ class XendDomain:
dom = int(dom)
return xc.atropos_domain_get(dom)
def domain_device_create(self, dom, devconfig):
dom = int(dom)
dominfo = self.domain_get(dom)
if not dominfo:
raise ValueError("invalid domain:" + str(dom))
return dominfo.device_create(devconfig)
def domain_device_destroy(self, dom, type, idx):
dom = int(dom)
dominfo = self.domain_get(dom)
if not dominfo:
raise ValueError("invalid domain:" + str(dom))
return dominfo.device_destroy(type, idx)
def domain_devtype_ls(self, dom, type):
"""Get list of device indexes for a domain.
+27 -1
View File
@@ -75,23 +75,49 @@ class SrvDomain(SrvDir):
[['dom', 'int'],
['destination', 'str']])
deferred = fn(req.args, {'dom': self.dom.id})
print 'op_migrate>', deferred
deferred.addCallback(self._op_migrate_cb, req)
deferred.addErrback(self._op_migrate_err, req)
return deferred
def _op_migrate_cb(self, info, req):
print '_op_migrate_cb>', info, req
#req.setResponseCode(http.ACCEPTED)
host = info.dst_host
port = info.dst_port
dom = info.dst_dom
url = "http://%s:%d/xend/domain/%d" % (host, port, dom)
req.setHeader("Location", url)
print '_op_migrate_cb> url=', url
return url
def _op_migrate_err(self, err, req):
print '_op_migrate_err>', err, req
req.setResponseCode(http.BAD_REQUEST, "Error: "+ str(err))
return str(err)
def op_device_create(self, op, req):
fn = FormFn(self.xd.domain_device_create,
[['dom', 'int'],
['config', 'sxpr']])
try:
d = fn(req.args, {'dom': self.dom.id})
d.addErrback(self._op_device_create_err, req)
return d
except ValueError, ex:
return ['err', str(ex)]
def _op_device_create_err(self, err, req):
return ['err', str(err)]
def op_device_destroy(self, op, req):
fn = FormFn(self.xd.domain_device_destroy,
[['dom', 'int'],
['type', 'str'],
['index', 'int']])
val = fn(req.args, {'dom': self.dom.id})
return val
def op_pincpu(self, op, req):
fn = FormFn(self.xd.domain_pincpu,
[['dom', 'int'],
-1
View File
@@ -236,7 +236,6 @@ class BlkDev(controller.Dev):
return val
def destroy(self):
PrettyPrint.prettyprint(self.sxpr())
self.controller.send_be_vbd_destroy(self.vdev)
class BlkifController(controller.Controller):
+1 -1
View File
@@ -246,7 +246,7 @@ def randomMAC():
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
return ':'.join(map(lambda x: "%x" % x, mac))
return ':'.join(map(lambda x: "%02x" % x, mac))
def configure_vifs(config_devs, vals):
"""Create the config for virtual network interfaces.
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.