{"action":"created","comment":{"url":"https://api.github.com/repos/Mirantis/kqueen/pulls/comments/189559842","pull_request_review_id":121760751,"id":189559842,"diff_hunk":"@@ -0,0 +1,178 @@\n+from collections import namedtuple\n+import importlib\n+import yaml\n+import logging\n+import sys\n+import os\n+\n+from kqueen.config import current_config\n+import openstack\n+\n+from .base import BaseEngine\n+\n+logger = logging.getLogger('kqueen_api')\n+config = current_config()\n+\n+\n+STATE_MAP = {\n+    'IN_PROGRESS': config.get('CLUSTER_PROVISIONING_STATE'),\n+    'COMPLETE': config.get('CLUSTER_OK_STATE'),\n+}\n+\n+\n+class Heat:\n+    templates = {\n+        \"default\": \"kqueen.engines.resources.heat.default\",\n+        \"empty\": \"kqueen.engines.resources.heat.empty\",\n+    }\n+\n+    def __init__(self, **kwargs):\n+        self.connection = openstack.connection.Connection(**kwargs)\n+\n+    def _get_template_and_files(self, name):\n+        # NOTE(sskripnick)\n+        # we need to custom load and decode all files because of this bug:\n+        # https://storyboard.openstack.org/#!/story/2002002\n+        package = importlib.import_module(self.templates[name])\n+        path = list(package.__path__)[0]\n+        files = {}\n+        for root, dirs, _files in os.walk(path):\n+            for f in _files:\n+                fpath = os.path.join(root, f)\n+                files[\"file://\" + fpath] = open(fpath, \"rb\").read().decode(\"utf8\")\n+        return os.path.join(path, \"template.yaml\"), files\n+\n+    def create(self, *, name, template_name, ssh_key_name, server_image):\n+        template_file, files = self._get_template_and_files(template_name)\n+        try:\n+            self.connection.create_stack(\n+                name=name,\n+                template_file=template_file,\n+                files=files,\n+                ssh_key_name=ssh_key_name,\n+                server_image=server_image,\n+            )\n+        except openstack.exceptions.BadRequestException as e:\n+            # NOTE(sskripnick)\n+            # handle this exception separately because useful information\n+            # may be found only in e.details\n+            logger.exception(\"Failed to create stack: %s\" % e.details)","path":"kqueen/engines/heat.py","position":59,"original_position":59,"commit_id":"faa90a7f69c6a1e367b95191750b2c576d5a12e0","original_commit_id":"faa90a7f69c6a1e367b95191750b2c576d5a12e0","user":{"login":"katyafervent","id":4489907,"avatar_url":"https://avatars3.githubusercontent.com/u/4489907?v=4","gravatar_id":"","url":"https://api.github.com/users/katyafervent","html_url":"https://github.com/katyafervent","followers_url":"https://api.github.com/users/katyafervent/followers","following_url":"https://api.github.com/users/katyafervent/following{/other_user}","gists_url":"https://api.github.com/users/katyafervent/gists{/gist_id}","starred_url":"https://api.github.com/users/katyafervent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katyafervent/subscriptions","organizations_url":"https://api.github.com/users/katyafervent/orgs","repos_url":"https://api.github.com/users/katyafervent/repos","events_url":"https://api.github.com/users/katyafervent/events{/privacy}","received_events_url":"https://api.github.com/users/katyafervent/received_events","type":"User","site_admin":false},"body":"https://docs.python.org/3.1/library/string.html#format-examples\r\nIt is officially old","created_at":"2018-05-21T11:09:51Z","updated_at":"2018-05-21T11:09:52Z","html_url":"https://github.com/Mirantis/kqueen/pull/295#discussion_r189559842","pull_request_url":"https://api.github.com/repos/Mirantis/kqueen/pulls/295","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Mirantis/kqueen/pulls/comments/189559842"},"html":{"href":"https://github.com/Mirantis/kqueen/pull/295#discussion_r189559842"},"pull_request":{"href":"https://api.github.com/repos/Mirantis/kqueen/pulls/295"}},"in_reply_to_id":187937591},"pull_request":{"url":"https://api.github.com/repos/Mirantis/kqueen/pulls/295","id":187804059,"html_url":"https://github.com/Mirantis/kqueen/pull/295","diff_url":"https://github.com/Mirantis/kqueen/pull/295.diff","patch_url":"https://github.com/Mirantis/kqueen/pull/295.patch","issue_url":"https://api.github.com/repos/Mirantis/kqueen/issues/295","number":295,"state":"open","locked":false,"title":"WIP: Heat engine","user":{"login":"redixin","id":103634,"avatar_url":"https://avatars2.githubusercontent.com/u/103634?v=4","gravatar_id":"","url":"https://api.github.com/users/redixin","html_url":"https://github.com/redixin","followers_url":"https://api.github.com/users/redixin/followers","following_url":"https://api.github.com/users/redixin/following{/other_user}","gists_url":"https://api.github.com/users/redixin/gists{/gist_id}","starred_url":"https://api.github.com/users/redixin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redixin/subscriptions","organizations_url":"https://api.github.com/users/redixin/orgs","repos_url":"https://api.github.com/users/redixin/repos","events_url":"https://api.github.com/users/redixin/events{/privacy}","received_events_url":"https://api.github.com/users/redixin/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-14T12:00:01Z","updated_at":"2018-05-21T11:09:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1c3c81e52e9db6a6c38cec495a052f3af0fe77a8","assignee":null,"assignees":[],"requested_reviewers":[{"login":"atengler","id":11465219,"avatar_url":"https://avatars2.githubusercontent.com/u/11465219?v=4","gravatar_id":"","url":"https://api.github.com/users/atengler","html_url":"https://github.com/atengler","followers_url":"https://api.github.com/users/atengler/followers","following_url":"https://api.github.com/users/atengler/following{/other_user}","gists_url":"https://api.github.com/users/atengler/gists{/gist_id}","starred_url":"https://api.github.com/users/atengler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atengler/subscriptions","organizations_url":"https://api.github.com/users/atengler/orgs","repos_url":"https://api.github.com/users/atengler/repos","events_url":"https://api.github.com/users/atengler/events{/privacy}","received_events_url":"https://api.github.com/users/atengler/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":736125985,"url":"https://api.github.com/repos/Mirantis/kqueen/labels/P1%20-%20top","name":"P1 - top","color":"a9f477","default":false},{"id":721349400,"url":"https://api.github.com/repos/Mirantis/kqueen/labels/WIP","name":"WIP","color":"f9e172","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Mirantis/kqueen/pulls/295/commits","review_comments_url":"https://api.github.com/repos/Mirantis/kqueen/pulls/295/comments","review_comment_url":"https://api.github.com/repos/Mirantis/kqueen/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Mirantis/kqueen/issues/295/comments","statuses_url":"https://api.github.com/repos/Mirantis/kqueen/statuses/faa90a7f69c6a1e367b95191750b2c576d5a12e0","head":{"label":"redixin:heat","ref":"heat","sha":"faa90a7f69c6a1e367b95191750b2c576d5a12e0","user":{"login":"redixin","id":103634,"avatar_url":"https://avatars2.githubusercontent.com/u/103634?v=4","gravatar_id":"","url":"https://api.github.com/users/redixin","html_url":"https://github.com/redixin","followers_url":"https://api.github.com/users/redixin/followers","following_url":"https://api.github.com/users/redixin/following{/other_user}","gists_url":"https://api.github.com/users/redixin/gists{/gist_id}","starred_url":"https://api.github.com/users/redixin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redixin/subscriptions","organizations_url":"https://api.github.com/users/redixin/orgs","repos_url":"https://api.github.com/users/redixin/repos","events_url":"https://api.github.com/users/redixin/events{/privacy}","received_events_url":"https://api.github.com/users/redixin/received_events","type":"User","site_admin":false},"repo":{"id":129886549,"name":"kqueen","full_name":"redixin/kqueen","owner":{"login":"redixin","id":103634,"avatar_url":"https://avatars2.githubusercontent.com/u/103634?v=4","gravatar_id":"","url":"https://api.github.com/users/redixin","html_url":"https://github.com/redixin","followers_url":"https://api.github.com/users/redixin/followers","following_url":"https://api.github.com/users/redixin/following{/other_user}","gists_url":"https://api.github.com/users/redixin/gists{/gist_id}","starred_url":"https://api.github.com/users/redixin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redixin/subscriptions","organizations_url":"https://api.github.com/users/redixin/orgs","repos_url":"https://api.github.com/users/redixin/repos","events_url":"https://api.github.com/users/redixin/events{/privacy}","received_events_url":"https://api.github.com/users/redixin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/redixin/kqueen","description":"Kubernetes queen - cluster manager","fork":true,"url":"https://api.github.com/repos/redixin/kqueen","forks_url":"https://api.github.com/repos/redixin/kqueen/forks","keys_url":"https://api.github.com/repos/redixin/kqueen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/redixin/kqueen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/redixin/kqueen/teams","hooks_url":"https://api.github.com/repos/redixin/kqueen/hooks","issue_events_url":"https://api.github.com/repos/redixin/kqueen/issues/events{/number}","events_url":"https://api.github.com/repos/redixin/kqueen/events","assignees_url":"https://api.github.com/repos/redixin/kqueen/assignees{/user}","branches_url":"https://api.github.com/repos/redixin/kqueen/branches{/branch}","tags_url":"https://api.github.com/repos/redixin/kqueen/tags","blobs_url":"https://api.github.com/repos/redixin/kqueen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/redixin/kqueen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/redixin/kqueen/git/refs{/sha}","trees_url":"https://api.github.com/repos/redixin/kqueen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/redixin/kqueen/statuses/{sha}","languages_url":"https://api.github.com/repos/redixin/kqueen/languages","stargazers_url":"https://api.github.com/repos/redixin/kqueen/stargazers","contributors_url":"https://api.github.com/repos/redixin/kqueen/contributors","subscribers_url":"https://api.github.com/repos/redixin/kqueen/subscribers","subscription_url":"https://api.github.com/repos/redixin/kqueen/subscription","commits_url":"https://api.github.com/repos/redixin/kqueen/commits{/sha}","git_commits_url":"https://api.github.com/repos/redixin/kqueen/git/commits{/sha}","comments_url":"https://api.github.com/repos/redixin/kqueen/comments{/number}","issue_comment_url":"https://api.github.com/repos/redixin/kqueen/issues/comments{/number}","contents_url":"https://api.github.com/repos/redixin/kqueen/contents/{+path}","compare_url":"https://api.github.com/repos/redixin/kqueen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/redixin/kqueen/merges","archive_url":"https://api.github.com/repos/redixin/kqueen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/redixin/kqueen/downloads","issues_url":"https://api.github.com/repos/redixin/kqueen/issues{/number}","pulls_url":"https://api.github.com/repos/redixin/kqueen/pulls{/number}","milestones_url":"https://api.github.com/repos/redixin/kqueen/milestones{/number}","notifications_url":"https://api.github.com/repos/redixin/kqueen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/redixin/kqueen/labels{/name}","releases_url":"https://api.github.com/repos/redixin/kqueen/releases{/id}","deployments_url":"https://api.github.com/repos/redixin/kqueen/deployments","created_at":"2018-04-17T10:19:31Z","updated_at":"2018-04-17T10:19:33Z","pushed_at":"2018-05-14T09:45:43Z","git_url":"git://github.com/redixin/kqueen.git","ssh_url":"git@github.com:redixin/kqueen.git","clone_url":"https://github.com/redixin/kqueen.git","svn_url":"https://github.com/redixin/kqueen","homepage":"","size":2922,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Mirantis:master","ref":"master","sha":"6e0a54da8d7507c331a4cecb4f1633d7512f4910","user":{"login":"Mirantis","id":609319,"avatar_url":"https://avatars2.githubusercontent.com/u/609319?v=4","gravatar_id":"","url":"https://api.github.com/users/Mirantis","html_url":"https://github.com/Mirantis","followers_url":"https://api.github.com/users/Mirantis/followers","following_url":"https://api.github.com/users/Mirantis/following{/other_user}","gists_url":"https://api.github.com/users/Mirantis/gists{/gist_id}","starred_url":"https://api.github.com/users/Mirantis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mirantis/subscriptions","organizations_url":"https://api.github.com/users/Mirantis/orgs","repos_url":"https://api.github.com/users/Mirantis/repos","events_url":"https://api.github.com/users/Mirantis/events{/privacy}","received_events_url":"https://api.github.com/users/Mirantis/received_events","type":"Organization","site_admin":false},"repo":{"id":104763063,"name":"kqueen","full_name":"Mirantis/kqueen","owner":{"login":"Mirantis","id":609319,"avatar_url":"https://avatars2.githubusercontent.com/u/609319?v=4","gravatar_id":"","url":"https://api.github.com/users/Mirantis","html_url":"https://github.com/Mirantis","followers_url":"https://api.github.com/users/Mirantis/followers","following_url":"https://api.github.com/users/Mirantis/following{/other_user}","gists_url":"https://api.github.com/users/Mirantis/gists{/gist_id}","starred_url":"https://api.github.com/users/Mirantis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mirantis/subscriptions","organizations_url":"https://api.github.com/users/Mirantis/orgs","repos_url":"https://api.github.com/users/Mirantis/repos","events_url":"https://api.github.com/users/Mirantis/events{/privacy}","received_events_url":"https://api.github.com/users/Mirantis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Mirantis/kqueen","description":"Kubernetes queen - cluster manager","fork":false,"url":"https://api.github.com/repos/Mirantis/kqueen","forks_url":"https://api.github.com/repos/Mirantis/kqueen/forks","keys_url":"https://api.github.com/repos/Mirantis/kqueen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mirantis/kqueen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mirantis/kqueen/teams","hooks_url":"https://api.github.com/repos/Mirantis/kqueen/hooks","issue_events_url":"https://api.github.com/repos/Mirantis/kqueen/issues/events{/number}","events_url":"https://api.github.com/repos/Mirantis/kqueen/events","assignees_url":"https://api.github.com/repos/Mirantis/kqueen/assignees{/user}","branches_url":"https://api.github.com/repos/Mirantis/kqueen/branches{/branch}","tags_url":"https://api.github.com/repos/Mirantis/kqueen/tags","blobs_url":"https://api.github.com/repos/Mirantis/kqueen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mirantis/kqueen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mirantis/kqueen/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mirantis/kqueen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mirantis/kqueen/statuses/{sha}","languages_url":"https://api.github.com/repos/Mirantis/kqueen/languages","stargazers_url":"https://api.github.com/repos/Mirantis/kqueen/stargazers","contributors_url":"https://api.github.com/repos/Mirantis/kqueen/contributors","subscribers_url":"https://api.github.com/repos/Mirantis/kqueen/subscribers","subscription_url":"https://api.github.com/repos/Mirantis/kqueen/subscription","commits_url":"https://api.github.com/repos/Mirantis/kqueen/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mirantis/kqueen/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mirantis/kqueen/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mirantis/kqueen/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mirantis/kqueen/contents/{+path}","compare_url":"https://api.github.com/repos/Mirantis/kqueen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mirantis/kqueen/merges","archive_url":"https://api.github.com/repos/Mirantis/kqueen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mirantis/kqueen/downloads","issues_url":"https://api.github.com/repos/Mirantis/kqueen/issues{/number}","pulls_url":"https://api.github.com/repos/Mirantis/kqueen/pulls{/number}","milestones_url":"https://api.github.com/repos/Mirantis/kqueen/milestones{/number}","notifications_url":"https://api.github.com/repos/Mirantis/kqueen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mirantis/kqueen/labels{/name}","releases_url":"https://api.github.com/repos/Mirantis/kqueen/releases{/id}","deployments_url":"https://api.github.com/repos/Mirantis/kqueen/deployments","created_at":"2017-09-25T14:47:07Z","updated_at":"2018-05-18T14:01:05Z","pushed_at":"2018-05-21T07:45:19Z","git_url":"git://github.com/Mirantis/kqueen.git","ssh_url":"git@github.com:Mirantis/kqueen.git","clone_url":"https://github.com/Mirantis/kqueen.git","svn_url":"https://github.com/Mirantis/kqueen","homepage":"","size":3034,"stargazers_count":47,"watchers_count":47,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":24,"mirror_url":null,"archived":false,"open_issues_count":36,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":24,"open_issues":36,"watchers":47,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Mirantis/kqueen/pulls/295"},"html":{"href":"https://github.com/Mirantis/kqueen/pull/295"},"issue":{"href":"https://api.github.com/repos/Mirantis/kqueen/issues/295"},"comments":{"href":"https://api.github.com/repos/Mirantis/kqueen/issues/295/comments"},"review_comments":{"href":"https://api.github.com/repos/Mirantis/kqueen/pulls/295/comments"},"review_comment":{"href":"https://api.github.com/repos/Mirantis/kqueen/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Mirantis/kqueen/pulls/295/commits"},"statuses":{"href":"https://api.github.com/repos/Mirantis/kqueen/statuses/faa90a7f69c6a1e367b95191750b2c576d5a12e0"}},"author_association":"NONE"}}
{"actor":{"display_login":"katyafervent"}}