Skip to content
  • Lubomir Rintel's avatar
    nmcli: streamline connection addition · c5324ed2
    Lubomir Rintel authored
    This is a huge refactoring in attempt to 1.) reduce the horrible redundancy in
    the connection addition path and 2.) reduce confusion between various sources
    of property value (command line, properties, interactive mode).
    
    * The conversions from the strings was done all over the place:
      settings.c already does for all sensible properties.
      The rest is removed.
    
    * The validations are done randomly and redundantly:
      server does some validation, and per-property client validations
      useful for interactive mode are done in settings.c
      The rest is removed.
    
    * The information about defaults and required options was redundantly
      scattered in per-type completion functions and interactive mode
      questionnaries. This is now driven by the option_info[] table.
    
    In general, we do our best to just map the command line options to
    properties and allow mixing them. For the rest there's the
    check_and_set() callbacks (basically to keep compatibility with previous
    nmcli versions). This this is now all possible:
    
    $ nmcli c add type ethernet ifname '*'
      This always worked
    
    $ nmcli c add type bond-slave save no -- connection.autoconnect no
      The "save" and "--" still work
    
    $ nmcli c add connection.type ethernet ifname eth0
      Properties can now be used
    
    $ nmcli c add type ethernet ip4 1.2.3.4 mac 80:86:66:77:88:99 con-name whatever
      There's no implementation mandated order of the properties (the type
      still must be known to determine which properties make sense)
    
    $ nmcli --ask c add type ethernet ip4 1.2.3.4 mac 80:86:66:77:88:99 con-name whatever
      The interactive mode asks only for properties that weren't specified
      on command line
    c5324ed2