%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/utils/ |
Current File : //usr/lib/python2.7/site-packages/salt/utils/pydsl.pyc |
� ���^c @@ s d Z d d l m Z m Z m Z d d l m Z d d l m Z d d l m Z d d l m Z e d j � � Z d e f d � � YZ d e f d � � YZ d a d e f d � � YZ d e f d � � YZ d e f d � � YZ d � Z d e f d � � YZ d S( u� :maintainer: Jack Kuan <kjkuan@gmail.com> :maturity: new :platform: all A Python DSL for generating Salt's highstate data structure. This module is intended to be used with the `pydsl` renderer, but can also be used on its own. Here's what you can do with Salt PyDSL:: # Example translated from the online salt tutorial apache = state('apache') apache.pkg.installed() apache.service.running() \ .watch(pkg='apache', file='/etc/httpd/conf/httpd.conf', user='apache') if __grains__['os'] == 'RedHat': apache.pkg.installed(name='httpd') apache.service.running(name='httpd') apache.group.present(gid=87).require(apache.pkg) apache.user.present(uid=87, gid=87, home='/var/www/html', shell='/bin/nologin') \ .require(apache.group) state('/etc/httpd/conf/httpd.conf').file.managed( source='salt://apache/httpd.conf', user='root', group='root', mode=644) Example with ``include`` and ``extend``, translated from the online salt tutorial:: include('http', 'ssh') extend( state('apache').file( name='/etc/httpd/conf/httpd.conf', source='salt://http/httpd2.conf' ), state('ssh-server').service.watch(file='/etc/ssh/banner') ) state('/etc/ssh/banner').file.managed(source='salt://ssh/banner') Example of a ``cmd`` state calling a python function:: def hello(s): s = "hello world, %s" % s return dict(result=True, changes=dict(changed=True, output=s)) state('hello').cmd.call(hello, 'pydsl!') i ( t absolute_importt print_functiont unicode_literals( t uuid4( t OrderedDict( t HighState( t sixu_ listen require watch prereq use listen_in require_in watch_in prereq_in use_in onchanges onfailt PyDslErrorc B@ s e Z RS( ( t __name__t __module__( ( ( s4 /usr/lib/python2.7/site-packages/salt/utils/pydsl.pyR e s t Optionsc B@ s e Z d � Z RS( c C@ s | j | � S( N( t get( t selft name( ( s4 /usr/lib/python2.7/site-packages/salt/utils/pydsl.pyt __getattr__j s ( R R R ( ( ( s4 /usr/lib/python2.7/site-packages/salt/utils/pydsl.pyR i s t Slsc B@ sz e Z d � Z e d � � Z e d � � Z d � Z d � Z d � Z d d � Z d � Z d � Z d � Z d � Z RS( c C@ s| | | _ | | _ g | _ t j � j | _ g | _ g | _ t � | _ g | _ | | _ t j � sx t d � � n d S( Nu+ PyDSL only works with a running high state!( R t saltenvt includesR t get_activet building_highstatet included_highstatet extendst declsR t optionst funcst rendered_slsR ( R t slsR R ( ( s4 /usr/lib/python2.7/site-packages/salt/utils/pydsl.pyt __init__s s c C@ s t j � j S( N( R R t _pydsl_all_decls( t cls( ( s4 /usr/lib/python2.7/site-packages/salt/utils/pydsl.pyt get_all_decls� s c C@ s t j � j S( N( R R t _pydsl_render_stack( R ( ( s4 /usr/lib/python2.7/site-packages/salt/utils/pydsl.pyt get_render_stack� s c K@ s | j j | � d S( N( R t update( R R ( ( s4 /usr/lib/python2.7/site-packages/salt/utils/pydsl.pyt set� s c O@ s� d | k r | j d � n | j d | j � } | j d t � rn x$ | D] } | j j | | f � qJ Wd St j � } t d k r� | j | j � � a n | j } g } x!| D]} d j | | � } | | j k rM| j j | � | j | | | j t � \ } } | j | | | � | r=t d j | � � � n | j | � n d j | � } | | k rx| j d � q� xR | | d D]B } t | t � r�t t | � � d k r�| j | d � Pq�q�Wq� W| s�d St | � d k r�| d S| S( Nu envu saltenvu delayedu {0}:{1}u u _slsmod_{0}u stateconfu slsmodi i ( t popR R t FalseR t appendR R t SLS_MATCHESt Nonet top_matchest get_topR t formatR t addt render_statet merge_included_statesR t joint clean_duplicate_extendst isinstancet dictt nextt itert len( R t sls_namest kwsR t inclt HIGHSTATEt highstatet slsmodsR t r_envt histatest errorst state_idt arg( ( s4 /usr/lib/python2.7/site-packages/salt/utils/pydsl.pyt include� s@ 'c G@ s� | j j s | j � r'