{"action":"created","comment":{"url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments/63488621","id":63488621,"diff_hunk":"@@ -0,0 +1,91 @@\n+# Licensed to the StackStorm, Inc ('StackStorm') under one or more\n+# contributor license agreements.  See the NOTICE file distributed with\n+# this work for additional information regarding copyright ownership.\n+# The ASF licenses this file to You under the Apache License, Version 2.0\n+# (the \"License\"); you may not use this file except in compliance with\n+# the License.  You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+import re\n+import operator\n+\n+\n+def status_code_to_text(status):\n+    \"\"\"\n+    Takes an Solarwinds Orion status code and translates it to\n+    human text and also a colour that can be used in Slack.\n+    \"\"\"\n+\n+    if status == 0:\n+        return (\"Unknown\", None)  # aka slack 'grey'\n+    elif status == 1:\n+        return (\"Up\", \"#00ad52\")  # aka slack 'good'\n+    elif status == 2:\n+        return (\"Down\", \"#eb0000\")  # aka slack 'danger'\n+    elif status == 3:\n+        return (\"Warning\", \"#e89e0e\")  # aka slack 'warning'\n+    elif status == 14:\n+        return (\"Critical\", \"#eb0000\")  # aka slack 'danger'\n+\n+\n+def send_user_error(message):\n+    \"\"\"\n+    Prints an user error message.\n+    \"\"\"\n+    print(message)\n+\n+\n+def discovery_status_to_text(status):\n+    \"\"\"\n+    Convert a Discovery Status code into meaningful text.\n+\n+    Args:\n+       status: Staus code from Orion.\n+\n+    Returns:\n+       String: Human text for status code.\n+    \"\"\"\n+    discovery_statuses = {\"0\": 'Unknown',\n+                          \"1\": 'InProgress',\n+                          \"2\": 'Finished',\n+                          \"3\": 'Error',\n+                          \"4\": \"NotScheduled\",\n+                          \"5\": \"Scheduled\",\n+                          \"6\": \"NotCompleted\",\n+                          \"7\": \"Canceling\",\n+                          \"8\": \"ReadyForImport\"}\n+    return discovery_statuses[status]\n+\n+\n+def is_ip(ip_address):","path":"packs/orion/actions/lib/utils.py","position":67,"original_position":67,"commit_id":"0b9ff28476f0c09c92a35136318e42edc10f7231","original_commit_id":"0b9ff28476f0c09c92a35136318e42edc10f7231","user":{"login":"Kami","id":125088,"avatar_url":"https://avatars.githubusercontent.com/u/125088?v=3","gravatar_id":"","url":"https://api.github.com/users/Kami","html_url":"https://github.com/Kami","followers_url":"https://api.github.com/users/Kami/followers","following_url":"https://api.github.com/users/Kami/following{/other_user}","gists_url":"https://api.github.com/users/Kami/gists{/gist_id}","starred_url":"https://api.github.com/users/Kami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kami/subscriptions","organizations_url":"https://api.github.com/users/Kami/orgs","repos_url":"https://api.github.com/users/Kami/repos","events_url":"https://api.github.com/users/Kami/events{/privacy}","received_events_url":"https://api.github.com/users/Kami/received_events","type":"User","site_admin":false},"body":"If you want to avoid using regexes, you can also use `socket` module as shown here - https://github.com/apache/libcloud/blob/trunk/libcloud/utils/networking.py#L66\r\n\r\nOnly downside of this approach is that IPv6 checking isn't supported on Windows.","created_at":"2016-05-17T09:13:15Z","updated_at":"2016-05-17T09:13:15Z","html_url":"https://github.com/StackStorm/st2contrib/pull/487#discussion_r63488621","pull_request_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/487","_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments/63488621"},"html":{"href":"https://github.com/StackStorm/st2contrib/pull/487#discussion_r63488621"},"pull_request":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/487"}}},"pull_request":{"url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/487","id":68699981,"html_url":"https://github.com/StackStorm/st2contrib/pull/487","diff_url":"https://github.com/StackStorm/st2contrib/pull/487.diff","patch_url":"https://github.com/StackStorm/st2contrib/pull/487.patch","issue_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/487","number":487,"state":"open","locked":false,"title":"Additional actions, aliases, rule and testing for the Orion Pack","user":{"login":"jjm","id":11451,"avatar_url":"https://avatars.githubusercontent.com/u/11451?v=3","gravatar_id":"","url":"https://api.github.com/users/jjm","html_url":"https://github.com/jjm","followers_url":"https://api.github.com/users/jjm/followers","following_url":"https://api.github.com/users/jjm/following{/other_user}","gists_url":"https://api.github.com/users/jjm/gists{/gist_id}","starred_url":"https://api.github.com/users/jjm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjm/subscriptions","organizations_url":"https://api.github.com/users/jjm/orgs","repos_url":"https://api.github.com/users/jjm/repos","events_url":"https://api.github.com/users/jjm/events{/privacy}","received_events_url":"https://api.github.com/users/jjm/received_events","type":"User","site_admin":false},"body":"## Pack Orion\r\n\r\n### Status \r\n\r\n- pack extension (Complete),\r\n\r\n### Description\r\n\r\nExtend the Orion pack with new action, rules and expand testing and docs. \r\n\r\n### Checklist (tick everything that applies)\r\n\r\n- [X] Version bump (required for changed packs)\r\n- [x] Code linting (required, can be done after the PR checks)\r\n- [x] [Tests](https://docs.stackstorm.com/development/pack_testing.html) (not required but really recommended).\r\n- [x] Completed additions highlighted in the README.\r\n- [x] Replace slack color names in action/lib/actions.py with hex strings (aka keep @emedvedev happy).\r\n- [x] Docstring's for actions.\r\n","created_at":"2016-05-03T12:48:10Z","updated_at":"2016-05-17T09:13:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3594966559d037ea289e7f5648d8aba3c39b846f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/487/commits","review_comments_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/487/comments","review_comment_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/487/comments","statuses_url":"https://api.github.com/repos/StackStorm/st2contrib/statuses/0b9ff28476f0c09c92a35136318e42edc10f7231","head":{"label":"Pulsant:jjm/orion-additions-sprint8","ref":"jjm/orion-additions-sprint8","sha":"0b9ff28476f0c09c92a35136318e42edc10f7231","user":{"login":"Pulsant","id":11800783,"avatar_url":"https://avatars.githubusercontent.com/u/11800783?v=3","gravatar_id":"","url":"https://api.github.com/users/Pulsant","html_url":"https://github.com/Pulsant","followers_url":"https://api.github.com/users/Pulsant/followers","following_url":"https://api.github.com/users/Pulsant/following{/other_user}","gists_url":"https://api.github.com/users/Pulsant/gists{/gist_id}","starred_url":"https://api.github.com/users/Pulsant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pulsant/subscriptions","organizations_url":"https://api.github.com/users/Pulsant/orgs","repos_url":"https://api.github.com/users/Pulsant/repos","events_url":"https://api.github.com/users/Pulsant/events{/privacy}","received_events_url":"https://api.github.com/users/Pulsant/received_events","type":"Organization","site_admin":false},"repo":{"id":50573000,"name":"st2contrib","full_name":"Pulsant/st2contrib","owner":{"login":"Pulsant","id":11800783,"avatar_url":"https://avatars.githubusercontent.com/u/11800783?v=3","gravatar_id":"","url":"https://api.github.com/users/Pulsant","html_url":"https://github.com/Pulsant","followers_url":"https://api.github.com/users/Pulsant/followers","following_url":"https://api.github.com/users/Pulsant/following{/other_user}","gists_url":"https://api.github.com/users/Pulsant/gists{/gist_id}","starred_url":"https://api.github.com/users/Pulsant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pulsant/subscriptions","organizations_url":"https://api.github.com/users/Pulsant/orgs","repos_url":"https://api.github.com/users/Pulsant/repos","events_url":"https://api.github.com/users/Pulsant/events{/privacy}","received_events_url":"https://api.github.com/users/Pulsant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Pulsant/st2contrib","description":"StackStorm integration packs for many common tools and also helpful tools to build integrations and automations with StackStorm.","fork":true,"url":"https://api.github.com/repos/Pulsant/st2contrib","forks_url":"https://api.github.com/repos/Pulsant/st2contrib/forks","keys_url":"https://api.github.com/repos/Pulsant/st2contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Pulsant/st2contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Pulsant/st2contrib/teams","hooks_url":"https://api.github.com/repos/Pulsant/st2contrib/hooks","issue_events_url":"https://api.github.com/repos/Pulsant/st2contrib/issues/events{/number}","events_url":"https://api.github.com/repos/Pulsant/st2contrib/events","assignees_url":"https://api.github.com/repos/Pulsant/st2contrib/assignees{/user}","branches_url":"https://api.github.com/repos/Pulsant/st2contrib/branches{/branch}","tags_url":"https://api.github.com/repos/Pulsant/st2contrib/tags","blobs_url":"https://api.github.com/repos/Pulsant/st2contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Pulsant/st2contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Pulsant/st2contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/Pulsant/st2contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Pulsant/st2contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/Pulsant/st2contrib/languages","stargazers_url":"https://api.github.com/repos/Pulsant/st2contrib/stargazers","contributors_url":"https://api.github.com/repos/Pulsant/st2contrib/contributors","subscribers_url":"https://api.github.com/repos/Pulsant/st2contrib/subscribers","subscription_url":"https://api.github.com/repos/Pulsant/st2contrib/subscription","commits_url":"https://api.github.com/repos/Pulsant/st2contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/Pulsant/st2contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/Pulsant/st2contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/Pulsant/st2contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/Pulsant/st2contrib/contents/{+path}","compare_url":"https://api.github.com/repos/Pulsant/st2contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Pulsant/st2contrib/merges","archive_url":"https://api.github.com/repos/Pulsant/st2contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Pulsant/st2contrib/downloads","issues_url":"https://api.github.com/repos/Pulsant/st2contrib/issues{/number}","pulls_url":"https://api.github.com/repos/Pulsant/st2contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/Pulsant/st2contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/Pulsant/st2contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Pulsant/st2contrib/labels{/name}","releases_url":"https://api.github.com/repos/Pulsant/st2contrib/releases{/id}","deployments_url":"https://api.github.com/repos/Pulsant/st2contrib/deployments","created_at":"2016-01-28T09:47:09Z","updated_at":"2016-02-01T10:54:44Z","pushed_at":"2016-05-16T18:23:42Z","git_url":"git://github.com/Pulsant/st2contrib.git","ssh_url":"git@github.com:Pulsant/st2contrib.git","clone_url":"https://github.com/Pulsant/st2contrib.git","svn_url":"https://github.com/Pulsant/st2contrib","homepage":"http://www.stackstorm.com/community","size":5231,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"StackStorm:master","ref":"master","sha":"6703e9bc1373736f7381dd395f84adb4b4f83c86","user":{"login":"StackStorm","id":4969009,"avatar_url":"https://avatars.githubusercontent.com/u/4969009?v=3","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"repo":{"id":24968227,"name":"st2contrib","full_name":"StackStorm/st2contrib","owner":{"login":"StackStorm","id":4969009,"avatar_url":"https://avatars.githubusercontent.com/u/4969009?v=3","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/StackStorm/st2contrib","description":"StackStorm integration packs for many common tools and services. It also contains helpful tools to build integrations and automations with StackStorm.","fork":false,"url":"https://api.github.com/repos/StackStorm/st2contrib","forks_url":"https://api.github.com/repos/StackStorm/st2contrib/forks","keys_url":"https://api.github.com/repos/StackStorm/st2contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StackStorm/st2contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StackStorm/st2contrib/teams","hooks_url":"https://api.github.com/repos/StackStorm/st2contrib/hooks","issue_events_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/events{/number}","events_url":"https://api.github.com/repos/StackStorm/st2contrib/events","assignees_url":"https://api.github.com/repos/StackStorm/st2contrib/assignees{/user}","branches_url":"https://api.github.com/repos/StackStorm/st2contrib/branches{/branch}","tags_url":"https://api.github.com/repos/StackStorm/st2contrib/tags","blobs_url":"https://api.github.com/repos/StackStorm/st2contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StackStorm/st2contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StackStorm/st2contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/StackStorm/st2contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StackStorm/st2contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/StackStorm/st2contrib/languages","stargazers_url":"https://api.github.com/repos/StackStorm/st2contrib/stargazers","contributors_url":"https://api.github.com/repos/StackStorm/st2contrib/contributors","subscribers_url":"https://api.github.com/repos/StackStorm/st2contrib/subscribers","subscription_url":"https://api.github.com/repos/StackStorm/st2contrib/subscription","commits_url":"https://api.github.com/repos/StackStorm/st2contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/StackStorm/st2contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/StackStorm/st2contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/StackStorm/st2contrib/contents/{+path}","compare_url":"https://api.github.com/repos/StackStorm/st2contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StackStorm/st2contrib/merges","archive_url":"https://api.github.com/repos/StackStorm/st2contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StackStorm/st2contrib/downloads","issues_url":"https://api.github.com/repos/StackStorm/st2contrib/issues{/number}","pulls_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/StackStorm/st2contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/StackStorm/st2contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StackStorm/st2contrib/labels{/name}","releases_url":"https://api.github.com/repos/StackStorm/st2contrib/releases{/id}","deployments_url":"https://api.github.com/repos/StackStorm/st2contrib/deployments","created_at":"2014-10-09T01:19:56Z","updated_at":"2016-05-17T03:00:05Z","pushed_at":"2016-05-16T18:23:43Z","git_url":"git://github.com/StackStorm/st2contrib.git","ssh_url":"git@github.com:StackStorm/st2contrib.git","clone_url":"https://github.com/StackStorm/st2contrib.git","svn_url":"https://github.com/StackStorm/st2contrib","homepage":"http://www.stackstorm.com/community","size":6358,"stargazers_count":86,"watchers_count":86,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":94,"mirror_url":null,"open_issues_count":24,"forks":94,"open_issues":24,"watchers":86,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/487"},"html":{"href":"https://github.com/StackStorm/st2contrib/pull/487"},"issue":{"href":"https://api.github.com/repos/StackStorm/st2contrib/issues/487"},"comments":{"href":"https://api.github.com/repos/StackStorm/st2contrib/issues/487/comments"},"review_comments":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/487/comments"},"review_comment":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/487/commits"},"statuses":{"href":"https://api.github.com/repos/StackStorm/st2contrib/statuses/0b9ff28476f0c09c92a35136318e42edc10f7231"}}}}