{"action":"created","comment":{"url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments/78188418","id":78188418,"diff_hunk":"@@ -573,31 +573,69 @@ def install_puppet_scap_client():\n     run('yum -y install puppet-foreman_scap_client', warn_only=True)\n \n \n-def setup_foreman_discovery():\n-    \"\"\"Task to setup foreman discovery.\"\"\"\n-    # Install required packages to enable discovery plugin\n+def setup_foreman_discovery(sat_version, upstream=False):\n+    \"\"\"Task to setup foreman discovery.\n+\n+    :param str sat_version: should contain satellite version e.g. 6.1, 6.2\n+    :param bool upstream: Flag whether we run on upstream. Default: ``False``.\n+    \"\"\"\n     packages = (\n         'tfm-rubygem-foreman_discovery',\n         'rubygem-smart_proxy_discovery',\n-        'foreman-discovery-image',\n         'tfm-rubygem-hammer_cli_foreman_discovery',\n     )\n-    run('yum install -y {0}'.format(' '.join(packages)))\n+    admin_password = os.environ.get('ADMIN_PASSWORD', 'changeme')\n \n-    for daemon in ('foreman', 'httpd', 'foreman-proxy'):\n-        manage_daemon('restart', daemon)\n+    if not upstream and sat_version in ('6.1', '6.2'):\n+        run('yum install -y {0}'.format(' '.join(packages)), warn_only=True)\n+        run('yum install -y foreman-discovery-image')\n+        for daemon in ('foreman', 'httpd', 'foreman-proxy'):\n+            manage_daemon('restart', daemon)\n+        template_url = os.environ.get('PXE_DEFAULT_TEMPLATE_URL')\n+        template_file = run('mktemp')\n+        hostname = run('hostname -f', quiet=True).strip()\n+        run('wget -O {0} {1}'.format(template_file, template_url))\n+        run('sed -i -e \"s/SatelliteCapsule_HOST/{0}/\" {1}'\n+            .format(hostname, template_file))\n+        # Update the template\n+        run('hammer -u admin -p {0} template update --name '\n+            '\"PXELinux global default\" --file {1}'\n+            .format(admin_password, template_file))\n+        run('rm -rf {0}'.format(template_file))\n+        return\n \n-    admin_password = os.environ.get('ADMIN_PASSWORD', 'changeme')\n-    template_url = os.environ.get('PXE_DEFAULT_TEMPLATE_URL')\n-    if template_url is None:\n-        print('You must specify the PXE default template URL')\n-        sys.exit(1)\n+    if upstream:\n+        run('yum install -y {0}'.format(' '.join(packages)), warn_only=True)\n+        # Fetch the nightly FDI from upstream\n+        image_url = 'http://downloads.theforeman.org/discovery/nightly/fdi-image-latest.tar'  # noqa\n+        run('wget {0} + -O - | tar x --overwrite -C /var/lib/tftpboot/boot'\n+            .format(image_url))\n+    if not upstream and sat_version == '6.3':\n+        # In 6.3, installer should install all required packages except FDI\n+        run('rpm -q {0}'.format(' '.join(packages)))\n+        run('yum install -y foreman-discovery-image')\n \n+    for daemon in ('foreman', 'httpd', 'foreman-proxy'):\n+            manage_daemon('restart', daemon)\n+    # Unlock the default Locked template for discovery\n+    run('hammer -u admin -p {0} template update --name '\n+        '\"PXELinux global default\" --lock \"false\"'\n+        .format(admin_password))\n+    # Fetch the updated template where ONTIMEOUT set to 'discovery'\n+    # Note that this template is for discovery7.0\n+    template_url = os.environ.get('PXE_DEFAULT_TEMPLATE_URL_FOR_70')\n+    # Fetch the updated discovery snippet where URL includes proxy port\n+    snippet_url = os.environ.get('PXELINUX_DISCOVERY_SNIPPET_URL')\n+    snippet_file = run('mktemp')\n+    run('wget -O {0} {1}'.format(snippet_file, snippet_url))\n+    # Update the template\n+    run('hammer -u admin -p {0} template update --name '\n+        '\"pxelinux_discovery\" --file {1}'\n+        .format(admin_password, snippet_file))\n+    run('rm -rf {0}'.format(snippet_file))\n     template_file = run('mktemp')\n-    hostname = run('hostname -f', quiet=True).strip()\n     run('wget -O {0} {1}'.format(template_file, template_url))\n-    run('sed -i -e \"s/SatelliteCapsule_HOST/{0}/\" {1}'\n-        .format(hostname, template_file))\n+    # Update the template\n     run('hammer -u admin -p {0} template update --name '\n         '\"PXELinux global default\" --file {1}'\n         .format(admin_password, template_file))","path":"automation_tools/__init__.py","position":84,"original_position":84,"commit_id":"d4d0cc4b078b604f249f005714fbd9816df4ca0b","original_commit_id":"d4d0cc4b078b604f249f005714fbd9816df4ca0b","user":{"login":"lpramuk","id":7138254,"avatar_url":"https://avatars.githubusercontent.com/u/7138254?v=3","gravatar_id":"","url":"https://api.github.com/users/lpramuk","html_url":"https://github.com/lpramuk","followers_url":"https://api.github.com/users/lpramuk/followers","following_url":"https://api.github.com/users/lpramuk/following{/other_user}","gists_url":"https://api.github.com/users/lpramuk/gists{/gist_id}","starred_url":"https://api.github.com/users/lpramuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpramuk/subscriptions","organizations_url":"https://api.github.com/users/lpramuk/orgs","repos_url":"https://api.github.com/users/lpramuk/repos","events_url":"https://api.github.com/users/lpramuk/events{/privacy}","received_events_url":"https://api.github.com/users/lpramuk/received_events","type":"User","site_admin":false},"body":"....up to this line (indented lines)","created_at":"2016-09-09T14:22:17Z","updated_at":"2016-09-09T14:22:17Z","html_url":"https://github.com/SatelliteQE/automation-tools/pull/404#discussion_r78188418","pull_request_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/404","_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments/78188418"},"html":{"href":"https://github.com/SatelliteQE/automation-tools/pull/404#discussion_r78188418"},"pull_request":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/404"}}},"pull_request":{"url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/404","id":84460075,"html_url":"https://github.com/SatelliteQE/automation-tools/pull/404","diff_url":"https://github.com/SatelliteQE/automation-tools/pull/404.diff","patch_url":"https://github.com/SatelliteQE/automation-tools/pull/404.patch","issue_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/404","number":404,"state":"open","locked":false,"title":"Changes to setup discovery7.0 in upstream","user":{"login":"sghai","id":620852,"avatar_url":"https://avatars.githubusercontent.com/u/620852?v=3","gravatar_id":"","url":"https://api.github.com/users/sghai","html_url":"https://github.com/sghai","followers_url":"https://api.github.com/users/sghai/followers","following_url":"https://api.github.com/users/sghai/following{/other_user}","gists_url":"https://api.github.com/users/sghai/gists{/gist_id}","starred_url":"https://api.github.com/users/sghai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sghai/subscriptions","organizations_url":"https://api.github.com/users/sghai/orgs","repos_url":"https://api.github.com/users/sghai/repos","events_url":"https://api.github.com/users/sghai/events{/privacy}","received_events_url":"https://api.github.com/users/sghai/received_events","type":"User","site_admin":false},"body":"- Added a new task to setup discovery for upstream `setup_foreman_discovery_70`. \r\n- Please note that steps to setup discovery in upstream is different than 6.1, 6.2 releases. So I proffered to define separate task and same would be applicable for upcoming 6.3 release.\r\n\r\nPlease review it and suggest if any changes are required.","created_at":"2016-09-08T11:28:19Z","updated_at":"2016-09-09T14:22:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ea26cdddc8673fcc381afe8e29b13b477efbbae8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/404/commits","review_comments_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/404/comments","review_comment_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/404/comments","statuses_url":"https://api.github.com/repos/SatelliteQE/automation-tools/statuses/d4d0cc4b078b604f249f005714fbd9816df4ca0b","head":{"label":"sghai:fix-setup-discovery","ref":"fix-setup-discovery","sha":"d4d0cc4b078b604f249f005714fbd9816df4ca0b","user":{"login":"sghai","id":620852,"avatar_url":"https://avatars.githubusercontent.com/u/620852?v=3","gravatar_id":"","url":"https://api.github.com/users/sghai","html_url":"https://github.com/sghai","followers_url":"https://api.github.com/users/sghai/followers","following_url":"https://api.github.com/users/sghai/following{/other_user}","gists_url":"https://api.github.com/users/sghai/gists{/gist_id}","starred_url":"https://api.github.com/users/sghai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sghai/subscriptions","organizations_url":"https://api.github.com/users/sghai/orgs","repos_url":"https://api.github.com/users/sghai/repos","events_url":"https://api.github.com/users/sghai/events{/privacy}","received_events_url":"https://api.github.com/users/sghai/received_events","type":"User","site_admin":false},"repo":{"id":40583082,"name":"automation-tools","full_name":"sghai/automation-tools","owner":{"login":"sghai","id":620852,"avatar_url":"https://avatars.githubusercontent.com/u/620852?v=3","gravatar_id":"","url":"https://api.github.com/users/sghai","html_url":"https://github.com/sghai","followers_url":"https://api.github.com/users/sghai/followers","following_url":"https://api.github.com/users/sghai/following{/other_user}","gists_url":"https://api.github.com/users/sghai/gists{/gist_id}","starred_url":"https://api.github.com/users/sghai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sghai/subscriptions","organizations_url":"https://api.github.com/users/sghai/orgs","repos_url":"https://api.github.com/users/sghai/repos","events_url":"https://api.github.com/users/sghai/events{/privacy}","received_events_url":"https://api.github.com/users/sghai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sghai/automation-tools","description":"A set of tools to help automating testing Foreman with Robottelo (https://github.com/SatelliteQE/robottelo)","fork":true,"url":"https://api.github.com/repos/sghai/automation-tools","forks_url":"https://api.github.com/repos/sghai/automation-tools/forks","keys_url":"https://api.github.com/repos/sghai/automation-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sghai/automation-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sghai/automation-tools/teams","hooks_url":"https://api.github.com/repos/sghai/automation-tools/hooks","issue_events_url":"https://api.github.com/repos/sghai/automation-tools/issues/events{/number}","events_url":"https://api.github.com/repos/sghai/automation-tools/events","assignees_url":"https://api.github.com/repos/sghai/automation-tools/assignees{/user}","branches_url":"https://api.github.com/repos/sghai/automation-tools/branches{/branch}","tags_url":"https://api.github.com/repos/sghai/automation-tools/tags","blobs_url":"https://api.github.com/repos/sghai/automation-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sghai/automation-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sghai/automation-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/sghai/automation-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sghai/automation-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/sghai/automation-tools/languages","stargazers_url":"https://api.github.com/repos/sghai/automation-tools/stargazers","contributors_url":"https://api.github.com/repos/sghai/automation-tools/contributors","subscribers_url":"https://api.github.com/repos/sghai/automation-tools/subscribers","subscription_url":"https://api.github.com/repos/sghai/automation-tools/subscription","commits_url":"https://api.github.com/repos/sghai/automation-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/sghai/automation-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/sghai/automation-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/sghai/automation-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/sghai/automation-tools/contents/{+path}","compare_url":"https://api.github.com/repos/sghai/automation-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sghai/automation-tools/merges","archive_url":"https://api.github.com/repos/sghai/automation-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sghai/automation-tools/downloads","issues_url":"https://api.github.com/repos/sghai/automation-tools/issues{/number}","pulls_url":"https://api.github.com/repos/sghai/automation-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/sghai/automation-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/sghai/automation-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sghai/automation-tools/labels{/name}","releases_url":"https://api.github.com/repos/sghai/automation-tools/releases{/id}","deployments_url":"https://api.github.com/repos/sghai/automation-tools/deployments","created_at":"2015-08-12T06:02:36Z","updated_at":"2016-04-21T06:08:30Z","pushed_at":"2016-09-09T14:05:12Z","git_url":"git://github.com/sghai/automation-tools.git","ssh_url":"git@github.com:sghai/automation-tools.git","clone_url":"https://github.com/sghai/automation-tools.git","svn_url":"https://github.com/sghai/automation-tools","homepage":"","size":754,"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":"SatelliteQE:master","ref":"master","sha":"1c637230ee74dc1773c21be9ad43ee84af476ed9","user":{"login":"SatelliteQE","id":8754276,"avatar_url":"https://avatars.githubusercontent.com/u/8754276?v=3","gravatar_id":"","url":"https://api.github.com/users/SatelliteQE","html_url":"https://github.com/SatelliteQE","followers_url":"https://api.github.com/users/SatelliteQE/followers","following_url":"https://api.github.com/users/SatelliteQE/following{/other_user}","gists_url":"https://api.github.com/users/SatelliteQE/gists{/gist_id}","starred_url":"https://api.github.com/users/SatelliteQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SatelliteQE/subscriptions","organizations_url":"https://api.github.com/users/SatelliteQE/orgs","repos_url":"https://api.github.com/users/SatelliteQE/repos","events_url":"https://api.github.com/users/SatelliteQE/events{/privacy}","received_events_url":"https://api.github.com/users/SatelliteQE/received_events","type":"Organization","site_admin":false},"repo":{"id":22513327,"name":"automation-tools","full_name":"SatelliteQE/automation-tools","owner":{"login":"SatelliteQE","id":8754276,"avatar_url":"https://avatars.githubusercontent.com/u/8754276?v=3","gravatar_id":"","url":"https://api.github.com/users/SatelliteQE","html_url":"https://github.com/SatelliteQE","followers_url":"https://api.github.com/users/SatelliteQE/followers","following_url":"https://api.github.com/users/SatelliteQE/following{/other_user}","gists_url":"https://api.github.com/users/SatelliteQE/gists{/gist_id}","starred_url":"https://api.github.com/users/SatelliteQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SatelliteQE/subscriptions","organizations_url":"https://api.github.com/users/SatelliteQE/orgs","repos_url":"https://api.github.com/users/SatelliteQE/repos","events_url":"https://api.github.com/users/SatelliteQE/events{/privacy}","received_events_url":"https://api.github.com/users/SatelliteQE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SatelliteQE/automation-tools","description":"A set of tools to help automating testing Foreman with Robottelo (https://github.com/SatelliteQE/robottelo)","fork":false,"url":"https://api.github.com/repos/SatelliteQE/automation-tools","forks_url":"https://api.github.com/repos/SatelliteQE/automation-tools/forks","keys_url":"https://api.github.com/repos/SatelliteQE/automation-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SatelliteQE/automation-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SatelliteQE/automation-tools/teams","hooks_url":"https://api.github.com/repos/SatelliteQE/automation-tools/hooks","issue_events_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/events{/number}","events_url":"https://api.github.com/repos/SatelliteQE/automation-tools/events","assignees_url":"https://api.github.com/repos/SatelliteQE/automation-tools/assignees{/user}","branches_url":"https://api.github.com/repos/SatelliteQE/automation-tools/branches{/branch}","tags_url":"https://api.github.com/repos/SatelliteQE/automation-tools/tags","blobs_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SatelliteQE/automation-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/SatelliteQE/automation-tools/languages","stargazers_url":"https://api.github.com/repos/SatelliteQE/automation-tools/stargazers","contributors_url":"https://api.github.com/repos/SatelliteQE/automation-tools/contributors","subscribers_url":"https://api.github.com/repos/SatelliteQE/automation-tools/subscribers","subscription_url":"https://api.github.com/repos/SatelliteQE/automation-tools/subscription","commits_url":"https://api.github.com/repos/SatelliteQE/automation-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/SatelliteQE/automation-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/SatelliteQE/automation-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/SatelliteQE/automation-tools/contents/{+path}","compare_url":"https://api.github.com/repos/SatelliteQE/automation-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SatelliteQE/automation-tools/merges","archive_url":"https://api.github.com/repos/SatelliteQE/automation-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SatelliteQE/automation-tools/downloads","issues_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues{/number}","pulls_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/SatelliteQE/automation-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/SatelliteQE/automation-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SatelliteQE/automation-tools/labels{/name}","releases_url":"https://api.github.com/repos/SatelliteQE/automation-tools/releases{/id}","deployments_url":"https://api.github.com/repos/SatelliteQE/automation-tools/deployments","created_at":"2014-08-01T14:27:34Z","updated_at":"2016-03-31T14:58:31Z","pushed_at":"2016-09-09T14:05:13Z","git_url":"git://github.com/SatelliteQE/automation-tools.git","ssh_url":"git@github.com:SatelliteQE/automation-tools.git","clone_url":"https://github.com/SatelliteQE/automation-tools.git","svn_url":"https://github.com/SatelliteQE/automation-tools","homepage":"","size":985,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":14,"forks":19,"open_issues":14,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/404"},"html":{"href":"https://github.com/SatelliteQE/automation-tools/pull/404"},"issue":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/404"},"comments":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/404/comments"},"review_comments":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/404/comments"},"review_comment":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/404/commits"},"statuses":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/statuses/d4d0cc4b078b604f249f005714fbd9816df4ca0b"}}}}
{"actor":{"display_login":"lpramuk"}}