Re: [Pki-devel] [PATCH 0009] More misc. fixes for pki-server commands

2016-07-01 Thread Endi Sukma Dewata

On 7/1/2016 5:03 AM, Abhijeet Kasurde wrote:

Hi All,

Please find the patch for review.

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

--
Thanks,
Abhijeet Kasurde


Thanks! Pushed to master with some changes:

1. The instance.subsystems contains non-empty elements, so "not 
subsystem" will always be False. The db-schema-upgrade command requires 
that there is at least one subsystem in the instance, so the check is 
changed to "not instance.subsystems".


2. The bind password prompt is a nice addition. I moved it down after 
checking the instance and subsystem so we don't have to enter the 
password if the instance/subsystem is invalid.


--
Endi S. Dewata

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


[Pki-devel] [PATCH 0009] More misc. fixes for pki-server commands

2016-07-01 Thread Abhijeet Kasurde

Hi All,

Please find the patch for review.

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

--
Thanks,
Abhijeet Kasurde

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

From e26d2115863d394c16bd5d1d4f53bc5cc8d4a4f4 Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde 
Date: Fri, 1 Jul 2016 15:08:09 +0530
Subject: [PATCH] Updated notification message for DB subsystem command

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

Signed-off-by: Abhijeet Kasurde 
---
 base/server/python/pki/server/cli/db.py | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/base/server/python/pki/server/cli/db.py b/base/server/python/pki/server/cli/db.py
index 6555e4078af1a1e85c5e972a0247115ebd52e6f1..4ed885053f2e994ab0fb08c41a079b0d7faf23e2 100644
--- a/base/server/python/pki/server/cli/db.py
+++ b/base/server/python/pki/server/cli/db.py
@@ -25,6 +25,7 @@ import ldap
 import nss.nss as nss
 import subprocess
 import sys
+import getpass
 
 import pki.cli
 
@@ -94,24 +95,30 @@ class DBSchemaUpgrade(pki.cli.CLI):
 self.usage()
 sys.exit(1)
 
+if not bind_password:
+bind_password = getpass.getpass(prompt='Enter password : ')
+
 instance = pki.server.PKIInstance(instance_name)
 if not instance.is_valid():
-print("ERROR: Instance name '%s' not found" % instance)
+print("ERROR: Instance name '%s' not found" % instance_name)
 sys.exit(1)
 instance.load()
 
+subsystem = instance.subsystems[0]
+if not subsystem:
+print("ERROR: No subsystem found.")
+sys.exit(1)
+
 try:
-self.update_schema(instance, bind_dn, bind_password)
-
+self.update_schema(subsystem, bind_dn, bind_password)
 except subprocess.CalledProcessError as e:
 print("ERROR: " + e.output)
 sys.exit(e.returncode)
 
 self.print_message('Upgrade complete')
 
-def update_schema(self, instance, bind_dn, bind_password):
+def update_schema(self, subsystem, bind_dn, bind_password):
 # TODO(alee) re-implement this using open_database
-subsystem = instance.subsystems[0]
 host = subsystem.config['internaldb.ldapconn.host']
 port = subsystem.config['internaldb.ldapconn.port']
 secure = subsystem.config['internaldb.ldapconn.secureConn']
@@ -174,6 +181,9 @@ class DBUpgrade(pki.cli.CLI):
 nss.nss_init_nodb()
 
 instance = pki.server.PKIInstance(instance_name)
+if not instance.is_valid():
+print("ERROR: Instance name '%s' not found" % instance_name)
+sys.exit(1)
 instance.load()
 
 subsystem = instance.get_subsystem('ca')
-- 
2.7.4

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