def handle(self, request, data): group_id = self.initial['group_id'] try: message = _('Creating group snapshot "%s".') \ % data['name'] snapshot = cinder.group_snapshot_create(request, group_id, data['name'], data['description']) messages.info(request, message) return snapshot except Exception as e: redirect = reverse("horizon:project:volume_groups:index") msg = _('Unable to create group snapshot.') if e.code == 413: msg = _('Requested snapshot would exceed the allowed quota.') else: search_opts = {'group_id': group_id} volumes = cinder.volume_list(request, search_opts=search_opts) if not volumes: msg = _('Unable to create snapshot. ' 'group must contain volumes.') exceptions.handle(request, msg, redirect=redirect)
def handle(self, request, data): group_id = self.initial['group_id'] try: message = _('Creating group snapshot "%s".') \ % data['name'] snapshot = cinder.group_snapshot_create(request, group_id, data['name'], data['description']) messages.info(request, message) return snapshot except Exception as e: redirect = reverse("horizon:project:volume_groups:index") msg = _('Unable to create group snapshot.') if e.code == 413: msg = _('Requested snapshot would exceed the allowed quota.') else: search_opts = {'group_id': group_id} volumes = cinder.volume_list(request, search_opts=search_opts) if len(volumes) == 0: msg = _('Unable to create snapshot. ' 'group must contain volumes.') exceptions.handle(request, msg, redirect=redirect)