summaryrefslogtreecommitdiffstats
path: root/base/server/python
diff options
context:
space:
mode:
authorAbhijeet Kasurde <akasurde@redhat.com>2016-07-01 15:08:09 +0530
committerEndi S. Dewata <edewata@redhat.com>2016-07-01 19:19:52 +0200
commitaef84ae829bf2645937363ee3e61f002c2682869 (patch)
treec7f41c7ad7e640d1d8f698646c51302b6e326648 /base/server/python
parenteb0f8d0f1e9d396efb071c6432aa22ff0a39d613 (diff)
downloadpki-aef84ae829bf2645937363ee3e61f002c2682869.tar.gz
pki-aef84ae829bf2645937363ee3e61f002c2682869.tar.xz
pki-aef84ae829bf2645937363ee3e61f002c2682869.zip
Updated notification message for DB subsystem command
Partially fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1351295
Diffstat (limited to 'base/server/python')
-rw-r--r--base/server/python/pki/server/cli/db.py20
1 files 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 6555e4078..cc768da73 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
@@ -96,12 +97,19 @@ class DBSchemaUpgrade(pki.cli.CLI):
instance = pki.server.PKIInstance(instance_name)
if not instance.is_valid():
- print("ERROR: Instance name '%s' not found" % instance)
+ print("ERROR: Invalid instance %s." % instance_name)
sys.exit(1)
instance.load()
+ if not instance.subsystems:
+ print("ERROR: No subsystem in instance %s." % instance_name)
+ sys.exit(1)
+
+ if not bind_password:
+ bind_password = getpass.getpass(prompt='Enter password: ')
+
try:
- self.update_schema(instance, bind_dn, bind_password)
+ self.update_schema(instance.subsystems[0], bind_dn, bind_password)
except subprocess.CalledProcessError as e:
print("ERROR: " + e.output)
@@ -109,9 +117,8 @@ class DBSchemaUpgrade(pki.cli.CLI):
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,11 +181,14 @@ class DBUpgrade(pki.cli.CLI):
nss.nss_init_nodb()
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('ca')
if not subsystem:
- print('ERROR: missing subsystem ca')
+ print('ERROR: No CA subsystem in instance %s.' + instance_name)
sys.exit(1)
base_dn = subsystem.config['internaldb.basedn']