{"action":"created","comment":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/comments/81381663","pull_request_review_id":2367409,"id":81381663,"diff_hunk":"@@ -0,0 +1,320 @@\n+########\n+# Copyright (c) 2015 GigaSpaces Technologies Ltd. All rights reserved\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# 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+# Stdlib imports\n+\n+# Third party imports\n+\n+# Cloudify imports\n+from cloudify import ctx\n+from cloudify.decorators import operation\n+from cloudify.exceptions import NonRecoverableError\n+\n+# This package imports\n+from cloudify_aws import constants\n+from cloudify_aws.base import AwsBaseNode\n+from cloudify_aws.connection import EC2ConnectionClient\n+\n+\n+@operation\n+def create(args=None, **_):\n+    return Service().created(args)\n+\n+\n+@operation\n+def delete(args=None, **_):\n+    return Service().deleted(args)\n+\n+\n+class Service(AwsBaseNode):\n+    def __init__(self, client=None):\n+        client = client or EC2ConnectionClient().client3('ecs')\n+\n+        super(Service, self).__init__(\n+            constants.ECS_SERVICE['AWS_RESOURCE_TYPE'],\n+            constants.ECS_SERVICE['REQUIRED_PROPERTIES'],\n+            client=client,\n+            resource_id_key=constants.ECS_SERVICE['RESOURCE_ID_KEY'],\n+        )\n+\n+        self.not_found_error = constants.ECS_SERVICE['NOT_FOUND_ERROR']\n+\n+    def get_relationship_target(self, relationships, intended_relationship):\n+        target = None\n+\n+        for relationship in relationships:\n+            if relationship.type == intended_relationship:\n+                target = relationship.target\n+                break\n+\n+        return target\n+\n+    def get_target_attribute(self, relationships, from_relationship,\n+                             desired_attribute):\n+        target = self.get_relationship_target(relationships, from_relationship)\n+\n+        attr = None\n+\n+        if target is not None:\n+            attr = target.instance.runtime_properties.get(\n+                desired_attribute,\n+                None\n+            )\n+\n+        return attr\n+\n+    def get_target_property(self, relationships, from_relationship,\n+                            desired_property):\n+        target = self.get_relationship_target(relationships, from_relationship)\n+\n+        prop = None\n+\n+        if target is not None:\n+            prop = target.node.properties.get(\n+                desired_property,\n+                None\n+            )\n+\n+        return prop\n+\n+    def get_arn(self, relationships, from_relationship):\n+        return self.get_target_attribute(\n+            relationships=relationships,\n+            from_relationship=from_relationship,\n+            desired_attribute=constants.EXTERNAL_RESOURCE_ID,\n+        )\n+\n+    def get_related_elb_name(self, relationships):\n+        return self.get_target_property(\n+            relationships=relationships,\n+            from_relationship=(\n+                'cloudify.aws.relationships.ecs_service_behind_load_balancer'\n+            ),\n+            desired_property='elb_name',\n+        )\n+\n+    def get_container_instance_count(self, relationships):\n+        return self.get_target_attribute(\n+            relationships=relationships,\n+            from_relationship=(\n+                'cloudify.aws.relationships.ecs_service_running_on_cluster'\n+            ),\n+            desired_attribute='instances',\n+        )\n+\n+    def get_task_container_names(self, relationships):\n+        return self.get_target_attribute(\n+            relationships=relationships,\n+            from_relationship=(\n+                'cloudify.aws.relationships.ecs_service_runs_task'\n+            ),\n+            desired_attribute='container_names',\n+        )\n+\n+    def create(self, args=None, **_):\n+        # Don't try to do anything until the cluster has instances...\n+        container_instances = self.get_container_instance_count(\n+            ctx.instance.relationships,\n+        )\n+        if container_instances is None or len(container_instances) == 0:\n+            return ctx.operation.retry(\n+                'Waiting for cluster to have available instances.',\n+            )\n+\n+        cluster_arn = self.get_cluster_arn(self.get_arn(\n+            ctx.instance.relationships,\n+            'cloudify.aws.relationships.ecs_service_running_on_cluster',","path":"cloudify_aws/ecs/service.py","position":null,"original_position":138,"commit_id":"19dd8a7742c881371caeb9714053550b23598c5e","original_commit_id":"d77b6b8d5d3581a8d9b58e6af5c72274046414ce","user":{"login":"geokala","id":8859114,"avatar_url":"https://avatars.githubusercontent.com/u/8859114?v=3","gravatar_id":"","url":"https://api.github.com/users/geokala","html_url":"https://github.com/geokala","followers_url":"https://api.github.com/users/geokala/followers","following_url":"https://api.github.com/users/geokala/following{/other_user}","gists_url":"https://api.github.com/users/geokala/gists{/gist_id}","starred_url":"https://api.github.com/users/geokala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geokala/subscriptions","organizations_url":"https://api.github.com/users/geokala/orgs","repos_url":"https://api.github.com/users/geokala/repos","events_url":"https://api.github.com/users/geokala/events{/privacy}","received_events_url":"https://api.github.com/users/geokala/received_events","type":"User","site_admin":false},"body":"This is changed in the code, but apparently the new way of marking change requests doesn't update when the code is updated so I'm marking it with a comment so that I can see what I have left to deal with.","created_at":"2016-09-30T17:26:16Z","updated_at":"2016-09-30T17:26:16Z","html_url":"https://github.com/cloudify-cosmo/cloudify-aws-plugin/pull/161#discussion_r81381663","pull_request_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/161","_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/comments/81381663"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-aws-plugin/pull/161#discussion_r81381663"},"pull_request":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/161"}}},"pull_request":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/161","id":81217068,"html_url":"https://github.com/cloudify-cosmo/cloudify-aws-plugin/pull/161","diff_url":"https://github.com/cloudify-cosmo/cloudify-aws-plugin/pull/161.diff","patch_url":"https://github.com/cloudify-cosmo/cloudify-aws-plugin/pull/161.patch","issue_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/issues/161","number":161,"state":"open","locked":false,"title":"S3 and ECS poc","user":{"login":"geokala","id":8859114,"avatar_url":"https://avatars.githubusercontent.com/u/8859114?v=3","gravatar_id":"","url":"https://api.github.com/users/geokala","html_url":"https://github.com/geokala","followers_url":"https://api.github.com/users/geokala/followers","following_url":"https://api.github.com/users/geokala/following{/other_user}","gists_url":"https://api.github.com/users/geokala/gists{/gist_id}","starred_url":"https://api.github.com/users/geokala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geokala/subscriptions","organizations_url":"https://api.github.com/users/geokala/orgs","repos_url":"https://api.github.com/users/geokala/repos","events_url":"https://api.github.com/users/geokala/events{/privacy}","received_events_url":"https://api.github.com/users/geokala/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-13T14:30:40Z","updated_at":"2016-09-30T17:26:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96f1315054fa1883646385e55aaa058d07bf11ed","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/161/commits","review_comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/161/comments","review_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/issues/161/comments","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/statuses/19dd8a7742c881371caeb9714053550b23598c5e","head":{"label":"geokala:s3_and_ecs_poc","ref":"s3_and_ecs_poc","sha":"19dd8a7742c881371caeb9714053550b23598c5e","user":{"login":"geokala","id":8859114,"avatar_url":"https://avatars.githubusercontent.com/u/8859114?v=3","gravatar_id":"","url":"https://api.github.com/users/geokala","html_url":"https://github.com/geokala","followers_url":"https://api.github.com/users/geokala/followers","following_url":"https://api.github.com/users/geokala/following{/other_user}","gists_url":"https://api.github.com/users/geokala/gists{/gist_id}","starred_url":"https://api.github.com/users/geokala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geokala/subscriptions","organizations_url":"https://api.github.com/users/geokala/orgs","repos_url":"https://api.github.com/users/geokala/repos","events_url":"https://api.github.com/users/geokala/events{/privacy}","received_events_url":"https://api.github.com/users/geokala/received_events","type":"User","site_admin":false},"repo":{"id":62731976,"name":"cloudify-aws-plugin","full_name":"geokala/cloudify-aws-plugin","owner":{"login":"geokala","id":8859114,"avatar_url":"https://avatars.githubusercontent.com/u/8859114?v=3","gravatar_id":"","url":"https://api.github.com/users/geokala","html_url":"https://github.com/geokala","followers_url":"https://api.github.com/users/geokala/followers","following_url":"https://api.github.com/users/geokala/following{/other_user}","gists_url":"https://api.github.com/users/geokala/gists{/gist_id}","starred_url":"https://api.github.com/users/geokala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geokala/subscriptions","organizations_url":"https://api.github.com/users/geokala/orgs","repos_url":"https://api.github.com/users/geokala/repos","events_url":"https://api.github.com/users/geokala/events{/privacy}","received_events_url":"https://api.github.com/users/geokala/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/geokala/cloudify-aws-plugin","description":"A Cloudify Plugin that provisions resources in Amazon Web Services","fork":true,"url":"https://api.github.com/repos/geokala/cloudify-aws-plugin","forks_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/forks","keys_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/teams","hooks_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/hooks","issue_events_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/events","assignees_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/tags","blobs_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/languages","stargazers_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/stargazers","contributors_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/contributors","subscribers_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/subscribers","subscription_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/subscription","commits_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/merges","archive_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/downloads","issues_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/labels{/name}","releases_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/geokala/cloudify-aws-plugin/deployments","created_at":"2016-07-06T15:26:52Z","updated_at":"2016-07-06T15:26:53Z","pushed_at":"2016-09-30T17:18:52Z","git_url":"git://github.com/geokala/cloudify-aws-plugin.git","ssh_url":"git@github.com:geokala/cloudify-aws-plugin.git","clone_url":"https://github.com/geokala/cloudify-aws-plugin.git","svn_url":"https://github.com/geokala/cloudify-aws-plugin","homepage":null,"size":1026,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cloudify-cosmo:master","ref":"master","sha":"bd325b6c4d3142596825c361c223def5d685893f","user":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"repo":{"id":28482346,"name":"cloudify-aws-plugin","full_name":"cloudify-cosmo/cloudify-aws-plugin","owner":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudify-cosmo/cloudify-aws-plugin","description":"A Cloudify Plugin that provisions resources in Amazon Web Services","fork":false,"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin","forks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/forks","keys_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/teams","hooks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/hooks","issue_events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/events","assignees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/tags","blobs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/languages","stargazers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/stargazers","contributors_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/contributors","subscribers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/subscribers","subscription_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/subscription","commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/merges","archive_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/downloads","issues_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/labels{/name}","releases_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/deployments","created_at":"2014-12-25T13:32:30Z","updated_at":"2016-07-22T18:47:17Z","pushed_at":"2016-09-30T17:18:53Z","git_url":"git://github.com/cloudify-cosmo/cloudify-aws-plugin.git","ssh_url":"git@github.com:cloudify-cosmo/cloudify-aws-plugin.git","clone_url":"https://github.com/cloudify-cosmo/cloudify-aws-plugin.git","svn_url":"https://github.com/cloudify-cosmo/cloudify-aws-plugin","homepage":null,"size":1076,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":4,"forks":17,"open_issues":4,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/161"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-aws-plugin/pull/161"},"issue":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/issues/161"},"comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/issues/161/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/161/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/pulls/161/commits"},"statuses":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-aws-plugin/statuses/19dd8a7742c881371caeb9714053550b23598c5e"}}}}
{"actor":{"display_login":"geokala"}}