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)
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)
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)
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})
def test_service_update(self): ENABLED = True NAME = "serviceName" admin_api = self.stub_admin_api() admin_api.services = self.mox.CreateMockAnything() admin_api.services.update(NAME, ENABLED).AndReturn(TEST_RETURN) self.mox.ReplayAll() ret_val = api.service_update(self.request, NAME, ENABLED) self.assertIsInstance(ret_val, api.Services) self.assertEqual(ret_val._apiresource, TEST_RETURN) self.mox.VerifyAll()