Exemplo n.º 1
0
 def handle(self, request, data):
     try:
         service = api.service_get(request, data["service"])
         api.service_update(request, data["service"], not service.disabled)
         if service.disabled:
             messages.info(request, "Service '%s' has been enabled" % data["name"])
         else:
             messages.info(request, "Service '%s' has been disabled" % data["name"])
     except api_exceptions.ApiException, e:
         messages.error(request, "Unable to update service '%s': %s" % data["name"], e.message)
Exemplo n.º 2
0
    def test_service_get(self):
        NAME = "serviceName"

        admin_api = self.stub_admin_api()
        admin_api.services = self.mox.CreateMockAnything()
        admin_api.services.get(NAME).AndReturn(TEST_RETURN)

        self.mox.ReplayAll()

        ret_val = api.service_get(self.request, NAME)

        self.assertIsInstance(ret_val, api.Services)
        self.assertEqual(ret_val._apiresource, TEST_RETURN)

        self.mox.VerifyAll()
Exemplo n.º 3
0
 def handle(self, request, data):
     try:
         service = api.service_get(request, data['service'])
         api.service_update(request, data['service'], not service.disabled)
         if service.disabled:
             messages.info(request,
                           "Service '%s' has been enabled" % data['name'])
         else:
             messages.info(request,
                           "Service '%s' has been disabled" % data['name'])
     except api_exceptions.ApiException, e:
         LOG.exception('ApiException while toggling service %s' %
                       data['service'])
         messages.error(request,
                        "Unable to update service '%s': %s" % data['name'],
                        e.message)
Exemplo n.º 4
0
 def handle(self, request, data):
     try:
         service = api.service_get(request, data['service'])
         api.service_update(request,
                            data['service'],
                            not service.disabled)
         if service.disabled:
             messages.info(request, "Service '%s' has been enabled"
                                     % data['name'])
         else:
             messages.info(request, "Service '%s' has been disabled"
                                     % data['name'])
     except api_exceptions.ApiException, e:
         LOG.error('ApiException while toggling service %s' %
                   data['service'], exc_info=True)
         messages.error(request, "Unable to update service '%s': %s"
                                  % data['name'], e.message)
Exemplo n.º 5
0
 def handle(self, request, data):
     try:
         service = api.service_get(request, data['service'])
         api.service_update(request,
                            data['service'],
                            not service.disabled)
         if service.disabled:
             messages.info(request, _("Service '%s' has been enabled")
                                     % data['name'])
         else:
             messages.info(request, _("Service '%s' has been disabled")
                                     % data['name'])
     except api_exceptions.ApiException, e:
         LOG.exception('ApiException while toggling service %s' %
                   data['service'])
         messages.error(request,
                        _("Unable to update service '%(name)s': %(msg)s")
                        % {"name": data['name'], "msg": e.message})