Example #1
0
    def execute(self, argv):

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

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

        instance_name = 'pki-tomcat'
        wait = False
        max_wait = 60
        timeout = None

        for o, a in opts:
            if o == '--wait':
                wait = True

            elif o == '--max-wait':
                max_wait = int(a)

            elif o == '--timeout':
                timeout = int(a)

            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.exists():
            logger.error('Invalid instance: %s', instance_name)
            sys.exit(1)

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

        instance.stop(wait=wait, max_wait=max_wait, timeout=timeout)
Example #2
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.exists():
            logger.error('Invalid instance: %s', instance_name)
            sys.exit(1)

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

        instance.start()
Example #3
0
    def print_status(instance):
        print('  Instance ID: %s' % instance.name)
        print('  Active: %s' % instance.is_active())
        print('  Nuxwdog Enabled: %s' % instance.type.endswith('-nuxwdog'))

        server_config = instance.get_server_config()

        unsecurePort = server_config.get_unsecure_port()
        if unsecurePort:
            print('  Unsecure Port: %s' % unsecurePort)

        securePort = server_config.get_secure_port()
        if securePort:
            print('  Secure Port: %s' % securePort)

        ajpPort = server_config.get_ajp_port()
        if ajpPort:
            print('  AJP Port: %s' % ajpPort)

        tomcatPort = server_config.get_port()
        print('  Tomcat Port: %s' % tomcatPort)

        hostname = socket.gethostname()

        ca = instance.get_subsystem('ca')
        if ca:
            print()
            print('  CA Subsystem:')

            if ca.config['subsystem.select'] == 'Clone':
                subsystem_type = 'CA Clone'
            else:
                subsystem_type = ca.config['hierarchy.select'] + ' CA'
            if ca.config['securitydomain.select'] == 'new':
                subsystem_type += ' (Security Domain)'
            print('    Type:                %s' % subsystem_type)

            print('    SD Name:             %s' %
                  ca.config['securitydomain.name'])
            url = 'https://%s:%s' % (ca.config['securitydomain.host'], ca.
                                     config['securitydomain.httpsadminport'])
            print('    SD Registration URL: %s' % url)

            enabled = ca.is_enabled()
            print('    Enabled:             %s' % enabled)

            if enabled:
                url = 'http://%s:%s/ca' % (hostname, unsecurePort)
                print('    Unsecure URL:        %s/ee/ca' % url)

                url = 'https://%s:%s/ca' % (hostname, securePort)
                print('    Secure Agent URL:    %s/agent/ca' % url)
                print('    Secure EE URL:       %s/ee/ca' % url)
                print('    Secure Admin URL:    %s/services' % url)
                print('    PKI Console URL:     %s' % url)

        kra = instance.get_subsystem('kra')
        if kra:
            print()
            print('  KRA Subsystem:')

            subsystem_type = 'KRA'
            if kra.config['subsystem.select'] == 'Clone':
                subsystem_type += ' Clone'
            elif kra.config['kra.standalone'] == 'true':
                subsystem_type += ' (Standalone)'
            print('    Type:                %s' % subsystem_type)

            print('    SD Name:             %s' %
                  kra.config['securitydomain.name'])
            url = 'https://%s:%s' % (kra.config['securitydomain.host'], kra.
                                     config['securitydomain.httpsadminport'])
            print('    SD Registration URL: %s' % url)

            enabled = kra.is_enabled()
            print('    Enabled:             %s' % enabled)

            if enabled:
                url = 'https://%s:%s/kra' % (hostname, securePort)
                print('    Secure Agent URL:    %s/agent/kra' % url)
                print('    Secure Admin URL:    %s/services' % url)
                print('    PKI Console URL:     %s' % url)

        ocsp = instance.get_subsystem('ocsp')
        if ocsp:
            print()
            print('  OCSP Subsystem:')

            subsystem_type = 'OCSP'
            if ocsp.config['subsystem.select'] == 'Clone':
                subsystem_type += ' Clone'
            elif ocsp.config['ocsp.standalone'] == 'true':
                subsystem_type += ' (Standalone)'
            print('    Type:                %s' % subsystem_type)

            print('    SD Name:             %s' %
                  ocsp.config['securitydomain.name'])
            url = 'https://%s:%s' % (ocsp.config['securitydomain.host'], ocsp.
                                     config['securitydomain.httpsadminport'])
            print('    SD Registration URL: %s' % url)

            enabled = ocsp.is_enabled()
            print('    Enabled:             %s' % enabled)

            if enabled:
                url = 'http://%s:%s/ocsp' % (hostname, unsecurePort)
                print(
                    '    Unsecure URL:        %s/ee/ocsp/<ocsp request blob>' %
                    url)

                url = 'https://%s:%s/ocsp' % (hostname, securePort)
                print('    Secure Agent URL:    %s/agent/ocsp' % url)
                print(
                    '    Secure EE URL:       %s/ee/ocsp/<ocsp request blob>' %
                    url)
                print('    Secure Admin URL:    %s/services' % url)
                print('    PKI Console URL:     %s' % url)

        tks = instance.get_subsystem('tks')
        if tks:
            print()
            print('  TKS Subsystem:')

            subsystem_type = 'TKS'
            if tks.config['subsystem.select'] == 'Clone':
                subsystem_type += ' Clone'
            print('    Type:                %s' % subsystem_type)

            print('    SD Name:             %s' %
                  tks.config['securitydomain.name'])
            url = 'https://%s:%s' % (tks.config['securitydomain.host'], tks.
                                     config['securitydomain.httpsadminport'])
            print('    SD Registration URL: %s' % url)

            enabled = tks.is_enabled()
            print('    Enabled:             %s' % enabled)

            if enabled:
                url = 'https://%s:%s/tks' % (hostname, securePort)
                print('    Secure Agent URL:    %s/agent/tks' % url)
                print('    Secure Admin URL:    %s/services' % url)
                print('    PKI Console URL:     %s' % url)

        tps = instance.get_subsystem('tps')
        if tps:
            print()
            print('  TPS Subsystem:')

            subsystem_type = 'TPS'
            if tps.config['subsystem.select'] == 'Clone':
                subsystem_type += ' Clone'
            print('    Type:                %s' % subsystem_type)

            print('    SD Name:             %s' %
                  tps.config['securitydomain.name'])
            url = 'https://%s:%s' % (tps.config['securitydomain.host'], tps.
                                     config['securitydomain.httpsadminport'])
            print('    SD Registration URL: %s' % url)

            enabled = tps.is_enabled()
            print('    Enabled:             %s' % enabled)

            if enabled:
                url = 'http://%s:%s/tps' % (hostname, unsecurePort)
                print('    Unsecure URL:        %s' % url)
                print('    Unsecure PHONE HOME: %s/phoneHome' % url)

                url = 'https://%s:%s/tps' % (hostname, securePort)
                print('    Secure URL:          %s' % url)
                print('    Secure PHONE HOME:   %s/phoneHome' % url)
Example #4
0
 def print_status(instance):
     print('  Instance ID: %s' % instance.name)
     print('  Active: %s' % instance.is_active())