+
    Û1j¿!  ã                   óh   € ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt R	R ltR t	 ! R R]4      t
R# )
é    N)ÚCluster)Úsos_parse_version©Úsos_get_command_outputc                ó|   € V '       g   . # V P                  R4       Uu. uF  qP                  4       NK  	  up# u upi )zParse comma separated string.Ú,)ÚsplitÚstrip)ÚstringsÚstrings   & Ú=/usr/lib/python3/dist-packages/sos/collector/clusters/juju.pyÚ_parse_option_stringr      s1   € çØˆ	Ø)0¯©°sÔ);Ó<Ñ);˜v�L‰LŽNÑ);Ñ<Ð<ùÒ<s   ž9c                ó&   €  ! R R4      pV! V 4      # )a:  Helper function to get Index.

The reason why we need Index defined in function is because currently
the collector.__init__ will load all the classes in this module
and also Index. This will cause bug because it think Index is
Cluster type. Also We don't want to provide a customized
filter to remove Index class.
c                   ó<   a € ] tR t^%t o RtR tR tR tR tRt	V t
R# )Ú_get_index.<locals>.IndexzÔIndex structure to help parse juju status output.

Attributes apps, units and machines are dict which key
is the app/unit/machine name
and the value is list of targets which format are
{model_name}:{machine_id}.
c                ór   € Wn         / V n        / V n        / V n        \        P
                  ! R 4      V n        R# )ÚsosN)Ú
model_nameÚappsÚunitsÚmachinesÚloggingÚ	getLoggerÚui_log)Úselfr   s   &&r   Ú__init__Ú"_get_index.<locals>.Index.__init__.   s.   € Ø#-ŒOØˆDŒIØˆDŒJØˆDŒMÜ!×+Ò+¨EÓ2ˆDŽKó    c                óR  € VR,          P                  4        F‹  w  r#. pVP                  R/ 4      pVP                  4        FP  w  rgVR,          pV P                   RV 2p	V	.V P                  V&   V	.V P                  V&   VP                  V	4       KR  	  W@P                  V&   K�  	  R# )zAdds principal units to index.Úapplicationsr   ÚmachineÚ:N)ÚitemsÚgetr   r   r   Úappendr   )
r   Újuju_statusÚappÚapp_infoÚnodesr   ÚunitÚ	unit_infor!   Únodes
   &&        r   Úadd_principalsÚ(_get_index.<locals>.Index.add_principals5   sœ   € à!,¨^Õ!<×!BÑ!BÖ!D‘�Ø�Ø Ÿ™ W¨bÓ1�Ø',§{¡{¦}‘O�DØ'¨	Õ2�GØ"Ÿo™oÐ.¨a°¨yÐ9�DØ(, v�D—J‘J˜tÑ$Ø.2¨V�D—M‘M 'Ñ*Ø—L‘L Ö&ñ (5ð "'—	‘	˜#“ó "Er   c                ó  € VR,          P                  4        EFo  w  r#VP                  R. 4      pV EFP  pV P                  P                  V4      '       g"   V P                  P	                  RV R24       KF  V P                  V,          P                  V P                  V,          4       RVR,          V,          9  d"   V P                  P	                  RV R24       K¯  VR,          V,          R,          pVP                  4        Fv  w  rxV P                   RVR,           2p	VP                  R	/ 4      P                  4        F5  w  r§V
P                  VR
,           4      '       g   K%  V	.V P                  V
&   K7  	  Kx  	  EKS  	  EKr  	  R# )zcAdd subordinates to index.

Since subordinates does not have units they need to be
manually added.
r    zsubordinate-tozPrincipal charm z is missingr   z is missing unitsr"   r!   ÚsubordinatesÚ/N)	r#   r$   r   r   ÚwarningÚextendr   Ú
startswithr   )r   r&   r'   r(   Úsubordinate_toÚparentr   Ú_r+   r,   Úsub_keys   &&         r   Úadd_subordinatesÚ*_get_index.<locals>.Index.add_subordinatesC   sU  € ð "-¨^Õ!<×!BÑ!B×!D‘�Ø!)§¡Ð.>ÀÓ!C�Ü,�FàŸ9™9Ÿ=™=¨×0Ò0ØŸ™×+Ñ+Ø.¨v¨h°kÐBôñ !Ø—I‘I˜c•N×)Ñ)¨$¯)©)°FÕ*;Ô<ð  k°.Õ&AÀ&Õ&IÔIØŸ™×+Ñ+Ø.¨v¨hÐ6GÐHôñ !à'¨Õ7¸Õ?ÀÕH�EØ(-¯©®™˜Ø"&§/¡/Ð!2°!°I¸iÕ4HÐ3IÐJ˜Ø*3¯-©-Ø*¨Bó+ç™%›'ò+"™J˜Gð  '×1Ñ1°#¸µ)×<Ô<Ø7;°f §
¡
¨7Ó 3ó	+"ô )6ô# -ó "Er   c                ó„   € VR,          P                  4        F$  pV P                   RV 2pV.V P                  V&   K&  	  R# )z_Add machines to index.

If model does not have any applications it needs to be
manually added.
r   r"   N)Úkeysr   r   )r   r&   r!   r,   s   &&  r   Úadd_machinesÚ&_get_index.<locals>.Index.add_machinesd   sA   € ð ' zÕ2×7Ñ7Ö9�ØŸ/™/Ð*¨!¨G¨9Ð5�Ø*.¨�—‘˜gÓ&ó :r   )r   r   r   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r-   r9   r=   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   ÚIndexr   %   s$   ø‡ € ñ	ò	3ò	'ò	=÷B	0ð 	0r   rH   © )r   rH   s   & r   Ú
_get_indexrJ      s   € ÷G0ñ G0ñR �ÓÐr   c                   ód   a € ] tR t^qt o RtR tRt. ROtR tR t	R t
R tR tR tR	 tR
 tRtV tR# )Újujuaý  
