Ë ÿê<•Y"¹ãóT—dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlmZddlmZddlmZddlmZd d lmZmZd d lmZmZmZej:j=d «rdd lm Z ddl!m"Z"ddl#m$Z$ndZ$dZ"d Z%dZ&Gd„de'«Z(Gd„de)«Z*y)a3 Local RTNL ---------- Local RTNL source is a simple `IPRoute` instance. By default NDB starts with one local RTNL source names `localhost`:: >>> ndb = NDB() >>> ndb.sources.details() {'kind': u'local', u'nlm_generator': 1, 'target': u'localhost'} >>> ndb.sources['localhost'] [running] The `localhost` RTNL source starts an additional async cache thread. The `nlm_generator` option means that instead of collections the `IPRoute` object returns generators, so `IPRoute` responses will not consume memory regardless of the RTNL objects number:: >>> ndb.sources['localhost'].nl.link('dump') See also: :ref:`iproute` Network namespaces ------------------ There are two ways to connect additional sources to an NDB instance. One is to specify sources when creating an NDB object:: ndb = NDB(sources=[{'target': 'localhost'}, {'netns': 'test01'}]) Another way is to call `ndb.sources.add()` method:: ndb.sources.add(netns='test01') This syntax: `{target': 'localhost'}` and `{'netns': 'test01'}` is the short form. The full form would be:: {'target': 'localhost', # the label for the DB 'kind': 'local', # use IPRoute class to start the source 'nlm_generator': 1} # {'target': 'test01', # the label 'kind': 'netns', # use NetNS class 'netns': 'test01'} # See also: :ref:`netns` Remote systems -------------- It is possible also to connect to remote systems using SSH. In order to use this kind of sources it is required to install the `mitogen `_ module. The `remote` kind of sources uses the `RemoteIPRoute` class. The short form:: ndb.sources.add(hostname='worker1.example.com') In some more extended form:: ndb.sources.add(**{'target': 'worker1.example.com', 'kind': 'remote', 'hostname': 'worker1.example.com', 'username': 'jenkins', 'check_host_keys': False}) See also: :ref:`remote` éN)Ú basestring)ÚIPRoute)Ú NetlinkError)ÚNetlinkSocketBase)Úifinfmsg)Ú RemoteIPRouteé)ÚShutdownExceptionÚState)Ú cmsg_eventÚ cmsg_failedÚ cmsg_sstartÚlinux)Únetns)Ú NetNSManager)ÚNetNSécó—eZdZd„Zd„Zy)Ú SourceProxycóR—||_tj«|_||_y©N)ÚndbÚqueueÚQueueÚeventsÚtarget)Úselfrrs ú8/usr/lib/python3.12/site-packages/pyroute2/ndb/source.pyÚ__init__zSourceProxy.__init__hs€ØˆŒÜ—k‘k“mˆŒ ؈� óc óÆ—ttj«j«}t j «x|j j|<}|j«|j jjd|j||||dœ«|j«|j jj|«}d|vr|dSd|vr|d‚y)NÚapi)ÚtyperÚcall_idÚnameÚargvÚkwargÚreturnÚ exception)ÚstrÚuuidÚuuid4ÚhexÚ threadingÚEventrÚ_call_registryÚclearÚ messengerÚemitrÚwaitÚpop)rr%r&r'r$ÚeventÚresponses rr"zSourceProxy.apimsĀܔd—j‘j“l×&Ñ&Ó'ˆÜ3<·?±?Ó3DÐDˆ�‰×Ñ Ñ(¨5Ø � ‰ Œ à �H‰H× Ñ × #Ñ #à!Ø"Ÿk™kØ&Ø Ø Ø"ñ ô ð � ‰ Œ Ø—8‘8×*Ñ*×.Ñ.¨wÓ7ˆØ �xÑ Ø˜HÑ%Ð %Ø ˜HÑ $ؘ;Ñ'Ð 'ð%r N)Ú__name__Ú __module__Ú __qualname__rr"©r rrrgs „òó (r rcó"—eZdZdZdZdZdZdZdZe e e e dœZ d„Zed„«Zed„«Zd „Zed „«Zd „Zed „«Zed „«Zed„«Zed„«Zed„«Zd„Zd„Zd„Zd„Zd„Zd„Z e!jDdfd„Z#dd„Z$d„Z%d„Z&d„Z'y)ÚSourcezÞ The RNTL source. The source that is used to init the object must comply to IPRoute API, must support the async_cache. If the source starts additional threads, they must be joined in the source.close() ÚsrcNÚsources)ÚlocalrÚremoteÚ nsmanagerc ó^—d|_d|_||_|jj|_|d|_|j dd«|_|j dt«|_ |j d«|_ |j|j«|_ ||_ |jj�9|jjjj!|j «d|_t%j&«|_t%j&«|_t%j,«|_t%j,«|_|j*j3«|j4j7d|j z«|_t9|j4dg¬ «|_|j:j=d «|jj>jA|j |j|«|jC«y) NrÚkindr@Ú max_errorsr6rz sources.%sÚrunning)ÚlogÚ wait_listÚinit)"ÚthÚnlrÚ _event_queueÚevqrr5rDÚSOURCE_MAX_ERRORSrEr6Ú get_primeÚnl_primeÚnl_kwargr2ÚtargetsÚaddÚerrors_counterr.r/ÚshutdownÚstartedÚRLockÚlockÚ shutdown_lockr1rGÚchannelr ÚstateÚsetÚ task_managerÚdb_add_nl_sourceÚload_sql)rrÚspecs rrzSource.__init__šst€ØˆŒØˆŒØˆŒØ—8‘8×(Ñ(ˆŒà˜8‘nˆŒ Ø—H‘H˜V WÓ-ˆŒ ØŸ(™( <Ô1BÓCˆŒØ—X‘X˜gÓ&ˆŒ àŸ™ t§y¡yÓ1ˆŒ ؈Œ à �8‰8× Ñ Ð )Ø �H‰H× Ñ × &Ñ &× *Ñ *¨4¯;©;Ô 7àˆÔÜ!Ÿ™Ó)ˆŒ Ü —‘Ó(ˆŒ Ü—O‘OÓ%ˆŒ Ü&Ÿ_™_Ó.ˆÔØ � ‰ ×ÑÔØ—7‘7—?‘? <°$·+±+Ñ#=Ó>ˆŒÜ˜tŸx™x°I°;Ô?ˆŒ Ø � ‰ �‰�vÔØ �‰×Ñ×.Ñ.¨t¯{©{¸D¿I¹IÀtÔLØ � ‰ �r cóV—|jdks|j|jkryy)NrTF)rErT©rs rÚ must_restartzSource.must_restart·s%€à �?‰?˜QÒ  $×"5Ñ"5¸¿¹Ò"HØØr c ój—ttd„ddd|jjd«ff««S)Ncó—|dduS)Nr r;)Úxs rÚz'Source.bind_arguments..Ás €˜!˜A™$ dÑ*r )Ú async_cacheT)Ú clone_socketTÚgroups)ÚdictÚfilterrQÚgetrbs rÚbind_argumentszSource.bind_arguments½s<€äÜ Ù*à)Ø*ؘtŸ}™}×0Ñ0°Ó:Ð;ðó ó  ð r cóx— |j�G|jjt|j|j«f|j¬«y|jjt |j«f|j¬« y#t $r|jjd«YywxYw)N©ÚsourceÚstopFT) r6rMÚputr rrr r[r\rbs rÚ set_readyzSource.set_readyÊs•€ð Ø�z‰zÐ%Ø—‘— ‘ Ü § ¡ ¨T¯Z©ZÓ8Ð:À4Ç;Á;ðôðð —‘— ‘ œk¨$¯+©+Ó6Ð8ÀÇÁ� ÕMðøô!ò Ø �J‰J�N‰N˜6Ô "Ùð ús‚ABÁ;BÂ$B9Â8B9cóÌ—t|«}i}d|vrd|d<d|d<|d|d<d|vr(d|d<|d|d<tj|d«|d<|D]}||vsŒ||||<Œ|S)NÚhostnamerArDÚsshÚprotocolrr)rkrÚ_get_netnspath)Úclsr`ÚretÚdefaultsÚkeys rr|zSource.defaults×s—€ä�4‹jˆØˆØ ˜Ñ Ø'ˆH�VÑ Ø#(ˆH�ZÑ Ø!% jÑ!1ˆH�XÑ Ø �d‰?Ø&ˆH�VÑ Ø!% g¡ˆH�XÑ Ü ×/Ñ/°°W± Ó>ˆC�‰LÛˆCؘ#Š~Ø# C™=��C’ððˆ r có4—t|jt«r!|jjj}n0t|jt «r|jj}d|j j«›d›d|j›d�S)NÚ[z] <Ú Ú>) Ú isinstancerPrÚ __class__r8r#r[rmrQ©rr%s rÚ__repr__zSource.__repr__ès`€Ü �d—m‘mÔ%6Ô 7Ø—=‘=×*Ñ*×3Ñ3‰DÜ ˜Ÿ ™ ¤tÔ ,Ø—=‘=×)Ñ)ˆDøà!%§¡§¡Õ!1²4¸¿»ÐGÐGr có—|Srr;©rzr%s rÚnla2namezSource.nla2nameðó€àˆ r có—|Srr;r‡s rÚname2nlazSource.name2nlaôr‰r c#óžK—d–—|j«D]2}||jj«|||j›f–—Œ4y­w)N)r[r%r`)Úkeysr[rmrQ)rzÚviewr}s rÚsummaryzSource.summaryøsDèø€à'Ò'Ø—9‘9–;ˆCؘ‘9—?‘?×&Ñ&Ó(¨#°t¸C±y×7IÒ7IÐLÓ Lñùs‚A A có$—|j|«Sr)r�)rzrŽs rÚdumpz Source.dumpþs€à�{‰{˜4Ó Ð r có4—t|t«r||dk(Sy)Nr%)r‚r)rÚleftÚrights rÚcompare_recordzSource.compare_records"€ô �eœZÔ (ؘD ™LÑ(Ð (ð )r có¤—|jj|jd«xs)tt j d«|j«S)NÚpyroute2)ÚvmaprmrDÚgetattrÚ importlibÚ import_moduler„s rrOzSource.get_primes=€Ø�y‰y�}‰}˜TŸY™Y¨Ó-ò ´Ü × #Ñ # JÓ /°·±ó2 ð r c óN—td«D]Z}|j5 |jjd|›d|›d|›�«t |j |«|i|¤Žcddd«cSt%d«‚#t tttttjtjf$r‚t$rS}|xjdz c_|jjd|›d�«t!j"d«Yd}~nd}~wwxYw ddd«�Œ#1swY�ŒxYw)Nédzsource api run r€r zsource api error: Ü—J‘J˜q—M‘Mûð "úð"÷%—“ús0›D�?A4Á4AD Â9A DÄDÄD Ä DÄD$ có —d}t«}d|d<d|d<d|d<d|d d<d |d d <|j|d d <d |d<d|fdg|d<|j«|jj |g|j¬«y)Nz.https://github.com/svinota/pyroute2/issues/737rÚindexÚupr[r ÚflagséÚheaderér#rÚ RTM_NEWLINKr6Ú IFLA_IFNAME)Ú IFLA_ADDRESSz00:00:00:00:00:00Úattrsrp)rrÚencoderMrs)rÚurlÚzero_ifs rÚ fake_zero_ifzSource.fake_zero_if$s¤€Ø>ˆÜ“*ˆØˆ�ÑØˆ�ÑØˆ�ÑØ%&ˆ�ј'Ñ"Ø$&ˆ�ј&Ñ!Ø&*§k¡kˆ�ј(Ñ#Ø(ˆ�Ñà ˜CÐ Ø 1ð ˆ�Ñð �‰ÔØ �‰� ‰ �g�Y t§{¡{ˆ Õ3r có`—|jj«dk7�rc|jj«r�nG|j5|j � |j j d¬« |jjd«t|jt«r\i}|j|j«|j dvr|j"j$|d<|jdi|¤Ž|_n t'd«‚|jjd «|j j(di|j*¤Ž |j"j,j/|j0«|j d vr|j3«|j4j7|j j9«|j0¬ « d|_ ddd«|j5|jj«d k(rj|jM«s ddd«�nP|j<j«|jjO«|jjd«ddd«|jj«dvr¾ tQ|j j««}d}|r |dddr|dddjR}|�|tTjVk(r|jjd«nE |j4j7||j0¬ «|jj«dvrŒ¾|jj«dk7r�Œc |jY«|jjGd«|j"j,j/|j0«|jjd«y#t$r)}|jjd|z«Yd}~�Œµd}~wwxYw#wxYw#t$�rå}|xj:d z c_|j<j«|jjd |j:›�«|jj?dt|«›d|›�« |j4j7tA|j0«f|j0¬ «n7#tB$r+|jjd«YYd}~ddd«�Œ¬wxYw|jDr³|jjGd«|jjd«|jjItJ«|jj«rb|jjGd«|jjd«Yd}~ddd«�Œo|jM«cYd}~cddd«SYd}~ddd«�Œd}~wwxYw#1swY�ŒBxYw#1swY�Œ³xYw#t$r�}|xj:d z c_|jj?dt|«›d|›�«d}|jDr|jjd«n|jjd«Yd}~�Œod}~wwxYw#tB$r|jjd«Y�ŒžwxYw#tB$r|jjGd«Y�ŒOwxYw)Nrrr©Úcodezsource restart: %sÚ connecting)rBÚlibczsource channel not supportedÚloading)r@rrArpr zfailed, counter zsource error: r€zsleeping before restartÚrestartúsource shutdownrF)rrrÂr²r¥zflush DB for the targetz#shutdown handled by the main threadÚstoppedr;)-r[rmrUÚis_setrXrKÚcloser§rGÚwarningr\r‚rPr#ÚupdaterQrDrrÀr£Úbindrnr]Údb_flushrr»rMrsr‘rTrVr¥r r rcrŸr4ÚSOURCE_FAIL_PAUSErtr1Útupler¾ÚerrnoÚ ECONNRESETÚsync)rr¬r`Úmsgr¾s rÚreceiverzSource.receiver5sM€ð�j‰j�n‰nÓ &Ó(Ø�}‰}×#Ñ#Ô%Ùà—“Ø—7‘7Ð&ðCØŸ™Ÿ ™ ¨1˜ Ô-ð.Ø—J‘J—N‘N <Ô0Ü! $§-¡-´Ô6Ø!˜ØŸ ™  D§M¡MÔ2ØŸ9™9¨Ñ6Ø+/¯8©8¯=©=˜D ™LØ"/ $§-¡-Ñ"7°$Ñ"7˜�ä'Ð(FÓGÐGØ—J‘J—N‘N 9Ô-à �D—G‘G—L‘LÑ7 4×#6Ñ#6Ò7ðØŸ™×-Ñ-×6Ñ6°t·{±{ÔCØŸ9™9Ð(DÑDØ ×-Ñ-Ô/ØŸ™Ÿ ™  T§W¡W§\¡\£^¸D¿K¹K˜ ÔHàØ*+�DÕ'÷;ðl—“Ø—:‘:—>‘>Ó# yÒ0ØŸ>™>Ô+Ø÷‘ð—L‘L×$Ñ$Ô&Ø—M‘M×'Ñ'Ô)Ø—J‘J—N‘N 9Ô-÷ ð—*‘*—.‘.Ó"Ð*=Ñ=ð Ü §¡§ ¡ £ Ó.�Cð�Ù˜3˜q™6 (Ñ+¨GÒ4ؘq™6 (Ñ+¨GÑ4×9Ñ9�Dà�; $¬%×*:Ñ*:Ò":Ø—J‘J—N‘N 6Ô*ØðØ—H‘H—L‘L ¨T¯[©[�LÔ9ð-—*‘*—.‘.Ó"Ð*=Ò=ðE�j‰j�n‰nÓ &Ô(ð@ Ø �I‰IŒKØ �H‰H�N‰NÐ4Ô 5Ø �H‰H× !Ñ !× *Ñ *¨4¯;©;Ô 7ð � ‰ �‰�yÕ!øô%òCØŸ™×(Ñ(Ð)=ÀÑ)A×BÒBûðCûð0ûä óØ×'Ò'¨1Ñ,Õ'Ø—L‘L×$Ñ$Ô&Ø—J‘J—N‘NÐ%5°d×6IÑ6IÐ5JÐ#KÔLØ—H‘H—N‘N ^´D¸³G°9¸A¸a¸SÐ#AÔBðØŸ™Ÿ ™ Ü(¨¯©Ó5Ð7ÀÇ Á ð%õøô-òØŸ ™ Ÿ™ vÔ.Ü÷S‘ðNúð×(Ò(ØŸ™Ÿ™Ð'@ÔAØŸ ™ Ÿ™ yÔ1ØŸ ™ ×*Ñ*Ô+<Ô=ØŸ=™=×/Ñ/Ô1Ø ŸH™HŸN™NÐ+<Ô=Ø ŸJ™JŸN™N¨6Ô2Û!÷c‘ðf $Ÿ~™~Ó/Ô/÷g‘óh÷i‘ûð<ú÷=‘ú÷l‘ûô!òØ×'Ò'¨1Ñ,Õ'Ø—H‘H—N’N¼DÀ½GÁQÐ#GÔHØ�CØ×(Ò(ØŸ ™ Ÿ™ yÕ1àŸ ™ Ÿ™ vÔ.Ýûðûô()òØ—J‘J—N‘N 6Ô*Úðûô!ò Ø �H‰H�N‰NÐ@Ô AÚ ð úsÁ X%ÁO9Á2CP3ÅB P.ÇP3Ç9/X2È2AX2Ê&#X?Ì'[ÎA\Ï9 P+ÐP&Ð X%Ð&P+Ð+X%Ð.P0Ð0P3Ð3 X"Ð=BXÒ?;S;Ó:XÓ;$T/ÔXÔ X%Ô.T/Ô/B4X×#X%×1XØX"ØX%ØX%ØX"Ø"X%Ø%X/Ø2X<Ø? [ÙB[Û[Û$\Ü\Ü$\-Ü,\-cóú—|jjd«tj«}|jj t |j|«f|j¬«|j«y)NrÏrp) rGrŸr.r/rMrsr rr4)rrÏs rrÏz Source.sync¥sM€Ø �‰�‰�vÔÜ�‰Ó ˆØ �‰� ‰ ”j §¡¨dÓ3Ð5¸d¿k¹kˆ ÔJØ � ‰ � r có|—|j5|jjd«|j�%|jj «r t d«‚t j|jd|jz¬«|_|jj«|cddd«S#1swYyxYw)Nzstarting the sourcezsource is runningzNDB event source: %s)rr%) rXrGrŸrJÚis_aliverªr.ÚThreadrÑrÚstartrbs rrÖz Source.start«s‚€ð�Y‹YØ �H‰H�N‰NÐ0Ô 1Ø—‘Ð#¨¯©×)9Ñ)9Ô);Ü"Ð#6Ó7Ð7ä×&Ñ&Ø—}‘}Ø+¨t¯{©{Ñ;ôˆDŒGð �G‰G�M‰MŒOØ÷�YŠYús �BB2Â2B;Tcó€—|j5|jj«r%|jj d« ddd«y|jj d«|jj «|j � |j j|¬«ddd«|rJ|j�"|jj«d|_ y|jj d«yy#t$r(}|jjd|z«Yd}~Œ�d}~wwxYw#1swYŒŠxYw)Nzalready stoppedrÃr½zsource close: %szreceiver thread missing) rYrUrÅrGrŸr\rKrÆr§r¥rJÚjoin)rr¾rÏr¬s rrÆz Source.closeºsí€Ø × Ó Ø�}‰}×#Ñ#Ô%Ø—‘—‘Ð0Ô1Ø÷ Ð ð �H‰H�N‰NÐ,Ô -Ø �M‰M× Ñ Ô Ø�w‰wÐ"ð;Ø—G‘G—M‘M t�MÔ,÷ ñ Ø�w‰wÐ"Ø—‘— ‘ ”Ø�•à—‘—‘Ð8Õ9ð øô!ò;Ø—H‘H—N‘NÐ#5¸Ñ#9×:Ñ:ûð;ú÷ Ð ús6�7D4Á AD4ÂDÄ D1Ä D,Ä'D4Ä,D1Ä1D4Ä4D=cóú—|j5|j5|jjd|z«|jj « |j «|jr|jj«|jj «|j« ddd«ddd«|jj«y#wxYw#1swYŒ1xYw#1swYŒ5xYw)Nz"restarting the source, reason <%s>) rXrYrGrŸrVr1rÆrJrØrUrÖr4)rÚreasons rrÂzSource.restartÍsª€Ø �Y‹YØ×#Ó#Ø—‘—‘ÐCÀvÑNÔOØ— ‘ ×"Ñ"Ô$ðØ—J‘J”LØ—w’wØŸ™Ÿ ™ œØ—M‘M×'Ñ'Ô)Ø—J‘J”Là÷$÷ð � ‰ ×ÑÕøðú÷$Ð#ú÷ˆYús5� C1š9C%ÁA C Â5C1à C"Ã"C%Ã%C. Ã*C1Ã1C:có—|Srr;rbs rÚ __enter__zSource.__enter__Üs€Øˆ r có$—|j«yr)rÆ)rÚexc_typeÚ exc_valueÚ tracebacks rÚ__exit__zSource.__exit__ßs €Ø � ‰ � r có¤—|jjjd|jjjz|j f«}|\|d<|d<|jjj d|jjjz|j f«D]}|\}}}}|dk(r t|«n|||<Œ y)Nz£ SELECT * FROM sources WHERE f_target = %s rrDz± SELECT * FROM sources_options WHERE f_target = %s Úint)rr]Ú db_fetchoneÚschemaÚplchrÚdb_fetchrã)rr`Úf_targetÚf_nameÚf_typeÚf_values rr_zSource.load_sqlâsÄ€à�x‰x×$Ñ$×0Ñ0ð ,ð�h‰h�o‰o×"Ñ"ñ  #ð �[‰[ˆNó  ˆð(,Ñ$ˆˆX‰˜˜V™ Ø—H‘H×)Ñ)×2Ñ2ð .ð�h‰h�o‰o×"Ñ"ñ  #ð �[‰[ˆNö  ˆDð15Ñ -ˆH�f˜f gØ+1°Uª?œ3˜wœ<ÀˆD�ŠLñ r )Úunknown)(r8r9r:Ú__doc__Ú table_aliasÚ dump_headerÚsummary_headerrŽÚtablerrrrr˜rÚpropertyrcrnrtÚ classmethodr|r…rˆr‹r�r‘r•rOr"r»rÑrÏrÖrÍrÎrÆrÂrÜrár_r;r rr=r=†s.„ñð€KØ€KØ€NØ €DØ €EàØØØ!ñ  €Dòð:ñóðð ñ  óð  ò ðñóðò HðñóððñóððñMóðMð ñ!óð!ðñ)óð)ò  ò .ò.4ò"n"ò`ò ð×)Ñ)°ó:ó& òòóHr r=)+rírÍršrr¤r¦Úsysr.r¨r+Úpyroute2.commonrÚpyroute2.iprouterÚpyroute2.netlink.exceptionsrÚpyroute2.netlink.nlsocketrÚpyroute2.netlink.rtnl.ifinfmsgrÚpyroute2.remoterrr r Úmessagesr r rÚplatformÚ startswithr—rÚpyroute2.netns.managerrÚpyroute2.nslink.nslinkrrËrNÚobjectrrkr=r;r rÚrs‘ðñEóL ÛÛ Û Û Û ÛÛ Û å&Ý$Ý4Ý7Ý3Ý)ç,ß:Ñ:à‡<�<×ј7Ô#ÝÝ3Þ,à €EØ€LàÐØÐô(�&ô(ô>pHˆTõpHr