← Back to team overview

curtin-dev team mailing list archive

Re: [Merge] ~lamoura/curtin:disable-networking-config into curtin:master

 


Diff comments:

> diff --git a/curtin/commands/apply_net.py b/curtin/commands/apply_net.py
> index ddc5056..5f1bc23 100644
> --- a/curtin/commands/apply_net.py
> +++ b/curtin/commands/apply_net.py
> @@ -99,6 +99,11 @@ def apply_net(target, network_state=None, network_config=None):
>          else:
>              ns = net.parse_net_config_data(netcfg.get('network', {}))
>  
> +            # We admit a None network state if we have a disabled config, since
> +            # this config may not have a version associated with it
> +            if ns is None and netcfg.get('config') == 'disabled':
> +                return

I just figured out another problem related to the parse_net_config_data:

This function is being called by parse_net_config, which is called inside vmtest/__init__.py +994. Since one of test have a version and the other not, what happens is that the network state for one is defined as:

Network state: {'interfaces': {}, 'routes': [], 'dns': {'nameservers': [], 'search': []}}

And without the version key:
Network state: None

To solve that, i have mode the config check logic to the parse_net_config_data function. Now both tests will behave exactly the same regarding the network state and we also guarantee that no network_state will be generated by a network disabled config.

> +
>      if not passthrough:
>          LOG.info('Rendering network configuration in target')
>          net.render_network_state(target=target, network_state=ns)
> diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
> index 4afe00c..ea835c1 100644
> --- a/curtin/commands/curthooks.py
> +++ b/curtin/commands/curthooks.py
> @@ -1152,7 +1152,10 @@ def detect_required_packages(cfg, osfamily=DISTROS.debian):
>  
>          # skip missing or invalid config items, configs may
>          # only have network or storage, not always both
> -        if not isinstance(cfg.get(cfg_type), dict):
> +        # we are also skipping if the network config is marked as disabled

Done

> +        cfg_type_value = cfg.get(cfg_type)
> +        if (not isinstance(cfg_type_value, dict) or
> +                cfg_type_value.get('config') == 'disabled'):
>              continue
>  
>          cfg_version = cfg[cfg_type].get('version')
> diff --git a/curtin/commands/net_meta.py b/curtin/commands/net_meta.py
> index fdb909e..fe43e66 100644
> --- a/curtin/commands/net_meta.py
> +++ b/curtin/commands/net_meta.py
> @@ -75,6 +75,9 @@ def net_meta(args):
>  
>      # if network-config hook exists in target,
>      # we do not run the builtin
> +    if args.mode == "disabled":

Done

> +        sys.exit(0)
> +
>      if util.run_hook_if_exists(args.target, 'network-config'):
>          sys.exit(0)
>  


-- 
https://code.launchpad.net/~lamoura/curtin/+git/curtin/+merge/383785
Your team curtin developers is subscribed to branch curtin:master.


References