Ë
    þI¶d("  ã                   ó²   — d dl Z d dl mZmZmZ ddlmZ  G d„ de«      Z G d„ de«      Z G d	„ d
e«      Z	 G d„ de«      Z
 G d„ de«      Zd„ Zd„ Zd„ Zd„ Zy)é    N)ÚFLAG_MOD_ADDÚFLAG_MOD_REPLACEÚLdbErroré   )ÚSiteNotFoundExceptionc                   ó   — e Zd ZdZy)ÚSubnetExceptionzBase element for Subnet errorsN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú//usr/lib/python3/dist-packages/samba/subnets.pyr	   r	      s   „ Ù(Ør   r	   c                   ó   — e Zd ZdZy)ÚSubnetNotFoundz$The subnet requested does not exist.Nr
   r   r   r   r   r   !   s   „ Ù.Ør   r   c                   ó   — e Zd ZdZy)ÚSubnetAlreadyExistsz&The subnet being added already exists.Nr
   r   r   r   r   r   &   s   „ Ù0Ør   r   c                   ó   — e Zd ZdZy)ÚSubnetInvalidzThe subnet CIDR is invalid.Nr
   r   r   r   r   r   +   s   „ Ù%Ør   r   c                   ó   — e Zd ZdZy)ÚSiteNotFoundz2The site to be used for the subnet does not exist.Nr
   r   r   r   r   r   0   s   „ Ù<Ør   r   c                 óê  — | j                  |t        j                  dt        j                  |«      z  ¬«      }t	        |«      dk7  rt        d|z  «      ‚|d   j                  }t        |t        «      st        d|z  «      ‚t        j                  | d«      }	 |j                  |«       	 |j                  d	«       |j                  dd|«       	 t        j                   «       }||_        t        j"                  dt$        d«      |d<   t        j"                  t        |«      t$        d«      |d<   | j'                  |«       y# t        j                  $ r t        d«      ‚w xY w# t        j                  $ r t        d
«      ‚w xY w# t        j                  $ rY}|j(                  \  }	}
|	t        j*                  k(  rt        |›d|
›�«      ‚|	t        j,                  k(  rt/        d|z  «      ‚‚ d}~ww xY w)aj  Create 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Ú
expressionr   z&A site with the name %s does not existr   z'%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_baser   r	   Ú	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_subnetrF   5   sÚ  € ð �,‰,˜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ÆAG-Ç-G2c                 óT  — t        j                  | d«      }	 |j                  |«       	 |j                  d«       |j                  dd|«       	 | j                  |t         j                  d¬«      }t        |«      d	k7  rt        d
|z  «      ‚	 | j                  |«       y# t         j                  $ r t	        d«      ‚w xY w# t         j                  $ r t	        d«      ‚w xY w# t        $ r:}|j                  \  }}|t         j                  k(  rt        d
|z  «      ‚Y d}~Œ”d}~ww xY w)a  Delete 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.
    r   r    r!   r"   r   r#   úobjectClass=subnetr   r   úSubnet %s does not existN)r*   r1   r2   r   r	   r3   r4   r)   Ú
SCOPE_BASEr-   r   r8   ÚERR_NO_SUCH_OBJECTÚdelete)r;   r<   r=   rA   r?   Úe1rD   rE   s           r   Údelete_subnetrN   m   s'  € ô �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                 ó¼  — t        j                  | d«      }	 |j                  |«       	 |j                  d«       |j                  dd|«       t        j                  | t        |«      «      }|j                  dd|«       	 | j                  ||«       y
# t         j                  $ r t	        d«      ‚w xY w# t         j                  $ r t	        d«      ‚w xY w# t        $ rz}|j                  \  }}|t         j                  k(  rt        d|z  «      ‚|t         j                  k(  rt        d|z  «      ‚|t         j                  k(  rt        |›d	|›�«      ‚‚ d
}~ww xY w)av  Rename 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.
    r   r    r!   r"   r   r#   rI   r(   r'   N)r*   r1   r2   r   r	   r3   r4   r0   Úrenamer8   rK   r   r:   r   r9   r   )	r;   r<   r=   Únew_namerA   ÚnewdnsubnetÚe2rD   rE   s	            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Â6CÃ	EÃ!A5EÅEc                 óv  — t        j                  | d«      }	 |j                  |«       	 |j                  d«       |j                  dd|«       	 | j                  |t         j                  d¬«      }t        |«      d	k7  rt        d
|z  «      ‚	 t        j                  | d«      }		 |	j                  |«       	 |	j                  d«       |	j                  dd|«       t        j                  | d«      }
|
j                  |	«       	 | j                  |	t         j                  d¬«      }t        |«      d	k7  rt        d|z  «      ‚	 t        d   j                  «      }t        j                   «       }||_        t        j"                  |t$        d«      |d<   | j'                  |«       y# t         j                  $ r t	        d«      ‚w xY w# t         j                  $ r t	        d«      ‚w xY w# t        $ r;}|j                  \  }}|t         j                  k(  rt        d
|z  «      ‚Y d}~�Œšd}~ww xY w# t         j                  $ r t	        d«      ‚w xY w# t         j                  $ r t	        d«      ‚w xY w# t        $ r;}|j                  \  }}|t         j                  k(  rt        d|z  «      ‚Y d}~�Œqd}~ww xY w)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.
    r   r    r!   r"   r   r#   rH   r   r   rI   NzCN=Siteszdnsite.add_base() failedzdnsite.add_child() failedz
CN=ServerszobjectClass=sitezSite %s does not existr&   )r*   r1   r2   r   r	   r3   r4   r)   rJ   r-   r   r8   rK   r   r0   r.   r5   r6   r   Úmodify)r;   r<   r=   r>   rA   r?   Úe3rD   rE   ÚdnsiteÚ	dnserversÚe4ÚsiteDnrB   s                 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 Â7I Ä>I4 Æ%GÇG&Ç)	H-Ç20H(È(H-È0IÉI1É4	J8É=0J3Ê3J8)r*   r   r   r   Úsitesr   Ú	Exceptionr	   r   r   r   r   rF   rN   rT   r\   r   r   r   ú<module>r_      sg   ðó. ß 8Ñ 8Ý )ô	�iô 	ô
	�_ô 	ô
	˜/ô 	ô
	�Oô 	ô
	�?ô 	ò
5òpòB%óPAr   