Lines 198-204
class UCSTestUDM(object):
|
Link Here
|
---|
|
198 |
:param list options: A list of UDM option group to set. |
198 |
:param list options: A list of UDM option group to set. |
199 |
:param str_or_list set: A list or one single *name=value* property. |
199 |
:param str_or_list set: A list or one single *name=value* property. |
200 |
:param list append: A list of *name=value* properties to add. |
200 |
:param list append: A list of *name=value* properties to add. |
201 |
:param list remove: A list of *name=value* properties to add. |
201 |
:param list remove: A list of *name=value* properties to remove. |
202 |
:param boolean remove_referring: Remove other LDAP entries referred by this entry. |
202 |
:param boolean remove_referring: Remove other LDAP entries referred by this entry. |
203 |
:param boolean ignore_exists: Ignore error on creation if entry already exists. |
203 |
:param boolean ignore_exists: Ignore error on creation if entry already exists. |
204 |
:param boolean ignore_not_exists: Ignore error on deletion if entry does not exists. |
204 |
:param boolean ignore_not_exists: Ignore error on deletion if entry does not exists. |
Lines 252-265
class UCSTestUDM(object):
|
Link Here
|
---|
|
252 |
|
252 |
|
253 |
return cmd |
253 |
return cmd |
254 |
|
254 |
|
255 |
def create_object(self, modulename, wait_for_replication=True, check_for_drs_replication=False, **kwargs): |
255 |
def create_object(self, modulename, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): |
256 |
r""" |
256 |
r""" |
257 |
Creates a LDAP object via UDM. Values for UDM properties can be passed via keyword arguments |
257 |
Creates a LDAP object via UDM. Values for UDM properties can be passed via keyword arguments |
258 |
only and have to exactly match UDM property names (case-sensitive!). |
258 |
only and have to exactly match UDM property names (case-sensitive!). |
259 |
|
259 |
|
260 |
:param str modulename: name of UDM module (e.g. 'users/user') |
260 |
:param str modulename: name of UDM module (e.g. 'users/user') |
261 |
:param bool wait_for_replication: delay return until Listener has settled. |
261 |
:param bool wait_for_replication: delay return until Listener has settled. |
262 |
:param bool check_for_drs_replication: delay return until Samab4 has settled. |
262 |
:param bool wait_for_s4connector: delay return until S4-Connector has settled. |
|
|
263 |
:param bool check_for_drs_replication: delay return until Samba4 has settled. |
263 |
:param \*\*kwargs: |
264 |
:param \*\*kwargs: |
264 |
""" |
265 |
""" |
265 |
if not modulename: |
266 |
if not modulename: |
Lines 284-299
class UCSTestUDM(object):
|
Link Here
|
---|
|
284 |
else: |
285 |
else: |
285 |
raise UCSTestUDM_CreateUDMUnknownDN({'module': modulename, 'kwargs': kwargs, 'stdout': stdout, 'stderr': stderr}) |
286 |
raise UCSTestUDM_CreateUDMUnknownDN({'module': modulename, 'kwargs': kwargs, 'stdout': stdout, 'stderr': stderr}) |
286 |
|
287 |
|
287 |
self.wait_for(modulename, dn, wait_for_replication, wait_for_drs_replication=(wait_for_replication and check_for_drs_replication and ("options" not in kwargs or "kerberos" in kwargs["options"]))) |
288 |
self.wait_for(modulename, dn, wait_for_replication, wait_for_s4connector, wait_for_drs_replication=(wait_for_replication and check_for_drs_replication and ("options" not in kwargs or "kerberos" in kwargs["options"]))) |
288 |
return dn |
289 |
return dn |
289 |
|
290 |
|
290 |
def modify_object(self, modulename, wait_for_replication=True, check_for_drs_replication=False, **kwargs): |
291 |
def modify_object(self, modulename, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): |
291 |
""" |
292 |
""" |
292 |
Modifies a LDAP object via UDM. Values for UDM properties can be passed via keyword arguments |
293 |
Modifies a LDAP object via UDM. Values for UDM properties can be passed via keyword arguments |
293 |
only and have to exactly match UDM property names (case-sensitive!). |
294 |
only and have to exactly match UDM property names (case-sensitive!). |
294 |
Please note: the object has to be created by create_object otherwise this call will raise an exception! |
295 |
Please note: the object has to be created by create_object otherwise this call will raise an exception! |
295 |
|
296 |
|
296 |
:param str modulename: name of UDM module (e.g. 'users/user') |
297 |
:param str modulename: name of UDM module (e.g. 'users/user') |
|
|
298 |
:param bool wait_for_replication: delay return until Listener has settled. |
299 |
:param bool wait_for_s4connector: delay return until S4-Connector has settled. |
300 |
:param bool check_for_drs_replication: delay return until Samba4 has settled. |
301 |
:param \*\*kwargs: |
297 |
""" |
302 |
""" |
298 |
if not modulename: |
303 |
if not modulename: |
299 |
raise UCSTestUDM_MissingModulename() |
304 |
raise UCSTestUDM_MissingModulename() |
Lines 325-334
class UCSTestUDM(object):
|
Link Here
|
---|
|
325 |
else: |
330 |
else: |
326 |
raise UCSTestUDM_ModifyUDMUnknownDN({'module': modulename, 'kwargs': kwargs, 'stdout': stdout, 'stderr': stderr}) |
331 |
raise UCSTestUDM_ModifyUDMUnknownDN({'module': modulename, 'kwargs': kwargs, 'stdout': stdout, 'stderr': stderr}) |
327 |
|
332 |
|
328 |
self.wait_for(modulename, dn, wait_for_replication, check_for_drs_replication) |
333 |
self.wait_for(modulename, dn, wait_for_replication, wait_for_s4connector, check_for_drs_replication) |
329 |
return dn |
334 |
return dn |
330 |
|
335 |
|
331 |
def move_object(self, modulename, wait_for_replication=True, check_for_drs_replication=False, **kwargs): |
336 |
def move_object(self, modulename, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): |
332 |
if not modulename: |
337 |
if not modulename: |
333 |
raise UCSTestUDM_MissingModulename() |
338 |
raise UCSTestUDM_MissingModulename() |
334 |
dn = kwargs.get('dn') |
339 |
dn = kwargs.get('dn') |
Lines 355-364
class UCSTestUDM(object):
|
Link Here
|
---|
|
355 |
else: |
360 |
else: |
356 |
raise UCSTestUDM_ModifyUDMUnknownDN({'module': modulename, 'kwargs': kwargs, 'stdout': stdout, 'stderr': stderr}) |
361 |
raise UCSTestUDM_ModifyUDMUnknownDN({'module': modulename, 'kwargs': kwargs, 'stdout': stdout, 'stderr': stderr}) |
357 |
|
362 |
|
358 |
self.wait_for(modulename, dn, wait_for_replication, check_for_drs_replication) |
363 |
self.wait_for(modulename, dn, wait_for_replication, wait_for_s4connector, check_for_drs_replication) |
359 |
return new_dn |
364 |
return new_dn |
360 |
|
365 |
|
361 |
def remove_object(self, modulename, wait_for_replication=True, **kwargs): |
366 |
def remove_object(self, modulename, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): |
362 |
if not modulename: |
367 |
if not modulename: |
363 |
raise UCSTestUDM_MissingModulename() |
368 |
raise UCSTestUDM_MissingModulename() |
364 |
dn = kwargs.get('dn') |
369 |
dn = kwargs.get('dn') |
Lines 378-386
class UCSTestUDM(object):
|
Link Here
|
---|
|
378 |
if dn in self._cleanup.get(modulename, []): |
383 |
if dn in self._cleanup.get(modulename, []): |
379 |
self._cleanup[modulename].remove(dn) |
384 |
self._cleanup[modulename].remove(dn) |
380 |
|
385 |
|
381 |
self.wait_for(modulename, dn, wait_for_replication) |
386 |
self.wait_for(modulename, dn, wait_for_replication, wait_for_s4connector, wait_for_drs_replication) |
382 |
|
387 |
|
383 |
def wait_for(self, modulename, dn, wait_for_replication=True, wait_for_drs_replication=False, wait_for_s4connector=False): |
388 |
def wait_for(self, modulename, dn, wait_for_replication=True, wait_for_s4connector=True, wait_for_drs_replication=False): |
384 |
conditions = [] |
389 |
conditions = [] |
385 |
if wait_for_replication: |
390 |
if wait_for_replication: |
386 |
conditions.append((utils.ReplicationType.LISTENER, wait_for_replication)) |
391 |
conditions.append((utils.ReplicationType.LISTENER, wait_for_replication)) |
Lines 396-402
class UCSTestUDM(object):
|
Link Here
|
---|
|
396 |
conditions.append((utils.ReplicationType.DRS, drs_replication)) |
401 |
conditions.append((utils.ReplicationType.DRS, drs_replication)) |
397 |
return utils.wait_for(conditions, verbose=False) |
402 |
return utils.wait_for(conditions, verbose=False) |
398 |
|
403 |
|
399 |
def create_user(self, wait_for_replication=True, check_for_drs_replication=True, **kwargs): # :pylint: disable-msg=W0613 |
404 |
def wait_for_ng(self, modulename, dn, wait_for_drs_replication=False): |
|
|
405 |
if wait_for_drs_replication and not isinstance(wait_for_drs_replication, basestring): |
406 |
attr = {'container/ou': 'ou'}.get(modulename, 'cn') |
407 |
samba4_condition_filter = ldap.filter.filter_format('%s=%s', (attr, ldap.dn.str2dn(dn)[0][0][1],)) |
408 |
return utils.wait_for_replication_from_master_openldap_to_local_samba(ldap_filter = samba4_condition_filter, verbose=False) |
409 |
|
410 |
def create_user(self, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=True, **kwargs): # :pylint: disable-msg=W0613 |
400 |
""" |
411 |
""" |
401 |
Creates a user via UDM CLI. Values for UDM properties can be passed via keyword arguments only and |
412 |
Creates a user via UDM CLI. Values for UDM properties can be passed via keyword arguments only and |
402 |
have to exactly match UDM property names (case-sensitive!). Some properties have default values: |
413 |
have to exactly match UDM property names (case-sensitive!). Some properties have default values: |
Lines 417-425
class UCSTestUDM(object):
|
Link Here
|
---|
|
417 |
('firstname', uts.random_name()) |
428 |
('firstname', uts.random_name()) |
418 |
)) |
429 |
)) |
419 |
|
430 |
|
420 |
return (self.create_object('users/user', wait_for_replication, check_for_drs_replication, **attr), attr['username']) |
431 |
return (self.create_object('users/user', wait_for_replication, wait_for_s4connector, check_for_drs_replication, **attr), attr['username']) |
421 |
|
432 |
|
422 |
def create_ldap_user(self, wait_for_replication=True, check_for_drs_replication=False, **kwargs): # :pylint: disable-msg=W0613 |
433 |
def create_ldap_user(self, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): # :pylint: disable-msg=W0613 |
423 |
# check_for_drs_replication=False -> ldap users are not replicated to s4 |
434 |
# check_for_drs_replication=False -> ldap users are not replicated to s4 |
424 |
attr = self._set_module_default_attr(kwargs, ( |
435 |
attr = self._set_module_default_attr(kwargs, ( |
425 |
('position', 'cn=users,%s' % self.LDAP_BASE), |
436 |
('position', 'cn=users,%s' % self.LDAP_BASE), |
Lines 429-435
class UCSTestUDM(object):
|
Link Here
|
---|
|
429 |
('name', uts.random_name()) |
440 |
('name', uts.random_name()) |
430 |
)) |
441 |
)) |
431 |
|
442 |
|
432 |
return (self.create_object('users/ldap', wait_for_replication, check_for_drs_replication, **attr), attr['username']) |
443 |
return (self.create_object('users/ldap', wait_for_replication, wait_for_s4connector, check_for_drs_replication, **attr), attr['username']) |
433 |
|
444 |
|
434 |
def remove_user(self, username, wait_for_replication=True): |
445 |
def remove_user(self, username, wait_for_replication=True): |
435 |
"""Removes a user object from the ldap given it's username.""" |
446 |
"""Removes a user object from the ldap given it's username.""" |
Lines 438-444
class UCSTestUDM(object):
|
Link Here
|
---|
|
438 |
} |
449 |
} |
439 |
self.remove_object('users/user', wait_for_replication, **kwargs) |
450 |
self.remove_object('users/user', wait_for_replication, **kwargs) |
440 |
|
451 |
|
441 |
def create_group(self, wait_for_replication=True, check_for_drs_replication=True, **kwargs): # :pylint: disable-msg=W0613 |
452 |
def create_group(self, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=True, **kwargs): # :pylint: disable-msg=W0613 |
442 |
""" |
453 |
""" |
443 |
Creates a group via UDM CLI. Values for UDM properties can be passed via keyword arguments only and |
454 |
Creates a group via UDM CLI. Values for UDM properties can be passed via keyword arguments only and |
444 |
have to exactly match UDM property names (case-sensitive!). Some properties have default values: |
455 |
have to exactly match UDM property names (case-sensitive!). Some properties have default values: |
Lines 454-460
class UCSTestUDM(object):
|
Link Here
|
---|
|
454 |
('name', uts.random_groupname()) |
465 |
('name', uts.random_groupname()) |
455 |
)) |
466 |
)) |
456 |
|
467 |
|
457 |
return (self.create_object('groups/group', wait_for_replication, check_for_drs_replication, **attr), attr['name']) |
468 |
return (self.create_object('groups/group', wait_for_replication, wait_for_s4connector, check_for_drs_replication, **attr), attr['name']) |
458 |
|
469 |
|
459 |
def _set_module_default_attr(self, attributes, defaults): |
470 |
def _set_module_default_attr(self, attributes, defaults): |
460 |
""" |
471 |
""" |