Hi All,

Please review these patches.

Partially fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1351295

--
Thanks,
Abhijeet Kasurde

IRC: akasurde
http://akasurde.github.io

From c97514152a50e34936a465963d41965a33caa2a7 Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde <akasu...@redhat.com>
Date: Fri, 1 Jul 2016 10:35:21 +0530
Subject: [PATCH 8/8] Updated notification message for TPS subsystem command

Partially fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1351295

Signed-off-by: Abhijeet Kasurde <akasu...@redhat.com>
---
 base/server/python/pki/server/cli/tps.py | 34 ++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/base/server/python/pki/server/cli/tps.py b/base/server/python/pki/server/cli/tps.py
index 63da3414ea2ac9caf5101ce3b51f198b42712eeb..1f71b8ece1431426d865d7e98fa87e5417beb36c 100644
--- a/base/server/python/pki/server/cli/tps.py
+++ b/base/server/python/pki/server/cli/tps.py
@@ -127,9 +127,15 @@ class TPSClonePrepareCLI(pki.cli.CLI):
             sys.exit(1)
 
         instance = pki.server.PKIInstance(instance_name)
+        if not instance.is_valid():
+            print('ERROR: Invalid instance %s.' % instance_name)
+            sys.exit(1)
         instance.load()
 
         subsystem = instance.get_subsystem('tps')
+        if not subsystem:
+            print("ERROR: No TPS subsystem in instance %s." % instance_name)
+            sys.exit(1)
 
         tmpdir = tempfile.mkdtemp()
 
@@ -228,12 +234,15 @@ class TPSDBVLVFindCLI(pki.cli.CLI):
                 sys.exit(1)
 
         instance = pki.server.PKIInstance(instance_name)
+        if not instance.is_valid():
+            print('ERROR: Invalid instance %s.' % instance_name)
+            sys.exit(1)
         instance.load()
 
         subsystem = instance.get_subsystem('tps')
-
         if not subsystem:
-            raise Exception('Subsystem not found')
+            print("ERROR: No TPS subsystem in instance %s." % instance_name)
+            sys.exit(1)
 
         self.find_vlv(subsystem, bind_dn, bind_password)
 
@@ -340,12 +349,15 @@ class TPSDBVLVAddCLI(pki.cli.CLI):
                 sys.exit(1)
 
         instance = pki.server.PKIInstance(instance_name)
+        if not instance.is_valid():
+            print('ERROR: Invalid instance %s.' % instance_name)
+            sys.exit(1)
         instance.load()
 
         subsystem = instance.get_subsystem('tps')
-
         if not subsystem:
-            raise Exception('Subsystem not found')
+            print("ERROR: No TPS subsystem in instance %s." % instance_name)
+            sys.exit(1)
 
         if out_file:
             self.generate_ldif(subsystem, out_file)
@@ -450,12 +462,15 @@ class TPSDBVLVDeleteCLI(pki.cli.CLI):
                 sys.exit(1)
 
         instance = pki.server.PKIInstance(instance_name)
+        if not instance.is_valid():
+            print('ERROR: Invalid instance %s.' % instance_name)
+            sys.exit(1)
         instance.load()
 
         subsystem = instance.get_subsystem('tps')
-
         if not subsystem:
-            raise Exception('Subsystem not found')
+            print("ERROR: No TPS subsystem in instance %s." % instance_name)
+            sys.exit(1)
 
         if out_file:
             self.generate_ldif(subsystem, out_file)
@@ -582,12 +597,15 @@ class TPSDBVLVReindexCLI(pki.cli.CLI):
                 sys.exit(1)
 
         instance = pki.server.PKIInstance(instance_name)
+        if not instance.is_valid():
+            print('ERROR: Invalid instance %s.' % instance_name)
+            sys.exit(1)
         instance.load()
 
         subsystem = instance.get_subsystem('tps')
-
         if not subsystem:
-            raise Exception('Subsystem not found')
+            print("ERROR: No TPS subsystem in instance %s." % instance_name)
+            sys.exit(1)
 
         if out_file:
             self.generate_ldif(subsystem, out_file)
-- 
2.7.4

From d248b6c3abcac5be9bea9311741d493e20561b85 Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde <akasu...@redhat.com>
Date: Fri, 1 Jul 2016 10:31:32 +0530
Subject: [PATCH 7/8] Updated notification message for TKS subsystem command

Partially fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1351295

Signed-off-by: Abhijeet Kasurde <akasu...@redhat.com>
---
 base/server/python/pki/server/cli/tks.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/base/server/python/pki/server/cli/tks.py b/base/server/python/pki/server/cli/tks.py
index 0bcf748c3ca65980a888946d807536d62bfdf894..2c4157a03bc601c36141f67880fe7624aa1febee 100644
--- a/base/server/python/pki/server/cli/tks.py
+++ b/base/server/python/pki/server/cli/tks.py
@@ -118,9 +118,16 @@ class TKSClonePrepareCLI(pki.cli.CLI):
             sys.exit(1)
 
         instance = pki.server.PKIInstance(instance_name)
+        if not instance.is_valid():
+            print('ERROR: Invalid instance %s.' % instance_name)
+            sys.exit(1)
+
         instance.load()
 
         subsystem = instance.get_subsystem('tks')
+        if not subsystem:
+            print("ERROR: No TKS subsystem in instance %s." % instance_name)
+            sys.exit(1)
 
         tmpdir = tempfile.mkdtemp()
 
-- 
2.7.4

