diff --git a/Makefile b/Makefile index 1772cc9..5cb31c5 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,17 @@ MAKE = make --no-print-directory $(BCOMPOSE): templates/compose.yaml.j2 scripts/jinja/customize.py $(BCONFIG) - @echo Building $(BCOMPOSE) from jinja template + @if [ $(BCONFIG) -ot default-config.yaml ]; then \ + echo "Warning: default-config.yaml has been updated recently, consider updating $(BCONFIG)"; \ + fi + @echo Building $(BCOMPOSE) from jinja template. @mkdir -p $$(dirname $(BCOMPOSE)) @j2 --customize scripts/jinja/customize.py -o $(BCOMPOSE) templates/compose.yaml.j2 $(BCONFIG) -$(BCONFIG): default-config.yaml +$(BCONFIG): + # Note: "default-config.yaml" is not a dependency of this target + # to avoid overriding local config. + # You may want to do a "make clean" when updating the template. @echo Copying default-config.yaml into $(BCONFIG) @mkdir -p $$(dirname $(BCONFIG)) @cp default-config.yaml $(BCONFIG) diff --git a/default-config.yaml b/default-config.yaml index 44d9290..f52dd8c 100644 --- a/default-config.yaml +++ b/default-config.yaml @@ -222,69 +222,69 @@ subnets: ipv4_address: 10.4.0.2 slice0: subnet: - ipv4_address: 10.2.0.0/24 + ipv4_prefix: 10.2.0.0/24 slice0-static: subnet: - ipv4_address: 10.2.0.128/25 + ipv4_prefix: 10.2.0.128/25 slice1: subnet: - ipv4_address: 10.2.1.0/24 + ipv4_prefix: 10.2.1.0/24 slice1-e1: subnet: - ipv4_address: 10.2.1.0/26 + ipv4_prefix: 10.2.1.0/26 slice1-e1-static: subnet: - ipv4_address: 10.2.1.64/26 + ipv4_prefix: 10.2.1.64/26 slice1-e2: subnet: - ipv4_address: 10.2.1.128/26 + ipv4_prefix: 10.2.1.128/26 slice1-e2-static: subnet: - ipv4_address: 10.2.1.192/26 + ipv4_prefix: 10.2.1.192/26 slice2: subnet: - ipv4_address: 10.2.2.0/24 + ipv4_prefix: 10.2.2.0/24 slice2-e1: subnet: - ipv4_address: 10.2.2.0/26 + ipv4_prefix: 10.2.2.0/26 slice2-e1-static: subnet: - ipv4_address: 10.2.2.64/26 + ipv4_prefix: 10.2.2.64/26 slice2-e2: subnet: - ipv4_address: 10.2.2.128/26 + ipv4_prefix: 10.2.2.128/26 slice2-e2-static: subnet: - ipv4_address: 10.2.2.192/26 + ipv4_prefix: 10.2.2.192/26 srgw0: subnet: - ipv6_address: fc00:1::/32 + ipv6_prefix: fc00:1::/32 srgw0: ipv4_address: 10.3.0.1 end-m-gtp4-e: ipv6_prefix: fc00:1:1::/48 srgw1: subnet: - ipv6_address: fc00:4::/32 + ipv6_prefix: fc00:4::/32 srgw1: ipv4_address: 10.3.0.2 end-m-gtp4-e: ipv6_prefix: fc00:4:1::/48 r0: subnet: - ipv6_address: fc00:2::/32 + ipv6_prefix: fc00:2::/32 end-dx4: ipv6_address: "fc00:2:1::" ipv6_prefix: fc00:2:1::/48 r1: subnet: - ipv6_address: fc00:3::/32 + ipv6_prefix: fc00:3::/32 end-dx4: ipv6_address: "fc00:3:1::" ipv6_prefix: fc00:3:1::/48 r2: subnet: - ipv6_address: fc00:5::/32 + ipv6_prefix: fc00:5::/32 end-dx4: ipv6_address: "fc00:5:1::" ipv6_prefix: fc00:5:1::/48 diff --git a/scripts/jinja/customize.py b/scripts/jinja/customize.py index 2b4b0e4..932e383 100644 --- a/scripts/jinja/customize.py +++ b/scripts/jinja/customize.py @@ -412,18 +412,28 @@ def ipv6(host: str, subnet: str, _context: _Context) -> str: def ipv4_subnet(subnet: str, _context: _Context) -> str: '''Get IPv4 subnet''' try: - addr = _context.dict['subnets'][subnet]['subnet']['ipv4_address'] + addr = _context.dict['subnets'][subnet]['subnet']['ipv4_prefix'] except KeyError as exc: - raise(TemplateError(f'Unknown ipv4 subnet: {subnet}')) from exc + # XXX: remove this backward compatibility fallback after some time + try: + addr = _context.dict['subnets'][subnet]['subnet']['ipv4_address'] + print('warning: subnets[].subnet.ipv4_address is deprecated and must be replaced by subnets[].subnet.ipv4_prefix') + except KeyError as exc: + raise(TemplateError(f'Unknown ipv4 subnet: {subnet}')) from exc return addr @j2_function def ipv6_subnet(subnet: str, _context: _Context) -> str: '''Get IPv6 subnet''' try: - addr = _context.dict['subnets'][subnet]['subnet']['ipv6_address'] + addr = _context.dict['subnets'][subnet]['subnet']['ipv6_prefix'] except KeyError as exc: - raise(TemplateError(f'Unknown ipv6 subnet: {subnet}')) from exc + # XXX: remove this backward compatibility fallback after some time + try: + addr = _context.dict['subnets'][subnet]['subnet']['ipv6_address'] + print('warning: subnets[].subnet.ipv6_address is deprecated and must be replaced by subnets[].subnet.ipv6_prefix') + except KeyError as exc: + raise(TemplateError(f'Unknown ipv6 subnet: {subnet}')) from exc return addr @j2_function