{"action":"created","comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/comments/57973905","id":57973905,"diff_hunk":"@@ -279,10 +279,31 @@ def unregister(self):\n     def subscribe(self, channels=[]):\n         if len(channels) <= 0:\n             return\n-        current_channels = self.api('channel.software.listSystemChannels', self.systemid)\n-        new_channels = [item['channel_label'] for item in current_channels]\n-        new_channels.extend(channels)\n-        return self.api('channel.software.setSystemChannels', self.systemid, new_channels)\n+        if self._is_hosted():\n+            current_channels = self.api('channel.software.listSystemChannels', self.systemid)\n+            new_channels = [item['channel_label'] for item in current_channels]\n+            new_channels.extend(channels)\n+            return self.api('channel.software.setSystemChannels', self.systemid, list(new_channels))\n+        else:\n+            current_channels = self.api('channel.software.listSystemChannels', self.systemid)\n+            current_channels = [item['label'] for item in current_channels]\n+            new_base = None\n+            new_childs = []\n+            for ch in channels:\n+                if ch in current_channels:\n+                    continue\n+                if self.api('channel.software.getDetails', ch)['parent_channel_label'] == '':\n+                    new_base = ch\n+                else:\n+                    if ch not in new_childs:\n+                        new_childs.append(ch)\n+            out_base = 0\n+            out_childs = 0\n+            if new_base:\n+              out_base = self.api('system.setBaseChannel', self.systemid, new_base)","path":"packaging/os/rhn_register.py","position":29,"original_position":29,"commit_id":"4b70e9697158e8002142258d3f59ea78a43d260d","original_commit_id":"4b70e9697158e8002142258d3f59ea78a43d260d","user":{"login":"alikins","id":15162,"avatar_url":"https://avatars.githubusercontent.com/u/15162?v=3","gravatar_id":"","url":"https://api.github.com/users/alikins","html_url":"https://github.com/alikins","followers_url":"https://api.github.com/users/alikins/followers","following_url":"https://api.github.com/users/alikins/following{/other_user}","gists_url":"https://api.github.com/users/alikins/gists{/gist_id}","starred_url":"https://api.github.com/users/alikins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alikins/subscriptions","organizations_url":"https://api.github.com/users/alikins/orgs","repos_url":"https://api.github.com/users/alikins/repos","events_url":"https://api.github.com/users/alikins/events{/privacy}","received_events_url":"https://api.github.com/users/alikins/received_events","type":"User","site_admin":false},"body":"should be 4 space indent here","created_at":"2016-03-30T22:19:59Z","updated_at":"2016-03-30T22:19:59Z","html_url":"https://github.com/ansible/ansible-modules-core/pull/3289#discussion_r57973905","pull_request_url":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/3289","_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/comments/57973905"},"html":{"href":"https://github.com/ansible/ansible-modules-core/pull/3289#discussion_r57973905"},"pull_request":{"href":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/3289"}}},"pull_request":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/3289","id":63561397,"html_url":"https://github.com/ansible/ansible-modules-core/pull/3289","diff_url":"https://github.com/ansible/ansible-modules-core/pull/3289.diff","patch_url":"https://github.com/ansible/ansible-modules-core/pull/3289.patch","issue_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3289","number":3289,"state":"open","locked":false,"title":"Add support for Satellite/Spacewalk which have slightly different API","user":{"login":"jhutar","id":3397250,"avatar_url":"https://avatars.githubusercontent.com/u/3397250?v=3","gravatar_id":"","url":"https://api.github.com/users/jhutar","html_url":"https://github.com/jhutar","followers_url":"https://api.github.com/users/jhutar/followers","following_url":"https://api.github.com/users/jhutar/following{/other_user}","gists_url":"https://api.github.com/users/jhutar/gists{/gist_id}","starred_url":"https://api.github.com/users/jhutar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhutar/subscriptions","organizations_url":"https://api.github.com/users/jhutar/orgs","repos_url":"https://api.github.com/users/jhutar/repos","events_url":"https://api.github.com/users/jhutar/events{/privacy}","received_events_url":"https://api.github.com/users/jhutar/received_events","type":"User","site_admin":false},"body":"##### Issue Type:\r\n\r\n - Feature Pull Request\r\n\r\n##### Plugin Name:\r\n\r\npackaging/os/rhn_register.py\r\n\r\n##### Summary:\r\n\r\nSpacewalk/Satellite API is a bit different, so to add a support for subscribing into specific channels slightly more code was needed. Tested against Hosted (rhn.redhat.com) and against Satellite.\r\n\r\n##### Example:\r\n\r\n```\r\n  - name: ensure we are registered to satellite\r\n    rhn_register: state=present server_url=https://satellite.example.com/XMLRPC username=<user> password=<pass> sslcacert=/etc/sysconfig/rhn/RHN-ORG-TRUSTED-SSL-CERT channels=rhel-x86_64-server-6,rhn-tools-rhel-x86_64-server-6\r\n```\r\nor:\r\n```\r\n  - name: ensure we are registered to hosted\r\n    rhn_register: state=present server_url=https://xmlrpc.rhn.redhat.com/XMLRPC username=<user> password=<pass> sslcacert=/usr/share/rhn/RHNS-CA-CERT channels=rhel-x86_64-server-6,rhn-tools-rhel-x86_64-server-6\r\n```","created_at":"2016-03-21T13:12:32Z","updated_at":"2016-03-30T22:19:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e84a2cd2efb10ba2f0b13f236f978ae7dcff2c0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/3289/commits","review_comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/3289/comments","review_comment_url":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3289/comments","statuses_url":"https://api.github.com/repos/ansible/ansible-modules-core/statuses/4b70e9697158e8002142258d3f59ea78a43d260d","head":{"label":"jhutar:hosted_vs_satellite_api","ref":"hosted_vs_satellite_api","sha":"4b70e9697158e8002142258d3f59ea78a43d260d","user":{"login":"jhutar","id":3397250,"avatar_url":"https://avatars.githubusercontent.com/u/3397250?v=3","gravatar_id":"","url":"https://api.github.com/users/jhutar","html_url":"https://github.com/jhutar","followers_url":"https://api.github.com/users/jhutar/followers","following_url":"https://api.github.com/users/jhutar/following{/other_user}","gists_url":"https://api.github.com/users/jhutar/gists{/gist_id}","starred_url":"https://api.github.com/users/jhutar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhutar/subscriptions","organizations_url":"https://api.github.com/users/jhutar/orgs","repos_url":"https://api.github.com/users/jhutar/repos","events_url":"https://api.github.com/users/jhutar/events{/privacy}","received_events_url":"https://api.github.com/users/jhutar/received_events","type":"User","site_admin":false},"repo":{"id":54382069,"name":"ansible-modules-core","full_name":"jhutar/ansible-modules-core","owner":{"login":"jhutar","id":3397250,"avatar_url":"https://avatars.githubusercontent.com/u/3397250?v=3","gravatar_id":"","url":"https://api.github.com/users/jhutar","html_url":"https://github.com/jhutar","followers_url":"https://api.github.com/users/jhutar/followers","following_url":"https://api.github.com/users/jhutar/following{/other_user}","gists_url":"https://api.github.com/users/jhutar/gists{/gist_id}","starred_url":"https://api.github.com/users/jhutar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhutar/subscriptions","organizations_url":"https://api.github.com/users/jhutar/orgs","repos_url":"https://api.github.com/users/jhutar/repos","events_url":"https://api.github.com/users/jhutar/events{/privacy}","received_events_url":"https://api.github.com/users/jhutar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jhutar/ansible-modules-core","description":"Ansible modules - these modules ship with ansible","fork":true,"url":"https://api.github.com/repos/jhutar/ansible-modules-core","forks_url":"https://api.github.com/repos/jhutar/ansible-modules-core/forks","keys_url":"https://api.github.com/repos/jhutar/ansible-modules-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jhutar/ansible-modules-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jhutar/ansible-modules-core/teams","hooks_url":"https://api.github.com/repos/jhutar/ansible-modules-core/hooks","issue_events_url":"https://api.github.com/repos/jhutar/ansible-modules-core/issues/events{/number}","events_url":"https://api.github.com/repos/jhutar/ansible-modules-core/events","assignees_url":"https://api.github.com/repos/jhutar/ansible-modules-core/assignees{/user}","branches_url":"https://api.github.com/repos/jhutar/ansible-modules-core/branches{/branch}","tags_url":"https://api.github.com/repos/jhutar/ansible-modules-core/tags","blobs_url":"https://api.github.com/repos/jhutar/ansible-modules-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jhutar/ansible-modules-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jhutar/ansible-modules-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/jhutar/ansible-modules-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jhutar/ansible-modules-core/statuses/{sha}","languages_url":"https://api.github.com/repos/jhutar/ansible-modules-core/languages","stargazers_url":"https://api.github.com/repos/jhutar/ansible-modules-core/stargazers","contributors_url":"https://api.github.com/repos/jhutar/ansible-modules-core/contributors","subscribers_url":"https://api.github.com/repos/jhutar/ansible-modules-core/subscribers","subscription_url":"https://api.github.com/repos/jhutar/ansible-modules-core/subscription","commits_url":"https://api.github.com/repos/jhutar/ansible-modules-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/jhutar/ansible-modules-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/jhutar/ansible-modules-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/jhutar/ansible-modules-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/jhutar/ansible-modules-core/contents/{+path}","compare_url":"https://api.github.com/repos/jhutar/ansible-modules-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jhutar/ansible-modules-core/merges","archive_url":"https://api.github.com/repos/jhutar/ansible-modules-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jhutar/ansible-modules-core/downloads","issues_url":"https://api.github.com/repos/jhutar/ansible-modules-core/issues{/number}","pulls_url":"https://api.github.com/repos/jhutar/ansible-modules-core/pulls{/number}","milestones_url":"https://api.github.com/repos/jhutar/ansible-modules-core/milestones{/number}","notifications_url":"https://api.github.com/repos/jhutar/ansible-modules-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jhutar/ansible-modules-core/labels{/name}","releases_url":"https://api.github.com/repos/jhutar/ansible-modules-core/releases{/id}","deployments_url":"https://api.github.com/repos/jhutar/ansible-modules-core/deployments","created_at":"2016-03-21T11:05:39Z","updated_at":"2016-03-21T11:05:41Z","pushed_at":"2016-03-21T13:06:56Z","git_url":"git://github.com/jhutar/ansible-modules-core.git","ssh_url":"git@github.com:jhutar/ansible-modules-core.git","clone_url":"https://github.com/jhutar/ansible-modules-core.git","svn_url":"https://github.com/jhutar/ansible-modules-core","homepage":"","size":8059,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"ansible:devel","ref":"devel","sha":"bff7cb6cad2dfee02b41e4b1d01a4e4471c45bfd","user":{"login":"ansible","id":1507452,"avatar_url":"https://avatars.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"repo":{"id":24474126,"name":"ansible-modules-core","full_name":"ansible/ansible-modules-core","owner":{"login":"ansible","id":1507452,"avatar_url":"https://avatars.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ansible/ansible-modules-core","description":"Ansible modules - these modules ship with ansible","fork":false,"url":"https://api.github.com/repos/ansible/ansible-modules-core","forks_url":"https://api.github.com/repos/ansible/ansible-modules-core/forks","keys_url":"https://api.github.com/repos/ansible/ansible-modules-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ansible/ansible-modules-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ansible/ansible-modules-core/teams","hooks_url":"https://api.github.com/repos/ansible/ansible-modules-core/hooks","issue_events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/events{/number}","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/events","assignees_url":"https://api.github.com/repos/ansible/ansible-modules-core/assignees{/user}","branches_url":"https://api.github.com/repos/ansible/ansible-modules-core/branches{/branch}","tags_url":"https://api.github.com/repos/ansible/ansible-modules-core/tags","blobs_url":"https://api.github.com/repos/ansible/ansible-modules-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ansible/ansible-modules-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ansible/ansible-modules-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/ansible/ansible-modules-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ansible/ansible-modules-core/statuses/{sha}","languages_url":"https://api.github.com/repos/ansible/ansible-modules-core/languages","stargazers_url":"https://api.github.com/repos/ansible/ansible-modules-core/stargazers","contributors_url":"https://api.github.com/repos/ansible/ansible-modules-core/contributors","subscribers_url":"https://api.github.com/repos/ansible/ansible-modules-core/subscribers","subscription_url":"https://api.github.com/repos/ansible/ansible-modules-core/subscription","commits_url":"https://api.github.com/repos/ansible/ansible-modules-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/ansible/ansible-modules-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/ansible/ansible-modules-core/contents/{+path}","compare_url":"https://api.github.com/repos/ansible/ansible-modules-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ansible/ansible-modules-core/merges","archive_url":"https://api.github.com/repos/ansible/ansible-modules-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ansible/ansible-modules-core/downloads","issues_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues{/number}","pulls_url":"https://api.github.com/repos/ansible/ansible-modules-core/pulls{/number}","milestones_url":"https://api.github.com/repos/ansible/ansible-modules-core/milestones{/number}","notifications_url":"https://api.github.com/repos/ansible/ansible-modules-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/labels{/name}","releases_url":"https://api.github.com/repos/ansible/ansible-modules-core/releases{/id}","deployments_url":"https://api.github.com/repos/ansible/ansible-modules-core/deployments","created_at":"2014-09-25T20:28:25Z","updated_at":"2016-03-30T10:44:48Z","pushed_at":"2016-03-30T22:06:09Z","git_url":"git://github.com/ansible/ansible-modules-core.git","ssh_url":"git@github.com:ansible/ansible-modules-core.git","clone_url":"https://github.com/ansible/ansible-modules-core.git","svn_url":"https://github.com/ansible/ansible-modules-core","homepage":"","size":14937,"stargazers_count":630,"watchers_count":630,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1434,"mirror_url":null,"open_issues_count":993,"forks":1434,"open_issues":993,"watchers":630,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/3289"},"html":{"href":"https://github.com/ansible/ansible-modules-core/pull/3289"},"issue":{"href":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3289"},"comments":{"href":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3289/comments"},"review_comments":{"href":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/3289/comments"},"review_comment":{"href":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/3289/commits"},"statuses":{"href":"https://api.github.com/repos/ansible/ansible-modules-core/statuses/4b70e9697158e8002142258d3f59ea78a43d260d"}}}}