Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
34 changes: 17 additions & 17 deletions default-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 14 additions & 4 deletions scripts/jinja/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading