def _uploadimage(self, name, newname, pool='default', origin='/tmp', suffix='.iso'):
name = "%s" % (name)
_pool = self.conn.storagePoolLookupByName(pool)
poolxml = _pool.XMLDesc(0)
root = ET.fromstring(poolxml)
for element in root.getiterator('path'):
poolpath = element.text
break
imagepath = "%s/%s" % (poolpath, newname)
imagexml = self._xmlvolume(path=imagepath, size=0, diskformat='raw')
_pool.createXML(imagexml, 0)
imagevolume = self.conn.storageVolLookupByPath(imagepath)
stream = self.conn.newStream(0)
imagevolume.upload(stream, 0, 0)
with open("%s/%s" % (origin, name)) as ori:
stream.sendAll(self.handler, ori)
stream.finish()
return imagepath
评论列表
文章目录