Add --replace-touch parameter
This commit is contained in:
parent
b4004e2a0f
commit
e9b1f0f26f
1 changed files with 10 additions and 2 deletions
|
@ -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,
|
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)
|
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()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
@ -230,8 +235,11 @@ class LdapServer(object):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def touch_object(self,dn,attr,orig_value):
|
def touch_object(self,dn,attr,orig_value):
|
||||||
new_value=list(orig_value)
|
if options.replacetouch:
|
||||||
new_value.append(TOUCH_VALUE)
|
new_value=[new_value]
|
||||||
|
else:
|
||||||
|
new_value=list(orig_value)
|
||||||
|
new_value.append(TOUCH_VALUE)
|
||||||
try:
|
try:
|
||||||
logging.info('Add value "%s" to attribute %s of object %s' % (TOUCH_VALUE,attr,dn))
|
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}):
|
if self.update_object(dn,{attr: orig_value}, {attr: new_value}):
|
||||||
|
|
Loading…
Reference in a new issue