OwlCyberSecurity - MANAGER
Edit File: cli.cpython-36.opt-1.pyc
3 i�f<8������������������@���s����d�dl�mZmZmZ�d�dlZd�dlZd�dlZd�dlZd�dlm Z �d�dl mZmZ�d�dl mZ�d�dlZed�Zed�Zdd ��Zd d��Zdd ��Zdd��Zdd��Zdd��Zdd��Zddd�Zdd��ZdS�)�����)�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}ttd�jt|�t��j�d���qttd�jt|�t��j�d���qW�|dkrtdS�td�jt��j�d�}d j��j��}d j��jd�|�}t|��fdd �||��jd��dS�)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 FTzAdded "{value}" to {prop_name}.)�value� prop_namez=Not adding value "{value}" to {prop_name}; it already exists.Nz{attr} updated.)�attr��zsyspurpose add-{name} )�namec����������������s���t����fdd��jD���S�)Nc�������������3���s ���|�]}|�j���jg��kV��qd�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����zadd_command.<locals>.<lambda>)�expectation�success_msg�commandr���) r����addr ����print�_�formatr����join�check_result)r����syspurposestoreZany_prop_addedr ���r���Zto_addr���r���)r���r����add_command"���s&���� r#���c����������������s����xb��j�D�]X}|j��j|�r<ttd�jt|�t��j�d���qttd�jt|�t��j�d���dS�qW�td�jt��j�d�}dj��j��}dj��jd �|�}t|��fd d�||��jd��dS�) 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 zRemoved "{val}" from {name}.)�valr ���z9Not removing value "{val}" from {name}; it was not there.Nz{attr} updated.)r���r���zsyspurpose remove-{name} )r ���c����������������s���t���fdd��jD���S�)Nc�������������3���s���|�]}|��j�d�g��kV��qdS�)�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��td�jt��j�t��j�d�}t|��fdd�|dj��j��jd���jd��dS�) 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���jkS�)N)r���r ���r ���)r���)r���r���r���r���o���s����zset_command.<locals>.<lambda>zsyspurpose 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��td�jt��j�d�}t|��fdd�|dj��jd���jd��dS�) 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�dd�g�gkS�)Nr���)r���r ���)r���)r���r���r���r�������s����zunset_command.<locals>.<lambda>zsyspurpose 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����fdd���D����ttj��dddd���|S�)z? :param args: :param syspurposestore: :return: c����������������s���i�|�]}��|�r��|�|�qS�r���r���)r����key)�contentsr���r���� <dictcomp>����s����z!show_contents.<locals>.<dictcomp>����FT)�indentZensure_asciiZ sort_keys)�sync�resultr����json�dumps)r���r"���Zsync_resultr���)r-���r���� show_contents����s ����r5���c��������������C���s,��t�jdtd�td�d�}�|�jdd�}t�jdd�}|jd td �dd��|jtd d��t�jdd�}|jd td�dd��|jtd d��t�jdd�}|jdtd�dd��|jtd d��t�jdd�}|jt d d��|j dtd�d�}|jddtd�dd��|jdtd�dd��|jtd d��|j dtd�|gd�}|jddtd�dd��|j dtd�d�}|jddtd�dd��|jd td �ddd ��|jtd d��|j d!td"�d�} | jddtd�dd��| jd td�ddd ��| jtd d��|j d#td$�|gd�} | jd%d&��|j d'td(�|gd�}|jd%d&��|j d)td*�|gd�}|jd+d&��|j d,td-�|gd�} | jd+d&��|j d.td/�|gd�}|jd+d&��|j d0td1�|gd�}|jd2d&��|j d3td4�|gd�}|jd2d&��|j d5td6�|gd�}|jd7d&��|j d8td9�|gd�}|jd7d&��|j d:td;�d�}|jtdd��|�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 Toolz�The 'syspurpose' command is deprecated and will be removed in a future major release. Please use the 'subscription-manager syspurpose' command going forward.)�prog�descriptionZepilogzsub-command help)�helpF)Zadd_helpr���zThe value(s) to add�+)r8����nargsT)�funcZ requires_synczThe value(s) to remover ���zThe value to setZstore)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 propertyzset-rolez,Set the system role to the system syspurposeZrole)r ���z unset-rolezClear set rolez add-addonsz#Add addons to the system syspurposer%���z remove-addonsz(Remove addons from the system syspurposezunset-addonszClear set addonszset-slazSet the system slaZservice_level_agreementz unset-slaz Clear set slaz set-usagezSet the system usageZusagezunset-usagezClear set usageZshowz"Show the current system syspurpose)�argparse�ArgumentParserr���Zadd_subparsers�add_argumentZset_defaultsr#���r'���r)���r+���Z add_parserr5���)�parserZ subparsersZadd_optionsZremove_optionsZset_optionsZ unset_optionsZgeneric_set_parserZgeneric_unset_parserZgeneric_add_parserZgeneric_remove_parserZset_role_parserZunset_role_parserZadd_addons_parserZremove_addons_parserZset_sla_parserZunset_sla_parserZset_usage_parserZunset_usage_parserZshow_parserr���r���r����setup_arg_parser����s����� rD���c����������� ���C���s����t���}�|�j��}t��r ttd���ttd�tjd��y2ddlm}�ddl m }�|��}|j}|��j��}W�n(�t k r����d}d}ttd���Y�nX�t||d d �}t|dd�dk r�|j||��n|�j���dS�dS�)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. z�The '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_uuidZuse_valid_fieldsr;���)rD���� parse_argsr���r���r����sys�stderrZsubscription_manager.identityrF���Z subscription_manager.cp_providerrG����uuidZget_consumer_auth_cp�ImportErrorr����getattrr;���Z print_help)rC���r���rF���rG���ZidentityrL���rH���r"���r���r���r����mainS��s,���� rO���c�������������C���s����|r�t�|�t�g��t�f��gkr"|f}xh|D�]`}t|t�r>d|�}t|tj�rptjrptjj|j d���tjjd��q(tjj|��tjjd��q(W�ytj j���tjj���W�n�tk r����Y�nX�tj |���dS�)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_typeZPY2rJ���rK����write�encode�stdout�flush�IOError�exit)�code�msgs�msgr���r���r����system_exity��s"���� r_���c�������������C���sh���|�r|�j����|�j��}ni�}|r\||��r\tj|d�}||�}ttjttj|||d��d��nt |��d�S�)N)r���)r���Zdownload_value�advice)r]���) r1���Zget_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���Zsyspurpose.filesr���Zsyspurpose.utilsr���r���Zsyspurpose.i18nr���r���r3���rd���ra���r#���r'���r)���r+���r5���rD���rO���r_���r!���r���r���r���r����<module>���s(���" �<&