[Pki-devel] Fixes 1339263 issue.
Hi, I fixes bugzilla issue no 1339263. Please review this patch. PFA. Thank You. Amol K. >From caf7e6c692fcd626d572ec31352d87ff3b507a8e Mon Sep 17 00:00:00 2001 From: Amol Kahat Date: Thu, 9 Jun 2016 16:34:22 +0530 Subject: [PATCH] Description : Fixed --help option for instance-show, instance-start, instance-stop, instance-migrate, instance-nuxwdog-enable, instance-nuxwdog-disable. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1339263 Signed-off-by: Amol Kahat --- base/server/python/pki/server/cli/instance.py | 86 +-- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/base/server/python/pki/server/cli/instance.py b/base/server/python/pki/server/cli/instance.py index 7520b32b81cf222ebc7ac1def928701b1116ae86..d5fc644a1d9ae992907aed8674c793e26bdc0ef8 100644 --- a/base/server/python/pki/server/cli/instance.py +++ b/base/server/python/pki/server/cli/instance.py @@ -261,13 +261,6 @@ class InstanceShowCLI(pki.cli.CLI): self.print_help() sys.exit(1) -if len(args) != 1: -print('ERROR: missing instance ID') -self.print_help() -sys.exit(1) - -instance_name = args[0] - for o, _ in opts: if o in ('-v', '--verbose'): self.set_verbose(True) @@ -281,6 +274,13 @@ class InstanceShowCLI(pki.cli.CLI): self.print_help() sys.exit(1) +if len(args) != 1: +print('ERROR: missing instance ID') +self.print_help() +sys.exit(1) + +instance_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -310,13 +310,6 @@ class InstanceStartCLI(pki.cli.CLI): self.print_help() sys.exit(1) -if len(args) != 1: -print('ERROR: missing instance ID') -self.print_help() -sys.exit(1) - -instance_name = args[0] - for o, _ in opts: if o in ('-v', '--verbose'): self.set_verbose(True) @@ -330,6 +323,13 @@ class InstanceStartCLI(pki.cli.CLI): self.print_help() sys.exit(1) +if len(args) != 1: +print('ERROR: missing instance ID') +self.print_help() +sys.exit(1) + +instance_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() instance.start() @@ -360,13 +360,6 @@ class InstanceStopCLI(pki.cli.CLI): self.print_help() sys.exit(1) -if len(args) != 1: -print('ERROR: missing instance ID') -self.print_help() -sys.exit(1) - -instance_name = args[0] - for o, _ in opts: if o in ('-v', '--verbose'): self.set_verbose(True) @@ -380,6 +373,13 @@ class InstanceStopCLI(pki.cli.CLI): self.print_help() sys.exit(1) +if len(args) != 1: +print('ERROR: missing instance ID') +self.print_help() +sys.exit(1) + +instance_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() instance.stop() @@ -412,14 +412,6 @@ class InstanceMigrateCLI(pki.cli.CLI): self.print_help() sys.exit(1) -if len(args) != 1: -print('ERROR: missing instance ID') -self.print_help() -sys.exit(1) - -instance_name = args[0] -tomcat_version = None - for o, a in opts: if o == '--tomcat': tomcat_version = a @@ -440,6 +432,14 @@ class InstanceMigrateCLI(pki.cli.CLI): self.print_help() sys.exit(1) +if len(args) != 1: +print('ERROR: missing instance ID') +self.print_help() +sys.exit(1) + +instance_name = args[0] +tomcat_version = None + if not tomcat_version: tomcat_version = pki.server.Tomcat.get_major_version() @@ -484,13 +484,6 @@ class InstanceNuxwdogEnableCLI(pki.cli.CLI): self.print_help() sys.exit(1) -if len(args) != 1: -print('ERROR: missing instance ID') -self.print_help() -sys.exit(1) - -instance_name = args[0] - for o, _ in opts: if o in ('-v', '--verbose'): self.set_verbose(True) @@ -502,6 +495,13 @@ class InstanceNuxwdogEnableCLI(pki.cli.CLI): self.print_help() sys.exit(1) +if len(args) != 1: +print('ERROR: missing instance ID') +self.print_help() +sys.exit(1) +
Re: [Pki-devel] Fixes 1339263 issue.
Endi thanks. On 06/13/2016 08:06 PM, Endi Sukma Dewata wrote: On 6/13/2016 2:22 AM, Amol Kahat wrote: Hi, I fixes bugzilla issue no 1339263. Please review this patch. PFA. Thank You. Amol K. Thanks for the patch! Just one issue, in InstanceMigrateCLI the tomcat_version needs to stay where it was since it's getting the value from --tomcat option. ACK. I fixed the patch and pushed it to master. ___ Pki-devel mailing list Pki-devel@redhat.com https://www.redhat.com/mailman/listinfo/pki-devel
[Pki-devel] Patch for pki-server cli and man page.
Hi, I fixed the bugzilla issue 1341953. And enhance code of pki-server instance-start. And also i fixed man page for pki-server instance-cert. Please review this patches. PFA. Thanks Amol K >From e7ca72b6346126b6a4fb5f3d3c51f61fa36c15cf Mon Sep 17 00:00:00 2001 From: Amol Kahat Date: Tue, 14 Jun 2016 16:36:40 +0530 Subject: [PATCH] Fixed pki-server instance-start command. Fixed pki-server instance-stop command. Fixes : https://bugzilla.redhat.com/show_bug.cgi?id=1341953 Signed-off-by: Amol Kahat --- base/server/python/pki/server/cli/instance.py | 31 +++ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/base/server/python/pki/server/cli/instance.py b/base/server/python/pki/server/cli/instance.py index d5fc644a1d9ae992907aed8674c793e26bdc0ef8..8eff750872715db109ef83a76a6a6766d0bacdc1 100644 --- a/base/server/python/pki/server/cli/instance.py +++ b/base/server/python/pki/server/cli/instance.py @@ -329,12 +329,19 @@ class InstanceStartCLI(pki.cli.CLI): sys.exit(1) instance_name = args[0] - -instance = pki.server.PKIInstance(instance_name) -instance.load() -instance.start() - -self.print_message('%s instance started' % instance_name) +try: +instance = pki.server.PKIInstance(instance_name) +if instance.is_valid(): +if instance.is_active(): +self.print_message('%s instance already started.' % instance_name) +else: +instance.load() +instance.start() +self.print_message('%s instance started' % instance_name) +else: +self.print_message('%s no such instance exists.' % instance_name) +except : +self.print_message('Error in starting %s' % instance_name) class InstanceStopCLI(pki.cli.CLI): @@ -381,10 +388,16 @@ class InstanceStopCLI(pki.cli.CLI): instance_name = args[0] instance = pki.server.PKIInstance(instance_name) -instance.load() -instance.stop() +if instance.is_valid(): +if instance.is_active(): +instance.load() +instance.stop() -self.print_message('%s instance stopped' % instance_name) +self.print_message('%s instance stopped' % instance_name) +else: +self.print_message('%s instance already stopped' % instance_name) +else: +self.print_message('%s no such instance exits.' % instance_name) class InstanceMigrateCLI(pki.cli.CLI): -- 2.5.5 >From 2e8d8ec9f8a29f541d99de7c71c1bedd3b268cc9 Mon Sep 17 00:00:00 2001 From: Amol Kahat Date: Tue, 14 Jun 2016 12:42:32 +0530 Subject: [PATCH] Added entry of pki-server instance-cert command in man page. Signed-off-by: Amol Kahat --- base/server/man/man8/pki-server-instance.8 | 6 ++ 1 file changed, 6 insertions(+) diff --git a/base/server/man/man8/pki-server-instance.8 b/base/server/man/man8/pki-server-instance.8 index 4d0f52bd97ae27b008e25f7765b03eeaa166a139..bbbc0f9e7f20e8f538e39be1bab8ba4b41712132 100644 --- a/base/server/man/man8/pki-server-instance.8 +++ b/base/server/man/man8/pki-server-instance.8 @@ -20,6 +20,7 @@ pki-server instance \- Command-Line Interface for managing Certificate System in .SH SYNOPSIS .nf \fBpki-server [CLI options] instance\fR +\fBpki-server [CLI options] instance-cert\fR \fBpki-server [CLI options] instance-find\fR \fBpki-server [CLI options] instance-show\fR \fBpki-server [CLI options] instance-start\fR @@ -48,6 +49,11 @@ enabling or disabling password prompted instance startup using \fBnuxwdog\fR. This command is to list available instance commands. .RE .PP +\fBpki-server [CLI options] instance-cert\fR +.RS 4 +This command is to export the all instance cerficates in p12 file. +.RE +.PP \fBpki-server [CLI options] instance-find\fR .RS 4 This command is to list local CS instances. -- 2.5.5 ___ Pki-devel mailing list Pki-devel@redhat.com https://www.redhat.com/mailman/listinfo/pki-devel
[Pki-devel] Fixes pki-server subsystem --help options.
Hi, Please review this patch. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1340718 Thanks Amol K. >From ad4e565f54db5e38102f3cbceeb98b22090c0ef5 Mon Sep 17 00:00:00 2001 From: Amol Kahat Date: Tue, 21 Jun 2016 12:47:23 +0530 Subject: [PATCH] Fixes pki-server subsystem-* --help options. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1340718 --- base/server/python/pki/server/cli/subsystem.py | 165 + 1 file changed, 86 insertions(+), 79 deletions(-) diff --git a/base/server/python/pki/server/cli/subsystem.py b/base/server/python/pki/server/cli/subsystem.py index c92ed16be251af87aa20ddada17da48de2ea4511..a4d91610fd2fa9f575923f3361c5a544bacb1927 100644 --- a/base/server/python/pki/server/cli/subsystem.py +++ b/base/server/python/pki/server/cli/subsystem.py @@ -90,7 +90,7 @@ class SubsystemFindCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': -self.print_help() +self.usage() sys.exit() else: @@ -138,12 +138,6 @@ class SubsystemShowCLI(pki.cli.CLI): self.usage() sys.exit(1) -if len(args) != 1: -print('ERROR: missing subsystem ID') -self.usage() -sys.exit(1) - -subsystem_name = args[0] instance_name = 'pki-tomcat' for o, a in opts: @@ -154,7 +148,7 @@ class SubsystemShowCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': -self.print_help() +self.usage() sys.exit() else: @@ -162,6 +156,13 @@ class SubsystemShowCLI(pki.cli.CLI): self.usage() sys.exit(1) +if len(args) != 1: +print('ERROR: missing subsystem ID') +self.usage() +sys.exit(1) + +subsystem_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -195,12 +196,6 @@ class SubsystemEnableCLI(pki.cli.CLI): self.usage() sys.exit(1) -if len(args) != 1: -print('ERROR: missing subsystem ID') -self.usage() -sys.exit(1) - -subsystem_name = args[0] instance_name = 'pki-tomcat' for o, a in opts: @@ -211,7 +206,7 @@ class SubsystemEnableCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': -self.print_help() +self.usage() sys.exit() else: @@ -219,6 +214,13 @@ class SubsystemEnableCLI(pki.cli.CLI): self.usage() sys.exit(1) +if len(args) != 1: +print('ERROR: missing subsystem ID') +self.usage() +sys.exit(1) + +subsystem_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -257,12 +259,6 @@ class SubsystemDisableCLI(pki.cli.CLI): self.usage() sys.exit(1) -if len(args) != 1: -print('ERROR: missing subsystem ID') -self.usage() -sys.exit(1) - -subsystem_name = args[0] instance_name = 'pki-tomcat' for o, a in opts: @@ -273,7 +269,7 @@ class SubsystemDisableCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': -self.print_help() +self.usage() sys.exit() else: @@ -281,6 +277,13 @@ class SubsystemDisableCLI(pki.cli.CLI): self.usage() sys.exit(1) +if len(args) != 1: +print('ERROR: missing subsystem ID') +self.usage() +sys.exit(1) + +subsystem_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -342,12 +345,6 @@ class SubsystemCertFindCLI(pki.cli.CLI): self.print_help() sys.exit(1) -if len(args) != 1: -print('ERROR: missing subsystem ID') -self.print_help() -sys.exit(1) - -subsystem_name = args[0] instance_name = 'pki-tomcat' show_all = False @@ -370,6 +367,13 @@ class SubsystemCertFindCLI(pki.cli.CLI): self.print_help() sys.exit(1) +if len(args) != 1: +print('ERROR: missing subsystem ID') +self.print_help() +sys.exit(1) + +subsystem_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -414,18 +418,6 @@ class SubsystemCertShowCLI(pki.cli.CLI): self.usage() sys.exit(1) -if len(args) < 1: -
[Pki-devel] Invalid instance exception fix.
Hi, Please review this patch. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1348433 Thanks Amol K. >From adaef8e7ca9d0c2a57eda09c52d0ed149e176224 Mon Sep 17 00:00:00 2001 From: Amol Kahat Date: Tue, 21 Jun 2016 13:20:59 +0530 Subject: [PATCH] Fixes: Invalid instance exception issue. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1348433 --- base/server/python/pki/server/cli/instance.py | 56 ++- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/base/server/python/pki/server/cli/instance.py b/base/server/python/pki/server/cli/instance.py index 6e336e3cb8b9af7745143440ede95022cb7b..b2b31e1b806162caf74277504cfb08f79810a3ef 100644 --- a/base/server/python/pki/server/cli/instance.py +++ b/base/server/python/pki/server/cli/instance.py @@ -157,7 +157,11 @@ class InstanceCertExportCLI(pki.cli.CLI): sys.exit(1) instance = pki.server.PKIInstance(instance_name) -instance.load() +if instance.is_active(): + instance.load() +else: +print('ERROR: Invalid tomcat instance specified.') +sys.exit(1) if not pkcs12_password and not pkcs12_password_file: pkcs12_password = getpass.getpass(prompt='Enter password for PKCS #12 file: ') @@ -233,7 +237,11 @@ class InstanceFindCLI(pki.cli.CLI): print() instance = pki.server.PKIInstance(instance_name) -instance.load() +if instance.is_valid(): +instance.load() +else: +print('ERROR: Invalid tomcat instance specfified.') +sys.exit(1) InstanceCLI.print_instance(instance) @@ -282,8 +290,12 @@ class InstanceShowCLI(pki.cli.CLI): instance_name = args[0] instance = pki.server.PKIInstance(instance_name) -instance.load() - +if instance.is_valid(): +instance.load() +else: +print('ERROR: Invalid tomcat instance specified.') +sys.exit(1) + InstanceCLI.print_instance(instance) @@ -470,7 +482,12 @@ class InstanceMigrateCLI(pki.cli.CLI): module.set_debug(self.debug) instance = pki.server.PKIInstance(instance_name) -instance.load() + +if instance.is_valid(): +instance.load() +else: +print('ERROR: Invalid tomcat instance specified.') +sys.exit(1) module.migrate( # pylint: disable=no-member,maybe-no-member instance, @@ -526,7 +543,12 @@ class InstanceNuxwdogEnableCLI(pki.cli.CLI): module.set_verbose(self.verbose) instance = pki.server.PKIInstance(instance_name) -instance.load() + +if instance.is_valid(): +instance.load() +else: +print('ERROR: Invalid tomcat instance specified.') +sys.exit(1) module.enable_nuxwdog( # pylint: disable=no-member,maybe-no-member instance) @@ -580,7 +602,11 @@ class InstanceNuxwdogDisableCLI(pki.cli.CLI): module.set_verbose(self.verbose) instance = pki.server.PKIInstance(instance_name) -instance.load() +if instance.is_valid(): +instance.load() +else: +print('ERROR: Invalid tomcat instance specified.') +sys.exit(1) module.disable_nuxwdog( instance) # pylint: disable=no-member,maybe-no-member @@ -664,7 +690,12 @@ class InstanceExternalCertAddCLI(pki.cli.CLI): sys.exit(1) instance = pki.server.PKIInstance(instance_name) -instance.load() + +if instance.is_valid(): +instance.load() +else: +print('ERROR: Invalid tomcat instance specified.') +sys.exit(1) if instance.external_cert_exists(nickname, token): print('ERROR: Certificate already imported for instance %s.' % @@ -753,8 +784,13 @@ class InstanceExternalCertDeleteCLI(pki.cli.CLI): sys.exit(1) instance = pki.server.PKIInstance(instance_name) -instance.load() - + +if instance.is_valid(): +instance.load() +else: +print('ERROR: Invalid tomcat instance specified.') +sys.exit(1) + self.remove_cert(instance, nickname, token) instance.delete_external_cert(nickname, token) -- 2.5.5 ___ Pki-devel mailing list Pki-devel@redhat.com https://www.redhat.com/mailman/listinfo/pki-devel
[Pki-devel] Fixes exception while invalid module.
Hi, Please review this patch. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1348446 Thanks Amol K >From 8ec731ecade07c269c735401ba15619be88544b9 Mon Sep 17 00:00:00 2001 From: Amol Kahat Date: Tue, 21 Jun 2016 13:45:06 +0530 Subject: [PATCH] Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1348446 --- base/common/python/pki/cli/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/base/common/python/pki/cli/__init__.py b/base/common/python/pki/cli/__init__.py index 3be9cce2e5583e2ee519cdb2860e6346f90426da..cae2b13d2792ef4620f8563a4ba2e8bd1851fae5 100644 --- a/base/common/python/pki/cli/__init__.py +++ b/base/common/python/pki/cli/__init__.py @@ -156,7 +156,7 @@ class CLI(object): (module, sub_command) = self.parse_command(command) if not module: -raise Exception('Invalid module "%s".' % command) +print('ERROR: Invalid module "%s".' % command) # Prepare module arguments. if sub_command: @@ -200,4 +200,5 @@ class CLI(object): (module, module_args) = self.parse_args(argv) -module.execute(module_args) +if module: +module.execute(module_args) -- 2.5.5 ___ Pki-devel mailing list Pki-devel@redhat.com https://www.redhat.com/mailman/listinfo/pki-devel
[Pki-devel] [PATCH] Added --token-password in pki-server instance-externalcert-add / del command.
Hi, Please review this patch. Fixes : https://bugzilla.redhat.com/show_bug.cgi?id=1348531 Thanks Amol K >From d0e514e4f3c96ce5f8c6dba9efc05aaa819d94e6 Mon Sep 17 00:00:00 2001 From: Amol Kahat Date: Wed, 22 Jun 2016 13:36:33 +0530 Subject: [PATCH] Added --token-password option in pki-server-externalcert-add / del command. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1348531 --- base/server/python/pki/server/cli/instance.py | 76 ++- 1 file changed, 63 insertions(+), 13 deletions(-) diff --git a/base/server/python/pki/server/cli/instance.py b/base/server/python/pki/server/cli/instance.py index b2b31e1b806162caf74277504cfb08f79810a3ef..0cf60cb8a2db615aa1f5e987c5f5621b934a5981 100644 --- a/base/server/python/pki/server/cli/instance.py +++ b/base/server/python/pki/server/cli/instance.py @@ -629,6 +629,7 @@ class InstanceExternalCertAddCLI(pki.cli.CLI): print(' --trust-args Trust args (default \",,\").') print(' --nickname Nickname to be used.') print(' --tokenToken (default: internal).') +print(' --token-password Token password.') print(' -v, --verbose Run in verbose mode.') print(' --help Show help message.') print() @@ -636,8 +637,8 @@ class InstanceExternalCertAddCLI(pki.cli.CLI): def execute(self, argv): try: opts, _ = getopt.gnu_getopt(argv, 'i:v', [ -'instance=', -'cert-file=', 'trust-args=', 'nickname=','token=', +'instance=', 'cert-file=', 'trust-args=', +'nickname=','token=', 'token-password=', 'verbose', 'help']) except getopt.GetoptError as e: @@ -650,6 +651,7 @@ class InstanceExternalCertAddCLI(pki.cli.CLI): trust_args = '\",,\"' nickname = None token = 'internal' +token_password = None for o, a in opts: if o in ('-i', '--instance'): @@ -667,6 +669,9 @@ class InstanceExternalCertAddCLI(pki.cli.CLI): elif o == '--token': token = a +elif o == '--token-password': +token_password = a + elif o in ('-v', '--verbose'): self.set_verbose(True) @@ -683,12 +688,27 @@ class InstanceExternalCertAddCLI(pki.cli.CLI): print('ERROR: missing input file containing certificate') self.print_help() sys.exit(1) + +if os.path.isfile(cert_file): +pass + +else: +print('ERROR: Invalid certificate file, no such file or directory.') +sys.exit(1) if not nickname: print('ERROR: missing nickname') self.print_help() sys.exit(1) +if token is 'internal' and token_password is None: +pass + +elif token is not 'internal' and token_password is None: +print('ERROR: Specify token password') +self.print_help() +sys.exit(1) + instance = pki.server.PKIInstance(instance_name) if instance.is_valid(): @@ -703,14 +723,23 @@ class InstanceExternalCertAddCLI(pki.cli.CLI): sys.exit(1) nicks = self.import_certs( -instance, cert_file, nickname, token, trust_args) -self.update_instance_config(instance, nicks, token) +instance, cert_file, nickname, token, trust_args, token_password) + +try: +self.update_instance_config(instance, nicks, token) -self.print_message('Certificate imported for instance %s.' % +self.print_message('Certificate imported for instance %s.' % instance_name) +except: +print('ERROR: Failed to run pki-server instance-externalcert-add command') +sys.exit(1) + +def import_certs(self, instance, cert_file, nickname, token, trust_args, token_password): +if not token_password: +password = instance.get_password(token) +else: +password = token_password -def import_certs(self, instance, cert_file, nickname, token, trust_args): -password = instance.get_password(token) certdb = pki.nssdb.NSSDatabase( directory=instance.nssdb_dir, password=password, @@ -737,6 +766,7 @@ class InstanceExternalCertDeleteCLI(pki.cli.CLI): print(' -i, --instanceInstance ID (default: pki-to