Cesar77RR's picture
download
raw
1.31 kB
from cinder.api import extensions
from cinder.api.openstack import wsgi
authorize = extensions.soft_extension_authorizer('volume', 'volume_host_attribute')
class VolumeHostAttributeController(wsgi.Controller, ):
def _add_volume_host_attribute(self, req, resp_volume):
db_volume = req.get_db_volume(resp_volume['id'])
key = ('%s:host' % Volume_host_attribute.alias)
resp_volume[key] = db_volume['host']
@wsgi.extends
def show(self, req, resp_obj, id):
context = req.environ['cinder.context']
if authorize(context):
volume = resp_obj.obj['volume']
raise Exception
@wsgi.extends
def detail(self, req, resp_obj):
context = req.environ['cinder.context']
if authorize(context):
for vol in list(resp_obj.obj['volumes']):
self._add_volume_host_attribute(req, vol)
class Volume_host_attribute(extensions.ExtensionDescriptor, ):
'Expose host as an attribute of a volume.'
name = 'VolumeHostAttribute'
alias = 'os-vol-host-attr'
updated = '2011-11-03T00:00:00+00:00'
def get_controller_extensions(self):
controller = VolumeHostAttributeController()
extension = extensions.ControllerExtension(self, 'volumes', controller)
return [extension]

Xet Storage Details

Size:
1.31 kB
·
Xet hash:
b16e356f17e7b46270f9ca0e60df8aec09321d27793bc8ae041d41e3cb39c103

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.