{"action":"closed","issue":{"url":"https://api.github.com/repos/lxc/lxc/issues/385","labels_url":"https://api.github.com/repos/lxc/lxc/issues/385/labels{/name}","comments_url":"https://api.github.com/repos/lxc/lxc/issues/385/comments","events_url":"https://api.github.com/repos/lxc/lxc/issues/385/events","html_url":"https://github.com/lxc/lxc/issues/385","id":52742281,"number":385,"title":"Setting gateway and ipv4 (incl. netmask) via python-lxc","user":{"login":"run2fail","id":9140871,"avatar_url":"https://avatars.githubusercontent.com/u/9140871?v=3","gravatar_id":"","url":"https://api.github.com/users/run2fail","html_url":"https://github.com/run2fail","followers_url":"https://api.github.com/users/run2fail/followers","following_url":"https://api.github.com/users/run2fail/following{/other_user}","gists_url":"https://api.github.com/users/run2fail/gists{/gist_id}","starred_url":"https://api.github.com/users/run2fail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/run2fail/subscriptions","organizations_url":"https://api.github.com/users/run2fail/orgs","repos_url":"https://api.github.com/users/run2fail/repos","events_url":"https://api.github.com/users/run2fail/events{/privacy}","received_events_url":"https://api.github.com/users/run2fail/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lxc/lxc/labels/Incomplete","name":"Incomplete","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-12-23T13:58:20Z","updated_at":"2015-01-26T08:26:08Z","closed_at":"2015-01-26T08:26:08Z","body":"Hi,\r\n\r\nI noticed the following with lxc version `1.0.6-0ubuntu0.1` on Ubuntu trusty. I did not try newer versions as there are no matching changelog entries for the following issue.\r\n\r\nThe container's `config` contains:\r\n\r\n    lxc.network.type = veth\r\n    lxc.network.flags = up\r\n    lxc.network.link = my_bridge\r\n    lxc.network.ipv4.gateway = 10.1.1.1\r\n    lxc.network.ipv4 = 10.1.1.2/24\r\n\r\nThen I create an `lxc.Container` instance:\r\n\r\n    >>> import lxc\r\n    >>> container = lxc.Container('container')\r\n    >>> container.get_config_item('lxc.network.0.ipv4')\r\n    ['10.1.1.2']\r\n    >>> container.get_config_item('lxc.network.0.ipv4.gateway')\r\n    ''\r\n    >>> container.get_config_item('lxc.network.0.ipv4_gateway')\r\n    '10.1.1.1'\r\n    >>> container.save_config()\r\n\r\nThe `config` is not changed - as expected. The `netmask` in CIDR notation is nevertheless not returned by `get_config_item()`. The gateway attribute seems to be accessed differently but that's not a problem.\r\n\r\nNow I try to set the IP address and the gateway:\r\n\r\n    >>> container.set_config_item('lxc.network.0.ipv4_gateway', '10.1.1.1')\r\n    False\r\n    >>> container.set_config_item('lxc.network.0.ipv4.gateway', '10.1.1.1')\r\n    False\r\n    >>> container.network[0].ipv4_gateway = '10.1.1.1'\r\n    \r\n    >>> container.set_config_item('lxc.network.0.ipv4', '10.1.1.2/24')\r\n    False\r\n    >>> container.network[0].ipv4 = '10.1.1.2/24'\r\n    \r\n    >>> container.save_config()\r\n\r\nNow the container's `config` contains:\r\n\r\n    lxc.network.type = veth\r\n    lxc.network.flags = up\r\n    lxc.network.link = my_bridge\r\n    lxc.network.ipv4 = 10.1.1.2/8\r\n    lxc.network.ipv4 = 10.1.1.1/8\r\n    lxc.network.ipv4 = 10.1.1.1/8\r\n    lxc.network.ipv4 = 10.1.1.1/8\r\n    lxc.network.ipv4 = 10.1.1.1/8\r\n\r\nResult:\r\n* The gateway is missing\r\n* The gateway's IP address was assigned to the container's interface\r\n* The netmask of `lxc.network.ipv4` is wrong\r\n* There are duplicated entries (as the `ipv4` seems to be a list in python)\r\n* `set_config_item()` returned `False` but did something nevertheless\r\n\r\nMaybe I am using the Python module in a wrong way but currently I am out of ideas.\r\n\r\nKind regards,\r\n\r\nBB"}}