Beispiel #1
0
    def post(self, request, command):
        """
        execute a command on the service
        """
        with self._handle_exception(request):
            service = Service.objects.get(name="ldap")
            if command == "config":
                try:
                    config = request.data["config"]
                    self._save_config(service, config)
                except Exception as e:
                    logger.exception(e)
                    e_msg = "Ldap could not be configured. Try again"
                    handle_exception(Exception(e_msg), request)

            else:
                try:
                    toggle_auth_service("ldap",
                                        command,
                                        config=self._get_config(service))
                except Exception as e:
                    logger.exception(e)
                    e_msg = "Failed to %s ldap service due to system error." % command
                    handle_exception(Exception(e_msg), request)

            return Response()
Beispiel #2
0
    def post(self, request, command):
        """
        execute a command on the service
        """
        with self._handle_exception(request):
            service = Service.objects.get(name='ldap')
            if (command == 'config'):
                try:
                    config = request.data['config']
                    self._save_config(service, config)
                except Exception as e:
                    logger.exception(e)
                    e_msg = ('Ldap could not be configured. Try again')
                    handle_exception(Exception(e_msg), request)

            else:
                try:
                    toggle_auth_service('ldap', command,
                                        config=self._get_config(service))
                except Exception as e:
                    logger.exception(e)
                    e_msg = ('Failed to %s ldap service due to system error.' %
                             command)
                    handle_exception(Exception(e_msg), request)

            return Response()
 def post(self, request, command):
     """
     execute a command on the service
     """
     service = Service.objects.get(name='winbind')
     if (command == 'config'):
         try:
             config = request.data['config']
             toggle_auth_service('winbind', 'start', config)
             logger.info('authconfig executed')
             self._save_config(service, config)
         except Exception, e:
             logger.exception(e)
             e_msg = ('Winbind could not be configured. Try again')
             handle_exception(Exception(e_msg), request)
Beispiel #4
0
 def post(self, request, command):
     """
     execute a command on the service
     """
     service = Service.objects.get(name='winbind')
     if (command == 'config'):
         try:
             config = request.DATA['config']
             toggle_auth_service('winbind', 'start', config)
             logger.info('authconfig executed')
             self._save_config(service, config)
         except Exception, e:
             logger.exception(e)
             e_msg = ('Winbind could not be configured. Try again')
             handle_exception(Exception(e_msg), request)
class LdapServiceView(BaseServiceDetailView):
    @transaction.atomic
    def post(self, request, command):
        """
        execute a command on the service
        """
        with self._handle_exception(request):
            service = Service.objects.get(name='ldap')
            if (command == 'config'):
                try:
                    config = request.data['config']
                    self._save_config(service, config)
                except Exception, e:
                    logger.exception(e)
                    e_msg = ('Ldap could not be configured. Try again')
                    handle_exception(Exception(e_msg), request)

            else:
                try:
                    toggle_auth_service('ldap',
                                        command,
                                        config=self._get_config(service))
                except Exception, e:
                    logger.exception(e)
                    e_msg = ('Failed to %s ldap service due to system error.' %
                             command)
                    handle_exception(Exception(e_msg), request)

            return Response()
        """
        service = Service.objects.get(name='winbind')
        if (command == 'config'):
            try:
                config = request.data['config']
                toggle_auth_service('winbind', 'start', config)
                logger.info('authconfig executed')
                self._save_config(service, config)
            except Exception, e:
                logger.exception(e)
                e_msg = ('Winbind could not be configured. Try again')
                handle_exception(Exception(e_msg), request)

        else:
            try:
                toggle_auth_service('winbind', command,
                                    config=self._get_config(service))
                logger.info('authconfig executed')
                if (command == 'stop'):
                    systemctl('winbind', 'disable')
                else:
                    systemctl('winbind', 'enable')
                systemctl('winbind', command)
                logger.info('winbind altered')
            except Exception, e:
                logger.exception(e)
                e_msg = ('Failed to %s winbind service due to system error.' %
                         command)
                handle_exception(Exception(e_msg), request)

        return Response()
Beispiel #7
0
        service = Service.objects.get(name='winbind')
        if (command == 'config'):
            try:
                config = request.DATA['config']
                toggle_auth_service('winbind', 'start', config)
                logger.info('authconfig executed')
                self._save_config(service, config)
            except Exception, e:
                logger.exception(e)
                e_msg = ('Winbind could not be configured. Try again')
                handle_exception(Exception(e_msg), request)

        else:
            try:
                toggle_auth_service('winbind',
                                    command,
                                    config=self._get_config(service))
                logger.info('authconfig executed')
                if (command == 'stop'):
                    systemctl('winbind', 'disable')
                else:
                    systemctl('winbind', 'enable')
                systemctl('winbind', command)
                logger.info('winbind altered')
            except Exception, e:
                logger.exception(e)
                e_msg = ('Failed to %s winbind service due to system error.' %
                         command)
                handle_exception(Exception(e_msg), request)

        return Response()
Beispiel #8
0
class LdapServiceView(BaseServiceDetailView):

    @transaction.atomic
    def post(self, request, command):
        """
        execute a command on the service
        """
        with self._handle_exception(request):
            service = Service.objects.get(name='ldap')
            if (command == 'config'):
                try:
                    config = request.data['config']
                    self._save_config(service, config)
                except Exception, e:
                    logger.exception(e)
                    e_msg = ('Ldap could not be configured. Try again')
                    handle_exception(Exception(e_msg), request)

            else:
                try:
                    toggle_auth_service('ldap', command,
                                        config=self._get_config(service))
                except Exception, e:
                    logger.exception(e)
                    e_msg = ('Failed to %s ldap service due to system error.' %
                             command)
                    handle_exception(Exception(e_msg), request)

            return Response()