ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     3
vh<8                 @   s   d dl mZmZmZ d dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZmZ d dlmZ d dlZedZedZdd	 Zd
d Zdd Zdd Zdd Zdd Zdd ZdddZdd ZdS )    )print_functiondivisionabsolute_importN)SyncedStore)in_container	make_utf8)ugettextzzWarning: A {attr} of "{download_value}" was recently set for this system by the entitlement server administrator.
{advice}zGIf you'd like to overwrite the server side change please run: {command}c                s   d}xb j D ]X}|j j|rDd}ttdjt|t jd qttdjt|t jd qW |dkrtdS tdjt jd}d	j j }d
j jd| }t| fdd|| jd dS )a  
    Uses the syspurposestore to add one or more values to a particular property.
    :param args: The parsed args from argparse, expected attributes are:
        prop_name: the string name of the property to add to
        values: A list of the values to add to the given property (could be anything json-serializable)
    :param syspurposestore: An SyspurposeStore object to manipulate
    :return: None
    FTzAdded "{value}" to {prop_name}.)value	prop_namez=Not adding value "{value}" to {prop_name}; it already exists.Nz{attr} updated.)attr zsyspurpose add-{name} )namec                s   t  fddjD S )Nc             3   s    | ]}|j  jg kV  qd S )N)getr
   ).0x)argsres /usr/lib/python3.6/cli.py	<genexpr>=   s    z0add_command.<locals>.<lambda>.<locals>.<genexpr>)allvalues)r   )r   )r   r   <lambda>=   s    zadd_command.<locals>.<lambda>)expectationsuccess_msgcommandr   )	r   addr
   print_formatr   joincheck_result)r   syspurposestoreZany_prop_addedr	   r   Zto_addr   r   )r   r   add_command"   s&    	


r#   c                s   xb j D ]X}|j j|r<ttdjt|t jd qttdjt|t jd dS qW tdjt jd}dj j }dj jd	| }t| fd
d|| jd dS )a  
    Uses the syspurposestore to remove one or more values from a particular property.
    :param args: The parsed args from argparse, expected attributes are:
        prop_name: the string name of the property to add to
        values: A list of the values to remove from the given property (could be anything json-serializable)
    :param syspurposestore: An SyspurposeStore object to manipulate
    :return: None
    zRemoved "{val}" from {name}.)valr   z9Not removing value "{val}" from {name}; it was not there.Nz{attr} updated.)r   r   zsyspurpose remove-{name} )r   c                s   t  fddjD S )Nc             3   s   | ]}| j d g kV  qdS )addonsN)r   )r   r   )r   r   r   r   Z   s    z3remove_command.<locals>.<lambda>.<locals>.<genexpr>)r   r   )r   )r   )r   r   r   Z   s    z remove_command.<locals>.<lambda>)r   r   r   r   )	r   remover
   r   r   r   r   r    r!   )r   r"   r	   r   Z	to_remover   r   )r   r   remove_commandD   s    	"

r'   c                s\   |j  j j tdjt jt jd}t| fdd|dj j jd jd dS )	ap  
    Uses the syspurposestore to set the prop_name to value.
    :param args: The parsed args from argparse, expected attributes are:
        prop_name: the string name of the property to set
        value: An object to set the property to (could be anything json-serializable)
    :param syspurposestore: An SyspurposeStore object to manipulate
    :return: None
    z{attr} set to "{val}".)r   r$   c                s   | j  j jkS )N)r   r
   r	   )r   )r   r   r   r   o   s    zset_command.<locals>.<lambda>zsyspurpose set {name} "{val}")r   r$   )r   r   r   r   N)setr
   r	   r   r   r   r!   )r   r"   r   r   )r   r   set_commanda   s    	
r)   c                sL   |j  j tdjt jd}t| fdd|dj jd jd dS )	a.  
    Uses the syspurposestore to unset (clear entirely) the prop_name.
    :param args: The parsed args from argparse, expected attributes are:
        prop_name: the string name of the property to unset (clear)
    :param syspurposestore: An SyspurposeStore object to manipulate
    :return: None
    z{attr} unset.)r   c                s   | j  jdd g gkS )Nr   )r   r
   )r   )r   r   r   r      s    zunset_command.<locals>.<lambda>zsyspurpose unset {name})r   )r   r   r   r   N)unsetr
   r   r   r   r!   )r   r"   r   r   )r   r   unset_commandw   s    
r+   c                s:   |j  }|j  fdd D  ttj dddd |S )z?
    :param args:
    :param syspurposestore:
    :return:
    c                s   i | ]} | r | |qS r   r   )r   key)contentsr   r   
<dictcomp>   s    z!show_contents.<locals>.<dictcomp>   FT)indentZensure_asciiZ	sort_keys)syncresultr   jsondumps)r   r"   Zsync_resultr   )r-   r   show_contents   s
    r5   c              C   s,  t jdtdtdd} | jdd}t jdd}|jd	td
