def get_object(self): if not hasattr(self, "_object"): snap_id = self.kwargs['snapshot_id'] try: self._object = manila.share_snapshot_get(self.request, snap_id) except Exception: msg = _('Unable to retrieve snapshot.') url = reverse('horizon:project:shares:index') exceptions.handle(self.request, msg, redirect=url) return self._object
def get_object(self): if not hasattr(self, "_object"): snap_id = self.kwargs['snapshot_id'] try: self._object = manila.share_snapshot_get(self.request, snap_id) except Exception: msg = _('Unable to retrieve share snapshot.') url = reverse('horizon:project:share_snapshots:index') exceptions.handle(self.request, msg, redirect=url) return self._object
def get_context_data(self, **kwargs): context = super(self.__class__, self).get_context_data(**kwargs) snapshot = manila.share_snapshot_get( self.request, self.kwargs['snapshot_id']) context['snapshot_display_name'] = snapshot.name or snapshot.id context["snapshot"] = self.get_data() context["page_title"] = _("Snapshot Rules: " "%(snapshot_display_name)s") % { 'snapshot_display_name': context['snapshot_display_name']} return context
def get_data(self): try: snapshot_id = self.kwargs['snapshot_id'] snapshot = manila.share_snapshot_get(self.request, snapshot_id) share = manila.share_get(self.request, snapshot.share_id) snapshot.share_name_or_id = share.name or share.id except Exception: exceptions.handle(self.request, _('Unable to retrieve snapshot details.'), redirect=self.redirect_url) return snapshot
def get_data(self): try: snapshot_id = self.kwargs['snapshot_id'] snapshot = manila.share_snapshot_get(self.request, snapshot_id) share = manila.share_get(self.request, snapshot.share_id) snapshot.share_name_or_id = share.name or share.id except Exception: redirect = reverse('horizon:project:shares:index') exceptions.handle(self.request, _('Unable to retrieve snapshot details.'), redirect=redirect) return snapshot
def get_context_data(self, **kwargs): context = super(self.__class__, self).get_context_data(**kwargs) snapshot = manila.share_snapshot_get(self.request, self.kwargs['snapshot_id']) context['snapshot_display_name'] = snapshot.name or snapshot.id context["snapshot"] = self.get_data() context["page_title"] = _("Snapshot Rules: " "%(snapshot_display_name)s") % { 'snapshot_display_name': context['snapshot_display_name'] } return context
def handle(self, request, data): snapshot_id = self.initial['snapshot_id'] try: share = manila.share_snapshot_get(self.request, snapshot_id) manila.share_snapshot_update( request, share, display_name=data['name'], display_description=data['description']) message = _('Updating snapshot "%s"') % data['name'] messages.success(request, message) return True except Exception: redirect = "?".join([reverse("horizon:project:shares:index"), urlencode({"tab": "snapshots"})]) exceptions.handle(request, _('Unable to update snapshot.'), redirect=redirect)
def handle(self, request, data): snapshot_id = self.initial['snapshot_id'] try: share = manila.share_snapshot_get(self.request, snapshot_id) manila.share_snapshot_update( request, share, display_name=data['name'], display_description=data['description']) message = _('Updating snapshot "%s"') % data['name'] messages.success(request, message) return True except Exception: redirect = "?".join([ reverse("horizon:project:shares:index"), urlencode({"tab": "snapshots"}) ]) exceptions.handle(request, _('Unable to update snapshot.'), redirect=redirect)
def get_data(self): try: snapshot_id = self.kwargs['snapshot_id'] snapshot = manila.share_snapshot_get(self.request, snapshot_id) share = manila.share_get(self.request, snapshot.share_id) if share.mount_snapshot_support: snapshot.rules = manila.share_snapshot_rules_list( self.request, snapshot_id) snapshot.export_locations = ( manila.share_snap_export_location_list( self.request, snapshot)) export_locations = [ exp['path'] for exp in snapshot.export_locations ] snapshot.el_size = ui_utils.calculate_longest_str_size( export_locations) snapshot.share_name_or_id = share.name or share.id except Exception: exceptions.handle(self.request, _('Unable to retrieve snapshot details.'), redirect=self.redirect_url) return snapshot
def get_data(self): try: snapshot_id = self.kwargs['snapshot_id'] snapshot = manila.share_snapshot_get(self.request, snapshot_id) share = manila.share_get(self.request, snapshot.share_id) if share.mount_snapshot_support: snapshot.rules = manila.share_snapshot_rules_list( self.request, snapshot_id) snapshot.export_locations = ( manila.share_snap_export_location_list( self.request, snapshot)) export_locations = [ exp['path'] for exp in snapshot.export_locations ] snapshot.el_size = ui_utils.calculate_longest_str_size( export_locations) snapshot.share_name_or_id = share.name or share.id except Exception: exceptions.handle( self.request, _('Unable to retrieve snapshot details.'), redirect=self.redirect_url) return snapshot
def get_snapshot(self, request, id): return manila.share_snapshot_get(request, id)
def allowed(self, request, snapshot=None): snapshot = manila.share_snapshot_get( request, self.table.kwargs['snapshot_id']) return snapshot.status in ("available", "in-use")
def test_share_snapshot_get(self): snapshot = 'fake_snapshot' api.share_snapshot_get(self.request, snapshot) self.manilaclient.share_snapshots.get.assert_called_once_with(snapshot)
def allowed(self, request, snapshot=None): snapshot = manila.share_snapshot_get(request, self.table.kwargs['snapshot_id']) return snapshot.status in ("available", "in-use")
def get_data(self, request, snapshot_id): snapshot = manila.share_snapshot_get(request, snapshot_id) if not snapshot.name: snapshot.name = snapshot_id return snapshot