Exemple #1
0
 def action(self, request, service_id):
     try:
         environment_id = self.table.kwargs.get('environment_id')
         for service in self.table.data:
             if service['?']['id'] == service_id:
                 api.service_delete(request, environment_id, service_id)
     except Exception:
         msg = _('Sorry, you can\'t delete service right now')
         redirect = reverse("horizon:murano:environments:index")
         exceptions.handle(request, msg, redirect=redirect)
 def action(self, request, service_id):
     try:
         environment_id = get_cloud_id()
         for service in self.table.data:
             if service['?']['id'] == service_id:
                 api.service_delete(request, environment_id, service_id)
     except Exception:
         msg = _('Sorry, you can\'t delete service right now')
         redirect = reverse("horizon:admin:clouds:index")
         exceptions.handle(request, msg, redirect=redirect)
Exemple #3
0
 def action(self, request, service_id):
     try:
         #svt = ServicesTable(self.table)
         environment_id = self.table.kwargs.get('environment_id')
         for service in self.table.data:
             if service['?']['id'] == service_id:
                 api.service_delete(request,
                                    environment_id,
                                    service_id)
     except Exception:
         msg = _('Sorry, you can\'t delete service right now')
         redirect = reverse("horizon:murano:environments:index")
         exceptions.handle(request, msg, redirect=redirect)
Exemple #4
0
    def test_service_delete(self, mock_log, mock_session, mock_api):
        mock_response = mock.Mock(status_code=200)
        mock_client = mock_api.muranoclient(mock.Mock())
        mock_client.services.delete.return_value = mock_response
        mock_session.get_or_create_or_delete.return_value = self.session_id

        result = env_api.service_delete(self.mock_request, self.env_id,
                                        self.service_id)

        self.assertEqual(mock_response, result)
        env_api.api.muranoclient.assert_called_with(self.mock_request)
        mock_session.get_or_create_or_delete.assert_called_with(
            self.mock_request, 'foo_env_id')
        mock_client.services.delete.assert_called_once_with(
            'foo_env_id', '/foo_service_id', 'foo_session_id')
        mock_log.debug.assert_called_with(
            'Service::Delete <SrvId: {0}>'.format('foo_service_id'))
    def test_service_delete(self, mock_log, mock_session, mock_api):
        mock_response = mock.Mock(status_code=200)
        mock_client = mock_api.muranoclient(mock.Mock())
        mock_client.services.delete.return_value = mock_response
        mock_session.get_or_create_or_delete.return_value = self.session_id

        result = env_api.service_delete(self.mock_request, self.env_id,
                                        self.service_id)

        self.assertEqual(mock_response, result)
        env_api.api.muranoclient.assert_called_with(self.mock_request)
        mock_session.get_or_create_or_delete.assert_called_with(
            self.mock_request, 'foo_env_id')
        mock_client.services.delete.assert_called_once_with(
            'foo_env_id', '/foo_service_id', 'foo_session_id')
        mock_log.debug.assert_called_with(
            'Service::Delete <SrvId: {0}>'.format('foo_service_id'))