{"action":"created","comment":{"url":"https://api.github.com/repos/pulp/pulp_packaging/pulls/comments/26702669","id":26702669,"diff_hunk":"@@ -0,0 +1,153 @@\n+\"\"\"\n+This module does a few things:\n+\n+1) Verify that all Bugzilla bugs which point to a Redmine issues also have\n+Redmine issues pointing back to Bugzilla bugs. E-mail a list of people if\n+only a uni-directional relationship exists so they can be fixed manually. The\n+EMAIL_RECEIVERS constant specifies the recipient list.\n+\n+2) For all Redmine issues that track Bugzilla bugs, ensure that the\n+Bugzilla external tracker description, status, and priority all mirror the\n+Redmine issue state.\n+\n+Requirements:\n+The Redmine and Bugzilla credentials are expected from to be read from a\n+file in ini format. See the example below. The location of this file is set\n+by the REDMINE_BUGZILLA_CONF environment variable.\n+\n+<SNIP>\n+[bugzilla]\n+username = XXXX\n+password = XXXX\n+\n+[redmine]\n+key = XXXX\n+</SNIP>\n+\"\"\"\n+\n+\n+import ConfigParser\n+import os\n+\n+from bugzilla.rhbugzilla import RHBugzilla\n+from redmine import Redmine\n+import urllib3.contrib.pyopenssl\n+\n+# Here due to InsecurePlatformWarning\n+# https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning\n+urllib3.contrib.pyopenssl.inject_into_urllib3()\n+\n+\n+BUGZILLA_URL = 'https://bugzilla.redhat.com'\n+REDMINE_URL = 'https://pulp.plan.io'\n+\n+\n+EMAIL_RECEIVERS = ['bmbouter@gmail.com']\n+FROM_ADDRESS = 'bbouters@redhat.com'\n+EMAIL_SUBJECT = 'Pulp upstream/downstream Bug Report'\n+\n+\n+def get_bugzilla_connection(user, password):\n+    \"\"\"\n+    Return the Bugzilla connection.\n+\n+    :param user: The username to connect with\n+    :type user: basestring\n+    :param password: The password to connect with\n+    :type password: basestring\n+\n+    :return: An instantiated Bugzilla connection object.\n+    \"\"\"\n+    return RHBugzilla(url='%s/xmlrpc.cgi' % BUGZILLA_URL, user=user, password=password)\n+\n+\n+def get_redmine_connection(key):\n+    \"\"\"\n+    Return the Redmine connection.\n+\n+    :param key: The api key to connect with\n+    :type key: basestring\n+\n+    :return: An instantiated Redmine connection object.\n+    \"\"\"\n+    return Redmine(REDMINE_URL, key=key)\n+\n+\n+def main():\n+    config = ConfigParser.ConfigParser()\n+    config.read(os.environ['REDMINE_BUGZILLA_CONF'])\n+\n+    username = config.get('bugzilla', 'username')\n+    password = config.get('bugzilla', 'password')\n+    key = config.get('redmine', 'key')\n+\n+    redmine = get_redmine_connection(key)\n+    BZ = get_bugzilla_connection(username, password)\n+\n+    redmine_issues = [issue for issue in redmine.issue.filter(query_id=24)]\n+\n+    non_closed_bug_with_ext_tracker = BUGZILLA_URL + '/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=POST&bug_status=MODIFIED&bug_status=ON_DEV&bug_status=ON_QA&bug_status=VERIFIED&bug_status=RELEASE_PENDING&columnlist=priority%2Cbug_severity%2Cbug_status%2Cshort_desc%2Cchangeddate%2Ccomponent%2Ctarget_release%2Cassigned_to%2Creporter&f1=external_bugzilla.url&list_id=3309842&o1=substring&query_format=advanced&v1=pulp.plan.io'\n+    bugzilla_bugs = BZ.query(RHBugzilla.url_to_query(non_closed_bug_with_ext_tracker))\n+\n+    links_issues_record = ''\n+    ext_bug_record = ''\n+\n+    for issue in redmine_issues:\n+        for custom_field in issue.custom_fields.resources:\n+            if custom_field['name'] == 'Bugzilla':\n+                bug = BZ.getbug(int(custom_field['value']))\n+                links_back = False\n+                for external_bug in bug.external_bugs:\n+                    if external_bug['type']['description'] == 'Pulp Redmine' and external_bug['ext_bz_bug_id'] == str(issue.id):\n+                        ext_params = {}\n+                        if external_bug['ext_description'] != issue.subject:\n+                            ext_params['ext_description'] = issue.subject\n+                        if external_bug['ext_status'] != issue.status.name:\n+                            ext_params['ext_status'] = issue.status.name\n+                        if external_bug['ext_priority'] != issue.priority.name:\n+                            ext_params['ext_priority'] = issue.priority.name\n+                        if len(ext_params.keys()) > 0:\n+                            ext_bug_record += 'Bugzilla bug %s updated from upstream bug %s with %s\\n' % (bug.id, issue.id, ext_params)\n+                            ext_params['ids'] = external_bug['id']\n+                            BZ.update_external_tracker(**ext_params)\n+\n+                        # Remove the bug list gotten via search so we don't examine it again when bugzilla_bugs are iterated through\n+                        bug_in_search_index_to_remove = -1\n+                        for i, bug_in_search in enumerate(bugzilla_bugs):\n+                            if bug_in_search.id == bug.id:\n+                                bug_in_search_index_to_remove = i\n+                                break\n+                        if bug_in_search_index_to_remove != -1:","path":"ci/redmine_bugzilla.py","position":120,"original_position":120,"commit_id":"2a63eb2a360d3a0086e69f02976887e3487db3b3","original_commit_id":"2a63eb2a360d3a0086e69f02976887e3487db3b3","user":{"login":"rbarlow","id":354506,"avatar_url":"https://avatars.githubusercontent.com/u/354506?v=3","gravatar_id":"","url":"https://api.github.com/users/rbarlow","html_url":"https://github.com/rbarlow","followers_url":"https://api.github.com/users/rbarlow/followers","following_url":"https://api.github.com/users/rbarlow/following{/other_user}","gists_url":"https://api.github.com/users/rbarlow/gists{/gist_id}","starred_url":"https://api.github.com/users/rbarlow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbarlow/subscriptions","organizations_url":"https://api.github.com/users/rbarlow/orgs","repos_url":"https://api.github.com/users/rbarlow/repos","events_url":"https://api.github.com/users/rbarlow/events{/privacy}","received_events_url":"https://api.github.com/users/rbarlow/received_events","type":"User","site_admin":false},"body":"If you used None here, it would read more naturally.","created_at":"2015-03-18T20:17:49Z","updated_at":"2015-03-18T20:17:49Z","html_url":"https://github.com/pulp/pulp_packaging/pull/48#discussion_r26702669","pull_request_url":"https://api.github.com/repos/pulp/pulp_packaging/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp_packaging/pulls/comments/26702669"},"html":{"href":"https://github.com/pulp/pulp_packaging/pull/48#discussion_r26702669"},"pull_request":{"href":"https://api.github.com/repos/pulp/pulp_packaging/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/pulp/pulp_packaging/pulls/48","id":31277480,"html_url":"https://github.com/pulp/pulp_packaging/pull/48","diff_url":"https://github.com/pulp/pulp_packaging/pull/48.diff","patch_url":"https://github.com/pulp/pulp_packaging/pull/48.patch","issue_url":"https://api.github.com/repos/pulp/pulp_packaging/issues/48","number":48,"state":"open","locked":false,"title":"141 - Validate and keep up-to-date redmine and bugzilla data","user":{"login":"bmbouter","id":180319,"avatar_url":"https://avatars.githubusercontent.com/u/180319?v=3","gravatar_id":"","url":"https://api.github.com/users/bmbouter","html_url":"https://github.com/bmbouter","followers_url":"https://api.github.com/users/bmbouter/followers","following_url":"https://api.github.com/users/bmbouter/following{/other_user}","gists_url":"https://api.github.com/users/bmbouter/gists{/gist_id}","starred_url":"https://api.github.com/users/bmbouter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmbouter/subscriptions","organizations_url":"https://api.github.com/users/bmbouter/orgs","repos_url":"https://api.github.com/users/bmbouter/repos","events_url":"https://api.github.com/users/bmbouter/events{/privacy}","received_events_url":"https://api.github.com/users/bmbouter/received_events","type":"User","site_admin":false},"body":"Adds a Jenkins job definition which periodically runs a python\r\nscript. The Python script validates that upstream and downstream\r\nbugs have bi-directional relationships. The script also replicates\r\nupstream issue status to the downstream external tracker info. A\r\nreport of issues identified and changes made are sent to a list\r\nof admins.","created_at":"2015-03-16T19:46:09Z","updated_at":"2015-03-18T20:17:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"42fe3b804902a8d58ff0834fae5835244e61ae96","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pulp/pulp_packaging/pulls/48/commits","review_comments_url":"https://api.github.com/repos/pulp/pulp_packaging/pulls/48/comments","review_comment_url":"https://api.github.com/repos/pulp/pulp_packaging/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pulp/pulp_packaging/issues/48/comments","statuses_url":"https://api.github.com/repos/pulp/pulp_packaging/statuses/2a63eb2a360d3a0086e69f02976887e3487db3b3","head":{"label":"bmbouter:141-add-bug-automation","ref":"141-add-bug-automation","sha":"2a63eb2a360d3a0086e69f02976887e3487db3b3","user":{"login":"bmbouter","id":180319,"avatar_url":"https://avatars.githubusercontent.com/u/180319?v=3","gravatar_id":"","url":"https://api.github.com/users/bmbouter","html_url":"https://github.com/bmbouter","followers_url":"https://api.github.com/users/bmbouter/followers","following_url":"https://api.github.com/users/bmbouter/following{/other_user}","gists_url":"https://api.github.com/users/bmbouter/gists{/gist_id}","starred_url":"https://api.github.com/users/bmbouter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmbouter/subscriptions","organizations_url":"https://api.github.com/users/bmbouter/orgs","repos_url":"https://api.github.com/users/bmbouter/repos","events_url":"https://api.github.com/users/bmbouter/events{/privacy}","received_events_url":"https://api.github.com/users/bmbouter/received_events","type":"User","site_admin":false},"repo":{"id":32084280,"name":"pulp_packaging","full_name":"bmbouter/pulp_packaging","owner":{"login":"bmbouter","id":180319,"avatar_url":"https://avatars.githubusercontent.com/u/180319?v=3","gravatar_id":"","url":"https://api.github.com/users/bmbouter","html_url":"https://github.com/bmbouter","followers_url":"https://api.github.com/users/bmbouter/followers","following_url":"https://api.github.com/users/bmbouter/following{/other_user}","gists_url":"https://api.github.com/users/bmbouter/gists{/gist_id}","starred_url":"https://api.github.com/users/bmbouter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmbouter/subscriptions","organizations_url":"https://api.github.com/users/bmbouter/orgs","repos_url":"https://api.github.com/users/bmbouter/repos","events_url":"https://api.github.com/users/bmbouter/events{/privacy}","received_events_url":"https://api.github.com/users/bmbouter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bmbouter/pulp_packaging","description":"","fork":true,"url":"https://api.github.com/repos/bmbouter/pulp_packaging","forks_url":"https://api.github.com/repos/bmbouter/pulp_packaging/forks","keys_url":"https://api.github.com/repos/bmbouter/pulp_packaging/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bmbouter/pulp_packaging/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bmbouter/pulp_packaging/teams","hooks_url":"https://api.github.com/repos/bmbouter/pulp_packaging/hooks","issue_events_url":"https://api.github.com/repos/bmbouter/pulp_packaging/issues/events{/number}","events_url":"https://api.github.com/repos/bmbouter/pulp_packaging/events","assignees_url":"https://api.github.com/repos/bmbouter/pulp_packaging/assignees{/user}","branches_url":"https://api.github.com/repos/bmbouter/pulp_packaging/branches{/branch}","tags_url":"https://api.github.com/repos/bmbouter/pulp_packaging/tags","blobs_url":"https://api.github.com/repos/bmbouter/pulp_packaging/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bmbouter/pulp_packaging/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bmbouter/pulp_packaging/git/refs{/sha}","trees_url":"https://api.github.com/repos/bmbouter/pulp_packaging/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bmbouter/pulp_packaging/statuses/{sha}","languages_url":"https://api.github.com/repos/bmbouter/pulp_packaging/languages","stargazers_url":"https://api.github.com/repos/bmbouter/pulp_packaging/stargazers","contributors_url":"https://api.github.com/repos/bmbouter/pulp_packaging/contributors","subscribers_url":"https://api.github.com/repos/bmbouter/pulp_packaging/subscribers","subscription_url":"https://api.github.com/repos/bmbouter/pulp_packaging/subscription","commits_url":"https://api.github.com/repos/bmbouter/pulp_packaging/commits{/sha}","git_commits_url":"https://api.github.com/repos/bmbouter/pulp_packaging/git/commits{/sha}","comments_url":"https://api.github.com/repos/bmbouter/pulp_packaging/comments{/number}","issue_comment_url":"https://api.github.com/repos/bmbouter/pulp_packaging/issues/comments{/number}","contents_url":"https://api.github.com/repos/bmbouter/pulp_packaging/contents/{+path}","compare_url":"https://api.github.com/repos/bmbouter/pulp_packaging/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bmbouter/pulp_packaging/merges","archive_url":"https://api.github.com/repos/bmbouter/pulp_packaging/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bmbouter/pulp_packaging/downloads","issues_url":"https://api.github.com/repos/bmbouter/pulp_packaging/issues{/number}","pulls_url":"https://api.github.com/repos/bmbouter/pulp_packaging/pulls{/number}","milestones_url":"https://api.github.com/repos/bmbouter/pulp_packaging/milestones{/number}","notifications_url":"https://api.github.com/repos/bmbouter/pulp_packaging/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bmbouter/pulp_packaging/labels{/name}","releases_url":"https://api.github.com/repos/bmbouter/pulp_packaging/releases{/id}","created_at":"2015-03-12T15:22:09Z","updated_at":"2015-03-12T15:22:10Z","pushed_at":"2015-03-16T19:29:48Z","git_url":"git://github.com/bmbouter/pulp_packaging.git","ssh_url":"git@github.com:bmbouter/pulp_packaging.git","clone_url":"https://github.com/bmbouter/pulp_packaging.git","svn_url":"https://github.com/bmbouter/pulp_packaging","homepage":null,"size":783,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pulp:master","ref":"master","sha":"e021ea9a619c60409450da9cf6161890eb524895","user":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"repo":{"id":23434004,"name":"pulp_packaging","full_name":"pulp/pulp_packaging","owner":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pulp/pulp_packaging","description":"","fork":false,"url":"https://api.github.com/repos/pulp/pulp_packaging","forks_url":"https://api.github.com/repos/pulp/pulp_packaging/forks","keys_url":"https://api.github.com/repos/pulp/pulp_packaging/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pulp/pulp_packaging/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pulp/pulp_packaging/teams","hooks_url":"https://api.github.com/repos/pulp/pulp_packaging/hooks","issue_events_url":"https://api.github.com/repos/pulp/pulp_packaging/issues/events{/number}","events_url":"https://api.github.com/repos/pulp/pulp_packaging/events","assignees_url":"https://api.github.com/repos/pulp/pulp_packaging/assignees{/user}","branches_url":"https://api.github.com/repos/pulp/pulp_packaging/branches{/branch}","tags_url":"https://api.github.com/repos/pulp/pulp_packaging/tags","blobs_url":"https://api.github.com/repos/pulp/pulp_packaging/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pulp/pulp_packaging/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pulp/pulp_packaging/git/refs{/sha}","trees_url":"https://api.github.com/repos/pulp/pulp_packaging/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pulp/pulp_packaging/statuses/{sha}","languages_url":"https://api.github.com/repos/pulp/pulp_packaging/languages","stargazers_url":"https://api.github.com/repos/pulp/pulp_packaging/stargazers","contributors_url":"https://api.github.com/repos/pulp/pulp_packaging/contributors","subscribers_url":"https://api.github.com/repos/pulp/pulp_packaging/subscribers","subscription_url":"https://api.github.com/repos/pulp/pulp_packaging/subscription","commits_url":"https://api.github.com/repos/pulp/pulp_packaging/commits{/sha}","git_commits_url":"https://api.github.com/repos/pulp/pulp_packaging/git/commits{/sha}","comments_url":"https://api.github.com/repos/pulp/pulp_packaging/comments{/number}","issue_comment_url":"https://api.github.com/repos/pulp/pulp_packaging/issues/comments{/number}","contents_url":"https://api.github.com/repos/pulp/pulp_packaging/contents/{+path}","compare_url":"https://api.github.com/repos/pulp/pulp_packaging/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pulp/pulp_packaging/merges","archive_url":"https://api.github.com/repos/pulp/pulp_packaging/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pulp/pulp_packaging/downloads","issues_url":"https://api.github.com/repos/pulp/pulp_packaging/issues{/number}","pulls_url":"https://api.github.com/repos/pulp/pulp_packaging/pulls{/number}","milestones_url":"https://api.github.com/repos/pulp/pulp_packaging/milestones{/number}","notifications_url":"https://api.github.com/repos/pulp/pulp_packaging/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pulp/pulp_packaging/labels{/name}","releases_url":"https://api.github.com/repos/pulp/pulp_packaging/releases{/id}","created_at":"2014-08-28T15:54:53Z","updated_at":"2015-03-13T16:12:34Z","pushed_at":"2015-03-13T16:12:34Z","git_url":"git://github.com/pulp/pulp_packaging.git","ssh_url":"git@github.com:pulp/pulp_packaging.git","clone_url":"https://github.com/pulp/pulp_packaging.git","svn_url":"https://github.com/pulp/pulp_packaging","homepage":null,"size":783,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":1,"forks":14,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp_packaging/pulls/48"},"html":{"href":"https://github.com/pulp/pulp_packaging/pull/48"},"issue":{"href":"https://api.github.com/repos/pulp/pulp_packaging/issues/48"},"comments":{"href":"https://api.github.com/repos/pulp/pulp_packaging/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/pulp/pulp_packaging/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/pulp/pulp_packaging/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pulp/pulp_packaging/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/pulp/pulp_packaging/statuses/2a63eb2a360d3a0086e69f02976887e3487db3b3"}}}}