The juju cluster profile is intended to be used on juju managed clouds.
It"s assumed that `juju` is installed on the machine where `sos` is called,
and that the juju user has superuser privilege to the current controller.

By default, the sos reports will be collected from all the applications in
the current model. If necessary, you can filter the nodes by models /
applications / units / machines with cluster options.

Example:

sos collect --cluster-type juju -c "juju.models=sos" -c "juju.apps=a,b,c"

zJuju Managed Cloudsc                óT   € \         P                  ! RRV^ \         P                  R7      # )z#Remove leading characters before {.z(^[^{]*)(.*)z\2)ÚcountÚflags)ÚreÚsubÚ	MULTILINE)r   Úoutputs   &&r   Ú_cleanup_juju_outputÚjuju._cleanup_juju_outputŽ   s"   € ä�vŠvØ˜U F°!¼2¿<¹<ô
ð 	
r   c                ó¦   € V P                  V4      p\        VR7      pVP                  V4       VP                  V4       VP	                  V4       V# )z—Parse juju status output and return target dict.

Here are couple helper functions to parse the juju principals units,
subordinate units and machines.
)r   )Ú_execute_juju_statusrJ   r-   r9   r=   )r   r   r&   Úindexs   &&  r   Ú_get_model_infoÚjuju._get_model_info”   sM   € ð ×/Ñ/°
Ó;ˆä jÔ1ˆØ×Ñ˜[Ô)Ø×Ñ˜{Ô+Ø×Ñ˜;Ô'àˆr   c                ó*   € \        R4      pVR,          # )zGrab the version of jujuzjuju versionrS   r   )r   Úress   & r   Ú_get_juju_versionÚjuju._get_juju_version£   s   € ä$ ^Ó4ˆØ�8�}Ðr   c                ó‚  € V'       d   R V 2MRpRpV P                  4       p\        V4      \        R4      8”  d
   VR,          pV P                   RV RV 2pV P                  V4      pVR,          ^ 8X  g   \	        RV R	VR,           24      hV P                  VR
,          4      pRp\        P                  ! V4      pV# )z-m Ú z--format jsonÚ3z --no-colorz status Ú ÚstatusÚ'z' returned error: rS   N)r]   r   ÚcmdÚexec_primary_cmdÚ	ExceptionrT   ÚjsonÚloads)	r   r   Úmodel_optionÚformat_optionÚjuju_versionÚ
status_cmdr\   Újuju_json_outputr&   s	   &&       r   rW   Újuju._execute_juju_status¨   sÄ   € ß-7˜˜Z˜LÑ)¸RˆØ'ˆØ×-Ñ-Ó/ˆÜ˜\Ó*Ô->¸sÓ-CÔCØ˜]Õ*ˆMØŸ™�z ¨,¨°q¸¸ÐHˆ
Ø×#Ñ# JÓ/ˆØ�8�} Ô!Ü˜a 
˜|Ð+=¸cÀ(½m¸_ÐMÓNÐNØ×4Ñ4°c¸(µmÓEÐàˆÜ—j’jÐ!1Ó2ˆØÐr   c                óâ   € \        4       pV F^  p\        W14      P                  4        F>  w  rg\        P                  ! WV4      '       g   K#  TP                  T;'       g    . 4       K@  	  K`  	  V# )zFilter with regex match.)ÚsetÚgetattrr#   rP   ÚmatchÚupdate©r   ÚkeyÚpatternsÚ
model_infor)   ÚpatternÚparamÚvalues   &&&&    r   Ú_filter_by_patternÚjuju._filter_by_pattern¸   sV   € ä“ˆÛˆGÜ '¨
Ó 8× >Ñ >Ö @‘�Ü—8’8˜G×+Ô+Ø—L‘L § ¨"Ö-ó !Añ  ð ˆr   c                ó¶   € \        4       pV FH  p\        W14      P                  4        F(  w  rgWV8X  g   K  TP                  T;'       g    . 4       K*  	  KJ  	  V# )zFilter with fixed match.)rq   rr   r#   rt   ru   s   &&&&    r   Ú_filter_by_fixedÚjuju._filter_by_fixedÁ   sM   € ä“ˆÛˆGÜ '¨
Ó 8× >Ñ >Ö @‘�ØÖ#Ø—L‘L § ¨"Ö-ó !Añ  ð ˆr   c                ó   € R# )z'Dynamically change transport to 'juju'.rL   rI   )r   s   &r   Úset_transport_typeÚjuju.set_transport_typeÊ   s   € ár   c                óT  € \        V P                  R4      4      p\        V P                  R4      4      p\        V P                  R4      4      p\        V P                  R4      4      pRVRVRV/p\        VP                  4       4      '       g   V'       g   . # V'       g   R.p\	        4       pV Fj  pV P                  V4      pVP                  4        FB  w  ršV	R8X  d   V P                  WšV4      pMV P                  WšV4      pVP                  V4       KD  	  Kl  	  \        V4      # )z+Get the machine numbers from `juju status`.Úmodelsr   r   r   r`   )r   Ú
get_optionÚanyÚvaluesrq   rY   r#   r|   r   rt   Úlist)r   r…   r   r   r   Úfiltersr)   Úmodelrx   rv   ÚresourceÚ_nodess   &           r   Ú	get_nodesÚjuju.get_nodesÎ   sû   € ä% d§o¡o°hÓ&?Ó@ˆÜ# D§O¡O°FÓ$;Ó<ˆÜ$ T§_¡_°WÓ%=Ó>ˆÜ'¨¯©¸
Ó(CÓDˆØ˜4 ¨%°¸XÐFˆô �7—>‘>Ó#×$Ò$¯VØˆIçØ�TˆFä“ˆãˆEØ×-Ñ-¨eÓ4ˆJØ!(§¡¦‘�à˜&”=Ø!×4Ñ4°SÀJÓO‘Fà!×2Ñ2°3À*ÓM�FØ—‘˜VÖ$ó "1ñ ô �E‹{Ðr   rI   N))r   r`   z1Filter node list by apps (comma separated regex).)r   r`   z3Filter node list by units (comma separated string).)r…   r`   z4Filter node list by models (comma separated string).)r   r`   z6Filter node list by machines (comma separated string).)r?   r@   rA   rB   rC   re   Úcluster_nameÚoption_listrT   rY   r]   rW   r|   r   r‚   rŽ   rD   rE   rF   s   @r   rL   rL   q   sJ   ø‡ € ñð €CØ(€Lò	€Kò
òòò
ò òò÷ð r   rL   )N)r   rh   rP   Úsos.collector.clustersr   Úsos.utilitiesr   r   r   rJ   rL   rI   r   r   Ú<module>r”      s3   ðó Û Û 	å *Ý +Ý 0ô=òSôlxˆ7ö xr   