mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Fixed routes
This commit is contained in:
parent
1383adbc35
commit
14b5bcf008
@ -82,7 +82,7 @@ def _error_msg_routes(iface, option, expected):
|
||||
a list of expected values.
|
||||
'''
|
||||
msg = 'Invalid option -- Route interface: {0}, Option: {1}, Expected: [{2}]'
|
||||
return msg.format(iface, option, '|'.join(expected))
|
||||
return msg.format(iface, option, expected)
|
||||
|
||||
|
||||
def _log_default_iface(iface, opt, value):
|
||||
@ -653,11 +653,9 @@ def _parse_routes(iface, opts):
|
||||
'''
|
||||
# Normalize keys
|
||||
opts = dict((k.lower(), v) for (k, v) in opts.iteritems())
|
||||
current = dict((k.lower(), v) for (k, v) in current.iteritems())
|
||||
result = {}
|
||||
|
||||
if not 'routes' in opts:
|
||||
_raise_error_routes(iface, 'routes', 'Dictionary of routes')
|
||||
_raise_error_routes(iface, 'routes', 'List of routes')
|
||||
|
||||
for opt in opts:
|
||||
result[opt] = opts[opt]
|
||||
@ -888,7 +886,6 @@ def build_routes(iface, **settings):
|
||||
'''
|
||||
|
||||
iface = iface.lower()
|
||||
|
||||
opts = _parse_routes(iface, settings)
|
||||
try:
|
||||
template = ENV.get_template('route_eth.jinja')
|
||||
@ -897,7 +894,7 @@ def build_routes(iface, **settings):
|
||||
'Could not load template route_eth.jinja'
|
||||
)
|
||||
return ''
|
||||
routecfg = template.render(opts)
|
||||
routecfg = template.render(routes=opts['routes'])
|
||||
|
||||
if settings['test']:
|
||||
return _read_temp(routecfg)
|
||||
@ -1031,3 +1028,4 @@ def build_network_settings(**settings):
|
||||
_write_file_network(network, _RH_NETWORK_FILE)
|
||||
|
||||
return _read_file(_RH_NETWORK_FILE)
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% for route in routes -%}
|
||||
{% if ipaddr %}ADDRESS{{loop.index}}="{{ipaddr}}"
|
||||
{%endif%}{% if netmask %}NETMASK{{loop.index}}="{{netmask}}"
|
||||
{%endif%}{% if gateway %}GATEWAY{{loop.index}}="{{gateway}}"
|
||||
{% for route in routes %}{% if route.name %}# {{route.name}}
|
||||
{%endif%}{% if route.ipaddr %}ADDRESS{{loop.index0}}="{{route.ipaddr}}"
|
||||
{%endif%}{% if route.netmask %}NETMASK{{loop.index0}}="{{route.netmask}}"
|
||||
{%endif%}{% if route.gateway %}GATEWAY{{loop.index0}}="{{route.gateway}}"
|
||||
{%endif%}
|
||||
{% endfor -%}
|
||||
|
||||
{% endfor %}
|
||||
|
@ -32,15 +32,16 @@ supported. This module will therefore only work on RH/CentOS/Fedora.
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
network.routes:
|
||||
- secure_network:
|
||||
ipaddr: 10.2.0.0
|
||||
netmask: 255.255.255.0
|
||||
gateway: 10.2.0.1
|
||||
- HQ_network:
|
||||
ipaddr: 10.100.0.0
|
||||
netmask: 255.255.0.0
|
||||
gateway: 10.100.0.10
|
||||
|
||||
- routes:
|
||||
- name: secure_network
|
||||
ipaddr: 10.2.0.0
|
||||
netmask: 255.255.255.0
|
||||
gateway: 10.1.0.3
|
||||
- name: HQ_network
|
||||
ipaddr: 10.100.0.0
|
||||
netmask: 255.255.0.0
|
||||
gateway: 10.1.0.10
|
||||
|
||||
eth2:
|
||||
network.managed:
|
||||
- type: slave
|
||||
@ -304,7 +305,7 @@ def routes(name, **kwargs):
|
||||
return ret
|
||||
|
||||
# Apply interface routes
|
||||
if apply_net_settings:
|
||||
if apply_routes:
|
||||
try:
|
||||
__salt__['ip.apply_network_settings'](**kwargs)
|
||||
except AttributeError as error:
|
||||
|
Loading…
Reference in New Issue
Block a user