def test_share_replica_reset_state(self): replica = "fake_replica" state = "fake_state" api.share_replica_reset_state(self.request, replica, state) mock_reset_state = self.manilaclient.share_replicas.reset_replica_state mock_reset_state.assert_called_once_with(replica, state)
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)