Example #1
0
 def get_object(self):
     if not hasattr(self, "_object"):
         replica_id = self.kwargs["replica_id"]
         try:
             self._object = manila.share_replica_get(
                 self.request, replica_id)
         except Exception:
             msg = _("Unable to retrieve replica '%s'.") % replica_id
             url = reverse('horizon:admin:shares:index')
             exceptions.handle(self.request, msg, redirect=url)
     return self._object
Example #2
0
 def get_object(self):
     if not hasattr(self, "_object"):
         replica_id = self.kwargs["replica_id"]
         try:
             self._object = manila.share_replica_get(
                 self.request, replica_id)
         except Exception:
             msg = _("Unable to retrieve replica '%s'.") % replica_id
             url = reverse('horizon:admin:shares:index')
             exceptions.handle(self.request, msg, redirect=url)
     return self._object
Example #3
0
 def handle(self, request, data):
     replica_id = self.initial['replica_id']
     try:
         replica = manila.share_replica_get(self.request, replica_id)
         manila.share_replica_resync(request, replica)
         message = _("Resync'ing replica '%s'") % replica_id
         messages.success(request, message)
         return True
     except Exception:
         redirect = reverse("horizon:admin:shares:index")
         exceptions.handle(request,
                           _("Unable to resync replica '%s'.") % replica_id,
                           redirect=redirect)
Example #4
0
 def handle(self, request, data):
     replica_id = self.initial['replica_id']
     try:
         replica = manila.share_replica_get(self.request, replica_id)
         manila.share_replica_promote(request, replica)
         message = _('Setting replica "%s" as active...') % replica_id
         messages.success(request, message)
         return True
     except Exception:
         redirect = reverse("horizon:project:shares:index")
         exceptions.handle(request,
                           _("Unable to set replica '%s' as active.") %
                           replica_id,
                           redirect=redirect)
Example #5
0
 def handle(self, request, data):
     replica_id = self.initial['replica_id']
     try:
         replica = manila.share_replica_get(self.request, replica_id)
         manila.share_replica_resync(request, replica)
         message = _("Resync'ing replica '%s'") % replica_id
         messages.success(request, message)
         return True
     except Exception:
         redirect = reverse("horizon:admin:shares:index")
         exceptions.handle(
             request,
             _("Unable to resync replica '%s'.") % replica_id,
             redirect=redirect)
Example #6
0
 def handle(self, request, data):
     replica_id = self.initial['replica_id']
     try:
         replica = manila.share_replica_get(self.request, replica_id)
         manila.share_replica_promote(request, replica)
         message = _('Setting replica "%s" as active...') % replica_id
         messages.success(request, message)
         return True
     except Exception:
         redirect = reverse("horizon:project:shares:index")
         exceptions.handle(
             request,
             _("Unable to set replica '%s' as active.") % replica_id,
             redirect=redirect)
Example #7
0
 def get_data(self):
     try:
         replica_id = self.kwargs['replica_id']
         replica = manila.share_replica_get(self.request, replica_id)
         replica.export_locations = (
             manila.share_instance_export_location_list(
                 self.request, replica_id))
         export_locations = [
             exp['path'] for exp in replica.export_locations
         ]
         replica.el_size = ui_utils.calculate_longest_str_size(
             export_locations)
     except Exception:
         redirect = reverse(self._redirect_url)
         exceptions.handle(
             self.request,
             _('Unable to retrieve replica %sdetails.') % replica_id,
             redirect=redirect)
     return replica
Example #8
0
 def handle(self, request, data):
     replica_id = self.initial['replica_id']
     try:
         replica = manila.share_replica_get(self.request, replica_id)
         manila.share_replica_reset_state(
             request, replica, data["replica_state"])
         message = _("Reseting replica ('%(id)s') state from '%(from)s' "
                     "to '%(to)s'.") % {
                         "id": replica_id,
                         "from": replica.replica_state,
                         "to": data["replica_state"]}
         messages.success(request, message)
         return True
     except Exception:
         redirect = reverse("horizon:admin:shares:index")
         exceptions.handle(
             request,
             _("Unable to reset state of replica '%s'.") % replica_id,
             redirect=redirect)
Example #9
0
 def handle(self, request, data):
     replica_id = self.initial['replica_id']
     try:
         replica = manila.share_replica_get(self.request, replica_id)
         manila.share_replica_reset_state(
             request, replica, data["replica_state"])
         message = _("Reseting replica ('%(id)s') state from '%(from)s' "
                     "to '%(to)s'.") % {
                         "id": replica_id,
                         "from": replica.replica_state,
                         "to": data["replica_state"]}
         messages.success(request, message)
         return True
     except Exception:
         redirect = reverse("horizon:admin:shares:index")
         exceptions.handle(
             request,
             _("Unable to reset state of replica '%s'.") % replica_id,
             redirect=redirect)
Example #10
0
 def get_data(self):
     try:
         replica_id = self.kwargs['replica_id']
         replica = manila.share_replica_get(self.request, replica_id)
         try:
             # The default policy for this API does not allow
             # non-admins to retrieve export locations.
             replica.export_locations = (
                 manila.share_instance_export_location_list(
                     self.request, replica_id))
             export_locations = [
                 exp['path'] for exp in replica.export_locations
             ]
             replica.el_size = ui_utils.calculate_longest_str_size(
                 export_locations)
         except Exception:
             replica.export_locations = []
     except Exception:
         redirect = reverse(self._redirect_url)
         exceptions.handle(self.request,
                           _('Unable to retrieve details of replica %s') %
                           self.kwargs['replica_id'],
                           redirect=redirect)
     return replica
Example #11
0
 def get_data(self):
     try:
         replica_id = self.kwargs['replica_id']
         replica = manila.share_replica_get(self.request, replica_id)
         try:
             # The default policy for this API does not allow
             # non-admins to retrieve export locations.
             replica.export_locations = (
                 manila.share_instance_export_location_list(
                     self.request, replica_id))
             export_locations = [
                 exp['path'] for exp in replica.export_locations
             ]
             replica.el_size = ui_utils.calculate_longest_str_size(
                 export_locations)
         except Exception:
             replica.export_locations = []
     except Exception:
         redirect = reverse(self._redirect_url)
         exceptions.handle(
             self.request,
             _('Unable to retrieve details of replica %s') %
             self.kwargs['replica_id'], redirect=redirect)
     return replica
Example #12
0
    def test_share_replica_get(self):
        api.share_replica_get(self.request, "fake")

        self.manilaclient.share_replicas.get.assert_called_once_with("fake")
Example #13
0
 def get_data(self, request, replica_id):
     replica = manila.share_replica_get(request, replica_id)
     return replica
Example #14
0
 def get_data(self, request, replica_id):
     replica = manila.share_replica_get(request, replica_id)
     return replica
Example #15
0
    def test_share_replica_get(self):
        api.share_replica_get(self.request, "fake")

        self.manilaclient.share_replicas.get.assert_called_once_with("fake")