"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/api/contrib/admin_actions.py" between
cinder-15.4.1.tar.gz and cinder-15.5.0.tar.gz

About: OpenStack Cinder (Core Service: Block Storage) provides persistent block storage to running instances. Its pluggable driver architecture facilitates the creation and management of block storage devices.
The "Train" series (maintained release).

admin_actions.py  (cinder-15.4.1):admin_actions.py  (cinder-15.5.0)
skipping to change at line 34 skipping to change at line 34
from cinder.api.openstack import wsgi from cinder.api.openstack import wsgi
from cinder.api.schemas import admin_actions from cinder.api.schemas import admin_actions
from cinder.api import validation from cinder.api import validation
from cinder import backup from cinder import backup
from cinder import db from cinder import db
from cinder import exception from cinder import exception
from cinder.i18n import _ from cinder.i18n import _
from cinder import objects from cinder import objects
from cinder import rpc from cinder import rpc
from cinder import volume from cinder import volume
from cinder.volume import volume_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class AdminController(wsgi.Controller): class AdminController(wsgi.Controller):
"""Abstract base class for AdminControllers.""" """Abstract base class for AdminControllers."""
collection = None # api collection to extend collection = None # api collection to extend
# FIXME(clayg): this will be hard to keep up-to-date # FIXME(clayg): this will be hard to keep up-to-date
# Concrete classes can expand or over-ride # Concrete classes can expand or over-ride
skipping to change at line 64 skipping to change at line 65
def _get(self, *args, **kwargs): def _get(self, *args, **kwargs):
raise NotImplementedError() raise NotImplementedError()
def _delete(self, *args, **kwargs): def _delete(self, *args, **kwargs):
raise NotImplementedError() raise NotImplementedError()
def validate_update(self, req, body): def validate_update(self, req, body):
raise NotImplementedError() raise NotImplementedError()
def _notify_reset_status(self, context, id, message):
raise NotImplementedError()
def authorize(self, context, action_name, target_obj=None): def authorize(self, context, action_name, target_obj=None):
context.authorize( context.authorize(
'volume_extension:%(resource)s_admin_actions:%(action)s' % 'volume_extension:%(resource)s_admin_actions:%(action)s' %
{'resource': self.resource_name, {'resource': self.resource_name,
'action': action_name}, target_obj=target_obj) 'action': action_name}, target_obj=target_obj)
def _remove_worker(self, context, id): def _remove_worker(self, context, id):
# Remove the cleanup worker from the DB when we change a resource # Remove the cleanup worker from the DB when we change a resource
# status since it renders useless the entry. # status since it renders useless the entry.
res = db.worker_destroy(context, resource_type=self.collection.title(), res = db.worker_destroy(context, resource_type=self.collection.title(),
skipping to change at line 98 skipping to change at line 102
db.volume_detached(context.elevated(), id, attachment.id) db.volume_detached(context.elevated(), id, attachment.id)
db.volume_admin_metadata_delete(context.elevated(), id, db.volume_admin_metadata_delete(context.elevated(), id,
'attached_mode') 'attached_mode')
context = req.environ['cinder.context'] context = req.environ['cinder.context']
update = self.validate_update(req, body=body) update = self.validate_update(req, body=body)
msg = "Updating %(resource)s '%(id)s' with '%(update)r'" msg = "Updating %(resource)s '%(id)s' with '%(update)r'"
LOG.debug(msg, {'resource': self.resource_name, 'id': id, LOG.debug(msg, {'resource': self.resource_name, 'id': id,
'update': update}) 'update': update})
# calling notifier here for volumeStatusUpdate is deprecated.
# Will be replaced with _notify_reset_status()
notifier_info = dict(id=id, update=update) notifier_info = dict(id=id, update=update)
notifier = rpc.get_notifier('volumeStatusUpdate') notifier = rpc.get_notifier('volumeStatusUpdate')
notifier.info(context, self.collection + '.reset_status.start', notifier.info(context, self.collection + '.reset_status.start',
notifier_info) notifier_info)
self._notify_reset_status(context, id, 'reset_status.start')
# Not found exception will be handled at the wsgi level # Not found exception will be handled at the wsgi level
self._update(context, id, update) self._update(context, id, update)
self._remove_worker(context, id) self._remove_worker(context, id)
if update.get('attach_status') == 'detached': if update.get('attach_status') == 'detached':
_clean_volume_attachment(context, id) _clean_volume_attachment(context, id)
notifier.info(context, self.collection + '.reset_status.end', notifier.info(context, self.collection + '.reset_status.end',
notifier_info) notifier_info)
self._notify_reset_status(context, id, 'reset_status.end')
@wsgi.response(http_client.ACCEPTED) @wsgi.response(http_client.ACCEPTED)
@wsgi.action('os-force_delete') @wsgi.action('os-force_delete')
def _force_delete(self, req, id, body): def _force_delete(self, req, id, body):
"""Delete a resource, bypassing the check that it must be available.""" """Delete a resource, bypassing the check that it must be available."""
context = req.environ['cinder.context'] context = req.environ['cinder.context']
# Not found exception will be handled at the wsgi level # Not found exception will be handled at the wsgi level
resource = self._get(context, id) resource = self._get(context, id)
self.authorize(context, 'force_delete', target_obj=resource) self.authorize(context, 'force_delete', target_obj=resource)
self._delete(context, resource, force=True) self._delete(context, resource, force=True)
class VolumeAdminController(AdminController): class VolumeAdminController(AdminController):
"""AdminController for Volumes.""" """AdminController for Volumes."""
collection = 'volumes' collection = 'volumes'
def _notify_reset_status(self, context, id, message):
volume = objects.Volume.get_by_id(context, id)
volume_utils.notify_about_volume_usage(context, volume,
message)
def _update(self, *args, **kwargs): def _update(self, *args, **kwargs):
context = args[0] context = args[0]
volume_id = args[1] volume_id = args[1]
volume = objects.Volume.get_by_id(context, volume_id) volume = objects.Volume.get_by_id(context, volume_id)
self.authorize(context, 'reset_status', target_obj=volume) self.authorize(context, 'reset_status', target_obj=volume)
db.volume_update(*args, **kwargs) db.volume_update(*args, **kwargs)
def _get(self, *args, **kwargs): def _get(self, *args, **kwargs):
return self.volume_api.get(*args, **kwargs) return self.volume_api.get(*args, **kwargs)
skipping to change at line 241 skipping to change at line 254
error = params.get('error', False) error = params.get('error', False)
ret = self.volume_api.migrate_volume_completion(context, volume, ret = self.volume_api.migrate_volume_completion(context, volume,
new_volume, error) new_volume, error)
return {'save_volume_id': ret} return {'save_volume_id': ret}
class SnapshotAdminController(AdminController): class SnapshotAdminController(AdminController):
"""AdminController for Snapshots.""" """AdminController for Snapshots."""
collection = 'snapshots' collection = 'snapshots'
def _notify_reset_status(self, context, id, message):
snapshot = objects.Snapshot.get_by_id(context, id)
volume_utils.notify_about_snapshot_usage(context, snapshot,
message)
@validation.schema(admin_actions.reset_status_snapshot) @validation.schema(admin_actions.reset_status_snapshot)
def validate_update(self, req, body): def validate_update(self, req, body):
status = body['os-reset_status']['status'] status = body['os-reset_status']['status']
update = {'status': status.lower()} update = {'status': status.lower()}
return update return update
def _update(self, *args, **kwargs): def _update(self, *args, **kwargs):
context = args[0] context = args[0]
snapshot_id = args[1] snapshot_id = args[1]
fields = args[2] fields = args[2]
skipping to change at line 267 skipping to change at line 285
return self.volume_api.get_snapshot(*args, **kwargs) return self.volume_api.get_snapshot(*args, **kwargs)
def _delete(self, *args, **kwargs): def _delete(self, *args, **kwargs):
return self.volume_api.delete_snapshot(*args, **kwargs) return self.volume_api.delete_snapshot(*args, **kwargs)
class BackupAdminController(AdminController): class BackupAdminController(AdminController):
"""AdminController for Backups.""" """AdminController for Backups."""
collection = 'backups' collection = 'backups'
def _notify_reset_status(self, context, id, message):
backup = objects.Backup.get_by_id(context, id)
volume_utils.notify_about_backup_usage(context, backup,
message)
def _get(self, *args, **kwargs): def _get(self, *args, **kwargs):
return self.backup_api.get(*args, **kwargs) return self.backup_api.get(*args, **kwargs)
def _delete(self, *args, **kwargs): def _delete(self, *args, **kwargs):
return self.backup_api.delete(*args, **kwargs) return self.backup_api.delete(*args, **kwargs)
@wsgi.response(http_client.ACCEPTED) @wsgi.response(http_client.ACCEPTED)
@wsgi.action('os-reset_status') @wsgi.action('os-reset_status')
@validation.schema(admin_actions.reset_status_backup) @validation.schema(admin_actions.reset_status_backup)
def _reset_status(self, req, id, body): def _reset_status(self, req, id, body):
skipping to change at line 289 skipping to change at line 312
status = body['os-reset_status']['status'] status = body['os-reset_status']['status']
update = {'status': status.lower()} update = {'status': status.lower()}
msg = "Updating %(resource)s '%(id)s' with '%(update)r'" msg = "Updating %(resource)s '%(id)s' with '%(update)r'"
LOG.debug(msg, {'resource': self.resource_name, 'id': id, LOG.debug(msg, {'resource': self.resource_name, 'id': id,
'update': update}) 'update': update})
notifier_info = {'id': id, 'update': update} notifier_info = {'id': id, 'update': update}
notifier = rpc.get_notifier('backupStatusUpdate') notifier = rpc.get_notifier('backupStatusUpdate')
notifier.info(context, self.collection + '.reset_status.start', notifier.info(context, self.collection + '.reset_status.start',
notifier_info) notifier_info)
self._notify_reset_status(context, id, 'reset_status.start')
# Not found exception will be handled at the wsgi level # Not found exception will be handled at the wsgi level
self.backup_api.reset_status(context=context, backup_id=id, self.backup_api.reset_status(context=context, backup_id=id,
status=update['status']) status=update['status'])
class Admin_actions(extensions.ExtensionDescriptor): class Admin_actions(extensions.ExtensionDescriptor):
"""Enable admin actions.""" """Enable admin actions."""
name = "AdminActions" name = "AdminActions"
alias = "os-admin-actions" alias = "os-admin-actions"
 End of changes. 9 change blocks. 
0 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)