<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import logging <EOL> import os . path <EOL> import os <EOL> import jinja2 <EOL> import jinja2 . exceptions <EOL> import salt . utils <EOL> import salt . utils . templates <EOL> import salt . utils . validate . net <EOL> import salt . ext . six as six <EOL> log = logging . getLogger ( __name__ ) <EOL> JINJA = jinja2 . Environment ( <EOL> loader = jinja2 . FileSystemLoader ( <EOL> os . path . join ( salt . utils . templates . TEMPLATE_DIRNAME , '<STR_LIT>' ) <EOL> ) <EOL> ) <EOL> __virtualname__ = '<STR_LIT>' <EOL> def __virtual__ ( ) : <EOL> '''<STR_LIT>''' <EOL> if __grains__ [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> return __virtualname__ <EOL> return ( False , '<STR_LIT>' ) <EOL> _ETHTOOL_CONFIG_OPTS = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> _RH_CONFIG_OPTS = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> _RH_CONFIG_BONDING_OPTS = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> _RH_NETWORK_SCRIPT_DIR = '<STR_LIT>' <EOL> _RH_NETWORK_FILE = '<STR_LIT>' <EOL> _RH_NETWORK_CONF_FILES = '<STR_LIT>' <EOL> _CONFIG_TRUE = [ '<STR_LIT:yes>' , '<STR_LIT>' , '<STR_LIT:true>' , '<STR_LIT:1>' , True ] <EOL> _CONFIG_FALSE = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:false>' , '<STR_LIT:0>' , False ] <EOL> _IFACE_TYPES = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> ] <EOL> def _error_msg_iface ( iface , option , expected ) : <EOL> '''<STR_LIT>''' <EOL> msg = '<STR_LIT>' <EOL> return msg . format ( iface , option , '<STR_LIT:|>' . join ( expected ) ) <EOL> def _error_msg_routes ( iface , option , expected ) : <EOL> '''<STR_LIT>''' <EOL> msg = '<STR_LIT>' <EOL> return msg . format ( iface , option , expected ) <EOL> def _log_default_iface ( iface , opt , value ) : <EOL> msg = '<STR_LIT>' <EOL> log . info ( msg . format ( iface , opt , value ) ) <EOL> def _error_msg_network ( option , expected ) : <EOL> '''<STR_LIT>''' <EOL> msg = '<STR_LIT>' <EOL> return msg . format ( option , '<STR_LIT:|>' . join ( expected ) ) <EOL> def _log_default_network ( opt , value ) : <EOL> msg = '<STR_LIT>' <EOL> log . info ( msg . format ( opt , value ) ) <EOL> def _parse_rh_config ( path ) : <EOL> rh_config = _read_file ( path ) <EOL> cv_rh_config = { } <EOL> if rh_config : <EOL> for line in rh_config : <EOL> line = line . strip ( ) <EOL> if len ( line ) == <NUM_LIT:0> or line . startswith ( '<STR_LIT:!>' ) or line . startswith ( '<STR_LIT:#>' ) : <EOL> continue <EOL> pair = [ p . rstrip ( ) for p in line . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) ] <EOL> if len ( pair ) != <NUM_LIT:2> : <EOL> continue <EOL> name , value = pair <EOL> cv_rh_config [ name . upper ( ) ] = value <EOL> return cv_rh_config <EOL> def _parse_ethtool_opts ( opts , iface ) : <EOL> '''<STR_LIT>''' <EOL> config = { } <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> config . update ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> config . update ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , _CONFIG_TRUE + _CONFIG_FALSE ) <EOL> if '<STR_LIT>' in opts : <EOL> valid = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if opts [ '<STR_LIT>' ] in valid : <EOL> config . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> if '<STR_LIT>' in opts : <EOL> valid = [ '<STR_LIT>' , '<STR_LIT:100>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if str ( opts [ '<STR_LIT>' ] ) in valid : <EOL> config . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> else : <EOL> _raise_error_iface ( iface , opts [ '<STR_LIT>' ] , valid ) <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> for option in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if option in opts : <EOL> if opts [ option ] in _CONFIG_TRUE : <EOL> config . update ( { option : '<STR_LIT>' } ) <EOL> elif opts [ option ] in _CONFIG_FALSE : <EOL> config . update ( { option : '<STR_LIT>' } ) <EOL> else : <EOL> _raise_error_iface ( iface , option , valid ) <EOL> return config <EOL> def _parse_settings_bond ( opts , iface ) : <EOL> '''<STR_LIT>''' <EOL> bond_def = { <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:100>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> if opts [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT:0>' ] : <EOL> log . info ( <EOL> '<STR_LIT>' . format ( <EOL> iface <EOL> ) <EOL> ) <EOL> return _parse_settings_bond_0 ( opts , iface , bond_def ) <EOL> elif opts [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT:1>' ] : <EOL> log . info ( <EOL> '<STR_LIT>' . format ( <EOL> iface <EOL> ) <EOL> ) <EOL> return _parse_settings_bond_1 ( opts , iface , bond_def ) <EOL> elif opts [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT:2>' ] : <EOL> log . info ( <EOL> '<STR_LIT>' . format ( iface ) <EOL> ) <EOL> return _parse_settings_bond_2 ( opts , iface , bond_def ) <EOL> elif opts [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT:3>' ] : <EOL> log . info ( <EOL> '<STR_LIT>' . format ( <EOL> iface <EOL> ) <EOL> ) <EOL> return _parse_settings_bond_3 ( opts , iface , bond_def ) <EOL> elif opts [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT:4>' ] : <EOL> log . info ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( iface ) <EOL> ) <EOL> return _parse_settings_bond_4 ( opts , iface , bond_def ) <EOL> elif opts [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT:5>' ] : <EOL> log . info ( <EOL> '<STR_LIT>' . format ( iface ) <EOL> ) <EOL> return _parse_settings_bond_5 ( opts , iface , bond_def ) <EOL> elif opts [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> log . info ( <EOL> '<STR_LIT>' . format ( iface ) <EOL> ) <EOL> return _parse_settings_bond_6 ( opts , iface , bond_def ) <EOL> else : <EOL> valid = [ <EOL> '<STR_LIT:0>' , '<STR_LIT:1>' , '<STR_LIT:2>' , '<STR_LIT:3>' , '<STR_LIT:4>' , '<STR_LIT:5>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> def _parse_settings_bond_0 ( opts , iface , bond_def ) : <EOL> '''<STR_LIT>''' <EOL> bond = { '<STR_LIT>' : '<STR_LIT:0>' } <EOL> valid = [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in opts : <EOL> if isinstance ( opts [ '<STR_LIT>' ] , list ) : <EOL> if <NUM_LIT:1> <= len ( opts [ '<STR_LIT>' ] ) <= <NUM_LIT:16> : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> for ip in opts [ '<STR_LIT>' ] : <EOL> if len ( bond [ '<STR_LIT>' ] ) > <NUM_LIT:0> : <EOL> bond [ '<STR_LIT>' ] = bond [ '<STR_LIT>' ] + '<STR_LIT:U+002C>' + ip <EOL> else : <EOL> bond [ '<STR_LIT>' ] = ip <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> if '<STR_LIT>' in opts : <EOL> try : <EOL> int ( opts [ '<STR_LIT>' ] ) <EOL> bond . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> except Exception : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> else : <EOL> _log_default_iface ( iface , '<STR_LIT>' , bond_def [ '<STR_LIT>' ] ) <EOL> bond . update ( { '<STR_LIT>' : bond_def [ '<STR_LIT>' ] } ) <EOL> return bond <EOL> def _parse_settings_bond_1 ( opts , iface , bond_def ) : <EOL> '''<STR_LIT>''' <EOL> bond = { '<STR_LIT>' : '<STR_LIT:1>' } <EOL> for binding in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if binding in opts : <EOL> try : <EOL> int ( opts [ binding ] ) <EOL> bond . update ( { binding : opts [ binding ] } ) <EOL> except Exception : <EOL> _raise_error_iface ( iface , binding , [ '<STR_LIT>' ] ) <EOL> else : <EOL> _log_default_iface ( iface , binding , bond_def [ binding ] ) <EOL> bond . update ( { binding : bond_def [ binding ] } ) <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:1>' } ) <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:0>' } ) <EOL> else : <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> else : <EOL> _log_default_iface ( iface , '<STR_LIT>' , bond_def [ '<STR_LIT>' ] ) <EOL> bond . update ( { '<STR_LIT>' : bond_def [ '<STR_LIT>' ] } ) <EOL> return bond <EOL> def _parse_settings_bond_2 ( opts , iface , bond_def ) : <EOL> '''<STR_LIT>''' <EOL> bond = { '<STR_LIT>' : '<STR_LIT:2>' } <EOL> valid = [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in opts : <EOL> if isinstance ( opts [ '<STR_LIT>' ] , list ) : <EOL> if <NUM_LIT:1> <= len ( opts [ '<STR_LIT>' ] ) <= <NUM_LIT:16> : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> for ip in opts [ '<STR_LIT>' ] : <EOL> if len ( bond [ '<STR_LIT>' ] ) > <NUM_LIT:0> : <EOL> bond [ '<STR_LIT>' ] = bond [ '<STR_LIT>' ] + '<STR_LIT:U+002C>' + ip <EOL> else : <EOL> bond [ '<STR_LIT>' ] = ip <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> if '<STR_LIT>' in opts : <EOL> try : <EOL> int ( opts [ '<STR_LIT>' ] ) <EOL> bond . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> except Exception : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> else : <EOL> _log_default_iface ( iface , '<STR_LIT>' , bond_def [ '<STR_LIT>' ] ) <EOL> bond . update ( { '<STR_LIT>' : bond_def [ '<STR_LIT>' ] } ) <EOL> if '<STR_LIT>' in opts : <EOL> bond . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> if '<STR_LIT>' in opts : <EOL> valid = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if opts [ '<STR_LIT>' ] in valid : <EOL> bond . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> return bond <EOL> def _parse_settings_bond_3 ( opts , iface , bond_def ) : <EOL> '''<STR_LIT>''' <EOL> bond = { '<STR_LIT>' : '<STR_LIT:3>' } <EOL> for binding in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if binding in opts : <EOL> try : <EOL> int ( opts [ binding ] ) <EOL> bond . update ( { binding : opts [ binding ] } ) <EOL> except Exception : <EOL> _raise_error_iface ( iface , binding , [ '<STR_LIT>' ] ) <EOL> else : <EOL> _log_default_iface ( iface , binding , bond_def [ binding ] ) <EOL> bond . update ( { binding : bond_def [ binding ] } ) <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:1>' } ) <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:0>' } ) <EOL> else : <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> else : <EOL> _log_default_iface ( iface , '<STR_LIT>' , bond_def [ '<STR_LIT>' ] ) <EOL> bond . update ( { '<STR_LIT>' : bond_def [ '<STR_LIT>' ] } ) <EOL> return bond <EOL> def _parse_settings_bond_4 ( opts , iface , bond_def ) : <EOL> '''<STR_LIT>''' <EOL> bond = { '<STR_LIT>' : '<STR_LIT:4>' } <EOL> for binding in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if binding in opts : <EOL> if binding == '<STR_LIT>' : <EOL> if opts [ binding ] == '<STR_LIT>' : <EOL> opts . update ( { binding : '<STR_LIT:1>' } ) <EOL> if opts [ binding ] == '<STR_LIT>' : <EOL> opts . update ( { binding : '<STR_LIT:0>' } ) <EOL> valid = [ '<STR_LIT>' , '<STR_LIT:1>' , '<STR_LIT>' , '<STR_LIT:0>' ] <EOL> else : <EOL> valid = [ '<STR_LIT>' ] <EOL> try : <EOL> int ( opts [ binding ] ) <EOL> bond . update ( { binding : opts [ binding ] } ) <EOL> except Exception : <EOL> _raise_error_iface ( iface , binding , valid ) <EOL> else : <EOL> _log_default_iface ( iface , binding , bond_def [ binding ] ) <EOL> bond . update ( { binding : bond_def [ binding ] } ) <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:1>' } ) <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:0>' } ) <EOL> else : <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> else : <EOL> _log_default_iface ( iface , '<STR_LIT>' , bond_def [ '<STR_LIT>' ] ) <EOL> bond . update ( { '<STR_LIT>' : bond_def [ '<STR_LIT>' ] } ) <EOL> if '<STR_LIT>' in opts : <EOL> valid = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if opts [ '<STR_LIT>' ] in valid : <EOL> bond . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> return bond <EOL> def _parse_settings_bond_5 ( opts , iface , bond_def ) : <EOL> '''<STR_LIT>''' <EOL> bond = { '<STR_LIT>' : '<STR_LIT:5>' } <EOL> for binding in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if binding in opts : <EOL> try : <EOL> int ( opts [ binding ] ) <EOL> bond . update ( { binding : opts [ binding ] } ) <EOL> except Exception : <EOL> _raise_error_iface ( iface , binding , [ '<STR_LIT>' ] ) <EOL> else : <EOL> _log_default_iface ( iface , binding , bond_def [ binding ] ) <EOL> bond . update ( { binding : bond_def [ binding ] } ) <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:1>' } ) <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:0>' } ) <EOL> else : <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> else : <EOL> _log_default_iface ( iface , '<STR_LIT>' , bond_def [ '<STR_LIT>' ] ) <EOL> bond . update ( { '<STR_LIT>' : bond_def [ '<STR_LIT>' ] } ) <EOL> return bond <EOL> def _parse_settings_bond_6 ( opts , iface , bond_def ) : <EOL> '''<STR_LIT>''' <EOL> bond = { '<STR_LIT>' : '<STR_LIT>' } <EOL> for binding in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if binding in opts : <EOL> try : <EOL> int ( opts [ binding ] ) <EOL> bond . update ( { binding : opts [ binding ] } ) <EOL> except Exception : <EOL> _raise_error_iface ( iface , binding , [ '<STR_LIT>' ] ) <EOL> else : <EOL> _log_default_iface ( iface , binding , bond_def [ binding ] ) <EOL> bond . update ( { binding : bond_def [ binding ] } ) <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:1>' } ) <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> bond . update ( { '<STR_LIT>' : '<STR_LIT:0>' } ) <EOL> else : <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> else : <EOL> _log_default_iface ( iface , '<STR_LIT>' , bond_def [ '<STR_LIT>' ] ) <EOL> bond . update ( { '<STR_LIT>' : bond_def [ '<STR_LIT>' ] } ) <EOL> return bond <EOL> def _parse_settings_vlan ( opts , iface ) : <EOL> '''<STR_LIT>''' <EOL> vlan = { } <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE + _CONFIG_FALSE : <EOL> vlan . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> else : <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> _raise_error_iface ( iface , '<STR_LIT>' , valid ) <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] > <NUM_LIT:0> : <EOL> vlan . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if '<STR_LIT>' in opts : <EOL> if len ( opts [ '<STR_LIT>' ] ) > <NUM_LIT:0> : <EOL> vlan . update ( { '<STR_LIT>' : opts [ '<STR_LIT>' ] } ) <EOL> else : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , '<STR_LIT>' ) <EOL> return vlan <EOL> def _parse_settings_eth ( opts , iface_type , enabled , iface ) : <EOL> '''<STR_LIT>''' <EOL> result = { '<STR_LIT:name>' : iface } <EOL> if '<STR_LIT>' in opts : <EOL> valid = [ '<STR_LIT:none>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if opts [ '<STR_LIT>' ] in valid : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> else : <EOL> _raise_error_iface ( iface , opts [ '<STR_LIT>' ] , valid ) <EOL> if '<STR_LIT>' in opts : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> result [ '<STR_LIT>' ] = '<STR_LIT:yes>' <EOL> if '<STR_LIT>' in opts : <EOL> try : <EOL> result [ '<STR_LIT>' ] = int ( opts [ '<STR_LIT>' ] ) <EOL> except ValueError : <EOL> _raise_error_iface ( iface , '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> if iface_type not in [ '<STR_LIT>' ] : <EOL> ethtool = _parse_ethtool_opts ( opts , iface ) <EOL> if ethtool : <EOL> result [ '<STR_LIT>' ] = ethtool <EOL> if iface_type == '<STR_LIT>' : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT:none>' <EOL> if iface_type == '<STR_LIT>' : <EOL> bonding = _parse_settings_bond ( opts , iface ) <EOL> if bonding : <EOL> result [ '<STR_LIT>' ] = bonding <EOL> result [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> if iface_type == '<STR_LIT>' : <EOL> vlan = _parse_settings_vlan ( opts , iface ) <EOL> if vlan : <EOL> result [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> for opt in vlan : <EOL> result [ opt ] = opts [ opt ] <EOL> if iface_type not in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if '<STR_LIT>' in opts : <EOL> if salt . utils . validate . net . mac ( opts [ '<STR_LIT>' ] ) : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> else : <EOL> _raise_error_iface ( iface , opts [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> else : <EOL> if iface_type != '<STR_LIT>' : <EOL> ifaces = __salt__ [ '<STR_LIT>' ] ( ) <EOL> if iface in ifaces and '<STR_LIT>' in ifaces [ iface ] : <EOL> result [ '<STR_LIT>' ] = ifaces [ iface ] [ '<STR_LIT>' ] <EOL> if iface_type == '<STR_LIT>' : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if iface_type == '<STR_LIT>' : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> bypassfirewall = True <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> for opt in [ '<STR_LIT>' ] : <EOL> if opt in opts : <EOL> if opts [ opt ] in _CONFIG_TRUE : <EOL> bypassfirewall = True <EOL> elif opts [ opt ] in _CONFIG_FALSE : <EOL> bypassfirewall = False <EOL> else : <EOL> _raise_error_iface ( iface , opts [ opt ] , valid ) <EOL> if bypassfirewall : <EOL> __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' , '<STR_LIT:0>' ) <EOL> __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' , '<STR_LIT:0>' ) <EOL> __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' , '<STR_LIT:0>' ) <EOL> else : <EOL> __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' , '<STR_LIT:1>' ) <EOL> __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' , '<STR_LIT:1>' ) <EOL> __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' , '<STR_LIT:1>' ) <EOL> else : <EOL> if '<STR_LIT>' in opts : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> if iface_type == '<STR_LIT>' : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> for opt in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if opt not in opts : <EOL> _raise_error_iface ( iface , opts [ opt ] , [ '<STR_LIT>' ] ) <EOL> else : <EOL> result [ opt ] = opts [ opt ] <EOL> if iface_type == '<STR_LIT>' : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if '<STR_LIT>' in opts : <EOL> if '<STR_LIT>' in opts : <EOL> msg = '<STR_LIT>' <EOL> log . error ( msg ) <EOL> raise AttributeError ( msg ) <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> elif '<STR_LIT>' in opts : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> for opt in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if opt in opts : <EOL> result [ opt ] = opts [ opt ] <EOL> for opt in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if opt in opts : <EOL> result [ opt ] = opts [ opt ] <EOL> for opt in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if opt in opts : <EOL> result [ opt ] = opts [ opt ] <EOL> if '<STR_LIT>' in opts : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> for opt in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if opt in opts : <EOL> if opts [ opt ] in _CONFIG_TRUE : <EOL> result [ opt ] = '<STR_LIT:yes>' <EOL> elif opts [ opt ] in _CONFIG_FALSE : <EOL> result [ opt ] = '<STR_LIT>' <EOL> else : <EOL> _raise_error_iface ( iface , opts [ opt ] , valid ) <EOL> if '<STR_LIT>' in opts : <EOL> log . warning ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( iface , enabled ) <EOL> ) <EOL> if enabled : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT:yes>' <EOL> else : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT:yes>' <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> _raise_error_iface ( iface , opts [ '<STR_LIT>' ] , valid ) <EOL> else : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT:yes>' <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> _raise_error_iface ( iface , opts [ '<STR_LIT>' ] , valid ) <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if '<STR_LIT>' in opts : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in opts : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in opts : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> return result <EOL> def _parse_routes ( iface , opts ) : <EOL> '''<STR_LIT>''' <EOL> opts = dict ( ( k . lower ( ) , v ) for ( k , v ) in six . iteritems ( opts ) ) <EOL> result = { } <EOL> if '<STR_LIT>' not in opts : <EOL> _raise_error_routes ( iface , '<STR_LIT>' , '<STR_LIT>' ) <EOL> for opt in opts : <EOL> result [ opt ] = opts [ opt ] <EOL> return result <EOL> def _parse_network_settings ( opts , current ) : <EOL> '''<STR_LIT>''' <EOL> opts = dict ( ( k . lower ( ) , v ) for ( k , v ) in six . iteritems ( opts ) ) <EOL> current = dict ( ( k . lower ( ) , v ) for ( k , v ) in six . iteritems ( current ) ) <EOL> result = { } <EOL> valid = _CONFIG_TRUE + _CONFIG_FALSE <EOL> if '<STR_LIT>' not in opts : <EOL> try : <EOL> opts [ '<STR_LIT>' ] = current [ '<STR_LIT>' ] <EOL> _log_default_network ( '<STR_LIT>' , current [ '<STR_LIT>' ] ) <EOL> except ValueError : <EOL> _raise_error_network ( '<STR_LIT>' , valid ) <EOL> else : <EOL> opts [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> if opts [ '<STR_LIT>' ] in valid : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT:yes>' <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> _raise_error_network ( '<STR_LIT>' , valid ) <EOL> if '<STR_LIT>' not in opts : <EOL> try : <EOL> opts [ '<STR_LIT>' ] = current [ '<STR_LIT>' ] <EOL> _log_default_network ( '<STR_LIT>' , current [ '<STR_LIT>' ] ) <EOL> except Exception : <EOL> _raise_error_network ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> if opts [ '<STR_LIT>' ] : <EOL> result [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> else : <EOL> _raise_error_network ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in opts : <EOL> if opts [ '<STR_LIT>' ] in valid : <EOL> if opts [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT:true>' <EOL> elif opts [ '<STR_LIT>' ] in _CONFIG_FALSE : <EOL> result [ '<STR_LIT>' ] = '<STR_LIT:false>' <EOL> else : <EOL> _raise_error_network ( '<STR_LIT>' , valid ) <EOL> for opt in opts : <EOL> if opt not in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> result [ opt ] = opts [ opt ] <EOL> return result <EOL> def _raise_error_iface ( iface , option , expected ) : <EOL> '''<STR_LIT>''' <EOL> msg = _error_msg_iface ( iface , option , expected ) <EOL> log . error ( msg ) <EOL> raise AttributeError ( msg ) <EOL> def _raise_error_network ( option , expected ) : <EOL> '''<STR_LIT>''' <EOL> msg = _error_msg_network ( option , expected ) <EOL> log . error ( msg ) <EOL> raise AttributeError ( msg ) <EOL> def _raise_error_routes ( iface , option , expected ) : <EOL> '''<STR_LIT>''' <EOL> msg = _error_msg_routes ( iface , option , expected ) <EOL> log . error ( msg ) <EOL> raise AttributeError ( msg ) <EOL> def _read_file ( path ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> with salt . utils . fopen ( path , '<STR_LIT:rb>' ) as contents : <EOL> lines = contents . read ( ) . splitlines ( ) <EOL> try : <EOL> lines . remove ( '<STR_LIT>' ) <EOL> except ValueError : <EOL> pass <EOL> return lines <EOL> except Exception : <EOL> return [ ] <EOL> def _write_file_iface ( iface , data , folder , pattern ) : <EOL> '''<STR_LIT>''' <EOL> filename = os . path . join ( folder , pattern . format ( iface ) ) <EOL> if not os . path . exists ( folder ) : <EOL> msg = '<STR_LIT>' <EOL> msg = msg . format ( filename , folder ) <EOL> log . error ( msg ) <EOL> raise AttributeError ( msg ) <EOL> fout = salt . utils . fopen ( filename , '<STR_LIT:w>' ) <EOL> fout . write ( data ) <EOL> fout . close ( ) <EOL> def _write_file_network ( data , filename ) : <EOL> '''<STR_LIT>''' <EOL> fout = salt . utils . fopen ( filename , '<STR_LIT:w>' ) <EOL> fout . write ( data ) <EOL> fout . close ( ) <EOL> def _read_temp ( data ) : <EOL> lines = data . splitlines ( ) <EOL> try : <EOL> lines . remove ( '<STR_LIT>' ) <EOL> except ValueError : <EOL> pass <EOL> return lines <EOL> def build_bond ( iface , ** settings ) : <EOL> '''<STR_LIT>''' <EOL> rh_major = __grains__ [ '<STR_LIT>' ] [ : <NUM_LIT:1> ] <EOL> opts = _parse_settings_bond ( settings , iface ) <EOL> try : <EOL> template = JINJA . get_template ( '<STR_LIT>' ) <EOL> except jinja2 . exceptions . TemplateNotFound : <EOL> log . error ( '<STR_LIT>' ) <EOL> return '<STR_LIT>' <EOL> data = template . render ( { '<STR_LIT:name>' : iface , '<STR_LIT>' : opts } ) <EOL> _write_file_iface ( iface , data , _RH_NETWORK_CONF_FILES , '<STR_LIT>' . format ( iface ) ) <EOL> path = os . path . join ( _RH_NETWORK_CONF_FILES , '<STR_LIT>' . format ( iface ) ) <EOL> if rh_major == '<STR_LIT:5>' : <EOL> __salt__ [ '<STR_LIT>' ] ( <EOL> '<STR_LIT>' . format ( iface ) , <EOL> python_shell = False <EOL> ) <EOL> __salt__ [ '<STR_LIT>' ] ( <EOL> '<STR_LIT>' . format ( iface ) , <EOL> python_shell = False <EOL> ) <EOL> __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' , path ) <EOL> __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> if settings [ '<STR_LIT:test>' ] : <EOL> return _read_temp ( data ) <EOL> return _read_file ( path ) <EOL> def build_interface ( iface , iface_type , enabled , ** settings ) : <EOL> '''<STR_LIT>''' <EOL> if __grains__ [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> rh_major = '<STR_LIT>' <EOL> else : <EOL> rh_major = __grains__ [ '<STR_LIT>' ] [ : <NUM_LIT:1> ] <EOL> iface = iface . lower ( ) <EOL> iface_type = iface_type . lower ( ) <EOL> if iface_type not in _IFACE_TYPES : <EOL> _raise_error_iface ( iface , iface_type , _IFACE_TYPES ) <EOL> if iface_type == '<STR_LIT>' : <EOL> settings [ '<STR_LIT>' ] = '<STR_LIT:yes>' <EOL> if '<STR_LIT>' not in settings : <EOL> msg = '<STR_LIT>' <EOL> log . error ( msg ) <EOL> raise AttributeError ( msg ) <EOL> if iface_type == '<STR_LIT>' : <EOL> settings [ '<STR_LIT>' ] = '<STR_LIT:yes>' <EOL> if iface_type == '<STR_LIT>' : <EOL> __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> if iface_type in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> opts = _parse_settings_eth ( settings , iface_type , enabled , iface ) <EOL> try : <EOL> template = JINJA . get_template ( '<STR_LIT>' . format ( rh_major ) ) <EOL> except jinja2 . exceptions . TemplateNotFound : <EOL> log . error ( <EOL> '<STR_LIT>' . format ( <EOL> rh_major <EOL> ) <EOL> ) <EOL> return '<STR_LIT>' <EOL> ifcfg = template . render ( opts ) <EOL> if '<STR_LIT:test>' in settings and settings [ '<STR_LIT:test>' ] : <EOL> return _read_temp ( ifcfg ) <EOL> _write_file_iface ( iface , ifcfg , _RH_NETWORK_SCRIPT_DIR , '<STR_LIT>' ) <EOL> path = os . path . join ( _RH_NETWORK_SCRIPT_DIR , '<STR_LIT>' . format ( iface ) ) <EOL> return _read_file ( path ) <EOL> def build_routes ( iface , ** settings ) : <EOL> '''<STR_LIT>''' <EOL> template = '<STR_LIT>' <EOL> try : <EOL> if int ( __grains__ [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) < <NUM_LIT:6> : <EOL> template = '<STR_LIT>' <EOL> except ValueError : <EOL> pass <EOL> log . debug ( '<STR_LIT>' + template ) <EOL> iface = iface . lower ( ) <EOL> opts = _parse_routes ( iface , settings ) <EOL> log . debug ( "<STR_LIT>" . format ( opts ) ) <EOL> try : <EOL> template = JINJA . get_template ( template ) <EOL> except jinja2 . exceptions . TemplateNotFound : <EOL> log . error ( <EOL> '<STR_LIT>' . format ( template ) <EOL> ) <EOL> return '<STR_LIT>' <EOL> opts6 = [ ] <EOL> opts4 = [ ] <EOL> for route in opts [ '<STR_LIT>' ] : <EOL> ipaddr = route [ '<STR_LIT>' ] <EOL> if salt . utils . validate . net . ipv6_addr ( ipaddr ) : <EOL> opts6 . append ( route ) <EOL> else : <EOL> opts4 . append ( route ) <EOL> log . debug ( "<STR_LIT>" . format ( opts4 ) ) <EOL> log . debug ( "<STR_LIT>" . format ( opts6 ) ) <EOL> routecfg = template . render ( routes = opts4 ) <EOL> routecfg6 = template . render ( routes = opts6 ) <EOL> if settings [ '<STR_LIT:test>' ] : <EOL> routes = _read_temp ( routecfg ) <EOL> routes . extend ( _read_temp ( routecfg6 ) ) <EOL> return routes <EOL> _write_file_iface ( iface , routecfg , _RH_NETWORK_SCRIPT_DIR , '<STR_LIT>' ) <EOL> _write_file_iface ( iface , routecfg6 , _RH_NETWORK_SCRIPT_DIR , '<STR_LIT>' ) <EOL> path = os . path . join ( _RH_NETWORK_SCRIPT_DIR , '<STR_LIT>' . format ( iface ) ) <EOL> path6 = os . path . join ( _RH_NETWORK_SCRIPT_DIR , '<STR_LIT>' . format ( iface ) ) <EOL> routes = _read_file ( path ) <EOL> routes . extend ( _read_file ( path6 ) ) <EOL> return routes <EOL> def down ( iface , iface_type ) : <EOL> '''<STR_LIT>''' <EOL> if iface_type not in [ '<STR_LIT>' ] : <EOL> return __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' . format ( iface ) ) <EOL> return None <EOL> def get_bond ( iface ) : <EOL> '''<STR_LIT>''' <EOL> path = os . path . join ( _RH_NETWORK_CONF_FILES , '<STR_LIT>' . format ( iface ) ) <EOL> return _read_file ( path ) <EOL> def get_interface ( iface ) : <EOL> '''<STR_LIT>''' <EOL> path = os . path . join ( _RH_NETWORK_SCRIPT_DIR , '<STR_LIT>' . format ( iface ) ) <EOL> return _read_file ( path ) <EOL> def up ( iface , iface_type ) : <EOL> '''<STR_LIT>''' <EOL> if iface_type not in [ '<STR_LIT>' ] : <EOL> return __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' . format ( iface ) ) <EOL> return None <EOL> def get_routes ( iface ) : <EOL> '''<STR_LIT>''' <EOL> path = os . path . join ( _RH_NETWORK_SCRIPT_DIR , '<STR_LIT>' . format ( iface ) ) <EOL> path6 = os . path . join ( _RH_NETWORK_SCRIPT_DIR , '<STR_LIT>' . format ( iface ) ) <EOL> routes = _read_file ( path ) <EOL> routes . extend ( _read_file ( path6 ) ) <EOL> return routes <EOL> def get_network_settings ( ) : <EOL> '''<STR_LIT>''' <EOL> return _read_file ( _RH_NETWORK_FILE ) <EOL> def apply_network_settings ( ** settings ) : <EOL> '''<STR_LIT>''' <EOL> if '<STR_LIT>' not in settings : <EOL> settings [ '<STR_LIT>' ] = False <EOL> if '<STR_LIT>' not in settings : <EOL> settings [ '<STR_LIT>' ] = False <EOL> hostname_res = True <EOL> if settings [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> if '<STR_LIT>' in settings : <EOL> hostname_res = __salt__ [ '<STR_LIT>' ] ( settings [ '<STR_LIT>' ] ) <EOL> else : <EOL> log . warning ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> hostname_res = False <EOL> res = True <EOL> if settings [ '<STR_LIT>' ] in _CONFIG_TRUE : <EOL> log . warning ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> res = True <EOL> else : <EOL> res = __salt__ [ '<STR_LIT>' ] ( '<STR_LIT>' ) <EOL> return hostname_res and res <EOL> def build_network_settings ( ** settings ) : <EOL> '''<STR_LIT>''' <EOL> current_network_settings = _parse_rh_config ( _RH_NETWORK_FILE ) <EOL> opts = _parse_network_settings ( settings , current_network_settings ) <EOL> try : <EOL> template = JINJA . get_template ( '<STR_LIT>' ) <EOL> except jinja2 . exceptions . TemplateNotFound : <EOL> log . error ( '<STR_LIT>' ) <EOL> return '<STR_LIT>' <EOL> network = template . render ( opts ) <EOL> if settings [ '<STR_LIT:test>' ] : <EOL> return _read_temp ( network ) <EOL> _write_file_network ( network , _RH_NETWORK_FILE ) <EOL> return _read_file ( _RH_NETWORK_FILE ) </s>
