{"action":"created","comment":{"url":"https://api.github.com/repos/saltstack/salt/pulls/comments/25138014","id":25138014,"diff_hunk":"@@ -2294,83 +2374,73 @@ def update_lxc_conf(name, lxc_conf, lxc_conf_unset):\n \n     changes = {'edited': [], 'added': [], 'removed': []}\n     ret = {'changes': changes, 'result': True, 'comment': ''}\n-    lxc_conf_p = '/var/lib/lxc/{0}/config'.format(name)\n-    if not exists(name):\n-        ret['result'] = False\n-        ret['comment'] = 'Container does not exist: {0}'.format(name)\n-    elif not os.path.exists(lxc_conf_p):\n-        ret['result'] = False\n-        ret['comment'] = (\n-            'Configuration does not exist: {0}'.format(lxc_conf_p))\n-    else:\n-        with salt.utils.fopen(lxc_conf_p, 'r') as fic:\n-            filtered_lxc_conf = []\n-            for row in lxc_conf:\n-                if not row:\n-                    continue\n-                for conf in row:\n-                    try:\n-                        filtered_lxc_conf.append((conf.strip(),\n-                                                  row[conf].strip()))\n-                    except AttributeError:\n-                        filtered_lxc_conf.append((conf.strip(),\n-                                                  str(row[conf]).strip()))\n-            ret['comment'] = 'lxc.conf is up to date'\n-            lines = []\n-            orig_config = fic.read()\n-            for line in orig_config.splitlines():\n-                if line.startswith('#') or not line.strip():\n-                    lines.append([line, ''])\n-                else:\n-                    line = line.split('=')\n-                    index = line.pop(0)\n-                    val = (index.strip(), '='.join(line).strip())\n-                    if val not in lines:\n-                        lines.append(val)\n-            for k, item in filtered_lxc_conf:\n-                matched = False\n-                for idx, line in enumerate(lines[:]):\n-                    if line[0] == k:\n-                        matched = True\n-                        lines[idx] = (k, item)\n-                        if '='.join(line[1:]).strip() != item.strip():\n-                            changes['edited'].append(\n-                                ({line[0]: line[1:]}, {k: item}))\n-                            break\n-                if not matched:\n-                    if not (k, item) in lines:\n-                        lines.append((k, item))\n-                    changes['added'].append({k: item})\n-            dest_lxc_conf = []\n-            # filter unset\n-            if lxc_conf_unset:\n-                for line in lines:\n-                    for opt in lxc_conf_unset:\n-                        if (\n-                            not line[0].startswith(opt)\n-                            and line not in dest_lxc_conf\n-                        ):\n-                            dest_lxc_conf.append(line)\n-                        else:\n-                            changes['removed'].append(opt)\n+\n+    # do not use salt.utils.fopen !\n+    with open(lxc_conf_p, 'r') as fic:","path":"salt/modules/lxc.py","position":513,"original_position":518,"commit_id":"66b061dab292052a2e53e34bd0e49743fc87c447","original_commit_id":"3938f370dbee672d8e28a1a4fe2bacd5e7076866","user":{"login":"s0undt3ch","id":300048,"avatar_url":"https://avatars.githubusercontent.com/u/300048?v=3","gravatar_id":"","url":"https://api.github.com/users/s0undt3ch","html_url":"https://github.com/s0undt3ch","followers_url":"https://api.github.com/users/s0undt3ch/followers","following_url":"https://api.github.com/users/s0undt3ch/following{/other_user}","gists_url":"https://api.github.com/users/s0undt3ch/gists{/gist_id}","starred_url":"https://api.github.com/users/s0undt3ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s0undt3ch/subscriptions","organizations_url":"https://api.github.com/users/s0undt3ch/orgs","repos_url":"https://api.github.com/users/s0undt3ch/repos","events_url":"https://api.github.com/users/s0undt3ch/events{/privacy}","received_events_url":"https://api.github.com/users/s0undt3ch/received_events","type":"User","site_admin":false},"body":"Well that's worth some investigation. Files shouldn't simply be wiped by using fopen...","created_at":"2015-02-22T23:00:21Z","updated_at":"2015-02-22T23:00:21Z","html_url":"https://github.com/saltstack/salt/pull/20916#discussion_r25138014","pull_request_url":"https://api.github.com/repos/saltstack/salt/pulls/20916","_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments/25138014"},"html":{"href":"https://github.com/saltstack/salt/pull/20916#discussion_r25138014"},"pull_request":{"href":"https://api.github.com/repos/saltstack/salt/pulls/20916"}}},"pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/20916","id":29772499,"html_url":"https://github.com/saltstack/salt/pull/20916","diff_url":"https://github.com/saltstack/salt/pull/20916.diff","patch_url":"https://github.com/saltstack/salt/pull/20916.patch","issue_url":"https://api.github.com/repos/saltstack/salt/issues/20916","number":20916,"state":"open","locked":false,"title":"LXC: Major fix & enhancements","user":{"login":"kiorky","id":90111,"avatar_url":"https://avatars.githubusercontent.com/u/90111?v=3","gravatar_id":"","url":"https://api.github.com/users/kiorky","html_url":"https://github.com/kiorky","followers_url":"https://api.github.com/users/kiorky/followers","following_url":"https://api.github.com/users/kiorky/following{/other_user}","gists_url":"https://api.github.com/users/kiorky/gists{/gist_id}","starred_url":"https://api.github.com/users/kiorky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiorky/subscriptions","organizations_url":"https://api.github.com/users/kiorky/orgs","repos_url":"https://api.github.com/users/kiorky/repos","events_url":"https://api.github.com/users/kiorky/events{/privacy}","received_events_url":"https://api.github.com/users/kiorky/received_events","type":"User","site_admin":false},"body":"This reconciles back makinacorpus's LXC fork into upstream.\r\n\r\nThis fixes various breakages introduced by the refactor which are\r\nso numerous that we cant enumerate them all :).\r\n\r\nThis also introduce some new features like network reconfiguration\r\nand container reboot.","created_at":"2015-02-22T16:20:33Z","updated_at":"2015-02-22T23:00:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"46f0033c88ebe324490f2b99fd760d44badb594a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/saltstack/salt/pulls/20916/commits","review_comments_url":"https://api.github.com/repos/saltstack/salt/pulls/20916/comments","review_comment_url":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/20916/comments","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/66b061dab292052a2e53e34bd0e49743fc87c447","head":{"label":"makinacorpus:lxc","ref":"lxc","sha":"66b061dab292052a2e53e34bd0e49743fc87c447","user":{"login":"makinacorpus","id":546696,"avatar_url":"https://avatars.githubusercontent.com/u/546696?v=3","gravatar_id":"","url":"https://api.github.com/users/makinacorpus","html_url":"https://github.com/makinacorpus","followers_url":"https://api.github.com/users/makinacorpus/followers","following_url":"https://api.github.com/users/makinacorpus/following{/other_user}","gists_url":"https://api.github.com/users/makinacorpus/gists{/gist_id}","starred_url":"https://api.github.com/users/makinacorpus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makinacorpus/subscriptions","organizations_url":"https://api.github.com/users/makinacorpus/orgs","repos_url":"https://api.github.com/users/makinacorpus/repos","events_url":"https://api.github.com/users/makinacorpus/events{/privacy}","received_events_url":"https://api.github.com/users/makinacorpus/received_events","type":"Organization","site_admin":false},"repo":{"id":11388017,"name":"salt","full_name":"makinacorpus/salt","owner":{"login":"makinacorpus","id":546696,"avatar_url":"https://avatars.githubusercontent.com/u/546696?v=3","gravatar_id":"","url":"https://api.github.com/users/makinacorpus","html_url":"https://github.com/makinacorpus","followers_url":"https://api.github.com/users/makinacorpus/followers","following_url":"https://api.github.com/users/makinacorpus/following{/other_user}","gists_url":"https://api.github.com/users/makinacorpus/gists{/gist_id}","starred_url":"https://api.github.com/users/makinacorpus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makinacorpus/subscriptions","organizations_url":"https://api.github.com/users/makinacorpus/orgs","repos_url":"https://api.github.com/users/makinacorpus/repos","events_url":"https://api.github.com/users/makinacorpus/events{/privacy}","received_events_url":"https://api.github.com/users/makinacorpus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/makinacorpus/salt","description":"Central system and configuration manager ","fork":true,"url":"https://api.github.com/repos/makinacorpus/salt","forks_url":"https://api.github.com/repos/makinacorpus/salt/forks","keys_url":"https://api.github.com/repos/makinacorpus/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/makinacorpus/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/makinacorpus/salt/teams","hooks_url":"https://api.github.com/repos/makinacorpus/salt/hooks","issue_events_url":"https://api.github.com/repos/makinacorpus/salt/issues/events{/number}","events_url":"https://api.github.com/repos/makinacorpus/salt/events","assignees_url":"https://api.github.com/repos/makinacorpus/salt/assignees{/user}","branches_url":"https://api.github.com/repos/makinacorpus/salt/branches{/branch}","tags_url":"https://api.github.com/repos/makinacorpus/salt/tags","blobs_url":"https://api.github.com/repos/makinacorpus/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/makinacorpus/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/makinacorpus/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/makinacorpus/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/makinacorpus/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/makinacorpus/salt/languages","stargazers_url":"https://api.github.com/repos/makinacorpus/salt/stargazers","contributors_url":"https://api.github.com/repos/makinacorpus/salt/contributors","subscribers_url":"https://api.github.com/repos/makinacorpus/salt/subscribers","subscription_url":"https://api.github.com/repos/makinacorpus/salt/subscription","commits_url":"https://api.github.com/repos/makinacorpus/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/makinacorpus/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/makinacorpus/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/makinacorpus/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/makinacorpus/salt/contents/{+path}","compare_url":"https://api.github.com/repos/makinacorpus/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/makinacorpus/salt/merges","archive_url":"https://api.github.com/repos/makinacorpus/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/makinacorpus/salt/downloads","issues_url":"https://api.github.com/repos/makinacorpus/salt/issues{/number}","pulls_url":"https://api.github.com/repos/makinacorpus/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/makinacorpus/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/makinacorpus/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/makinacorpus/salt/labels{/name}","releases_url":"https://api.github.com/repos/makinacorpus/salt/releases{/id}","created_at":"2013-07-13T12:54:25Z","updated_at":"2015-02-22T22:49:50Z","pushed_at":"2015-02-22T22:49:49Z","git_url":"git://github.com/makinacorpus/salt.git","ssh_url":"git@github.com:makinacorpus/salt.git","clone_url":"https://github.com/makinacorpus/salt.git","svn_url":"https://github.com/makinacorpus/salt","homepage":"saltstack.org","size":85962,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":2,"default_branch":"develop"}},"base":{"label":"saltstack:develop","ref":"develop","sha":"c85d38c4932dd562c29c9a545cfa1bc5096e7627","user":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"repo":{"id":1390248,"name":"salt","full_name":"saltstack/salt","owner":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/saltstack/salt","description":"Infrastructure automation and management system","fork":false,"url":"https://api.github.com/repos/saltstack/salt","forks_url":"https://api.github.com/repos/saltstack/salt/forks","keys_url":"https://api.github.com/repos/saltstack/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saltstack/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saltstack/salt/teams","hooks_url":"https://api.github.com/repos/saltstack/salt/hooks","issue_events_url":"https://api.github.com/repos/saltstack/salt/issues/events{/number}","events_url":"https://api.github.com/repos/saltstack/salt/events","assignees_url":"https://api.github.com/repos/saltstack/salt/assignees{/user}","branches_url":"https://api.github.com/repos/saltstack/salt/branches{/branch}","tags_url":"https://api.github.com/repos/saltstack/salt/tags","blobs_url":"https://api.github.com/repos/saltstack/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saltstack/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saltstack/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/saltstack/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/saltstack/salt/languages","stargazers_url":"https://api.github.com/repos/saltstack/salt/stargazers","contributors_url":"https://api.github.com/repos/saltstack/salt/contributors","subscribers_url":"https://api.github.com/repos/saltstack/salt/subscribers","subscription_url":"https://api.github.com/repos/saltstack/salt/subscription","commits_url":"https://api.github.com/repos/saltstack/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/saltstack/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/saltstack/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/saltstack/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/saltstack/salt/contents/{+path}","compare_url":"https://api.github.com/repos/saltstack/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saltstack/salt/merges","archive_url":"https://api.github.com/repos/saltstack/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saltstack/salt/downloads","issues_url":"https://api.github.com/repos/saltstack/salt/issues{/number}","pulls_url":"https://api.github.com/repos/saltstack/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/saltstack/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/saltstack/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saltstack/salt/labels{/name}","releases_url":"https://api.github.com/repos/saltstack/salt/releases{/id}","created_at":"2011-02-20T20:16:56Z","updated_at":"2015-02-22T20:01:44Z","pushed_at":"2015-02-22T20:01:44Z","git_url":"git://github.com/saltstack/salt.git","ssh_url":"git@github.com:saltstack/salt.git","clone_url":"https://github.com/saltstack/salt.git","svn_url":"https://github.com/saltstack/salt","homepage":"saltstack.com","size":183129,"stargazers_count":4732,"watchers_count":4732,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1948,"mirror_url":null,"open_issues_count":2282,"forks":1948,"open_issues":2282,"watchers":4732,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/20916"},"html":{"href":"https://github.com/saltstack/salt/pull/20916"},"issue":{"href":"https://api.github.com/repos/saltstack/salt/issues/20916"},"comments":{"href":"https://api.github.com/repos/saltstack/salt/issues/20916/comments"},"review_comments":{"href":"https://api.github.com/repos/saltstack/salt/pulls/20916/comments"},"review_comment":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/saltstack/salt/pulls/20916/commits"},"statuses":{"href":"https://api.github.com/repos/saltstack/salt/statuses/66b061dab292052a2e53e34bd0e49743fc87c447"}}}}