LXC gateway provisioned only when IP is provided

The directive `lxc.network.ipv4.gateway = auto` should not be added to an LXC configuration file when no IP address is specified. It results in the following error: 

```
lxc-start 1441227080.264 ERROR    lxc_conf - conf.c:setup_netdev:2724 - Cannot add ipv4 gateway for eth0 when not assigning an address
```
This commit is contained in:
Marc Vieira-Cardinal 2015-09-02 21:51:56 -04:00
parent a563af29d3
commit 36d5a62262

View file

@ -840,7 +840,8 @@ def _network_conf(conf_tuples=None, **kwargs):
# (lxc.network.ipv4.gateway: auto)
if (
distutils.version.LooseVersion(version()) <= '1.0.7' and
True not in ['lxc.network.ipv4.gateway' in a for a in ret]
True not in ['lxc.network.ipv4.gateway' in a for a in ret] and
True in ['lxc.network.ipv4' in a for a in ret]
):
ret.append({'lxc.network.ipv4.gateway': 'auto'})
return ret