<s> '''<STR_LIT>''' <EOL> from pprint import pformat <EOL> import copy <EOL> import cProfile <EOL> import crypt <EOL> import collections <EOL> import datetime <EOL> import hashlib <EOL> import logging <EOL> import os <EOL> import pstats <EOL> import re <EOL> from salt . config import master_config , minion_config <EOL> from salt . exceptions import SaltException <EOL> import salt . utils <EOL> import salt . utils . dictupdate <EOL> import salt . utils . network <EOL> from salt . utils . pycrypto import secure_password <EOL> from salt . utils . odict import OrderedDict <EOL> import salt . loader <EOL> from salt . ext import six as six <EOL> from mc_states import api <EOL> import mc_states . api <EOL> _CACHE = { '<STR_LIT>' : None } <EOL> _default_marker = object ( ) <EOL> _marker = object ( ) <EOL> log = logging . getLogger ( __name__ ) <EOL> def hash ( string , typ = '<STR_LIT>' , func = '<STR_LIT>' ) : <EOL> '''<STR_LIT>''' <EOL> if func not in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> func = '<STR_LIT>' <EOL> if typ not in [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ] : <EOL> raise TypeError ( '<STR_LIT>' . format ( typ ) ) <EOL> return getattr ( getattr ( hashlib , typ ) ( string ) , func ) ( ) <EOL> def uniquify ( * a , ** kw ) : <EOL> return api . uniquify ( * a , ** kw ) <EOL> def odict ( instance = True ) : <EOL> if instance : <EOL> return OrderedDict ( ) <EOL> return OrderedDict <EOL> def local_minion_id ( force = False ) : <EOL> '''<STR_LIT>''' <EOL> mid = _CACHE [ '<STR_LIT>' ] <EOL> if mid and not force : <EOL> return mid <EOL> paths = api . uniquify ( [ <EOL> __opts__ [ '<STR_LIT>' ] , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> for path in paths : <EOL> for cfgn , fun in OrderedDict ( <EOL> [ ( '<STR_LIT>' , master_config ) , <EOL> ( '<STR_LIT>' , minion_config ) ] <EOL> ) . items ( ) : <EOL> cfg = os . path . join ( path , cfgn ) <EOL> if os . path . exists ( cfg ) : <EOL> try : <EOL> cfgo = fun ( cfg ) <EOL> mid = cfgo . get ( '<STR_LIT:id>' , None ) <EOL> if mid . endswith ( '<STR_LIT>' ) : <EOL> mid = None <EOL> except Exception : <EOL> pass <EOL> if mid : <EOL> break <EOL> if mid : <EOL> break <EOL> if not mid : <EOL> mid = salt . utils . network . generate_minion_id ( ) <EOL> _CACHE [ '<STR_LIT>' ] = mid <EOL> return mid <EOL> def magicstring ( thestr ) : <EOL> """<STR_LIT>""" <EOL> return api . magicstring ( thestr ) <EOL> def generate_stored_password ( key , length = None , force = False , value = None ) : <EOL> '''<STR_LIT>''' <EOL> if length is None : <EOL> length = <NUM_LIT:16> <EOL> reg = __salt__ [ <EOL> '<STR_LIT>' ] ( <EOL> '<STR_LIT>' , registry_format = '<STR_LIT>' ) <EOL> sav = False <EOL> if not key in reg : <EOL> sav = True <EOL> rootpw = reg . setdefault ( key , __salt__ [ '<STR_LIT>' ] ( length ) ) <EOL> if force or not rootpw : <EOL> rootpw = __salt__ [ '<STR_LIT>' ] ( length ) <EOL> sav = True <EOL> if value is not None : <EOL> rootpw = value <EOL> reg [ key ] = rootpw <EOL> __salt__ [ '<STR_LIT>' ] ( <EOL> '<STR_LIT>' , reg , registry_format = '<STR_LIT>' ) <EOL> return rootpw <EOL> def generate_password ( length = None ) : <EOL> if length is None : <EOL> length = <NUM_LIT:16> <EOL> return secure_password ( length ) <EOL> class _CycleError ( Exception ) : <EOL> '''<STR_LIT:.>''' <EOL> def __init__ ( self , msg , new = None , original_dict = None , * args , ** kwargs ) : <EOL> super ( _CycleError , self ) . __init__ ( msg , * args , ** kwargs ) <EOL> self . new = new <EOL> self . original_dict = original_dict <EOL> def deepcopy ( arg ) : <EOL> return copy . deepcopy ( arg ) <EOL> def update_no_list ( dest , upd , recursive_update = True ) : <EOL> '''<STR_LIT>''' <EOL> if ( not isinstance ( dest , collections . Mapping ) ) or ( not isinstance ( upd , collections . Mapping ) ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> updkeys = list ( upd . keys ( ) ) <EOL> if not set ( list ( dest . keys ( ) ) ) & set ( updkeys ) : <EOL> recursive_update = False <EOL> if recursive_update : <EOL> for key in updkeys : <EOL> val = upd [ key ] <EOL> try : <EOL> dest_subkey = dest . get ( key , None ) <EOL> except AttributeError : <EOL> dest_subkey = None <EOL> if isinstance ( dest_subkey , collections . Mapping ) and isinstance ( val , collections . Mapping ) : <EOL> ret = update_no_list ( dest_subkey , val ) <EOL> dest [ key ] = ret <EOL> else : <EOL> dest [ key ] = upd [ key ] <EOL> return dest <EOL> else : <EOL> try : <EOL> dest . update ( upd ) <EOL> except AttributeError : <EOL> for k in upd : <EOL> dest [ k ] = upd [ k ] <EOL> return dest <EOL> def dictupdate ( dict1 , dict2 ) : <EOL> '''<STR_LIT>''' <EOL> if not isinstance ( dict1 , dict ) : <EOL> raise SaltException ( <EOL> '<STR_LIT>' ) <EOL> if not isinstance ( dict2 , dict ) : <EOL> raise SaltException ( <EOL> '<STR_LIT>' ) <EOL> return update_no_list ( dict1 , dict2 ) <EOL> def copy_dictupdate ( dict1 , dict2 ) : <EOL> '''<STR_LIT>''' <EOL> return dictupdate ( copy . deepcopy ( dict1 ) , <EOL> copy . deepcopy ( dict2 ) ) <EOL> def unresolved ( data ) : <EOL> ret = None <EOL> if isinstance ( data , six . string_types ) : <EOL> if '<STR_LIT:{>' in data and '<STR_LIT:}>' in data : <EOL> ret = True <EOL> else : <EOL> ret = False <EOL> elif isinstance ( data , dict ) : <EOL> for k , val in six . iteritems ( data ) : <EOL> ret1 = unresolved ( k ) <EOL> ret2 = unresolved ( val ) <EOL> ret = ret1 or ret2 <EOL> if ret : <EOL> break <EOL> elif isinstance ( data , ( list , set ) ) : <EOL> for val in data : <EOL> ret = unresolved ( val ) <EOL> if ret : <EOL> break <EOL> return ret <EOL> def _str_resolve ( new , original_dict = None , this_call = <NUM_LIT:0> , topdb = False ) : <EOL> '''<STR_LIT>''' <EOL> init_new = new <EOL> if isinstance ( original_dict , dict ) : <EOL> for k in original_dict : <EOL> reprk = k <EOL> if not isinstance ( reprk , six . string_types ) : <EOL> reprk = '<STR_LIT>' . format ( k ) <EOL> subst = '<STR_LIT:{>' + reprk + '<STR_LIT:}>' <EOL> if subst in new : <EOL> subst_val = original_dict [ k ] <EOL> if isinstance ( subst_val , ( list , dict ) ) : <EOL> inner_new = format_resolve ( <EOL> subst_val , original_dict , <EOL> this_call = this_call , topdb = topdb ) <EOL> if new != subst : <EOL> new = new . replace ( subst , str ( inner_new ) ) <EOL> else : <EOL> new = inner_new <EOL> else : <EOL> if new != subst_val : <EOL> new = new . replace ( subst , str ( subst_val ) ) <EOL> if not unresolved ( new ) : <EOL> break <EOL> return new , new != init_new <EOL> def str_resolve ( new , original_dict = None , this_call = <NUM_LIT:0> , topdb = False ) : <EOL> return _str_resolve ( <EOL> new , original_dict = original_dict , this_call = this_call , topdb = topdb ) [ <NUM_LIT:0> ] <EOL> def _format_resolve ( value , <EOL> original_dict = None , <EOL> this_call = <NUM_LIT:0> , <EOL> topdb = False , <EOL> retry = None , <EOL> ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if not original_dict : <EOL> original_dict = OrderedDict ( ) <EOL> if this_call == <NUM_LIT:0> : <EOL> if not original_dict and isinstance ( value , dict ) : <EOL> original_dict = value <EOL> changed = False <EOL> if kwargs : <EOL> original_dict . update ( kwargs ) <EOL> if not unresolved ( value ) : <EOL> return value , False <EOL> if isinstance ( value , dict ) : <EOL> new = type ( value ) ( ) <EOL> for key , v in value . items ( ) : <EOL> val , changed_ = _format_resolve ( v , original_dict , topdb = topdb ) <EOL> if changed_ : <EOL> changed = changed_ <EOL> new [ key ] = val <EOL> elif isinstance ( value , ( list , tuple ) ) : <EOL> new = type ( value ) ( ) <EOL> for v in value : <EOL> val , changed_ = _format_resolve ( v , original_dict , topdb = topdb ) <EOL> if changed_ : <EOL> changed = changed_ <EOL> new = new + type ( value ) ( [ val ] ) <EOL> elif isinstance ( value , six . string_types ) : <EOL> new , changed_ = _str_resolve ( value , original_dict , topdb = topdb ) <EOL> if changed_ : <EOL> changed = changed_ <EOL> else : <EOL> new = value <EOL> if retry is None : <EOL> retry = unresolved ( new ) <EOL> while retry and ( this_call < <NUM_LIT:100> ) : <EOL> new , changed = _format_resolve ( new , <EOL> original_dict , <EOL> this_call = this_call , <EOL> retry = False , <EOL> topdb = topdb ) <EOL> if not changed : <EOL> retry = False <EOL> this_call += <NUM_LIT:1> <EOL> return new , changed <EOL> def format_resolve ( value , <EOL> original_dict = None , <EOL> this_call = <NUM_LIT:0> , topdb = False , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> return _format_resolve ( value , <EOL> original_dict = original_dict , <EOL> this_call = this_call , <EOL> topdb = topdb , <EOL> ** kwargs ) [ <NUM_LIT:0> ] <EOL> def is_a_str ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , six . string_types ) <EOL> def is_a_bool ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , bool ) <EOL> def is_a_int ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , int ) <EOL> def is_a_float ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , float ) <EOL> def is_a_complex ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , complex ) <EOL> def is_a_long ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , long ) <EOL> def is_a_number ( value ) : <EOL> '''<STR_LIT>''' <EOL> return ( <EOL> is_a_int ( value ) or <EOL> is_a_float ( value ) or <EOL> is_a_complex ( value ) or <EOL> is_a_long ( value ) <EOL> ) <EOL> def is_a_set ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , set ) <EOL> def is_a_tuple ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , tuple ) <EOL> def is_a_list ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , list ) <EOL> def is_a_dict ( value ) : <EOL> '''<STR_LIT>''' <EOL> return isinstance ( value , dict ) <EOL> def is_iter ( value ) : <EOL> '''<STR_LIT>''' <EOL> return ( <EOL> is_a_list ( value ) or <EOL> is_a_dict ( value ) or <EOL> is_a_tuple ( value ) or <EOL> is_a_set ( value ) <EOL> ) <EOL> def traverse_dict ( data , key , delimiter = salt . utils . DEFAULT_TARGET_DELIM ) : <EOL> '''<STR_LIT>''' <EOL> delimiters = uniquify ( [ delimiter , salt . utils . DEFAULT_TARGET_DELIM , <EOL> '<STR_LIT::>' , '<STR_LIT:.>' ] ) <EOL> ret = dv = '<STR_LIT>' <EOL> for dl in delimiters : <EOL> for cdl in reversed ( delimiters ) : <EOL> ret = salt . utils . traverse_dict ( data , key , dv , delimiter = dl ) <EOL> if ret != dv : <EOL> return ret <EOL> if cdl in key and dl not in key : <EOL> nkey = key . replace ( cdl , dl ) <EOL> ret = salt . utils . traverse_dict ( data , nkey , dv , delimiter = dl ) <EOL> if ret != dv : <EOL> return ret <EOL> for i in range ( key . count ( cdl ) - <NUM_LIT:1> ) : <EOL> dkey = nkey . replace ( dl , cdl , i + <NUM_LIT:1> ) <EOL> ret = salt . utils . traverse_dict ( <EOL> data , dkey , dv , delimiter = dl ) <EOL> if ret != dv : <EOL> return ret <EOL> return ret <EOL> def uncached_get ( key , default = '<STR_LIT>' , <EOL> local_registry = None , registry_format = '<STR_LIT>' , <EOL> delimiter = salt . utils . DEFAULT_TARGET_DELIM ) : <EOL> '''<STR_LIT>''' <EOL> _s , _g , _p , _o = __salt__ , __grains__ , __pillar__ , __opts__ <EOL> if local_registry is None : <EOL> for reg , pref in api . _LOCAL_PREFS : <EOL> if key . startswith ( pref ) : <EOL> local_registry = reg <EOL> break <EOL> if ( <EOL> isinstance ( local_registry , basestring ) and <EOL> local_registry not in [ '<STR_LIT>' ] <EOL> ) : <EOL> local_registry = _s [ '<STR_LIT>' ] ( <EOL> local_registry , registry_format = registry_format ) <EOL> else : <EOL> local_registry = None <EOL> ret = traverse_dict ( _o , key , delimiter = delimiter ) <EOL> if ret != '<STR_LIT>' : <EOL> return ret <EOL> ret = traverse_dict ( _p , key , delimiter = delimiter ) <EOL> if ret != '<STR_LIT>' : <EOL> return ret <EOL> if local_registry is not None : <EOL> ret = traverse_dict ( local_registry , key , delimiter = delimiter ) <EOL> if ret != '<STR_LIT>' : <EOL> return ret <EOL> ret = traverse_dict ( _g , key , delimiter = delimiter ) <EOL> if ret != '<STR_LIT>' : <EOL> return ret <EOL> ret = traverse_dict ( _p . get ( '<STR_LIT>' , { } ) , key , delimiter = delimiter ) <EOL> if ret != '<STR_LIT>' : <EOL> return ret <EOL> return default <EOL> def cached_get ( key , default = '<STR_LIT>' , <EOL> local_registry = None , registry_format = '<STR_LIT>' , <EOL> delimiter = salt . utils . DEFAULT_TARGET_DELIM , ttl = <NUM_LIT> ) : <EOL> cache_key = '<STR_LIT>' . format ( key , <EOL> local_registry , <EOL> registry_format , <EOL> delimiter ) <EOL> return __salt__ [ '<STR_LIT>' ] ( <EOL> uncached_get , <EOL> [ key ] , <EOL> { '<STR_LIT:default>' : default , <EOL> '<STR_LIT>' : local_registry , <EOL> '<STR_LIT>' : registry_format , <EOL> '<STR_LIT>' : delimiter } , <EOL> cache_key , <EOL> ttl ) <EOL> get = uncached_get <EOL> def get_uniq_keys_for ( prefix ) : <EOL> '''<STR_LIT>''' <EOL> keys = OrderedDict ( ) <EOL> for mapping in ( __pillar__ , <EOL> __grains__ ) : <EOL> skeys = [ ] <EOL> for k in mapping : <EOL> if k . startswith ( prefix ) : <EOL> testn = k [ len ( prefix ) : ] <EOL> try : <EOL> if testn . index ( '<STR_LIT:.>' ) < <NUM_LIT:2> : <EOL> skeys . append ( k ) <EOL> except ( IndexError , ValueError ) : <EOL> continue <EOL> skeys . sort ( ) <EOL> for k in skeys : <EOL> keys [ k ] = mapping [ k ] <EOL> return keys <EOL> def defaults ( prefix , <EOL> datadict , <EOL> ignored_keys = None , <EOL> overridden = None , <EOL> noresolve = False , <EOL> firstcall = True ) : <EOL> '''<STR_LIT>''' <EOL> if not ignored_keys : <EOL> ignored_keys = [ ] <EOL> if firstcall : <EOL> global_pillar = copy . deepcopy ( <EOL> __salt__ [ '<STR_LIT>' ] ( prefix ) ) <EOL> if isinstance ( global_pillar , dict ) : <EOL> for k in [ a for a in ignored_keys if a in global_pillar ] : <EOL> if k in global_pillar : <EOL> del global_pillar [ k ] <EOL> datadict = __salt__ [ '<STR_LIT>' ] ( datadict , global_pillar ) <EOL> items = get_uniq_keys_for ( prefix ) <EOL> dotedprefix = '<STR_LIT>' . format ( prefix ) <EOL> for fullkey in items : <EOL> key = dotedprefix . join ( fullkey . split ( dotedprefix ) [ <NUM_LIT:1> : ] ) <EOL> val = items [ fullkey ] <EOL> if isinstance ( datadict , dict ) : <EOL> curval = datadict . get ( key , None ) <EOL> if isinstance ( curval , dict ) : <EOL> val = __salt__ [ '<STR_LIT>' ] ( curval , val ) <EOL> elif isinstance ( curval , ( list , set ) ) : <EOL> if val is not None : <EOL> curval . extend ( val ) <EOL> val = curval <EOL> datadict [ key ] = val <EOL> if overridden is None : <EOL> overridden = OrderedDict ( ) <EOL> if prefix not in overridden : <EOL> overridden [ prefix ] = OrderedDict ( ) <EOL> pkeys = OrderedDict ( ) <EOL> for a in datadict : <EOL> if a not in ignored_keys : <EOL> to_unicode = False <EOL> for i in prefix , a : <EOL> if isinstance ( i , unicode ) : <EOL> to_unicode = True <EOL> break <EOL> k = '<STR_LIT>' . format ( magicstring ( prefix ) , magicstring ( a ) ) <EOL> if to_unicode : <EOL> k = k . decode ( '<STR_LIT:utf-8>' ) <EOL> pkeys [ a ] = ( k , datadict [ a ] ) <EOL> for key , value_data in pkeys . items ( ) : <EOL> value_key , default_value = value_data <EOL> avalue = _default_marker <EOL> value = __salt__ [ '<STR_LIT>' ] ( <EOL> value_key + "<STR_LIT>" , _default_marker ) <EOL> if isinstance ( default_value , list ) : <EOL> avalue = __salt__ [ '<STR_LIT>' ] ( <EOL> value_key + "<STR_LIT>" , _default_marker ) <EOL> if value is not _default_marker : <EOL> overridden [ prefix ] [ key ] = value <EOL> else : <EOL> value = __salt__ [ '<STR_LIT>' ] ( value_key , _default_marker ) <EOL> if not isinstance ( default_value , list ) and value is _default_marker : <EOL> value = default_value <EOL> if isinstance ( default_value , list ) : <EOL> if key in overridden [ prefix ] : <EOL> value = overridden [ prefix ] [ key ] <EOL> else : <EOL> nvalue = default_value [ : ] <EOL> if ( <EOL> value and <EOL> ( value != nvalue ) and <EOL> ( value is not _default_marker ) <EOL> ) : <EOL> if nvalue is None : <EOL> nvalue = [ ] <EOL> nvalue . extend ( value ) <EOL> value = nvalue <EOL> if isinstance ( avalue , list ) : <EOL> value . extend ( avalue ) <EOL> elif isinstance ( value , dict ) : <EOL> ndefaults = defaults ( value_key , <EOL> value , <EOL> overridden = overridden , <EOL> noresolve = noresolve , <EOL> firstcall = firstcall ) <EOL> if overridden [ value_key ] : <EOL> for k , value in overridden [ value_key ] . items ( ) : <EOL> default_value [ k ] = value <EOL> for k , subvalue in get_uniq_keys_for ( value_key ) . items ( ) : <EOL> ndefaults [ k . split ( '<STR_LIT>' . format ( value_key ) ) [ <NUM_LIT:1> ] ] = subvalue <EOL> value = __salt__ [ '<STR_LIT>' ] ( default_value , ndefaults ) <EOL> datadict [ key ] = value <EOL> for k , value in overridden [ prefix ] . items ( ) : <EOL> datadict [ k ] = value <EOL> if not noresolve : <EOL> datadict = format_resolve ( datadict ) <EOL> return datadict <EOL> def sanitize_kw ( kw ) : <EOL> ckw = copy . deepcopy ( kw ) <EOL> for k in kw : <EOL> if ( '<STR_LIT>' in k ) and ( k in ckw ) : <EOL> ckw . pop ( k ) <EOL> return ckw <EOL> def salt_root ( ) : <EOL> '''<STR_LIT>''' <EOL> salt = __salt__ [ '<STR_LIT>' ] ( ) <EOL> return salt [ '<STR_LIT:c>' ] [ '<STR_LIT:o>' ] [ '<STR_LIT>' ] <EOL> def msr ( ) : <EOL> '''<STR_LIT>''' <EOL> salt = __salt__ [ '<STR_LIT>' ] ( ) <EOL> return salt [ '<STR_LIT:c>' ] [ '<STR_LIT:o>' ] [ '<STR_LIT>' ] <EOL> def remove_stuff_from_opts ( __opts ) : <EOL> opts = __context__ . setdefault ( '<STR_LIT>' , __opts ) <EOL> if opts is not __opts : <EOL> for k in [ a for a in __opts ] : <EOL> if k not in opts : <EOL> __opts . pop ( k , None ) <EOL> elif opts [ k ] != __opts [ k ] : <EOL> __opts [ k ] = opts [ k ] <EOL> __context__ . pop ( '<STR_LIT>' , None ) <EOL> return __opts <EOL> def add_stuff_to_opts ( __opts ) : <EOL> opts = __context__ . setdefault ( '<STR_LIT>' , __opts ) <EOL> if opts is __opts : <EOL> old_opts = copy . deepcopy ( __opts ) <EOL> try : <EOL> __opts [ '<STR_LIT>' ] = __grains__ <EOL> except Exception : <EOL> pass <EOL> try : <EOL> __opts [ '<STR_LIT>' ] = __pillar__ <EOL> except Exception : <EOL> pass <EOL> __context__ [ '<STR_LIT>' ] = old_opts <EOL> return __opts <EOL> def sls_load ( sls , get_inner = False ) : <EOL> if not os . path . exists ( sls ) : <EOL> raise OSError ( '<STR_LIT>' . format ( sls ) ) <EOL> try : <EOL> add_stuff_to_opts ( __opts__ ) <EOL> jinjarend = salt . loader . render ( __opts__ , __salt__ ) <EOL> data_l = salt . template . compile_template ( <EOL> sls , jinjarend , __opts__ [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> finally : <EOL> remove_stuff_from_opts ( __opts__ ) <EOL> if isinstance ( data_l , ( dict , list , set ) ) and get_inner : <EOL> if len ( data_l ) == <NUM_LIT:1> : <EOL> if isinstance ( data_l , dict ) : <EOL> for key in six . iterkeys ( data_l ) : <EOL> data_l = data_l [ key ] <EOL> break <EOL> else : <EOL> data_l = data_l [ <NUM_LIT:0> ] <EOL> return data_l <EOL> def file_read ( fic ) : <EOL> '''<STR_LIT>''' <EOL> data = '<STR_LIT>' <EOL> with open ( fic , '<STR_LIT:r>' ) as f : <EOL> data = f . read ( ) <EOL> return data <EOL> def unix_crypt ( passwd ) : <EOL> '''<STR_LIT>''' <EOL> return crypt . crypt ( passwd , '<STR_LIT>' ) <EOL> def sls_available ( sls , pillar = True ) : <EOL> ret = True <EOL> if pillar : <EOL> root = __opts__ [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> else : <EOL> root = __opts__ [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> fp = os . path . join ( root , sls . replace ( '<STR_LIT:.>' , '<STR_LIT:/>' ) + '<STR_LIT>' ) <EOL> try : <EOL> ret = os . path . exists ( fp ) <EOL> except OSError : <EOL> ret = False <EOL> return ret <EOL> def indent ( tstring , spaces = <NUM_LIT:16> , char = '<STR_LIT:U+0020>' ) : <EOL> data = '<STR_LIT>' <EOL> for ix , i in enumerate ( tstring . split ( '<STR_LIT:\n>' ) ) : <EOL> if ix > <NUM_LIT:0> : <EOL> data += char * spaces <EOL> data += i + '<STR_LIT:\n>' <EOL> return data <EOL> def profile ( func , * args , ** kw ) : <EOL> if not __opts__ . get ( '<STR_LIT>' , False ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> kw = copy . deepcopy ( kw ) <EOL> for i in [ a for a in kw if a . startswith ( '<STR_LIT>' ) ] : <EOL> kw . pop ( i , None ) <EOL> pr = cProfile . Profile ( ) <EOL> pr . enable ( ) <EOL> ret = __salt__ [ func ] ( * args , ** kw ) <EOL> pr . disable ( ) <EOL> if not os . path . isdir ( '<STR_LIT>' ) : <EOL> os . makedirs ( '<STR_LIT>' ) <EOL> ficp = '<STR_LIT>' . format ( func ) <EOL> fico = '<STR_LIT>' . format ( func ) <EOL> ficcl = '<STR_LIT>' . format ( func ) <EOL> ficn = '<STR_LIT>' . format ( func ) <EOL> fict = '<STR_LIT>' . format ( func ) <EOL> for i in [ ficp , fico , ficn , fict , ficcl ] : <EOL> if os . path . exists ( i ) : <EOL> os . unlink ( i ) <EOL> pr . dump_stats ( ficp ) <EOL> with open ( ficn , '<STR_LIT:w>' ) as fic : <EOL> ps = pstats . Stats ( <EOL> pr , stream = fic ) . sort_stats ( '<STR_LIT>' ) <EOL> ps . print_stats ( ) <EOL> with open ( ficcl , '<STR_LIT:w>' ) as fic : <EOL> ps = pstats . Stats ( <EOL> pr , stream = fic ) . sort_stats ( '<STR_LIT>' ) <EOL> ps . print_stats ( ) <EOL> with open ( fict , '<STR_LIT:w>' ) as fic : <EOL> ps = pstats . Stats ( <EOL> pr , stream = fic ) . sort_stats ( '<STR_LIT>' ) <EOL> ps . print_stats ( ) <EOL> os . system ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( ficp , fico ) ) <EOL> return ret , ficp , fico , ficn , ficcl , fict <EOL> def manage_file ( name , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> for i in [ a for a in kwargs if '<STR_LIT>' in a ] : <EOL> kwargs . pop ( i , None ) <EOL> log . error ( kwargs . keys ( ) ) <EOL> kwargs . setdefault ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , None ) <EOL> kwargs . setdefault ( '<STR_LIT>' , None ) <EOL> kwargs . setdefault ( '<STR_LIT>' , True ) <EOL> kwargs . setdefault ( '<STR_LIT:user>' , '<STR_LIT:root>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , '<STR_LIT:root>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , None ) <EOL> kwargs . setdefault ( '<STR_LIT>' , None ) <EOL> kwargs . setdefault ( '<STR_LIT:source>' , None ) <EOL> kwargs . setdefault ( '<STR_LIT>' , None ) <EOL> return __salt__ [ '<STR_LIT>' ] ( name , ** kwargs ) <EOL> def _outputters ( outputter = None ) : <EOL> outputters = salt . loader . outputters ( __opts__ ) <EOL> if outputter : <EOL> return outputters [ outputter ] <EOL> return outputters <EOL> def output ( mapping , raw = False , outputter = '<STR_LIT>' ) : <EOL> '''<STR_LIT>''' <EOL> color = __opts__ . get ( '<STR_LIT>' , None ) <EOL> slashre = re . compile ( '<STR_LIT>' , re . S | re . U | re . X ) <EOL> __opts__ [ '<STR_LIT>' ] = not raw <EOL> try : <EOL> if isinstance ( mapping , dict ) and ( outputter == '<STR_LIT>' ) : <EOL> ret = _outputters ( outputter ) ( { '<STR_LIT>' : mapping } ) <EOL> else : <EOL> ret = _outputters ( outputter ) ( mapping ) <EOL> except MemoryError : <EOL> mmapping = copy . deepcopy ( mapping ) <EOL> try : <EOL> if not isinstance ( mmapping , dict ) : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> for state in [ <EOL> i for i in mmapping <EOL> if isinstance ( mmapping [ i ] , dict ) <EOL> ] : <EOL> if not isinstance ( mmapping [ state ] , dict ) : <EOL> continue <EOL> for k in [ <EOL> j for j in mmapping [ state ] <EOL> if isinstance ( mapping [ state ] [ j ] , basestring ) <EOL> ] : <EOL> mmapping [ state ] [ k ] = slashre . sub ( '<STR_LIT>' , mmapping [ state ] [ k ] ) <EOL> if outputter == '<STR_LIT>' : <EOL> ret = _outputters ( outputter ) ( { '<STR_LIT>' : mmapping } ) <EOL> else : <EOL> ret = _outputters ( outputter ) ( mmapping ) <EOL> except Exception : <EOL> try : <EOL> ret = pformat ( mmapping ) <EOL> except Exception : <EOL> try : <EOL> ret = u"<STR_LIT>" . format ( mmapping ) <EOL> except Exception : <EOL> try : <EOL> ret = "<STR_LIT>" . format ( mmapping ) <EOL> except Exception : <EOL> raise <EOL> __opts__ [ '<STR_LIT>' ] = color <EOL> return ret <EOL> def is_this_lxc ( ) : <EOL> container = get_container ( <NUM_LIT:1> ) <EOL> if container not in [ '<STR_LIT>' ] : <EOL> return True <EOL> return False <EOL> def get_container ( pid ) : <EOL> lxc = '<STR_LIT>' <EOL> cg = '<STR_LIT>' . format ( pid ) <EOL> if os . path . isfile ( cg ) : <EOL> with open ( cg ) as fic : <EOL> content = fic . read ( ) <EOL> if '<STR_LIT>' in content : <EOL> lxc = content . split ( '<STR_LIT:\n>' ) [ <NUM_LIT:0> ] . split ( '<STR_LIT::>' ) [ - <NUM_LIT:1> ] <EOL> if '<STR_LIT>' in lxc : <EOL> lxc = lxc . split ( '<STR_LIT>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] <EOL> return lxc <EOL> def filter_host_pids ( pids ) : <EOL> thishost = get_container ( <NUM_LIT:1> ) <EOL> return [ a for a in pids <EOL> if get_container ( a ) == thishost ] <EOL> def cache_kwargs ( * args , ** kw ) : <EOL> shared = { '<STR_LIT>' : __opts__ , '<STR_LIT>' : __salt__ } <EOL> to_delete = [ i for i in kw <EOL> if i . startswith ( '<STR_LIT>' ) and i not in shared ] <EOL> dc = len ( to_delete ) <EOL> for i in shared : <EOL> if i not in kw : <EOL> dc = True <EOL> if dc : <EOL> kw = copy . deepcopy ( kw ) <EOL> [ kw . pop ( i , None ) for i in to_delete ] <EOL> for i , val in six . iteritems ( shared ) : <EOL> if not kw . get ( i ) : <EOL> kw [ i ] = val <EOL> return kw <EOL> def memoize_cache ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return api . memoize_cache ( * args , ** cache_kwargs ( * args , ** kw ) ) <EOL> def test_cache ( ttl = <NUM_LIT> ) : <EOL> '''<STR_LIT:.>''' <EOL> def _do ( ) : <EOL> return "<STR_LIT:a>" <EOL> cache_key = '<STR_LIT>' <EOL> __salt__ [ '<STR_LIT>' ] ( _do , [ ] , { } , cache_key , ttl ) <EOL> ret = list_cache_keys ( ) <EOL> remove_cache_entry ( ret [ <NUM_LIT:0> ] , debug = True ) <EOL> return ret <EOL> def remove_entry ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return mc_states . api . remove_entry ( * args , ** cache_kwargs ( * args , ** kw ) ) <EOL> def list_cache_keys ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return mc_states . api . list_cache_keys ( * args , ** cache_kwargs ( * args , ** kw ) ) <EOL> def remove_cache_entry ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return mc_states . api . remove_cache_entry ( * args , ** cache_kwargs ( * args , ** kw ) ) <EOL> def get_mc_server ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return mc_states . api . get_mc_server ( * args , ** kw ) <EOL> def get_local_cache ( * args ) : <EOL> '''<STR_LIT>''' <EOL> return mc_states . api . get_local_cache ( * args ) <EOL> def register_memcache_first ( pattern ) : <EOL> '''<STR_LIT>''' <EOL> return mc_states . api . register_memcache_first ( pattern ) <EOL> def invalidate_memoize_cache ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return mc_states . api . invalidate_memoize_cache ( * args , <EOL> ** cache_kwargs ( * args , ** kw ) ) <EOL> def purge_memoize_cache ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return mc_states . api . purge_memoize_cache ( * args , <EOL> ** cache_kwargs ( * args , ** kw ) ) <EOL> def cache_check ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return mc_states . api . cache_check ( * args , ** cache_kwargs ( * args , ** kw ) ) <EOL> def yencode ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def cyaml_load ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def yaml_load ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def yaml_dump ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def cyaml_dump ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def old_yaml_dump ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def nyaml_dump ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def iyaml_dump ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def msgpack_load ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def msgpack_dump ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ <EOL> '<STR_LIT>' ] ( * args , ** kw ) <EOL> def json_load ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) <EOL> def json_dump ( * args , ** kw ) : <EOL> '''<STR_LIT>''' <EOL> return __salt__ [ '<STR_LIT>' ] ( * args , ** kw ) </s>
