Add --replace-touch parameter

This commit is contained in:
Benjamin Renard 2013-12-19 18:38:47 +01:00
parent b4004e2a0f
commit e9b1f0f26f
1 changed files with 10 additions and 2 deletions

View File

@ -129,6 +129,11 @@ parser.add_option( "--touch",
help="Touch attribute giving in parameter to force resync a this LDAP object from provider. A value '%s' will be add to this attribute and remove after. The user use to connect to the LDAP directory must have write permission on this attribute on each object." % TOUCH_VALUE,
default=None)
parser.add_option( "--replace-touch",
dest="replacetouch",
action="store_true",
help="In touche mode, replace value instead of adding.",
default=False)
(options, args) = parser.parse_args()
@ -230,8 +235,11 @@ class LdapServer(object):
return []
def touch_object(self,dn,attr,orig_value):
new_value=list(orig_value)
new_value.append(TOUCH_VALUE)
if options.replacetouch:
new_value=[new_value]
else:
new_value=list(orig_value)
new_value.append(TOUCH_VALUE)
try:
logging.info('Add value "%s" to attribute %s of object %s' % (TOUCH_VALUE,attr,dn))
if self.update_object(dn,{attr: orig_value}, {attr: new_value}):