From dd7c5708606da60c143e886617942f3d0d18f8e7 Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde <akasu...@redhat.com>
Date: Fri, 1 Jul 2016 10:23:53 +0530
Subject: [PATCH 6/8] Updated notification message for OCSP subsystem command

Partially fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1351295

Signed-off-by: Abhijeet Kasurde <akasu...@redhat.com>
---
 base/server/python/pki/server/cli/ocsp.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/base/server/python/pki/server/cli/ocsp.py b/base/server/python/pki/server/cli/ocsp.py
index c32e8ded666b003fb4892053282a7e2d58d6094d..246f5932dc839d2be1207d8e67e46f1b5e5182b3 100644
--- a/base/server/python/pki/server/cli/ocsp.py
+++ b/base/server/python/pki/server/cli/ocsp.py
@@ -118,9 +118,15 @@ class OCSPClonePrepareCLI(pki.cli.CLI):
             sys.exit(1)
 
         instance = pki.server.PKIInstance(instance_name)
+        if not instance.is_valid():
+            print('ERROR: Invalid instance %s.' % instance_name)
+            sys.exit(1)
         instance.load()
 
         subsystem = instance.get_subsystem('ocsp')
+        if not subsystem:
+            print("ERROR: No OCSP subsystem in instance %s." % instance_name)
+            sys.exit(1)
 
         tmpdir = tempfile.mkdtemp()
 
-- 
2.7.4

From db6b2c9db2cc5b772eaf943c693d37f4a286e65d Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde <akasu...@redhat.com>
Date: Fri, 1 Jul 2016 10:05:05 +0530
Subject: [PATCH 5/8] Updated notification message for kra-db-vlv* command

Partially Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1351295

Signed-off-by: Abhijeet Kasurde <akasu...@redhat.com>
---
 base/server/python/pki/server/cli/kra.py | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/base/server/python/pki/server/cli/kra.py b/base/server/python/pki/server/cli/kra.py
index 17611a82b0e6c5eff910c2b4556e783da348d32f..7e031f16083f78e7605a89ef8b3224c2f7f4e78f 100644
--- a/base/server/python/pki/server/cli/kra.py
+++ b/base/server/python/pki/server/cli/kra.py
@@ -361,14 +361,15 @@ class KRADBVLVAddCLI(pki.cli.CLI):
             print('ERROR: Invalid instance %s.' % instance_name)
             sys.exit(1)
         instance.load()
-        self.add_vlv(instance, bind_dn, bind_password)
 
-    def add_vlv(self, instance, bind_dn, bind_password):
         subsystem = instance.get_subsystem('kra')
         if not subsystem:
-            print('No KRA subsystem available.')
-            return
+            print('ERROR: No KRA subsystem in instance %s.' % instance_name)
+            sys.exit(1)
 
+        self.add_vlv(subsystem, bind_dn, bind_password)
+
+    def add_vlv(self, subsystem, bind_dn, bind_password):
         if self.out_file:
             subsystem.customize_file(KRA_VLV_PATH, self.out_file)
             print('KRA VLVs written to ' + self.out_file)
@@ -386,11 +387,15 @@ class KRADBVLVAddCLI(pki.cli.CLI):
             for dn, entry in parser.all_records:
                 add_modlist = ldap.modlist.addModlist(entry)
                 conn.ldap.add_s(dn, add_modlist)
+        except ldap.ALREADY_EXISTS as e:
+            print("KRA VLVs already exists in the database "
+                  "for " + subsystem.instance.name)
+            return
         finally:
             os.unlink(ldif_file.name)
             conn.close()
 
-        print('KRA VLVs added to the database for ' + instance.name)
+        print('KRA VLVs added to the database for ' + subsystem.instance.name)
 
 
 class KRADBVLVDeleteCLI(pki.cli.CLI):
@@ -581,16 +586,17 @@ class KRADBVLVReindexCLI(pki.cli.CLI):
             print('ERROR: Invalid instance %s.' % instance_name)
             sys.exit(1)
         instance.load()
-        self.reindex_vlv(instance, bind_dn, bind_password)
 
-    def reindex_vlv(self, instance, bind_dn, bind_password):
         subsystem = instance.get_subsystem('kra')
         if not subsystem:
-            if self.verbose:
-                print('reindex_vlv: No KRA subsystem available.  '
-                      'Skipping ...')
-                return
+            print('ERROR: No KRA subsystem in instance %s.' % instance_name)
+            sys.exit(1)
 
+        self.reindex_vlv(subsystem, bind_dn, bind_password)
+
+        print('KRA VLV reindex completed for ' + instance_name)
+
+    def reindex_vlv(self, subsystem, bind_dn, bind_password):
         if self.out_file:
             subsystem.customize_file(KRA_VLV_TASKS_PATH, self.out_file)
             print('KRA VLV reindex task written to ' + self.out_file)
@@ -602,7 +608,7 @@ class KRADBVLVReindexCLI(pki.cli.CLI):
         conn = subsystem.open_database(bind_dn=bind_dn,
                                        bind_password=bind_password)
 
-        print('Initiating KRA VLV reindex for ' + instance.name)
+        print('Initiating KRA VLV reindex for ' + subsystem.instance.name)
 
         try:
             parser = ldif.LDIFRecordList(open(ldif_file.name, "rb"))
@@ -630,5 +636,3 @@ class KRADBVLVReindexCLI(pki.cli.CLI):
         finally:
             os.unlink(ldif_file.name)
             conn.close()
-
-        print('KRA VLV reindex completed for ' + instance.name)
-- 
2.7.4

_______________________________________________
Pki-devel mailing list
Pki-devel@redhat.com
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to