Ejemplo n.º 1
0
    def execute(self, argv):

        try:
            opts, args = getopt.gnu_getopt(
                argv, 'v',
                ['as-current-user', 'jdb', 'verbose', 'debug', 'help'])

        except getopt.GetoptError as e:
            logger.error(e)
            self.print_help()
            sys.exit(1)

        instance_name = 'pki-tomcat'
        as_current_user = False
        jdb = False
        gdb = False

        for o, _ in opts:
            if o == '--as-current-user':
                as_current_user = True

            elif o == '--gdb':
                gdb = True

            elif o == '--jdb':
                jdb = True

            elif o in ('-v', '--verbose'):
                logging.getLogger().setLevel(logging.INFO)

            elif o == '--debug':
                logging.getLogger().setLevel(logging.DEBUG)

            elif o == '--help':
                self.print_help()
                sys.exit()

            else:
                logger.error('Unknown option: %s', o)
                self.print_help()
                sys.exit(1)

        if len(args) > 0:
            instance_name = args[0]

        instance = pki.server.instance.PKIServerFactory.create(instance_name)

        if not instance.is_valid():
            logger.error('Invalid instance: %s', instance_name)
            sys.exit(1)

        instance.load()

        try:
            instance.run(gdb=gdb, jdb=jdb, as_current_user=as_current_user)

        except KeyboardInterrupt:
            logging.debug('Server stopped')
Ejemplo n.º 2
0
    def execute(self, argv):

        try:
            opts, args = getopt.gnu_getopt(
                argv, 'v',
                ['with-maven-deps', 'force', 'verbose', 'debug', 'help'])

        except getopt.GetoptError as e:
            logger.error(e)
            self.print_help()
            sys.exit(1)

        instance_name = 'pki-tomcat'
        with_maven_deps = False
        force = False

        for o, _ in opts:
            if o == '--with-maven-deps':
                with_maven_deps = True

            elif o == '--force':
                force = True

            elif o in ('-v', '--verbose'):
                logging.getLogger().setLevel(logging.INFO)

            elif o == '--debug':
                logging.getLogger().setLevel(logging.DEBUG)

            elif o == '--help':
                self.print_help()
                sys.exit()

            else:
                logger.error('Unknown option: %s', o)
                self.print_help()
                sys.exit(1)

        if len(args) > 0:
            instance_name = args[0]

        instance = pki.server.instance.PKIServerFactory.create(instance_name)

        if not force and instance.is_valid():
            logger.error('Instance already exists: %s', instance_name)
            sys.exit(1)

        logging.info('Creating instance: %s', instance_name)

        instance.with_maven_deps = with_maven_deps
        instance.create(force=force)
Ejemplo n.º 3
0
    def execute(self, argv):

        try:
            opts, args = getopt.gnu_getopt(argv, 'v',
                                           ['verbose', 'debug', 'help'])

        except getopt.GetoptError as e:
            logger.error(e)
            self.print_help()
            sys.exit(1)

        instance_name = 'pki-tomcat'

        for o, _ in opts:
            if o in ('-v', '--verbose'):
                logging.getLogger().setLevel(logging.INFO)

            elif o == '--debug':
                logging.getLogger().setLevel(logging.DEBUG)

            elif o == '--help':
                self.print_help()
                sys.exit()

            else:
                logger.error('Unknown option: %s', o)
                self.print_help()
                sys.exit(1)

        if len(args) > 0:
            instance_name = args[0]

        instance = pki.server.instance.PKIServerFactory.create(instance_name)

        if not instance.is_valid():
            logger.error('Invalid instance: %s', instance_name)
            sys.exit(1)

        if not instance.is_active():
            self.print_message('Instance already stopped')
            return

        instance.stop()
Ejemplo n.º 4
0
    def execute(self, argv):

        try:
            opts, args = getopt.gnu_getopt(
                argv, 'v', ['force', 'verbose', 'debug', 'help'])

        except getopt.GetoptError as e:
            print('ERROR: %s' % e)
            self.print_help()
            sys.exit(1)

        instance_name = 'pki-tomcat'
        force = False

        for o, _ in opts:
            if o == '--force':
                force = True

            elif o in ('-v', '--verbose'):
                logging.getLogger().setLevel(logging.INFO)

            elif o == '--debug':
                logging.getLogger().setLevel(logging.DEBUG)

            elif o == '--help':
                self.print_help()
                sys.exit()

            else:
                print('ERROR: Unknown option: %s' % o)
                self.print_help()
                sys.exit(1)

        if len(args) > 0:
            instance_name = args[0]

        instance = pki.server.PKIServerFactory.create(instance_name)

        if not force and not instance.is_valid():
            print('ERROR: Invalid instance: %s' % instance_name)
            sys.exit(1)

        instance.remove(force)