{"action":"opened","number":98,"pull_request":{"url":"https://api.github.com/repos/brigade-automation/brigade/pulls/98","id":178689987,"html_url":"https://github.com/brigade-automation/brigade/pull/98","diff_url":"https://github.com/brigade-automation/brigade/pull/98.diff","patch_url":"https://github.com/brigade-automation/brigade/pull/98.patch","issue_url":"https://api.github.com/repos/brigade-automation/brigade/issues/98","number":98,"state":"open","locked":false,"title":"severity levels","user":{"login":"dbarrosop","id":6246622,"avatar_url":"https://avatars3.githubusercontent.com/u/6246622?v=4","gravatar_id":"","url":"https://api.github.com/users/dbarrosop","html_url":"https://github.com/dbarrosop","followers_url":"https://api.github.com/users/dbarrosop/followers","following_url":"https://api.github.com/users/dbarrosop/following{/other_user}","gists_url":"https://api.github.com/users/dbarrosop/gists{/gist_id}","starred_url":"https://api.github.com/users/dbarrosop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbarrosop/subscriptions","organizations_url":"https://api.github.com/users/dbarrosop/orgs","repos_url":"https://api.github.com/users/dbarrosop/repos","events_url":"https://api.github.com/users/dbarrosop/events{/privacy}","received_events_url":"https://api.github.com/users/dbarrosop/received_events","type":"User","site_admin":false},"body":"Two things:\r\n\r\n1. I have cleaned a bit the task logic because it was messy. Now the task logic is only in the `start` method. There is still some room for cleaning some logic but I will leave it for now.\r\n2. I have added the concept of \"severity levels\". This way you can mark tasks and subtasks with different severity levels for various purposes. The most obvious ones are for the UI and the logs. You can use the following script to see how this works:\r\n\r\n```\r\nimport logging\r\n\r\nfrom brigade.core import Brigade\r\nfrom brigade.plugins.functions.text import print_result\r\nfrom brigade.plugins.inventory.simple import SimpleInventory\r\nfrom brigade.plugins.tasks import commands\r\n\r\n\r\ndef another_group_of_tasks(task):\r\n    task.run(task=commands.command,\r\n             command=\"echo 1. {}\".format(task.host),\r\n             severity=logging.INFO,\r\n             name=\"Task A\")\r\n    task.run(task=commands.command,\r\n             command=\"echo 1. {}\".format(task.host),\r\n             severity=logging.INFO,\r\n             name=\"Task B\")\r\n\r\n\r\ndef task_fails_for_some(task):\r\n    task.run(task=commands.command,\r\n             command=\"echo 1. {}\".format(task.host),\r\n             severity=logging.INFO,\r\n             name=\"Task 1\")\r\n    task.run(task=commands.command,\r\n             command=\"echo 2. {}\".format(task.host),\r\n             name=\"Task 2\")\r\n    task.run(another_group_of_tasks)\r\n    if task.host.name == \"dev3.group_2\":\r\n        # let's hardcode a failure\r\n        task.run(task=commands.command,\r\n                 command=\"sasdasdasd\",\r\n                 name=\"Task 3\")\r\n    else:\r\n        task.run(task=commands.command,\r\n                 command=\"echo 2. {}\".format(task.host),\r\n                 severity=logging.DEBUG,\r\n                 name=\"Task 3\")\r\n\r\n\r\nbrg = Brigade(\r\n    inventory=SimpleInventory(\"tests/inventory_data/hosts.yaml\",\r\n                              \"tests/inventory_data/groups.yaml\"),\r\n    dry_run=True,\r\n)\r\nresult = brg.run(task_fails_for_some)\r\nprint_result(result, severity_level=logging.INFO, vars=['stdout'])\r\n```\r\n\r\nJust change the `severity_level` in the `print_result` to `WARN`, `DEBUG`, etc... and see how tasks come and go from the UI.","created_at":"2018-03-31T16:36:33Z","updated_at":"2018-03-31T16:36:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/brigade-automation/brigade/pulls/98/commits","review_comments_url":"https://api.github.com/repos/brigade-automation/brigade/pulls/98/comments","review_comment_url":"https://api.github.com/repos/brigade-automation/brigade/pulls/comments{/number}","comments_url":"https://api.github.com/repos/brigade-automation/brigade/issues/98/comments","statuses_url":"https://api.github.com/repos/brigade-automation/brigade/statuses/97a97e3593ecf1294fa688139942db20a2958af0","head":{"label":"brigade-automation:print_levels","ref":"print_levels","sha":"97a97e3593ecf1294fa688139942db20a2958af0","user":{"login":"brigade-automation","id":37877297,"avatar_url":"https://avatars2.githubusercontent.com/u/37877297?v=4","gravatar_id":"","url":"https://api.github.com/users/brigade-automation","html_url":"https://github.com/brigade-automation","followers_url":"https://api.github.com/users/brigade-automation/followers","following_url":"https://api.github.com/users/brigade-automation/following{/other_user}","gists_url":"https://api.github.com/users/brigade-automation/gists{/gist_id}","starred_url":"https://api.github.com/users/brigade-automation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brigade-automation/subscriptions","organizations_url":"https://api.github.com/users/brigade-automation/orgs","repos_url":"https://api.github.com/users/brigade-automation/repos","events_url":"https://api.github.com/users/brigade-automation/events{/privacy}","received_events_url":"https://api.github.com/users/brigade-automation/received_events","type":"Organization","site_admin":false},"repo":{"id":76636028,"name":"brigade","full_name":"brigade-automation/brigade","owner":{"login":"brigade-automation","id":37877297,"avatar_url":"https://avatars2.githubusercontent.com/u/37877297?v=4","gravatar_id":"","url":"https://api.github.com/users/brigade-automation","html_url":"https://github.com/brigade-automation","followers_url":"https://api.github.com/users/brigade-automation/followers","following_url":"https://api.github.com/users/brigade-automation/following{/other_user}","gists_url":"https://api.github.com/users/brigade-automation/gists{/gist_id}","starred_url":"https://api.github.com/users/brigade-automation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brigade-automation/subscriptions","organizations_url":"https://api.github.com/users/brigade-automation/orgs","repos_url":"https://api.github.com/users/brigade-automation/repos","events_url":"https://api.github.com/users/brigade-automation/events{/privacy}","received_events_url":"https://api.github.com/users/brigade-automation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/brigade-automation/brigade","description":null,"fork":false,"url":"https://api.github.com/repos/brigade-automation/brigade","forks_url":"https://api.github.com/repos/brigade-automation/brigade/forks","keys_url":"https://api.github.com/repos/brigade-automation/brigade/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brigade-automation/brigade/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brigade-automation/brigade/teams","hooks_url":"https://api.github.com/repos/brigade-automation/brigade/hooks","issue_events_url":"https://api.github.com/repos/brigade-automation/brigade/issues/events{/number}","events_url":"https://api.github.com/repos/brigade-automation/brigade/events","assignees_url":"https://api.github.com/repos/brigade-automation/brigade/assignees{/user}","branches_url":"https://api.github.com/repos/brigade-automation/brigade/branches{/branch}","tags_url":"https://api.github.com/repos/brigade-automation/brigade/tags","blobs_url":"https://api.github.com/repos/brigade-automation/brigade/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brigade-automation/brigade/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brigade-automation/brigade/git/refs{/sha}","trees_url":"https://api.github.com/repos/brigade-automation/brigade/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brigade-automation/brigade/statuses/{sha}","languages_url":"https://api.github.com/repos/brigade-automation/brigade/languages","stargazers_url":"https://api.github.com/repos/brigade-automation/brigade/stargazers","contributors_url":"https://api.github.com/repos/brigade-automation/brigade/contributors","subscribers_url":"https://api.github.com/repos/brigade-automation/brigade/subscribers","subscription_url":"https://api.github.com/repos/brigade-automation/brigade/subscription","commits_url":"https://api.github.com/repos/brigade-automation/brigade/commits{/sha}","git_commits_url":"https://api.github.com/repos/brigade-automation/brigade/git/commits{/sha}","comments_url":"https://api.github.com/repos/brigade-automation/brigade/comments{/number}","issue_comment_url":"https://api.github.com/repos/brigade-automation/brigade/issues/comments{/number}","contents_url":"https://api.github.com/repos/brigade-automation/brigade/contents/{+path}","compare_url":"https://api.github.com/repos/brigade-automation/brigade/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brigade-automation/brigade/merges","archive_url":"https://api.github.com/repos/brigade-automation/brigade/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brigade-automation/brigade/downloads","issues_url":"https://api.github.com/repos/brigade-automation/brigade/issues{/number}","pulls_url":"https://api.github.com/repos/brigade-automation/brigade/pulls{/number}","milestones_url":"https://api.github.com/repos/brigade-automation/brigade/milestones{/number}","notifications_url":"https://api.github.com/repos/brigade-automation/brigade/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brigade-automation/brigade/labels{/name}","releases_url":"https://api.github.com/repos/brigade-automation/brigade/releases{/id}","deployments_url":"https://api.github.com/repos/brigade-automation/brigade/deployments","created_at":"2016-12-16T08:27:09Z","updated_at":"2018-03-30T08:44:48Z","pushed_at":"2018-03-31T16:30:13Z","git_url":"git://github.com/brigade-automation/brigade.git","ssh_url":"git@github.com:brigade-automation/brigade.git","clone_url":"https://github.com/brigade-automation/brigade.git","svn_url":"https://github.com/brigade-automation/brigade","homepage":"https://brigade.readthedocs.io/","size":1107,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":3,"open_issues":18,"watchers":14,"default_branch":"develop"}},"base":{"label":"brigade-automation:develop","ref":"develop","sha":"d7c247eafab5d5a8c2f458f610e1c2bee6ea6f7b","user":{"login":"brigade-automation","id":37877297,"avatar_url":"https://avatars2.githubusercontent.com/u/37877297?v=4","gravatar_id":"","url":"https://api.github.com/users/brigade-automation","html_url":"https://github.com/brigade-automation","followers_url":"https://api.github.com/users/brigade-automation/followers","following_url":"https://api.github.com/users/brigade-automation/following{/other_user}","gists_url":"https://api.github.com/users/brigade-automation/gists{/gist_id}","starred_url":"https://api.github.com/users/brigade-automation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brigade-automation/subscriptions","organizations_url":"https://api.github.com/users/brigade-automation/orgs","repos_url":"https://api.github.com/users/brigade-automation/repos","events_url":"https://api.github.com/users/brigade-automation/events{/privacy}","received_events_url":"https://api.github.com/users/brigade-automation/received_events","type":"Organization","site_admin":false},"repo":{"id":76636028,"name":"brigade","full_name":"brigade-automation/brigade","owner":{"login":"brigade-automation","id":37877297,"avatar_url":"https://avatars2.githubusercontent.com/u/37877297?v=4","gravatar_id":"","url":"https://api.github.com/users/brigade-automation","html_url":"https://github.com/brigade-automation","followers_url":"https://api.github.com/users/brigade-automation/followers","following_url":"https://api.github.com/users/brigade-automation/following{/other_user}","gists_url":"https://api.github.com/users/brigade-automation/gists{/gist_id}","starred_url":"https://api.github.com/users/brigade-automation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brigade-automation/subscriptions","organizations_url":"https://api.github.com/users/brigade-automation/orgs","repos_url":"https://api.github.com/users/brigade-automation/repos","events_url":"https://api.github.com/users/brigade-automation/events{/privacy}","received_events_url":"https://api.github.com/users/brigade-automation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/brigade-automation/brigade","description":null,"fork":false,"url":"https://api.github.com/repos/brigade-automation/brigade","forks_url":"https://api.github.com/repos/brigade-automation/brigade/forks","keys_url":"https://api.github.com/repos/brigade-automation/brigade/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brigade-automation/brigade/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brigade-automation/brigade/teams","hooks_url":"https://api.github.com/repos/brigade-automation/brigade/hooks","issue_events_url":"https://api.github.com/repos/brigade-automation/brigade/issues/events{/number}","events_url":"https://api.github.com/repos/brigade-automation/brigade/events","assignees_url":"https://api.github.com/repos/brigade-automation/brigade/assignees{/user}","branches_url":"https://api.github.com/repos/brigade-automation/brigade/branches{/branch}","tags_url":"https://api.github.com/repos/brigade-automation/brigade/tags","blobs_url":"https://api.github.com/repos/brigade-automation/brigade/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brigade-automation/brigade/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brigade-automation/brigade/git/refs{/sha}","trees_url":"https://api.github.com/repos/brigade-automation/brigade/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brigade-automation/brigade/statuses/{sha}","languages_url":"https://api.github.com/repos/brigade-automation/brigade/languages","stargazers_url":"https://api.github.com/repos/brigade-automation/brigade/stargazers","contributors_url":"https://api.github.com/repos/brigade-automation/brigade/contributors","subscribers_url":"https://api.github.com/repos/brigade-automation/brigade/subscribers","subscription_url":"https://api.github.com/repos/brigade-automation/brigade/subscription","commits_url":"https://api.github.com/repos/brigade-automation/brigade/commits{/sha}","git_commits_url":"https://api.github.com/repos/brigade-automation/brigade/git/commits{/sha}","comments_url":"https://api.github.com/repos/brigade-automation/brigade/comments{/number}","issue_comment_url":"https://api.github.com/repos/brigade-automation/brigade/issues/comments{/number}","contents_url":"https://api.github.com/repos/brigade-automation/brigade/contents/{+path}","compare_url":"https://api.github.com/repos/brigade-automation/brigade/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brigade-automation/brigade/merges","archive_url":"https://api.github.com/repos/brigade-automation/brigade/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brigade-automation/brigade/downloads","issues_url":"https://api.github.com/repos/brigade-automation/brigade/issues{/number}","pulls_url":"https://api.github.com/repos/brigade-automation/brigade/pulls{/number}","milestones_url":"https://api.github.com/repos/brigade-automation/brigade/milestones{/number}","notifications_url":"https://api.github.com/repos/brigade-automation/brigade/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brigade-automation/brigade/labels{/name}","releases_url":"https://api.github.com/repos/brigade-automation/brigade/releases{/id}","deployments_url":"https://api.github.com/repos/brigade-automation/brigade/deployments","created_at":"2016-12-16T08:27:09Z","updated_at":"2018-03-30T08:44:48Z","pushed_at":"2018-03-31T16:30:13Z","git_url":"git://github.com/brigade-automation/brigade.git","ssh_url":"git@github.com:brigade-automation/brigade.git","clone_url":"https://github.com/brigade-automation/brigade.git","svn_url":"https://github.com/brigade-automation/brigade","homepage":"https://brigade.readthedocs.io/","size":1107,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":3,"open_issues":18,"watchers":14,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/brigade-automation/brigade/pulls/98"},"html":{"href":"https://github.com/brigade-automation/brigade/pull/98"},"issue":{"href":"https://api.github.com/repos/brigade-automation/brigade/issues/98"},"comments":{"href":"https://api.github.com/repos/brigade-automation/brigade/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/brigade-automation/brigade/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/brigade-automation/brigade/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/brigade-automation/brigade/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/brigade-automation/brigade/statuses/97a97e3593ecf1294fa688139942db20a2958af0"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":6,"additions":111,"deletions":60,"changed_files":4}}
{"actor":{"display_login":"dbarrosop"}}