{"action":"created","comment":{"url":"https://api.github.com/repos/amplifylitco/asiaq/pulls/comments/72094586","id":72094586,"diff_hunk":"@@ -0,0 +1,80 @@\n+\"\"\"\n+Manage Placement Groups\n+\"\"\"\n+import logging\n+\n+import boto3\n+import botocore\n+\n+from disco_aws_automation.resource_helper import throttled_call\n+\n+\n+class DiscoPlacementGroup(object):\n+    \"\"\"\n+    A simple class to manage Placement Groups\n+    \"\"\"\n+\n+    def __init__(self, environment_name, ec2=None):\n+        self.environment_name = environment_name\n+        self._ec2_client = ec2\n+\n+    @property\n+    def ec2_client(self):\n+        \"\"\"\n+        Lazily creates boto3 EC2 Connection\n+        \"\"\"\n+        if not self._ec2_client:\n+            self._ec2_client = boto3.client('ec2')\n+        return self._ec2_client\n+\n+    def get_or_create(self, name):\n+        \"\"\"Get a placement group or create it if it doesn't exist\"\"\"\n+        if not self.get(name):\n+            self.create(name)\n+\n+        return self.get(name)\n+\n+    def create(self, name):\n+        \"\"\"Create a placement group\"\"\"\n+        group_id = self._get_id(name)\n+\n+        logging.info(\"Creating placement group %s\", group_id)\n+        throttled_call(self.ec2_client.create_placement_group, GroupName=group_id, Strategy='cluster')\n+\n+    def delete(self, name):\n+        \"\"\"Delete a placement group by name\"\"\"\n+        group_id = self._get_id(name)\n+\n+        logging.info(\"Deleting placement group %s\", group_id)\n+        throttled_call(self.ec2_client.delete_placement_group, GroupName=group_id)\n+\n+    def get(self, name):\n+        \"\"\"Get a placement group or None if it does not exist\"\"\"\n+        group_id = self._get_id(name)\n+\n+        try:\n+            response = throttled_call(self.ec2_client.describe_placement_groups, GroupNames=[group_id])\n+            placement_groups = response.get('PlacementGroups', [])\n+\n+            return placement_groups[0] if placement_groups else None\n+        except botocore.exceptions.ClientError:\n+            return None\n+\n+    def list(self):","path":"disco_aws_automation/disco_placement_group.py","position":63,"original_position":63,"commit_id":"0189ec95ecf42594b0ae7c11854ed67dd68ecb75","original_commit_id":"0189ec95ecf42594b0ae7c11854ed67dd68ecb75","user":{"login":"aoskotsky-amplify","id":15692902,"avatar_url":"https://avatars.githubusercontent.com/u/15692902?v=3","gravatar_id":"","url":"https://api.github.com/users/aoskotsky-amplify","html_url":"https://github.com/aoskotsky-amplify","followers_url":"https://api.github.com/users/aoskotsky-amplify/followers","following_url":"https://api.github.com/users/aoskotsky-amplify/following{/other_user}","gists_url":"https://api.github.com/users/aoskotsky-amplify/gists{/gist_id}","starred_url":"https://api.github.com/users/aoskotsky-amplify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aoskotsky-amplify/subscriptions","organizations_url":"https://api.github.com/users/aoskotsky-amplify/orgs","repos_url":"https://api.github.com/users/aoskotsky-amplify/repos","events_url":"https://api.github.com/users/aoskotsky-amplify/events{/privacy}","received_events_url":"https://api.github.com/users/aoskotsky-amplify/received_events","type":"User","site_admin":false},"body":"The method uses `self.environment_name`. Do you suggest passing in the `environment_name` as an argument?","created_at":"2016-07-25T16:15:15Z","updated_at":"2016-07-25T16:15:15Z","html_url":"https://github.com/amplifylitco/asiaq/pull/101#discussion_r72094586","pull_request_url":"https://api.github.com/repos/amplifylitco/asiaq/pulls/101","_links":{"self":{"href":"https://api.github.com/repos/amplifylitco/asiaq/pulls/comments/72094586"},"html":{"href":"https://github.com/amplifylitco/asiaq/pull/101#discussion_r72094586"},"pull_request":{"href":"https://api.github.com/repos/amplifylitco/asiaq/pulls/101"}}},"pull_request":{"url":"https://api.github.com/repos/amplifylitco/asiaq/pulls/101","id":78584234,"html_url":"https://github.com/amplifylitco/asiaq/pull/101","diff_url":"https://github.com/amplifylitco/asiaq/pull/101.diff","patch_url":"https://github.com/amplifylitco/asiaq/pull/101.patch","issue_url":"https://api.github.com/repos/amplifylitco/asiaq/issues/101","number":101,"state":"open","locked":false,"title":"Add support for placement groups","user":{"login":"aoskotsky-amplify","id":15692902,"avatar_url":"https://avatars.githubusercontent.com/u/15692902?v=3","gravatar_id":"","url":"https://api.github.com/users/aoskotsky-amplify","html_url":"https://github.com/aoskotsky-amplify","followers_url":"https://api.github.com/users/aoskotsky-amplify/followers","following_url":"https://api.github.com/users/aoskotsky-amplify/following{/other_user}","gists_url":"https://api.github.com/users/aoskotsky-amplify/gists{/gist_id}","starred_url":"https://api.github.com/users/aoskotsky-amplify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aoskotsky-amplify/subscriptions","organizations_url":"https://api.github.com/users/aoskotsky-amplify/orgs","repos_url":"https://api.github.com/users/aoskotsky-amplify/repos","events_url":"https://api.github.com/users/aoskotsky-amplify/events{/privacy}","received_events_url":"https://api.github.com/users/aoskotsky-amplify/received_events","type":"User","site_admin":false},"body":"See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html\r\n\r\nThere are cases when we need very low latency, high bandwidth communication between instances and are not as concerned with spreading instances across multiple availability zones.\r\n\r\nAdd a `placement_group` option in `disco_aws.ini` for putting hostclasses into placement groups.","created_at":"2016-07-23T22:31:02Z","updated_at":"2016-07-25T16:15:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a0504be913dc46f975afa00593fd0a52a0f748e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/amplifylitco/asiaq/pulls/101/commits","review_comments_url":"https://api.github.com/repos/amplifylitco/asiaq/pulls/101/comments","review_comment_url":"https://api.github.com/repos/amplifylitco/asiaq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amplifylitco/asiaq/issues/101/comments","statuses_url":"https://api.github.com/repos/amplifylitco/asiaq/statuses/0189ec95ecf42594b0ae7c11854ed67dd68ecb75","head":{"label":"amplifylitco:add_placement_groups","ref":"add_placement_groups","sha":"0189ec95ecf42594b0ae7c11854ed67dd68ecb75","user":{"login":"amplifylitco","id":15659472,"avatar_url":"https://avatars.githubusercontent.com/u/15659472?v=3","gravatar_id":"","url":"https://api.github.com/users/amplifylitco","html_url":"https://github.com/amplifylitco","followers_url":"https://api.github.com/users/amplifylitco/followers","following_url":"https://api.github.com/users/amplifylitco/following{/other_user}","gists_url":"https://api.github.com/users/amplifylitco/gists{/gist_id}","starred_url":"https://api.github.com/users/amplifylitco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplifylitco/subscriptions","organizations_url":"https://api.github.com/users/amplifylitco/orgs","repos_url":"https://api.github.com/users/amplifylitco/repos","events_url":"https://api.github.com/users/amplifylitco/events{/privacy}","received_events_url":"https://api.github.com/users/amplifylitco/received_events","type":"Organization","site_admin":false},"repo":{"id":53361236,"name":"asiaq","full_name":"amplifylitco/asiaq","owner":{"login":"amplifylitco","id":15659472,"avatar_url":"https://avatars.githubusercontent.com/u/15659472?v=3","gravatar_id":"","url":"https://api.github.com/users/amplifylitco","html_url":"https://github.com/amplifylitco","followers_url":"https://api.github.com/users/amplifylitco/followers","following_url":"https://api.github.com/users/amplifylitco/following{/other_user}","gists_url":"https://api.github.com/users/amplifylitco/gists{/gist_id}","starred_url":"https://api.github.com/users/amplifylitco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplifylitco/subscriptions","organizations_url":"https://api.github.com/users/amplifylitco/orgs","repos_url":"https://api.github.com/users/amplifylitco/repos","events_url":"https://api.github.com/users/amplifylitco/events{/privacy}","received_events_url":"https://api.github.com/users/amplifylitco/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/amplifylitco/asiaq","description":"","fork":false,"url":"https://api.github.com/repos/amplifylitco/asiaq","forks_url":"https://api.github.com/repos/amplifylitco/asiaq/forks","keys_url":"https://api.github.com/repos/amplifylitco/asiaq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amplifylitco/asiaq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amplifylitco/asiaq/teams","hooks_url":"https://api.github.com/repos/amplifylitco/asiaq/hooks","issue_events_url":"https://api.github.com/repos/amplifylitco/asiaq/issues/events{/number}","events_url":"https://api.github.com/repos/amplifylitco/asiaq/events","assignees_url":"https://api.github.com/repos/amplifylitco/asiaq/assignees{/user}","branches_url":"https://api.github.com/repos/amplifylitco/asiaq/branches{/branch}","tags_url":"https://api.github.com/repos/amplifylitco/asiaq/tags","blobs_url":"https://api.github.com/repos/amplifylitco/asiaq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amplifylitco/asiaq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amplifylitco/asiaq/git/refs{/sha}","trees_url":"https://api.github.com/repos/amplifylitco/asiaq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amplifylitco/asiaq/statuses/{sha}","languages_url":"https://api.github.com/repos/amplifylitco/asiaq/languages","stargazers_url":"https://api.github.com/repos/amplifylitco/asiaq/stargazers","contributors_url":"https://api.github.com/repos/amplifylitco/asiaq/contributors","subscribers_url":"https://api.github.com/repos/amplifylitco/asiaq/subscribers","subscription_url":"https://api.github.com/repos/amplifylitco/asiaq/subscription","commits_url":"https://api.github.com/repos/amplifylitco/asiaq/commits{/sha}","git_commits_url":"https://api.github.com/repos/amplifylitco/asiaq/git/commits{/sha}","comments_url":"https://api.github.com/repos/amplifylitco/asiaq/comments{/number}","issue_comment_url":"https://api.github.com/repos/amplifylitco/asiaq/issues/comments{/number}","contents_url":"https://api.github.com/repos/amplifylitco/asiaq/contents/{+path}","compare_url":"https://api.github.com/repos/amplifylitco/asiaq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amplifylitco/asiaq/merges","archive_url":"https://api.github.com/repos/amplifylitco/asiaq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amplifylitco/asiaq/downloads","issues_url":"https://api.github.com/repos/amplifylitco/asiaq/issues{/number}","pulls_url":"https://api.github.com/repos/amplifylitco/asiaq/pulls{/number}","milestones_url":"https://api.github.com/repos/amplifylitco/asiaq/milestones{/number}","notifications_url":"https://api.github.com/repos/amplifylitco/asiaq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amplifylitco/asiaq/labels{/name}","releases_url":"https://api.github.com/repos/amplifylitco/asiaq/releases{/id}","deployments_url":"https://api.github.com/repos/amplifylitco/asiaq/deployments","created_at":"2016-03-07T21:41:20Z","updated_at":"2016-06-24T20:02:36Z","pushed_at":"2016-07-25T16:12:49Z","git_url":"git://github.com/amplifylitco/asiaq.git","ssh_url":"git@github.com:amplifylitco/asiaq.git","clone_url":"https://github.com/amplifylitco/asiaq.git","svn_url":"https://github.com/amplifylitco/asiaq","homepage":null,"size":1030,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":18,"forks":1,"open_issues":18,"watchers":8,"default_branch":"master"}},"base":{"label":"amplifylitco:master","ref":"master","sha":"dfd9f63f37f69226296b6788457d94d47e3ead0c","user":{"login":"amplifylitco","id":15659472,"avatar_url":"https://avatars.githubusercontent.com/u/15659472?v=3","gravatar_id":"","url":"https://api.github.com/users/amplifylitco","html_url":"https://github.com/amplifylitco","followers_url":"https://api.github.com/users/amplifylitco/followers","following_url":"https://api.github.com/users/amplifylitco/following{/other_user}","gists_url":"https://api.github.com/users/amplifylitco/gists{/gist_id}","starred_url":"https://api.github.com/users/amplifylitco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplifylitco/subscriptions","organizations_url":"https://api.github.com/users/amplifylitco/orgs","repos_url":"https://api.github.com/users/amplifylitco/repos","events_url":"https://api.github.com/users/amplifylitco/events{/privacy}","received_events_url":"https://api.github.com/users/amplifylitco/received_events","type":"Organization","site_admin":false},"repo":{"id":53361236,"name":"asiaq","full_name":"amplifylitco/asiaq","owner":{"login":"amplifylitco","id":15659472,"avatar_url":"https://avatars.githubusercontent.com/u/15659472?v=3","gravatar_id":"","url":"https://api.github.com/users/amplifylitco","html_url":"https://github.com/amplifylitco","followers_url":"https://api.github.com/users/amplifylitco/followers","following_url":"https://api.github.com/users/amplifylitco/following{/other_user}","gists_url":"https://api.github.com/users/amplifylitco/gists{/gist_id}","starred_url":"https://api.github.com/users/amplifylitco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplifylitco/subscriptions","organizations_url":"https://api.github.com/users/amplifylitco/orgs","repos_url":"https://api.github.com/users/amplifylitco/repos","events_url":"https://api.github.com/users/amplifylitco/events{/privacy}","received_events_url":"https://api.github.com/users/amplifylitco/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/amplifylitco/asiaq","description":"","fork":false,"url":"https://api.github.com/repos/amplifylitco/asiaq","forks_url":"https://api.github.com/repos/amplifylitco/asiaq/forks","keys_url":"https://api.github.com/repos/amplifylitco/asiaq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amplifylitco/asiaq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amplifylitco/asiaq/teams","hooks_url":"https://api.github.com/repos/amplifylitco/asiaq/hooks","issue_events_url":"https://api.github.com/repos/amplifylitco/asiaq/issues/events{/number}","events_url":"https://api.github.com/repos/amplifylitco/asiaq/events","assignees_url":"https://api.github.com/repos/amplifylitco/asiaq/assignees{/user}","branches_url":"https://api.github.com/repos/amplifylitco/asiaq/branches{/branch}","tags_url":"https://api.github.com/repos/amplifylitco/asiaq/tags","blobs_url":"https://api.github.com/repos/amplifylitco/asiaq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amplifylitco/asiaq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amplifylitco/asiaq/git/refs{/sha}","trees_url":"https://api.github.com/repos/amplifylitco/asiaq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amplifylitco/asiaq/statuses/{sha}","languages_url":"https://api.github.com/repos/amplifylitco/asiaq/languages","stargazers_url":"https://api.github.com/repos/amplifylitco/asiaq/stargazers","contributors_url":"https://api.github.com/repos/amplifylitco/asiaq/contributors","subscribers_url":"https://api.github.com/repos/amplifylitco/asiaq/subscribers","subscription_url":"https://api.github.com/repos/amplifylitco/asiaq/subscription","commits_url":"https://api.github.com/repos/amplifylitco/asiaq/commits{/sha}","git_commits_url":"https://api.github.com/repos/amplifylitco/asiaq/git/commits{/sha}","comments_url":"https://api.github.com/repos/amplifylitco/asiaq/comments{/number}","issue_comment_url":"https://api.github.com/repos/amplifylitco/asiaq/issues/comments{/number}","contents_url":"https://api.github.com/repos/amplifylitco/asiaq/contents/{+path}","compare_url":"https://api.github.com/repos/amplifylitco/asiaq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amplifylitco/asiaq/merges","archive_url":"https://api.github.com/repos/amplifylitco/asiaq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amplifylitco/asiaq/downloads","issues_url":"https://api.github.com/repos/amplifylitco/asiaq/issues{/number}","pulls_url":"https://api.github.com/repos/amplifylitco/asiaq/pulls{/number}","milestones_url":"https://api.github.com/repos/amplifylitco/asiaq/milestones{/number}","notifications_url":"https://api.github.com/repos/amplifylitco/asiaq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amplifylitco/asiaq/labels{/name}","releases_url":"https://api.github.com/repos/amplifylitco/asiaq/releases{/id}","deployments_url":"https://api.github.com/repos/amplifylitco/asiaq/deployments","created_at":"2016-03-07T21:41:20Z","updated_at":"2016-06-24T20:02:36Z","pushed_at":"2016-07-25T16:12:49Z","git_url":"git://github.com/amplifylitco/asiaq.git","ssh_url":"git@github.com:amplifylitco/asiaq.git","clone_url":"https://github.com/amplifylitco/asiaq.git","svn_url":"https://github.com/amplifylitco/asiaq","homepage":null,"size":1030,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":18,"forks":1,"open_issues":18,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amplifylitco/asiaq/pulls/101"},"html":{"href":"https://github.com/amplifylitco/asiaq/pull/101"},"issue":{"href":"https://api.github.com/repos/amplifylitco/asiaq/issues/101"},"comments":{"href":"https://api.github.com/repos/amplifylitco/asiaq/issues/101/comments"},"review_comments":{"href":"https://api.github.com/repos/amplifylitco/asiaq/pulls/101/comments"},"review_comment":{"href":"https://api.github.com/repos/amplifylitco/asiaq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amplifylitco/asiaq/pulls/101/commits"},"statuses":{"href":"https://api.github.com/repos/amplifylitco/asiaq/statuses/0189ec95ecf42594b0ae7c11854ed67dd68ecb75"}}}}
{"actor":{"display_login":"aoskotsky-amplify"}}