|
|
590d18 |
From 23dd6ad21e09a14a802c7776bf073f22011f7eb6 Mon Sep 17 00:00:00 2001
|
|
|
590d18 |
From: Jan Cholasta <jcholast@redhat.com>
|
|
|
590d18 |
Date: Tue, 18 Aug 2015 21:44:13 +0200
|
|
|
590d18 |
Subject: [PATCH] vault: Add container information to vault command results
|
|
|
590d18 |
|
|
|
590d18 |
https://fedorahosted.org/freeipa/ticket/5150
|
|
|
590d18 |
|
|
|
590d18 |
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
|
|
|
590d18 |
---
|
|
|
590d18 |
ipalib/plugins/vault.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
590d18 |
1 file changed, 44 insertions(+)
|
|
|
590d18 |
|
|
|
590d18 |
diff --git a/ipalib/plugins/vault.py b/ipalib/plugins/vault.py
|
|
|
590d18 |
index ff021a6a2106b6bcbd690b50bf58e49249e80500..712e2d5ddfa723eb84b80a261289a7cf1c75674f 100644
|
|
|
590d18 |
--- a/ipalib/plugins/vault.py
|
|
|
590d18 |
+++ b/ipalib/plugins/vault.py
|
|
|
590d18 |
@@ -322,6 +322,21 @@ class vault(LDAPObject):
|
|
|
590d18 |
label=_('Failed owners'),
|
|
|
590d18 |
flags=['no_create', 'no_update', 'no_search'],
|
|
|
590d18 |
),
|
|
|
590d18 |
+ Str(
|
|
|
590d18 |
+ 'service?',
|
|
|
590d18 |
+ label=_('Vault service'),
|
|
|
590d18 |
+ flags={'virtual_attribute', 'no_create', 'no_update', 'no_search'},
|
|
|
590d18 |
+ ),
|
|
|
590d18 |
+ Flag(
|
|
|
590d18 |
+ 'shared?',
|
|
|
590d18 |
+ label=_('Shared vault'),
|
|
|
590d18 |
+ flags={'virtual_attribute', 'no_create', 'no_update', 'no_search'},
|
|
|
590d18 |
+ ),
|
|
|
590d18 |
+ Str(
|
|
|
590d18 |
+ 'username?',
|
|
|
590d18 |
+ label=_('Vault user'),
|
|
|
590d18 |
+ flags={'virtual_attribute', 'no_create', 'no_update', 'no_search'},
|
|
|
590d18 |
+ ),
|
|
|
590d18 |
)
|
|
|
590d18 |
|
|
|
590d18 |
def get_dn(self, *keys, **options):
|
|
|
590d18 |
@@ -523,6 +538,17 @@ class vault(LDAPObject):
|
|
|
590d18 |
raise errors.AuthenticationError(
|
|
|
590d18 |
message=_('Invalid credentials'))
|
|
|
590d18 |
|
|
|
590d18 |
+ def get_container_attribute(self, entry, options):
|
|
|
590d18 |
+ if options.get('raw', False):
|
|
|
590d18 |
+ return
|
|
|
590d18 |
+ container_dn = DN(self.container_dn, self.api.env.basedn)
|
|
|
590d18 |
+ if entry.dn.endswith(DN(('cn', 'services'), container_dn)):
|
|
|
590d18 |
+ entry['service'] = entry.dn[1]['cn']
|
|
|
590d18 |
+ elif entry.dn.endswith(DN(('cn', 'shared'), container_dn)):
|
|
|
590d18 |
+ entry['shared'] = True
|
|
|
590d18 |
+ elif entry.dn.endswith(DN(('cn', 'users'), container_dn)):
|
|
|
590d18 |
+ entry['username'] = entry.dn[1]['cn']
|
|
|
590d18 |
+
|
|
|
590d18 |
|
|
|
590d18 |
@register()
|
|
|
590d18 |
class vault_add(PKQuery, Local):
|
|
|
590d18 |
@@ -738,6 +764,10 @@ class vault_add_internal(LDAPCreate):
|
|
|
590d18 |
|
|
|
590d18 |
return dn
|
|
|
590d18 |
|
|
|
590d18 |
+ def post_callback(self, ldap, dn, entry, *keys, **options):
|
|
|
590d18 |
+ self.obj.get_container_attribute(entry, options)
|
|
|
590d18 |
+ return dn
|
|
|
590d18 |
+
|
|
|
590d18 |
|
|
|
590d18 |
@register()
|
|
|
590d18 |
class vault_del(LDAPDelete):
|
|
|
590d18 |
@@ -806,6 +836,11 @@ class vault_find(LDAPSearch):
|
|
|
590d18 |
|
|
|
590d18 |
return (filter, base_dn, scope)
|
|
|
590d18 |
|
|
|
590d18 |
+ def post_callback(self, ldap, entries, truncated, *args, **options):
|
|
|
590d18 |
+ for entry in entries:
|
|
|
590d18 |
+ self.obj.get_container_attribute(entry, options)
|
|
|
590d18 |
+ return truncated
|
|
|
590d18 |
+
|
|
|
590d18 |
def exc_callback(self, args, options, exc, call_func, *call_args,
|
|
|
590d18 |
**call_kwargs):
|
|
|
590d18 |
if call_func.__name__ == 'find_entries':
|
|
|
590d18 |
@@ -836,6 +871,10 @@ class vault_mod(LDAPUpdate):
|
|
|
590d18 |
|
|
|
590d18 |
return dn
|
|
|
590d18 |
|
|
|
590d18 |
+ def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
|
|
|
590d18 |
+ self.obj.get_container_attribute(entry_attrs, options)
|
|
|
590d18 |
+ return dn
|
|
|
590d18 |
+
|
|
|
590d18 |
|
|
|
590d18 |
@register()
|
|
|
590d18 |
class vault_show(LDAPRetrieve):
|
|
|
590d18 |
@@ -854,6 +893,10 @@ class vault_show(LDAPRetrieve):
|
|
|
590d18 |
|
|
|
590d18 |
return dn
|
|
|
590d18 |
|
|
|
590d18 |
+ def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
|
|
|
590d18 |
+ self.obj.get_container_attribute(entry_attrs, options)
|
|
|
590d18 |
+ return dn
|
|
|
590d18 |
+
|
|
|
590d18 |
|
|
|
590d18 |
@register()
|
|
|
590d18 |
class vaultconfig(Object):
|
|
|
590d18 |
@@ -1452,6 +1495,7 @@ class VaultModMember(LDAPModMember):
|
|
|
590d18 |
def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options):
|
|
|
590d18 |
for fail in failed.itervalues():
|
|
|
590d18 |
fail['services'] = fail.pop('service', [])
|
|
|
590d18 |
+ self.obj.get_container_attribute(entry_attrs, options)
|
|
|
590d18 |
return completed, dn
|
|
|
590d18 |
|
|
|
590d18 |
|
|
|
590d18 |
--
|
|
|
590d18 |
2.4.3
|
|
|
590d18 |
|