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
18 changes: 17 additions & 1 deletion netsim/cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from ..utils import log,strings,read
from ..utils.files import get_moddir
from . import external_commands,error_and_exit
from . import external_commands,error_and_exit,set_dry_run

#
# CLI parser for 'netlab install' command
Expand Down Expand Up @@ -84,6 +84,18 @@ def read_config_setup() -> Box:
error_and_exit(f'Cannot read {str(os_release)}: {str(ex)}')
return setup

"""
Adjust installation configuration:

* Update 'env' dictionary from topology variables
"""
def adjust_setup(setup: Box, topology: Box, args: argparse.Namespace) -> None:
for k,v in setup.env.items():
if v in topology.defaults:
os.environ[k] = topology.defaults[v]
if args.verbose:
print(f'ENV: {k}={os.environ[k]}')

"""
check_crazy_pip3: deals with crazy pip3 that thinks installing Python packages in
local directory will break its sanity
Expand Down Expand Up @@ -274,13 +286,17 @@ def run(cli_args: typing.List[str]) -> None:
return

args = install_parse(cli_args,setup)
topology = read.system_defaults()
adjust_setup(setup,topology,args)

for script in args.script:
if script not in setup.scripts:
error_and_exit(
f'Unknown installation script {script}',
more_hints='Run "netlab install" to display the available installation scripts')

set_quiet_flags(args)
set_dry_run(args)
set_sudo_flag()
install_path = f'{get_moddir()}/install'
os.environ['PATH'] = install_path + ":" + os.environ['PATH']
Expand Down
4 changes: 2 additions & 2 deletions netsim/install/containerlab.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Install a specific version of Containerlab
CONTAINERLAB_VERSION="0.62.2"
# Install a specific version of Containerlab -- it's now set in 'netlab install' before calling this script
# CONTAINERLAB_VERSION="0.62.2"
#
set -e
REPLACE="--upgrade"
Expand Down
3 changes: 3 additions & 0 deletions netsim/install/install.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
env:
CONTAINERLAB_VERSION: providers.clab.version

scripts:
ubuntu:
description: Mandatory and nice-to have Debian/Ubuntu packages
Expand Down
1 change: 1 addition & 0 deletions netsim/providers/clab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ config: clab.yml
lab_prefix: "clab" # Containerlab default, set to "" to remove prefix
node_config_attributes: [ type, cmd, dns, env, license, ports, startup-delay, restart-policy ]
template: clab.j2
version: 0.68.0
# Preserve env to allow user to configure PATH
start: sudo -E containerlab deploy --reconfigure -t clab.yml
stop: sudo -E containerlab destroy --cleanup -t clab.yml
Expand Down