Skip to content

Commit

Permalink
Add volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Oct 7, 2024
1 parent 639a82b commit 568e74f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The following Debian's packets are required (or their equivalent on your distrib
- [`docker-compose-plugin`](https://docs.docker.com/compose/install/linux/#install-using-the-repository)
- `j2cli`
- `make`
- `acl`

>[!NOTE]
> If you intend to use Free5GC’s UPF (with `make set/dataplane/free5gc`),
Expand Down
24 changes: 22 additions & 2 deletions scripts/jinja/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,13 @@ def ipv6_prefix(name: str, subnet: str, _context: _Context) -> str:
return addr

@j2_function(output='json')
def container(name: str, image: str, enable_ipv6: typing.Optional[bool] = False, # pylint: disable=too-many-arguments
def container(name: str, image: str, enable_ipv6: typing.Optional[bool] = False, # pylint: disable=too-many-arguments, disable=too-many-branches, disable=too-many-locals
srv6: typing.Optional[bool] = False, iface_tun: typing.Optional[bool] = False,
command: typing.Optional[str|bool] = None, init: typing.Optional[bool] = False,
cap_net_admin: typing.Optional[bool] = False, restart: typing.Optional[str] = None,
ipv4_forward: typing.Optional[bool] = False,
debug: typing.Optional[bool] = False) -> str:
debug: typing.Optional[bool] = False,
debug_volume: typing.Optional[bool] = False) -> str:
'''Add a container'''
containers = {}
if debug:
Expand All @@ -364,6 +365,25 @@ def container(name: str, image: str, enable_ipv6: typing.Optional[bool] = False,
"cap_add": ['NET_ADMIN',],
"profiles": ['debug',],
}
if debug_volume:
containers[f'{name}-debug']['volumes'] = [f'./volumes/{name}:/volume']
build, _ = build_and_template_dir()
build = os.path.join(build, f'./volumes/{name}')
os.makedirs(build, exist_ok=True)
try:
# set acl to allow current user to always be able to read
# and delete new files added in the volume
subprocess.run([
'setfacl', '-dRm', f'u:{os.environ["USER"]}:rw',
os.path.dirname(build)
],
check=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
except subprocess.CalledProcessError as exc:
raise(GenerationError(f'Could not set acl on directory {build}')) from exc

containers[name] = {
"container_name": name,
"hostname": name,
Expand Down
2 changes: 1 addition & 1 deletion templates/compose.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
name: "nextmn-testbed"

services:
{{ container_s(name='ue1', image='louisroyer/ueransim-ue', enable_ipv6=True, debug=True, iface_tun=True, cap_net_admin=True, init=True) }}
{{ container_s(name='ue1', image='louisroyer/ueransim-ue', enable_ipv6=True, debug=True, debug_volume=True, iface_tun=True, cap_net_admin=True, init=True) }}
environment:
MSISDN: "0000000001"
GNBS: |-
Expand Down

0 comments on commit 568e74f

Please sign in to comment.