{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/sonic-utilities/pulls/comments/216497365","pull_request_review_id":153992682,"id":216497365,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNjQ5NzM2NQ==","diff_hunk":"@@ -1170,6 +1171,91 @@ def line():\n     \"\"\"Show all /dev/ttyUSB lines and their info\"\"\"\n     cmd = \"consutil show\"\n     run_command(cmd, display_cmd=verbose)\n+    # TODO: Stub\n+    return\n+\n+\n+@cli.group(cls=AliasedGroup, default_if_no_args=False)\n+def warm_restart():\n+    \"\"\"Show warm restart configuration and state\"\"\"\n+    pass\n+\n+@warm_restart.command()\n+@click.option('-s', '--redis-unix-socket-path', help='unix socket path for redis connection')\n+def state(redis_unix_socket_path):\n+    \"\"\"Show warm restart state\"\"\"\n+    kwargs = {}\n+    if redis_unix_socket_path:\n+        kwargs['unix_socket_path'] = redis_unix_socket_path\n+\n+    data = {}\n+    db = SonicV2Connector(host='127.0.0.1')\n+    db.connect(db.STATE_DB, False)   # Make one attempt only\n+\n+    TABLE_NAME_SEPARATOR = '|'\n+    prefix = 'WARM_RESTART_TABLE' + TABLE_NAME_SEPARATOR\n+    _hash = '{}{}'.format(prefix, '*')\n+    table_keys = db.keys(db.STATE_DB, _hash)\n+\n+    def remove_prefix(text, prefix):\n+        if text.startswith(prefix):\n+            return text[len(prefix):]\n+        return text\n+\n+    table = []\n+    for tk in table_keys:\n+        entry = db.get_all(db.STATE_DB, tk)\n+        r = []\n+        r.append(remove_prefix(tk, prefix))\n+        r.append(entry['restart_count'])\n+\n+        if 'state' not in  entry:\n+            r.append(\"\")\n+        else:\n+            r.append(entry['state'])\n+\n+        table.append(r)\n+\n+    header = ['name', 'restart_count', 'state']\n+    click.echo(tabulate(table, header))\n+\n+@warm_restart.command()\n+@click.option('-s', '--redis-unix-socket-path', help='unix socket path for redis connection')\n+def config(redis_unix_socket_path):\n+    \"\"\"Show warm restart config\"\"\"\n+    kwargs = {}\n+    if redis_unix_socket_path:\n+        kwargs['unix_socket_path'] = redis_unix_socket_path\n+    config_db = ConfigDBConnector(**kwargs)\n+    config_db.connect(wait_for_init=False)\n+    data = config_db.get_table('WARM_RESTART')\n+    keys = data.keys()\n+\n+    def tablelize(keys, data):\n+        table = []\n+\n+        for k in keys:\n+            r = []\n+            r.append(k)\n+\n+            if 'enable' not in  data[k]:\n+                r.append(\"false\")\n+            else:\n+                r.append(data[k]['enable'])\n+\n+            if 'timer_name' in  data[k]:\n+                r.append(data[k]['timer_name'])\n+                r.append(data[k]['timer_duration'])\n+            else:\n+                r.append(\"NULL\")\n+                r.append(\"NULL\")\n+\n+            table.append(r)\n+\n+        return table\n+\n+    header = ['name', 'enable', 'timer_name', 'timer_duration']","path":"show/main.py","position":103,"original_position":104,"commit_id":"0df3ae51197842ea1e2e033246e41d94c7cae161","original_commit_id":"aa8e62787a293bef386aa5dfc03c127b87459f4f","user":{"login":"jipanyang","id":29779499,"node_id":"MDQ6VXNlcjI5Nzc5NDk5","avatar_url":"https://avatars3.githubusercontent.com/u/29779499?v=4","gravatar_id":"","url":"https://api.github.com/users/jipanyang","html_url":"https://github.com/jipanyang","followers_url":"https://api.github.com/users/jipanyang/followers","following_url":"https://api.github.com/users/jipanyang/following{/other_user}","gists_url":"https://api.github.com/users/jipanyang/gists{/gist_id}","starred_url":"https://api.github.com/users/jipanyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jipanyang/subscriptions","organizations_url":"https://api.github.com/users/jipanyang/orgs","repos_url":"https://api.github.com/users/jipanyang/repos","events_url":"https://api.github.com/users/jipanyang/events{/privacy}","received_events_url":"https://api.github.com/users/jipanyang/received_events","type":"User","site_admin":false},"body":"I don't think putting fixed timer name in header is a good idea.\r\nIf there are multiple timers per docker, just fill space in other fields and make multiple rows. \r\nAnyway it is kind of UI things,  people may have different opinions. \r\n","created_at":"2018-09-10T22:41:35Z","updated_at":"2018-09-10T22:41:35Z","html_url":"https://github.com/Azure/sonic-utilities/pull/294#discussion_r216497365","pull_request_url":"https://api.github.com/repos/Azure/sonic-utilities/pulls/294","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Azure/sonic-utilities/pulls/comments/216497365"},"html":{"href":"https://github.com/Azure/sonic-utilities/pull/294#discussion_r216497365"},"pull_request":{"href":"https://api.github.com/repos/Azure/sonic-utilities/pulls/294"}},"in_reply_to_id":216098309},"pull_request":{"url":"https://api.github.com/repos/Azure/sonic-utilities/pulls/294","id":206550245,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2NTUwMjQ1","html_url":"https://github.com/Azure/sonic-utilities/pull/294","diff_url":"https://github.com/Azure/sonic-utilities/pull/294.diff","patch_url":"https://github.com/Azure/sonic-utilities/pull/294.patch","issue_url":"https://api.github.com/repos/Azure/sonic-utilities/issues/294","number":294,"state":"open","locked":false,"title":"Warm reboot: warm_restart config and show commands","user":{"login":"jipanyang","id":29779499,"node_id":"MDQ6VXNlcjI5Nzc5NDk5","avatar_url":"https://avatars3.githubusercontent.com/u/29779499?v=4","gravatar_id":"","url":"https://api.github.com/users/jipanyang","html_url":"https://github.com/jipanyang","followers_url":"https://api.github.com/users/jipanyang/followers","following_url":"https://api.github.com/users/jipanyang/following{/other_user}","gists_url":"https://api.github.com/users/jipanyang/gists{/gist_id}","starred_url":"https://api.github.com/users/jipanyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jipanyang/subscriptions","organizations_url":"https://api.github.com/users/jipanyang/orgs","repos_url":"https://api.github.com/users/jipanyang/repos","events_url":"https://api.github.com/users/jipanyang/events{/privacy}","received_events_url":"https://api.github.com/users/jipanyang/received_events","type":"User","site_admin":false},"body":"Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>\r\n\r\n\r\n**- What I did**\r\nwarm_restart config and show commands\r\n\r\n**- How I did it**\r\n\r\n**- How to verify it**\r\n\r\n**- Previous command output (if the output of a command-line utility has changed)**\r\n\r\n**- New command output (if the output of a command-line utility has changed)**\r\n\r\n```\r\n\r\nroot@sonic:/# config warm_restart enable\r\nroot@sonic:/# config warm_restart disable swss\r\nroot@sonic:/# \r\n\r\n\r\nroot@sonic:/# show warm_restart \r\nUsage: show warm_restart [OPTIONS] COMMAND [ARGS]...\r\n\r\n  Show warm restart configuration and state\r\n\r\nOptions:\r\n  -?, -h, --help  Show this message and exit.\r\n\r\nCommands:\r\n  config  Show warm restart config\r\n  state   Show warm restart state\r\n\r\n\r\nroot@sonic:/# show warm_restart  config\r\nname    enable    timer_name    timer_duration\r\n------  --------  ------------  ----------------\r\nswss    false     NULL          NULL\r\nsystem  true      NULL          NULL\r\nroot@sonic:/# \r\nroot@sonic:/# config warm_restart enable swss\r\nroot@sonic:/# \r\n\r\n\r\nroot@sonic:/# show warm_restart config\r\nname    enable    timer_name    timer_duration\r\n------  --------  ------------  ----------------\r\nswss    true      NULL          NULL\r\nsystem  true      NULL          NULL\r\nroot@sonic:/# \r\n\r\n\r\nroot@sonic:/# show warm_restart  state\r\nname          restart_count  state\r\n----------  ---------------  -------\r\norchagent                 2  init\r\nneighsyncd                1\r\nportsyncd                 2\r\nvlanmgrd                  1\r\n\r\nroot@sonic:/# show warm_restart state \r\nname          restart_count  state\r\n----------  ---------------  ----------\r\norchagent                 2  reconciled\r\nneighsyncd                2\r\nportsyncd                 2\r\nvlanmgrd                  2\r\n\r\n\r\n```\r\n\r\n\r\n-->\r\n\r\n","created_at":"2018-08-07T00:30:54Z","updated_at":"2018-09-10T22:41:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"670aac69e8643fd1bb8187dcd2167905c4719f22","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/sonic-utilities/pulls/294/commits","review_comments_url":"https://api.github.com/repos/Azure/sonic-utilities/pulls/294/comments","review_comment_url":"https://api.github.com/repos/Azure/sonic-utilities/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/sonic-utilities/issues/294/comments","statuses_url":"https://api.github.com/repos/Azure/sonic-utilities/statuses/0df3ae51197842ea1e2e033246e41d94c7cae161","head":{"label":"jipanyang:warm_reboot_collab_9_config_show","ref":"warm_reboot_collab_9_config_show","sha":"0df3ae51197842ea1e2e033246e41d94c7cae161","user":{"login":"jipanyang","id":29779499,"node_id":"MDQ6VXNlcjI5Nzc5NDk5","avatar_url":"https://avatars3.githubusercontent.com/u/29779499?v=4","gravatar_id":"","url":"https://api.github.com/users/jipanyang","html_url":"https://github.com/jipanyang","followers_url":"https://api.github.com/users/jipanyang/followers","following_url":"https://api.github.com/users/jipanyang/following{/other_user}","gists_url":"https://api.github.com/users/jipanyang/gists{/gist_id}","starred_url":"https://api.github.com/users/jipanyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jipanyang/subscriptions","organizations_url":"https://api.github.com/users/jipanyang/orgs","repos_url":"https://api.github.com/users/jipanyang/repos","events_url":"https://api.github.com/users/jipanyang/events{/privacy}","received_events_url":"https://api.github.com/users/jipanyang/received_events","type":"User","site_admin":false},"repo":{"id":133591382,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM1OTEzODI=","name":"sonic-utilities","full_name":"jipanyang/sonic-utilities","owner":{"login":"jipanyang","id":29779499,"node_id":"MDQ6VXNlcjI5Nzc5NDk5","avatar_url":"https://avatars3.githubusercontent.com/u/29779499?v=4","gravatar_id":"","url":"https://api.github.com/users/jipanyang","html_url":"https://github.com/jipanyang","followers_url":"https://api.github.com/users/jipanyang/followers","following_url":"https://api.github.com/users/jipanyang/following{/other_user}","gists_url":"https://api.github.com/users/jipanyang/gists{/gist_id}","starred_url":"https://api.github.com/users/jipanyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jipanyang/subscriptions","organizations_url":"https://api.github.com/users/jipanyang/orgs","repos_url":"https://api.github.com/users/jipanyang/repos","events_url":"https://api.github.com/users/jipanyang/events{/privacy}","received_events_url":"https://api.github.com/users/jipanyang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jipanyang/sonic-utilities","description":"Command line utilities for the SONiC project","fork":true,"url":"https://api.github.com/repos/jipanyang/sonic-utilities","forks_url":"https://api.github.com/repos/jipanyang/sonic-utilities/forks","keys_url":"https://api.github.com/repos/jipanyang/sonic-utilities/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jipanyang/sonic-utilities/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jipanyang/sonic-utilities/teams","hooks_url":"https://api.github.com/repos/jipanyang/sonic-utilities/hooks","issue_events_url":"https://api.github.com/repos/jipanyang/sonic-utilities/issues/events{/number}","events_url":"https://api.github.com/repos/jipanyang/sonic-utilities/events","assignees_url":"https://api.github.com/repos/jipanyang/sonic-utilities/assignees{/user}","branches_url":"https://api.github.com/repos/jipanyang/sonic-utilities/branches{/branch}","tags_url":"https://api.github.com/repos/jipanyang/sonic-utilities/tags","blobs_url":"https://api.github.com/repos/jipanyang/sonic-utilities/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jipanyang/sonic-utilities/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jipanyang/sonic-utilities/git/refs{/sha}","trees_url":"https://api.github.com/repos/jipanyang/sonic-utilities/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jipanyang/sonic-utilities/statuses/{sha}","languages_url":"https://api.github.com/repos/jipanyang/sonic-utilities/languages","stargazers_url":"https://api.github.com/repos/jipanyang/sonic-utilities/stargazers","contributors_url":"https://api.github.com/repos/jipanyang/sonic-utilities/contributors","subscribers_url":"https://api.github.com/repos/jipanyang/sonic-utilities/subscribers","subscription_url":"https://api.github.com/repos/jipanyang/sonic-utilities/subscription","commits_url":"https://api.github.com/repos/jipanyang/sonic-utilities/commits{/sha}","git_commits_url":"https://api.github.com/repos/jipanyang/sonic-utilities/git/commits{/sha}","comments_url":"https://api.github.com/repos/jipanyang/sonic-utilities/comments{/number}","issue_comment_url":"https://api.github.com/repos/jipanyang/sonic-utilities/issues/comments{/number}","contents_url":"https://api.github.com/repos/jipanyang/sonic-utilities/contents/{+path}","compare_url":"https://api.github.com/repos/jipanyang/sonic-utilities/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jipanyang/sonic-utilities/merges","archive_url":"https://api.github.com/repos/jipanyang/sonic-utilities/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jipanyang/sonic-utilities/downloads","issues_url":"https://api.github.com/repos/jipanyang/sonic-utilities/issues{/number}","pulls_url":"https://api.github.com/repos/jipanyang/sonic-utilities/pulls{/number}","milestones_url":"https://api.github.com/repos/jipanyang/sonic-utilities/milestones{/number}","notifications_url":"https://api.github.com/repos/jipanyang/sonic-utilities/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jipanyang/sonic-utilities/labels{/name}","releases_url":"https://api.github.com/repos/jipanyang/sonic-utilities/releases{/id}","deployments_url":"https://api.github.com/repos/jipanyang/sonic-utilities/deployments","created_at":"2018-05-16T01:08:45Z","updated_at":"2018-08-03T23:07:30Z","pushed_at":"2018-09-10T20:16:50Z","git_url":"git://github.com/jipanyang/sonic-utilities.git","ssh_url":"git@github.com:jipanyang/sonic-utilities.git","clone_url":"https://github.com/jipanyang/sonic-utilities.git","svn_url":"https://github.com/jipanyang/sonic-utilities","homepage":null,"size":590,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"98add9e9a10fddcaadb9e23d358bbc61ccebace9","user":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":53515393,"node_id":"MDEwOlJlcG9zaXRvcnk1MzUxNTM5Mw==","name":"sonic-utilities","full_name":"Azure/sonic-utilities","owner":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/sonic-utilities","description":"Command line utilities for the SONiC project","fork":false,"url":"https://api.github.com/repos/Azure/sonic-utilities","forks_url":"https://api.github.com/repos/Azure/sonic-utilities/forks","keys_url":"https://api.github.com/repos/Azure/sonic-utilities/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/sonic-utilities/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/sonic-utilities/teams","hooks_url":"https://api.github.com/repos/Azure/sonic-utilities/hooks","issue_events_url":"https://api.github.com/repos/Azure/sonic-utilities/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/sonic-utilities/events","assignees_url":"https://api.github.com/repos/Azure/sonic-utilities/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/sonic-utilities/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/sonic-utilities/tags","blobs_url":"https://api.github.com/repos/Azure/sonic-utilities/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/sonic-utilities/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/sonic-utilities/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/sonic-utilities/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/sonic-utilities/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/sonic-utilities/languages","stargazers_url":"https://api.github.com/repos/Azure/sonic-utilities/stargazers","contributors_url":"https://api.github.com/repos/Azure/sonic-utilities/contributors","subscribers_url":"https://api.github.com/repos/Azure/sonic-utilities/subscribers","subscription_url":"https://api.github.com/repos/Azure/sonic-utilities/subscription","commits_url":"https://api.github.com/repos/Azure/sonic-utilities/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/sonic-utilities/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/sonic-utilities/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/sonic-utilities/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/sonic-utilities/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/sonic-utilities/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/sonic-utilities/merges","archive_url":"https://api.github.com/repos/Azure/sonic-utilities/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/sonic-utilities/downloads","issues_url":"https://api.github.com/repos/Azure/sonic-utilities/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/sonic-utilities/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/sonic-utilities/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/sonic-utilities/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/sonic-utilities/labels{/name}","releases_url":"https://api.github.com/repos/Azure/sonic-utilities/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/sonic-utilities/deployments","created_at":"2016-03-09T16:59:59Z","updated_at":"2018-09-09T03:18:13Z","pushed_at":"2018-09-10T20:16:52Z","git_url":"git://github.com/Azure/sonic-utilities.git","ssh_url":"git@github.com:Azure/sonic-utilities.git","clone_url":"https://github.com/Azure/sonic-utilities.git","svn_url":"https://github.com/Azure/sonic-utilities","homepage":null,"size":557,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":51,"mirror_url":null,"archived":false,"open_issues_count":46,"license":null,"forks":51,"open_issues":46,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/sonic-utilities/pulls/294"},"html":{"href":"https://github.com/Azure/sonic-utilities/pull/294"},"issue":{"href":"https://api.github.com/repos/Azure/sonic-utilities/issues/294"},"comments":{"href":"https://api.github.com/repos/Azure/sonic-utilities/issues/294/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/sonic-utilities/pulls/294/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/sonic-utilities/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/sonic-utilities/pulls/294/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/sonic-utilities/statuses/0df3ae51197842ea1e2e033246e41d94c7cae161"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jipanyang"}}