Got carryover indention correct.
This commit is contained in:
parent
306fd72287
commit
726f34379d
@ -17,15 +17,17 @@
|
|||||||
{%- set indentHolder = indent -%}
|
{%- set indentHolder = indent -%}
|
||||||
{%- for item in data|dictsort -%}
|
{%- for item in data|dictsort -%}
|
||||||
{%- if item[key] in carryovers -%}
|
{%- if item[key] in carryovers -%}
|
||||||
{{- keepalived_config(item[value], carryover=item[key]) -}}
|
{{- keepalived_config(item[value], carryover=item[key], indent=indent) -}}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
|
{%- set carryIndent = indentHolder -%}
|
||||||
{%- if carryover -%}
|
{%- if carryover -%}
|
||||||
{{- carryover }}{{ ' ' -}}
|
{{- carryover|indent(indentHolder, True) }}{{ ' ' -}}
|
||||||
|
{%- set carryIndent = 0 -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if item[value] is string or item[value] is not iterable -%}
|
{%- if item[value] is string or item[value] is not iterable -%}
|
||||||
{%- set indent = 0 -%}
|
{%- set indent = 0 -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{{- item[key]|indent(indentHolder, True) }} {{ keepalived_config(item[value], recurse=recurse, indent=indent) -}}
|
{{- item[key]|indent(carryIndent, True) }} {{ keepalived_config(item[value], recurse=recurse, indent=indent) -}}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
@ -34,7 +36,7 @@
|
|||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if recurse > 0 -%}
|
{%- if recurse > 0 -%}
|
||||||
{{- '}\n' -}}
|
{{- '}'|indent(indent - 2, True) -}}{{ '\n' }}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
|
@ -69,7 +69,7 @@ class TestKeepalivedConfiguration(unittest.TestCase):
|
|||||||
result = 'vrrp_script gizmo {\n fred flintstone\n barney rubble\n}\n'
|
result = 'vrrp_script gizmo {\n fred flintstone\n barney rubble\n}\n'
|
||||||
self.renderTest(testdata, result)
|
self.renderTest(testdata, result)
|
||||||
|
|
||||||
def test_carrover_vrrp_instance(self):
|
def test_carryover_vrrp_instance(self):
|
||||||
testdata = {'vrrp_instance': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
testdata = {'vrrp_instance': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
||||||
result = 'vrrp_instance gizmo {\n barney rubble\n fred flintstone\n}\n'
|
result = 'vrrp_instance gizmo {\n barney rubble\n fred flintstone\n}\n'
|
||||||
self.renderTest(testdata, result)
|
self.renderTest(testdata, result)
|
||||||
@ -79,25 +79,30 @@ class TestKeepalivedConfiguration(unittest.TestCase):
|
|||||||
result = 'vrrp_script gizmo {\n running dumdums\n}\nvrrp_instance dumdums {\n fred flintstone\n}\n'
|
result = 'vrrp_script gizmo {\n running dumdums\n}\nvrrp_instance dumdums {\n fred flintstone\n}\n'
|
||||||
self.renderTest(testdata, result)
|
self.renderTest(testdata, result)
|
||||||
|
|
||||||
def test_carrover_vrrp_sync_group(self):
|
def test_carryover_vrrp_sync_group(self):
|
||||||
testdata = {'vrrp_sync_group': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
testdata = {'vrrp_sync_group': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
||||||
result = 'vrrp_sync_group gizmo {\n barney rubble\n fred flintstone\n}\n'
|
result = 'vrrp_sync_group gizmo {\n barney rubble\n fred flintstone\n}\n'
|
||||||
self.renderTest(testdata, result)
|
self.renderTest(testdata, result)
|
||||||
|
|
||||||
def test_carrover_virtual_server_group(self):
|
def test_carryover_virtual_server_group(self):
|
||||||
testdata = {'virtual_server_group': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
testdata = {'virtual_server_group': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
||||||
result = 'virtual_server_group gizmo {\n barney rubble\n fred flintstone\n}\n'
|
result = 'virtual_server_group gizmo {\n barney rubble\n fred flintstone\n}\n'
|
||||||
self.renderTest(testdata, result)
|
self.renderTest(testdata, result)
|
||||||
|
|
||||||
def test_carrover_virtual_server(self):
|
def test_carryover_virtual_server(self):
|
||||||
testdata = {'virtual_server': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
testdata = {'virtual_server': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
||||||
result = 'virtual_server gizmo {\n barney rubble\n fred flintstone\n}\n'
|
result = 'virtual_server gizmo {\n barney rubble\n fred flintstone\n}\n'
|
||||||
self.renderTest(testdata, result)
|
self.renderTest(testdata, result)
|
||||||
|
|
||||||
def test_carrover_real_server(self):
|
def test_carryover_real_server(self):
|
||||||
testdata = {'real_server': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
testdata = {'real_server': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}}
|
||||||
result = 'real_server gizmo {\n barney rubble\n fred flintstone\n}\n'
|
result = 'real_server gizmo {\n barney rubble\n fred flintstone\n}\n'
|
||||||
self.renderTest(testdata, result)
|
self.renderTest(testdata, result)
|
||||||
|
|
||||||
|
def test_carryover_within_carryover(self):
|
||||||
|
testdata = {'virtual_server': {'gizmo': {'real_server': {'dumdums': {'fred': 'flintstone', 'barney': 'rubble'}}}}}
|
||||||
|
result = 'virtual_server gizmo {\n real_server dumdums {\n barney rubble\n fred flintstone\n }\n}\n'
|
||||||
|
self.renderTest(testdata, result)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user