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) instance.restart(wait=wait, max_wait=max_wait, timeout=timeout)
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) instance.restart()