dd |jtdd t jdd}|jd	tddd |jtdd t jdd}|jdtddd |jtdd t jdd}|jt	dd |j
dtdd}|jddtddd |jdtddd |jtdd |j
dtd|gd}|jddtddd |j
dtdd}|jddtddd |jd	td
ddd  |jtdd |j
d!td"d}	|	jddtddd |	jd	tdddd  |	jtdd |j
d#td$|gd}
|
jd%d& |j
d'td(|gd}|jd%d& |j
d)td*|gd}|jd+d& |j
d,td-|gd}|jd+d& |j
d.td/|gd}|jd+d& |j
d0td1|gd}|jd2d& |j
d3td4|gd}|jd2d& |j
d5td6|gd}|jd7d& |j
d8td9|gd}|jd7d& |j
d:td;d}|jtdd | S )<z~
    Sets up argument parsing for the syspurpose tool.
    :return: An argparse.ArgumentParser ready to use to parse_args
    Z
syspurposez!System Syspurpose Management ToolzThe 'syspurpose' command is deprecated and will be removed in a future major release. Please use the 'subscription-manager syspurpose' command going forward.)progdescriptionZepilogzsub-command help)helpF)Zadd_helpr   zThe value(s) to add+)r8   nargsT)funcZrequires_synczThe value(s) to remover	   zThe value to setZstore)r8   actionr(   z%Sets the value for the given propertyr
   propertyz&The name of the property to set/update)metavarr8   r<   r*   z0Unsets (clears) the value for the given property)r8   parentsr   z'Adds the value(s) to the given propertyz"The name of the property to update)r8   r<   r:   r&   z,Removes the value(s) from the given propertyzset-rolez,Set the system role to the system syspurposeZrole)r
   z
unset-rolezClear set rolez
add-addonsz#Add addons to the system syspurposer%   zremove-addonsz(Remove addons from the system syspurposezunset-addonszClear set addonszset-slazSet the system slaZservice_level_agreementz	unset-slazClear set slaz	set-usagezSet the system usageZusagezunset-usagezClear set usageZshowz"Show the current system syspurpose)argparseArgumentParserr   Zadd_subparsersadd_argumentZset_defaultsr#   r'   r)   r+   Z
add_parserr5   )parserZ
subparsersZadd_optionsZremove_optionsZset_optionsZunset_optionsZgeneric_set_parserZgeneric_unset_parserZgeneric_add_parserZgeneric_remove_parserZset_role_parserZunset_role_parserZadd_addons_parserZremove_addons_parserZset_sla_parserZunset_sla_parserZset_usage_parserZunset_usage_parserZshow_parserr   r   r   setup_arg_parser   s    









rD   c              C   s   t  } | j }t r ttd ttdtjd y2ddlm} ddl	m
} | }|j}| j }W n( tk
r   d}d}ttd Y nX t||d	d
}t|dddk	r|j|| n| j  dS dS )zE
    Run the cli (Do the syspurpose tool thing!!)
    :return: 0
    z\WARNING: Setting syspurpose in containers has no effect.
Please run syspurpose on the host.
zThe 'syspurpose' command is deprecated and will be removed in a future major release. Please use the 'subscription-manager syspurpose' command going forward.)filer   )Identity)
CPProviderNzyWarning: Unable to sync system purpose with subscription management server: subscription_manager module is not available.T)uepZconsumer_uuidZuse_valid_fieldsr;   )rD   
parse_argsr   r   r   sysstderrZsubscription_manager.identityrF   Z subscription_manager.cp_providerrG   uuidZget_consumer_auth_cpImportErrorr   getattrr;   Z
print_help)rC   r   rF   rG   ZidentityrL   rH   r"   r   r   r   mainS  s,    
rO   c             C   s   |rt |t g t f gkr"|f}xh|D ]`}t|tr>d| }t|tjrptjrptjj|j	d tjjd q(tjj| tjjd q(W ytj
j  tjj  W n tk
r   Y nX tj|  dS )z
    Exit with a code and optional message(s). Saved a few lines of code.
    Note: this method was copied from subscription_manager, because syspurpose should be independent
    on subscription_manager module as much as possible.
    z%sutf8
N)type
isinstance	ExceptionsixZ	text_typeZPY2rJ   rK   writeencodestdoutflushIOErrorexit)codemsgsmsgr   r   r   system_exity  s"    


r_   c             C   sh   | r| j   | j }ni }|r\|| r\tj|d}|| }ttjttj|||dd nt	| d S )N)r   )r   Zdownload_valueadvice)r]   )
r1   Zget_cached_contents	SP_ADVICEr   r_   osEX_SOFTWAREr   SP_CONFLICT_MESSAGEr   )r"   r   r   r   r   r2   r`   r	   r   r   r   r!     s    
r!   )N)Z
__future__r   r   r   r@   rb   rJ   rU   Zsyspurpose.filesr   Zsyspurpose.utilsr   r   Zsyspurpose.i18nr   r   r3   rd   ra   r#   r'   r)   r+   r5   rD   rO   r_   r!   r   r   r   r   <module>   s(   " <&
