diff options
| author | Abhijeet Kasurde <akasurde@redhat.com> | 2016-07-01 10:05:05 +0530 |
|---|---|---|
| committer | Endi S. Dewata <edewata@redhat.com> | 2016-07-01 19:19:25 +0200 |
| commit | e81cf4e11ca86562b27548d469fa606a072da23b (patch) | |
| tree | 0aedf8645df245a41cef81ebc9bb9d473907fbac /base/server/python | |
| parent | f8310a4ff306d28cf25ec71693a2e89c5323564d (diff) | |
| download | pki-e81cf4e11ca86562b27548d469fa606a072da23b.tar.gz pki-e81cf4e11ca86562b27548d469fa606a072da23b.tar.xz pki-e81cf4e11ca86562b27548d469fa606a072da23b.zip | |
Updated notification message for kra-db-vlv* 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/kra.py | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/base/server/python/pki/server/cli/kra.py b/base/server/python/pki/server/cli/kra.py index 17611a82b..5c9111d5b 100644 --- a/base/server/python/pki/server/cli/kra.py +++ b/base/server/python/pki/server/cli/kra.py @@ -361,19 +361,28 @@ 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) if self.out_file: subsystem.customize_file(KRA_VLV_PATH, self.out_file) print('KRA VLVs written to ' + self.out_file) return + try: + self.add_vlv(subsystem, bind_dn, bind_password) + + print('KRA VLVs added to the database for ' + instance_name) + + except ldap.LDAPError as e: + print("ERROR: " + e.message['desc']) + sys.exit(1) + + def add_vlv(self, subsystem, bind_dn, bind_password): + ldif_file = tempfile.NamedTemporaryFile(delete=False) subsystem.customize_file(KRA_VLV_PATH, ldif_file.name) @@ -386,12 +395,11 @@ 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) + finally: os.unlink(ldif_file.name) conn.close() - print('KRA VLVs added to the database for ' + instance.name) - class KRADBVLVDeleteCLI(pki.cli.CLI): @@ -581,28 +589,30 @@ 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) if self.out_file: subsystem.customize_file(KRA_VLV_TASKS_PATH, self.out_file) print('KRA VLV reindex task written to ' + self.out_file) return + 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): + ldif_file = tempfile.NamedTemporaryFile(delete=False) subsystem.customize_file(KRA_VLV_TASKS_PATH, ldif_file.name) 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 +640,3 @@ class KRADBVLVReindexCLI(pki.cli.CLI): finally: os.unlink(ldif_file.name) conn.close() - - print('KRA VLV reindex completed for ' + instance.name) |
