{"action":"created","comment":{"url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments/39636334","id":39636334,"diff_hunk":"@@ -1655,16 +1655,168 @@ def setenforce(mode):\n     run('setenforce {0}'.format(mode))\n \n \n-def host_pings(host, timeout=15):\n+# =============================================================================\n+# Satellite and Capsule Upgrade\n+# =============================================================================\n+def copy_ssh_key(from_host, to_host):\n+    \"\"\"This will generate(if not already) ssh-key on from_host\n+    and copy that ssh-key to to_host. Beware that both hosts\n+    should have authorized key added for test running host.\n+\n+    :param from_host: A string. Hostname on which the key to be generated and\n+        to be copied from.\n+    :param to_host: A string. Hostname on to which the ssh-key will be copied.\n+\n+    \"\"\"\n+    ssh_out = execute(lambda: run('ls .ssh/'), host=from_host)\n+    if 'id_rsa.pub' not in ssh_out[from_host]:\n+        execute(\n+            lambda: run('ssh-keygen -f .ssh/id_rsa -t rsa -N \\'\\''),\n+            host=from_host)\n+    local('scp root@{0}:.ssh/id_rsa.pub .'.format(from_host))\n+    local('cat id_rsa.pub | ssh -o \\'StrictHostKeyChecking no\\' '\n+          'root@{0} \\'cat >> .ssh/authorized_keys\\''.format(to_host))\n+\n+\n+def capsule_certs_generate(path=None, capsule=None):\n+    \"\"\"Generates Certs on Satellite for given Capsule.\n+    And also copies those certs into capsule.\n+\n+    :param capsule: A string. Capsule FQDN/hostname.\n+    :param path: A string. Path on capsule where capsule cert to be copied.\n+        If not provided then it will be copied in home directory of capsule.\n+\n+    \"\"\"\n+    if path is None:\n+        path = '/home/'\n+    # Generate Capsule Certificate\n+    run('capsule-certs-generate --capsule-fqdn {0} '\n+        '--certs-tar {0}-certs.tar'.format(capsule))\n+    # Copy the Certificate in Capsule. Ssh key should be already added.\n+    if capsule is not None:\n+        run('scp {0}-certs.tar root@{0}:{1}'.format(capsule, path))\n+\n+\n+def sync_capsule_tools_repos_to_upgrade(admin_password=None):\n+    \"\"\"This syncs capsule and sat-tools repos in Satellite server.\n+    For upgrading Capsule and Client in feature.\n+\n+    :param admin_password: A string. Defaults to 'changeme'.\n+        Foreman admin password for hammer commands.\n+\n+    Following environment variable affects this function.\n+    CAPSULE_REPO","path":"automation_tools/__init__.py","position":55,"original_position":55,"commit_id":"8769e9e729f0e5c54556d06b337b3581a7806ece","original_commit_id":"8769e9e729f0e5c54556d06b337b3581a7806ece","user":{"login":"Ichimonji10","id":1012989,"avatar_url":"https://avatars.githubusercontent.com/u/1012989?v=3","gravatar_id":"","url":"https://api.github.com/users/Ichimonji10","html_url":"https://github.com/Ichimonji10","followers_url":"https://api.github.com/users/Ichimonji10/followers","following_url":"https://api.github.com/users/Ichimonji10/following{/other_user}","gists_url":"https://api.github.com/users/Ichimonji10/gists{/gist_id}","starred_url":"https://api.github.com/users/Ichimonji10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ichimonji10/subscriptions","organizations_url":"https://api.github.com/users/Ichimonji10/orgs","repos_url":"https://api.github.com/users/Ichimonji10/repos","events_url":"https://api.github.com/users/Ichimonji10/events{/privacy}","received_events_url":"https://api.github.com/users/Ichimonji10/received_events","type":"User","site_admin":false},"body":"Definition lists must, by definition, be separated from surrounding documentation.","created_at":"2015-09-16T14:29:59Z","updated_at":"2015-09-16T14:29:59Z","html_url":"https://github.com/SatelliteQE/automation-tools/pull/236#discussion_r39636334","pull_request_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/236","_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/comments/39636334"},"html":{"href":"https://github.com/SatelliteQE/automation-tools/pull/236#discussion_r39636334"},"pull_request":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/236"}}},"pull_request":{"url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/236","id":45151607,"html_url":"https://github.com/SatelliteQE/automation-tools/pull/236","diff_url":"https://github.com/SatelliteQE/automation-tools/pull/236.diff","patch_url":"https://github.com/SatelliteQE/automation-tools/pull/236.patch","issue_url":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/236","number":236,"state":"open","locked":false,"title":"Product Upgrade with new Capsule Upgrade","user":{"login":"jyejare","id":11752425,"avatar_url":"https://avatars.githubusercontent.com/u/11752425?v=3","gravatar_id":"","url":"https://api.github.com/users/jyejare","html_url":"https://github.com/jyejare","followers_url":"https://api.github.com/users/jyejare/followers","following_url":"https://api.github.com/users/jyejare/following{/other_user}","gists_url":"https://api.github.com/users/jyejare/gists{/gist_id}","starred_url":"https://api.github.com/users/jyejare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyejare/subscriptions","organizations_url":"https://api.github.com/users/jyejare/orgs","repos_url":"https://api.github.com/users/jyejare/repos","events_url":"https://api.github.com/users/jyejare/events{/privacy}","received_events_url":"https://api.github.com/users/jyejare/received_events","type":"User","site_admin":false},"body":"A new addition to the Product Upgrade automation feature that is Capsule Upgrade.\r\n\r\nThis includes,\r\n1. Renewed product_upgrade function which now supports capsule upgrade.\r\n2. New capsule6_upgrade function.\r\n3. And the helper functions to achieve capsule upgrade.\r\n\r\nThe procedure/command to run Capsule upgrade is as follow:\r\n1. The already created openstack image having capsule 6.0.8 should be available.\r\n2. Capsule should be already connected to openstack satellite image having Satellite 6.0.8, so that both will be upgraded.\r\n3. The ssh key of the running machine should already available in openstack project to add in capsule instance and to perform capsule upgrade operations.\r\n\r\nFab Command:\r\n```\r\n#RHN_USERNAME=<cdn_username> RHN_PASSWORD=<cdn_password> RHN_POOLID=<cdn_pool_id> USERNAME=<openstack_username> PASSWORD=<password> AUTH_URL=http://<openstack_server>:<port>/<version> PROJECT_ID=<project_id> BASE_URL=http://example.com/Satellite/x86_64/os/  CAPSULE_REPO=http://example.com/Capsule/x86_64_os/ TOOLS_REPO=http://example.com/Sat_Tools/x86_64_os/\r\nfab -i <local private_ssh_key> product_upgrade:<product_name e.g 'capsule'>, <ssh_key>,<sat_instance_name>,<sat_image_name>,<sat_instance_flavor>,<cap_instance_name>,<cap_image_name>,<cap_instance_flavor>\r\n```\r\nImportant:\r\nThe upgrade execution switches as per product_name. \r\nIF product == 'satellite':\r\n       THEN 'Do only satellite upgrade'\r\nELSE IF product == 'capsule':\r\n       THEN 'First do Satellite upgrade and then capsule upgrade'\r\nELSE:\r\n       RETRY\r\n\r\nWelcome suggestions and comments.","created_at":"2015-09-16T09:54:33Z","updated_at":"2015-09-16T14:29:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dee257db43e5c08b60135bfa4d187a603b917c95","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/236/commits","review_comments_url":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/236/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/236/comments","statuses_url":"https://api.github.com/repos/SatelliteQE/automation-tools/statuses/8769e9e729f0e5c54556d06b337b3581a7806ece","head":{"label":"jyejare:capsule_upgrade","ref":"capsule_upgrade","sha":"8769e9e729f0e5c54556d06b337b3581a7806ece","user":{"login":"jyejare","id":11752425,"avatar_url":"https://avatars.githubusercontent.com/u/11752425?v=3","gravatar_id":"","url":"https://api.github.com/users/jyejare","html_url":"https://github.com/jyejare","followers_url":"https://api.github.com/users/jyejare/followers","following_url":"https://api.github.com/users/jyejare/following{/other_user}","gists_url":"https://api.github.com/users/jyejare/gists{/gist_id}","starred_url":"https://api.github.com/users/jyejare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyejare/subscriptions","organizations_url":"https://api.github.com/users/jyejare/orgs","repos_url":"https://api.github.com/users/jyejare/repos","events_url":"https://api.github.com/users/jyejare/events{/privacy}","received_events_url":"https://api.github.com/users/jyejare/received_events","type":"User","site_admin":false},"repo":{"id":37851466,"name":"automation-tools","full_name":"jyejare/automation-tools","owner":{"login":"jyejare","id":11752425,"avatar_url":"https://avatars.githubusercontent.com/u/11752425?v=3","gravatar_id":"","url":"https://api.github.com/users/jyejare","html_url":"https://github.com/jyejare","followers_url":"https://api.github.com/users/jyejare/followers","following_url":"https://api.github.com/users/jyejare/following{/other_user}","gists_url":"https://api.github.com/users/jyejare/gists{/gist_id}","starred_url":"https://api.github.com/users/jyejare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyejare/subscriptions","organizations_url":"https://api.github.com/users/jyejare/orgs","repos_url":"https://api.github.com/users/jyejare/repos","events_url":"https://api.github.com/users/jyejare/events{/privacy}","received_events_url":"https://api.github.com/users/jyejare/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jyejare/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/jyejare/automation-tools","forks_url":"https://api.github.com/repos/jyejare/automation-tools/forks","keys_url":"https://api.github.com/repos/jyejare/automation-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jyejare/automation-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jyejare/automation-tools/teams","hooks_url":"https://api.github.com/repos/jyejare/automation-tools/hooks","issue_events_url":"https://api.github.com/repos/jyejare/automation-tools/issues/events{/number}","events_url":"https://api.github.com/repos/jyejare/automation-tools/events","assignees_url":"https://api.github.com/repos/jyejare/automation-tools/assignees{/user}","branches_url":"https://api.github.com/repos/jyejare/automation-tools/branches{/branch}","tags_url":"https://api.github.com/repos/jyejare/automation-tools/tags","blobs_url":"https://api.github.com/repos/jyejare/automation-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jyejare/automation-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jyejare/automation-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/jyejare/automation-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jyejare/automation-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/jyejare/automation-tools/languages","stargazers_url":"https://api.github.com/repos/jyejare/automation-tools/stargazers","contributors_url":"https://api.github.com/repos/jyejare/automation-tools/contributors","subscribers_url":"https://api.github.com/repos/jyejare/automation-tools/subscribers","subscription_url":"https://api.github.com/repos/jyejare/automation-tools/subscription","commits_url":"https://api.github.com/repos/jyejare/automation-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/jyejare/automation-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/jyejare/automation-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/jyejare/automation-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/jyejare/automation-tools/contents/{+path}","compare_url":"https://api.github.com/repos/jyejare/automation-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jyejare/automation-tools/merges","archive_url":"https://api.github.com/repos/jyejare/automation-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jyejare/automation-tools/downloads","issues_url":"https://api.github.com/repos/jyejare/automation-tools/issues{/number}","pulls_url":"https://api.github.com/repos/jyejare/automation-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/jyejare/automation-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/jyejare/automation-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jyejare/automation-tools/labels{/name}","releases_url":"https://api.github.com/repos/jyejare/automation-tools/releases{/id}","created_at":"2015-06-22T11:23:46Z","updated_at":"2015-06-22T11:23:47Z","pushed_at":"2015-09-16T09:40:38Z","git_url":"git://github.com/jyejare/automation-tools.git","ssh_url":"git@github.com:jyejare/automation-tools.git","clone_url":"https://github.com/jyejare/automation-tools.git","svn_url":"https://github.com/jyejare/automation-tools","homepage":"","size":538,"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":"3147f7706cdbc628962354fd95b2e9f104e15f8e","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}","created_at":"2014-08-01T14:27:34Z","updated_at":"2015-05-20T03:49:25Z","pushed_at":"2015-09-16T10:45:07Z","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":1636,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":9,"forks":14,"open_issues":9,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/236"},"html":{"href":"https://github.com/SatelliteQE/automation-tools/pull/236"},"issue":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/236"},"comments":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/issues/236/comments"},"review_comments":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/pulls/236/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/236/commits"},"statuses":{"href":"https://api.github.com/repos/SatelliteQE/automation-tools/statuses/8769e9e729f0e5c54556d06b337b3581a7806ece"}}}}