mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
samba.drs_utils: Use new style classes and exceptions, fix formatting of docstrings to make pydoctor happy.
This commit is contained in:
parent
452d1ef8ef
commit
e76c981c80
@ -24,7 +24,7 @@ from samba.net import Net
|
|||||||
import samba, ldb
|
import samba, ldb
|
||||||
|
|
||||||
|
|
||||||
class drsException:
|
class drsException(Exception):
|
||||||
"""Base element for drs errors"""
|
"""Base element for drs errors"""
|
||||||
|
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
@ -35,8 +35,8 @@ class drsException:
|
|||||||
|
|
||||||
|
|
||||||
def drsuapi_connect(server, lp, creds):
|
def drsuapi_connect(server, lp, creds):
|
||||||
"""
|
"""Make a DRSUAPI connection to the server.
|
||||||
make a DRSUAPI connection to the server
|
|
||||||
:param server: the name of the server to connect to
|
:param server: the name of the server to connect to
|
||||||
:param lp: a samba line parameter object
|
:param lp: a samba line parameter object
|
||||||
:param creds: credential used for the connection
|
:param creds: credential used for the connection
|
||||||
@ -57,15 +57,18 @@ def drsuapi_connect(server, lp, creds):
|
|||||||
|
|
||||||
return (drsuapiBind, drsuapiHandle, bindSupportedExtensions)
|
return (drsuapiBind, drsuapiHandle, bindSupportedExtensions)
|
||||||
|
|
||||||
def sendDsReplicaSync(drsuapiBind, drsuapi_handle, source_dsa_guid, naming_context, req_option):
|
|
||||||
"""
|
def sendDsReplicaSync(drsuapiBind, drsuapi_handle, source_dsa_guid,
|
||||||
|
naming_context, req_option):
|
||||||
|
"""Send DS replica sync request.
|
||||||
|
|
||||||
:param drsuapiBind: a drsuapi Bind object
|
:param drsuapiBind: a drsuapi Bind object
|
||||||
:param drsuapi_handle: a drsuapi hanle on the drsuapi connection
|
:param drsuapi_handle: a drsuapi hanle on the drsuapi connection
|
||||||
:param source_dsa_guid: the guid of the source dsa for the replication
|
:param source_dsa_guid: the guid of the source dsa for the replication
|
||||||
:param naming_context: the DN of the naming context to replicate
|
:param naming_context: the DN of the naming context to replicate
|
||||||
:param req_options: replication options for the DsReplicaSync call
|
:param req_options: replication options for the DsReplicaSync call
|
||||||
:raise drsException: if any error occur while sending and receiving the reply
|
:raise drsException: if any error occur while sending and receiving the
|
||||||
for the dsReplicaSync
|
reply for the dsReplicaSync
|
||||||
"""
|
"""
|
||||||
|
|
||||||
nc = drsuapi.DsReplicaObjectIdentifier()
|
nc = drsuapi.DsReplicaObjectIdentifier()
|
||||||
@ -81,14 +84,17 @@ def sendDsReplicaSync(drsuapiBind, drsuapi_handle, source_dsa_guid, naming_conte
|
|||||||
except Exception, estr:
|
except Exception, estr:
|
||||||
raise drsException("DsReplicaSync failed %s" % estr)
|
raise drsException("DsReplicaSync failed %s" % estr)
|
||||||
|
|
||||||
|
|
||||||
def sendRemoveDsServer(drsuapiBind, drsuapi_handle, server_dsa_dn, domain):
|
def sendRemoveDsServer(drsuapiBind, drsuapi_handle, server_dsa_dn, domain):
|
||||||
"""
|
"""Send RemoveDSServer request.
|
||||||
|
|
||||||
:param drsuapiBind: a drsuapi Bind object
|
:param drsuapiBind: a drsuapi Bind object
|
||||||
:param drsuapi_handle: a drsuapi hanle on the drsuapi connection
|
:param drsuapi_handle: a drsuapi hanle on the drsuapi connection
|
||||||
:param server_dsa_dn: a DN object of the server's dsa that we want to demote
|
:param server_dsa_dn: a DN object of the server's dsa that we want to
|
||||||
|
demote
|
||||||
:param domain: a DN object of the server's domain
|
:param domain: a DN object of the server's domain
|
||||||
:raise drsException: if any error occur while sending and receiving the reply
|
:raise drsException: if any error occur while sending and receiving the
|
||||||
for the DsRemoveDSServer
|
reply for the DsRemoveDSServer
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -101,6 +107,7 @@ def sendRemoveDsServer(drsuapiBind, drsuapi_handle, server_dsa_dn, domain):
|
|||||||
except Exception, estr:
|
except Exception, estr:
|
||||||
raise drsException("DsRemoveDSServer failed %s" % estr)
|
raise drsException("DsRemoveDSServer failed %s" % estr)
|
||||||
|
|
||||||
|
|
||||||
def drs_DsBind(drs):
|
def drs_DsBind(drs):
|
||||||
'''make a DsBind call, returning the binding handle'''
|
'''make a DsBind call, returning the binding handle'''
|
||||||
bind_info = drsuapi.DsBindInfoCtr()
|
bind_info = drsuapi.DsBindInfoCtr()
|
||||||
@ -139,7 +146,7 @@ def drs_DsBind(drs):
|
|||||||
return (handle, info.info.supported_extensions)
|
return (handle, info.info.supported_extensions)
|
||||||
|
|
||||||
|
|
||||||
class drs_Replicate:
|
class drs_Replicate(object):
|
||||||
'''DRS replication calls'''
|
'''DRS replication calls'''
|
||||||
|
|
||||||
def __init__(self, binding_string, lp, creds, samdb):
|
def __init__(self, binding_string, lp, creds, samdb):
|
||||||
@ -239,7 +246,6 @@ class drs_Replicate:
|
|||||||
setattr(req5, a, getattr(req8, a))
|
setattr(req5, a, getattr(req8, a))
|
||||||
req = req5
|
req = req5
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
(level, ctr) = self.drs.DsGetNCChanges(self.drs_handle, req_level, req)
|
(level, ctr) = self.drs.DsGetNCChanges(self.drs_handle, req_level, req)
|
||||||
if ctr.first_object == None and ctr.object_count != 0:
|
if ctr.first_object == None and ctr.object_count != 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user