{"action":"created","comment":{"url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments/60065137","id":60065137,"diff_hunk":"@@ -0,0 +1,108 @@\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 time\n+\n+from st2actions.runners.pythonrunner import Action\n+from orionsdk import SwisClient\n+\n+\n+class OrionBaseAction(Action):\n+    def __init__(self, config):\n+        super(OrionBaseAction, self).__init__(config)\n+\n+        self.swis = None\n+\n+        if \"orion\" not in self.config:\n+            raise ValueError(\"Orion host details not in the config.yaml\")\n+\n+    def connect(self, platform):\n+        try:\n+            self.swis = SwisClient(self.config['orion'][platform]['host'],\n+                                   self.config['orion'][platform]['user'],\n+                                   self.config['orion'][platform]['password'])\n+        except KeyError:\n+            raise ValueError(\"Orion host details not in the config.yaml\")\n+\n+    def query(self, swql, **kargs):\n+        return self.swis.query(swql, **kargs)\n+\n+    def invoke(self, entity, verb, *args):\n+        return self.swis.invoke(entity, verb, *args)\n+\n+    def get_ncm_node_id(self, caption):\n+        swql = \"SELECT NodeID FROM Cirrus.Nodes WHERE NodeCaption=@node\"\n+        kargs = {'node': caption}\n+        data = self.query(swql, **kargs)\n+\n+        if len(data['results']) == 1:\n+            try:\n+                return data['results'][0]['NodeID']\n+            except IndexError:\n+                raise IndexError(\"Invalid Node\")\n+        elif len(data['results']) >= 2:\n+            raise IndexError(\"Muliple Nodes match '{}' NodeCaption\".format(\n+                caption))\n+        elif len(data['results']) == 0:\n+            raise IndexError(\"No matching NodeCaption for '{}'\".format(\n+                caption))\n+\n+    def get_ncm_transfer_results(self, transfer_id):\n+        ts = {}\n+        while True:\n+            swql = \"\"\"SELECT TransferID, Action, Status, ErrorMessage,\n+            DeviceOutput FROM NCM.TransferResults\n+            WHERE TransferID=@transfer_id\"\"\"\n+            kargs = {'transfer_id': transfer_id}\n+\n+            transfer_data = self.query(swql, **kargs)\n+            status = transfer_data['results'][0]['Status']\n+\n+            if status == 1:\n+                time.sleep(10)","path":"packs/orion/actions/lib/actions.py","position":175,"original_position":74,"commit_id":"c34b4de42c56292fefeb3e0ef25ef851a14841d1","original_commit_id":"a77601350b8694dcd090f6134a3c0fc54ca0e6db","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":"This still applies :)\r\n\r\nIt's also probably a good idea to make sleep delay user-configurable via method argument and action parameter...","created_at":"2016-04-18T14:14:09Z","updated_at":"2016-04-18T14:14:09Z","html_url":"https://github.com/StackStorm/st2contrib/pull/466#discussion_r60065137","pull_request_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/466","_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments/60065137"},"html":{"href":"https://github.com/StackStorm/st2contrib/pull/466#discussion_r60065137"},"pull_request":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/466"}}},"pull_request":{"url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/466","id":65294995,"html_url":"https://github.com/StackStorm/st2contrib/pull/466","diff_url":"https://github.com/StackStorm/st2contrib/pull/466.diff","patch_url":"https://github.com/StackStorm/st2contrib/pull/466.patch","issue_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/466","number":466,"state":"open","locked":false,"title":"Add Solarwinds 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":"## Orion\r\n\r\n### Status \r\n\r\nAlmost complete, just review comments and testing left.\r\n\r\n- new pack, work in progress\r\n\r\n### Description\r\n\r\nAdd pack for integrating with the Solarwinds Orion monitoring platform.\r\n\r\n### Checklist (tick everything that applies)\r\n\r\n- [X] Metadata: pack.yaml, icon, structure (required for new packs)\r\n- [X] Version bump (required for changed packs)\r\n- [X] Code linting (required, can be done after the PR checks)\r\n- [ ] Tests (not required but really recommended)\r\n- [X] Add more actions & alaises.\r\n- [x] Refactor actions to use lib.\r\n- [ ] Pack installs from GitHub.","created_at":"2016-04-05T12:21:52Z","updated_at":"2016-04-18T14:14:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee76ea27d0b5552458cce71922982076ac45747c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/466/commits","review_comments_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/466/comments","review_comment_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/466/comments","statuses_url":"https://api.github.com/repos/StackStorm/st2contrib/statuses/c34b4de42c56292fefeb3e0ef25ef851a14841d1","head":{"label":"Pulsant:jjm/add-orion-pack","ref":"jjm/add-orion-pack","sha":"c34b4de42c56292fefeb3e0ef25ef851a14841d1","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-04-18T13:35:07Z","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":5146,"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":"7945a6cef82f5e69885a05e9f5c74ade4b8709cc","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-04-08T14:41:30Z","pushed_at":"2016-04-18T13:35:08Z","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":6273,"stargazers_count":80,"watchers_count":80,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":90,"mirror_url":null,"open_issues_count":27,"forks":90,"open_issues":27,"watchers":80,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/466"},"html":{"href":"https://github.com/StackStorm/st2contrib/pull/466"},"issue":{"href":"https://api.github.com/repos/StackStorm/st2contrib/issues/466"},"comments":{"href":"https://api.github.com/repos/StackStorm/st2contrib/issues/466/comments"},"review_comments":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/466/comments"},"review_comment":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/466/commits"},"statuses":{"href":"https://api.github.com/repos/StackStorm/st2contrib/statuses/c34b4de42c56292fefeb3e0ef25ef851a14841d1"}}}}