{"action":"created","comment":{"url":"https://api.github.com/repos/dcos/dcos/pulls/comments/77878468","id":77878468,"diff_hunk":"@@ -0,0 +1,109 @@\n+import logging\n+from collections import namedtuple\n+\n+import boto3\n+\n+LOGGING_FORMAT = '[%(asctime)s|%(name)s|%(levelname)s]: %(message)s'\n+logging.basicConfig(format=LOGGING_FORMAT, level=logging.DEBUG)\n+logger = logging.getLogger(__name__)\n+\n+Host = namedtuple('Host', ['private_ip', 'public_ip'])\n+\n+\n+class BotoWrapper():\n+    def __init__(self, region, aws_access_key_id, aws_secret_access_key):\n+        self.region = region\n+        self.session = boto3.session.Session(\n+            aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)\n+\n+    def client(self, name):\n+        return self.session.client(service_name=name, region_name=self.region)\n+\n+    def resource(self, name):\n+        return self.session.resource(service_name=name, region_name=self.region)\n+\n+    def create_key_pair(self, key_name):\n+        \"\"\"Retruns private key of newly generated pair\n+        \"\"\"\n+        key = self.resource('ec2').KeyPair(key_name)\n+        return key.key_material\n+\n+    def delete_key_pair(self, key_name):\n+        self.resource('ec2').KeyPair(key_name).delete()\n+\n+    def create_stack(self, name, template_url, user_parameters, deploy_timeout=60):\n+        \"\"\"Returns boto stack object\n+        \"\"\"\n+        logging.info('Requesting AWS CloudFormation...')\n+        cf_parameters = []\n+        for k, v in user_parameters.items():\n+            cf_parameters.append({'ParameterKey': k, 'ParameterValue': v})\n+        self.resource('cloudformation').create_stack(\n+            StackName=name,\n+            TemplateURL=template_url,\n+            DisableRollback=True,\n+            TimeoutInMinutes=deploy_timeout,\n+            Capabilities=['CAPABILITY_IAM'],\n+            Parameters=cf_parameters)\n+        return CFStack(name, self)\n+\n+\n+class CFStack():\n+    def __init__(self, stack_name, boto_wrapper):\n+        self.boto_wrapper = boto_wrapper\n+        self.stack = self.boto_wrapper.resource('cloudformation').Stack(stack_name)\n+\n+    def wait_for_stack_creation(self):\n+        self.boto_wrapper.client('cloudformation').get_waiter('stack_create_complete').\\\n+            wait(StackName=self.stack.stack_name)\n+\n+    def wait_for_stack_deletion(self):\n+        self.boto_wrapper.client('cloudformation').get_waiter('stack_delete_complete').\\\n+            wait(StackName=self.stack.stack_name)\n+\n+\n+class DcosCfSimple(CFStack):\n+    @classmethod\n+    def create(cls, stack_name, template_url, public_agents, private_agents,\n+               admin_location, key_pair_name, boto_wrapper):\n+        parameters = {\n+            'KeyName': key_pair_name,\n+            'AdminLocation': admin_location,\n+            'PublicSlaveInstanceCount': str(public_agents),\n+            'SlaveInstanceCount': str(private_agents)}\n+        boto_wrapper.create_stack(stack_name, template_url, parameters)\n+        return cls(stack_name, boto_wrapper)\n+\n+    def delete(self):\n+        logger.info('Starting deletion of CF stack')\n+        self.stack.delete()","path":"test_util/aws.py","position":80,"original_position":79,"commit_id":"69dacd21eeae74b5f16180049fecbfe5e8f03209","original_commit_id":"e66709ff4d6a6c00aab95a8e2f96f96a6e4a6d04","user":{"login":"cmaloney","id":751088,"avatar_url":"https://avatars.githubusercontent.com/u/751088?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaloney","html_url":"https://github.com/cmaloney","followers_url":"https://api.github.com/users/cmaloney/followers","following_url":"https://api.github.com/users/cmaloney/following{/other_user}","gists_url":"https://api.github.com/users/cmaloney/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaloney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaloney/subscriptions","organizations_url":"https://api.github.com/users/cmaloney/orgs","repos_url":"https://api.github.com/users/cmaloney/repos","events_url":"https://api.github.com/users/cmaloney/events{/privacy}","received_events_url":"https://api.github.com/users/cmaloney/received_events","type":"User","site_admin":false},"body":"Sounds good, I was thinking we wanted to make sure it was all based on a stack id rather than a stack name since from the docs stack_id based you can access after deletion","created_at":"2016-09-07T18:29:13Z","updated_at":"2016-09-07T18:29:13Z","html_url":"https://github.com/dcos/dcos/pull/240#discussion_r77878468","pull_request_url":"https://api.github.com/repos/dcos/dcos/pulls/240","_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos/pulls/comments/77878468"},"html":{"href":"https://github.com/dcos/dcos/pull/240#discussion_r77878468"},"pull_request":{"href":"https://api.github.com/repos/dcos/dcos/pulls/240"}}},"pull_request":{"url":"https://api.github.com/repos/dcos/dcos/pulls/240","id":74321059,"html_url":"https://github.com/dcos/dcos/pull/240","diff_url":"https://github.com/dcos/dcos/pull/240.diff","patch_url":"https://github.com/dcos/dcos/pull/240.patch","issue_url":"https://api.github.com/repos/dcos/dcos/issues/240","number":240,"state":"open","locked":false,"title":"Integration Testing for AWS provided deployments","user":{"login":"mellenburg","id":14269783,"avatar_url":"https://avatars.githubusercontent.com/u/14269783?v=3","gravatar_id":"","url":"https://api.github.com/users/mellenburg","html_url":"https://github.com/mellenburg","followers_url":"https://api.github.com/users/mellenburg/followers","following_url":"https://api.github.com/users/mellenburg/following{/other_user}","gists_url":"https://api.github.com/users/mellenburg/gists{/gist_id}","starred_url":"https://api.github.com/users/mellenburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellenburg/subscriptions","organizations_url":"https://api.github.com/users/mellenburg/orgs","repos_url":"https://api.github.com/users/mellenburg/repos","events_url":"https://api.github.com/users/mellenburg/events{/privacy}","received_events_url":"https://api.github.com/users/mellenburg/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-18T00:14:32Z","updated_at":"2016-09-07T18:29:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"de070340012bcb39c5baa515b1d646a5e1c46b99","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/dcos/dcos/milestones/2","html_url":"https://github.com/dcos/dcos/milestones/1.8%20GA","labels_url":"https://api.github.com/repos/dcos/dcos/milestones/2/labels","id":1912566,"number":2,"title":"1.8 GA","description":"Targeted to land before 1.8 ships","creator":{"login":"spahl","id":40360,"avatar_url":"https://avatars.githubusercontent.com/u/40360?v=3","gravatar_id":"","url":"https://api.github.com/users/spahl","html_url":"https://github.com/spahl","followers_url":"https://api.github.com/users/spahl/followers","following_url":"https://api.github.com/users/spahl/following{/other_user}","gists_url":"https://api.github.com/users/spahl/gists{/gist_id}","starred_url":"https://api.github.com/users/spahl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spahl/subscriptions","organizations_url":"https://api.github.com/users/spahl/orgs","repos_url":"https://api.github.com/users/spahl/repos","events_url":"https://api.github.com/users/spahl/events{/privacy}","received_events_url":"https://api.github.com/users/spahl/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":49,"state":"open","created_at":"2016-07-29T20:01:19Z","updated_at":"2016-09-07T10:01:37Z","due_on":"2016-09-15T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/dcos/dcos/pulls/240/commits","review_comments_url":"https://api.github.com/repos/dcos/dcos/pulls/240/comments","review_comment_url":"https://api.github.com/repos/dcos/dcos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dcos/dcos/issues/240/comments","statuses_url":"https://api.github.com/repos/dcos/dcos/statuses/69dacd21eeae74b5f16180049fecbfe5e8f03209","head":{"label":"mellenburg:aws_integration","ref":"aws_integration","sha":"69dacd21eeae74b5f16180049fecbfe5e8f03209","user":{"login":"mellenburg","id":14269783,"avatar_url":"https://avatars.githubusercontent.com/u/14269783?v=3","gravatar_id":"","url":"https://api.github.com/users/mellenburg","html_url":"https://github.com/mellenburg","followers_url":"https://api.github.com/users/mellenburg/followers","following_url":"https://api.github.com/users/mellenburg/following{/other_user}","gists_url":"https://api.github.com/users/mellenburg/gists{/gist_id}","starred_url":"https://api.github.com/users/mellenburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellenburg/subscriptions","organizations_url":"https://api.github.com/users/mellenburg/orgs","repos_url":"https://api.github.com/users/mellenburg/repos","events_url":"https://api.github.com/users/mellenburg/events{/privacy}","received_events_url":"https://api.github.com/users/mellenburg/received_events","type":"User","site_admin":false},"repo":{"id":56731971,"name":"dcos","full_name":"mellenburg/dcos","owner":{"login":"mellenburg","id":14269783,"avatar_url":"https://avatars.githubusercontent.com/u/14269783?v=3","gravatar_id":"","url":"https://api.github.com/users/mellenburg","html_url":"https://github.com/mellenburg","followers_url":"https://api.github.com/users/mellenburg/followers","following_url":"https://api.github.com/users/mellenburg/following{/other_user}","gists_url":"https://api.github.com/users/mellenburg/gists{/gist_id}","starred_url":"https://api.github.com/users/mellenburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellenburg/subscriptions","organizations_url":"https://api.github.com/users/mellenburg/orgs","repos_url":"https://api.github.com/users/mellenburg/repos","events_url":"https://api.github.com/users/mellenburg/events{/privacy}","received_events_url":"https://api.github.com/users/mellenburg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mellenburg/dcos","description":"DC/OS Build and Release tools","fork":true,"url":"https://api.github.com/repos/mellenburg/dcos","forks_url":"https://api.github.com/repos/mellenburg/dcos/forks","keys_url":"https://api.github.com/repos/mellenburg/dcos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mellenburg/dcos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mellenburg/dcos/teams","hooks_url":"https://api.github.com/repos/mellenburg/dcos/hooks","issue_events_url":"https://api.github.com/repos/mellenburg/dcos/issues/events{/number}","events_url":"https://api.github.com/repos/mellenburg/dcos/events","assignees_url":"https://api.github.com/repos/mellenburg/dcos/assignees{/user}","branches_url":"https://api.github.com/repos/mellenburg/dcos/branches{/branch}","tags_url":"https://api.github.com/repos/mellenburg/dcos/tags","blobs_url":"https://api.github.com/repos/mellenburg/dcos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mellenburg/dcos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mellenburg/dcos/git/refs{/sha}","trees_url":"https://api.github.com/repos/mellenburg/dcos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mellenburg/dcos/statuses/{sha}","languages_url":"https://api.github.com/repos/mellenburg/dcos/languages","stargazers_url":"https://api.github.com/repos/mellenburg/dcos/stargazers","contributors_url":"https://api.github.com/repos/mellenburg/dcos/contributors","subscribers_url":"https://api.github.com/repos/mellenburg/dcos/subscribers","subscription_url":"https://api.github.com/repos/mellenburg/dcos/subscription","commits_url":"https://api.github.com/repos/mellenburg/dcos/commits{/sha}","git_commits_url":"https://api.github.com/repos/mellenburg/dcos/git/commits{/sha}","comments_url":"https://api.github.com/repos/mellenburg/dcos/comments{/number}","issue_comment_url":"https://api.github.com/repos/mellenburg/dcos/issues/comments{/number}","contents_url":"https://api.github.com/repos/mellenburg/dcos/contents/{+path}","compare_url":"https://api.github.com/repos/mellenburg/dcos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mellenburg/dcos/merges","archive_url":"https://api.github.com/repos/mellenburg/dcos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mellenburg/dcos/downloads","issues_url":"https://api.github.com/repos/mellenburg/dcos/issues{/number}","pulls_url":"https://api.github.com/repos/mellenburg/dcos/pulls{/number}","milestones_url":"https://api.github.com/repos/mellenburg/dcos/milestones{/number}","notifications_url":"https://api.github.com/repos/mellenburg/dcos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mellenburg/dcos/labels{/name}","releases_url":"https://api.github.com/repos/mellenburg/dcos/releases{/id}","deployments_url":"https://api.github.com/repos/mellenburg/dcos/deployments","created_at":"2016-04-21T01:13:27Z","updated_at":"2016-04-29T20:59:42Z","pushed_at":"2016-09-07T05:19:00Z","git_url":"git://github.com/mellenburg/dcos.git","ssh_url":"git@github.com:mellenburg/dcos.git","clone_url":"https://github.com/mellenburg/dcos.git","svn_url":"https://github.com/mellenburg/dcos","homepage":"https://dcos.io","size":1624,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"dcos:master","ref":"master","sha":"cbf3b83621ddb062c2748347db11cdc5f8be7b63","user":{"login":"dcos","id":17648048,"avatar_url":"https://avatars.githubusercontent.com/u/17648048?v=3","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"repo":{"id":56184050,"name":"dcos","full_name":"dcos/dcos","owner":{"login":"dcos","id":17648048,"avatar_url":"https://avatars.githubusercontent.com/u/17648048?v=3","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dcos/dcos","description":"DC/OS Build and Release tools","fork":false,"url":"https://api.github.com/repos/dcos/dcos","forks_url":"https://api.github.com/repos/dcos/dcos/forks","keys_url":"https://api.github.com/repos/dcos/dcos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcos/dcos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcos/dcos/teams","hooks_url":"https://api.github.com/repos/dcos/dcos/hooks","issue_events_url":"https://api.github.com/repos/dcos/dcos/issues/events{/number}","events_url":"https://api.github.com/repos/dcos/dcos/events","assignees_url":"https://api.github.com/repos/dcos/dcos/assignees{/user}","branches_url":"https://api.github.com/repos/dcos/dcos/branches{/branch}","tags_url":"https://api.github.com/repos/dcos/dcos/tags","blobs_url":"https://api.github.com/repos/dcos/dcos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcos/dcos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcos/dcos/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcos/dcos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcos/dcos/statuses/{sha}","languages_url":"https://api.github.com/repos/dcos/dcos/languages","stargazers_url":"https://api.github.com/repos/dcos/dcos/stargazers","contributors_url":"https://api.github.com/repos/dcos/dcos/contributors","subscribers_url":"https://api.github.com/repos/dcos/dcos/subscribers","subscription_url":"https://api.github.com/repos/dcos/dcos/subscription","commits_url":"https://api.github.com/repos/dcos/dcos/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcos/dcos/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcos/dcos/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcos/dcos/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcos/dcos/contents/{+path}","compare_url":"https://api.github.com/repos/dcos/dcos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcos/dcos/merges","archive_url":"https://api.github.com/repos/dcos/dcos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcos/dcos/downloads","issues_url":"https://api.github.com/repos/dcos/dcos/issues{/number}","pulls_url":"https://api.github.com/repos/dcos/dcos/pulls{/number}","milestones_url":"https://api.github.com/repos/dcos/dcos/milestones{/number}","notifications_url":"https://api.github.com/repos/dcos/dcos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcos/dcos/labels{/name}","releases_url":"https://api.github.com/repos/dcos/dcos/releases{/id}","deployments_url":"https://api.github.com/repos/dcos/dcos/deployments","created_at":"2016-04-13T20:31:58Z","updated_at":"2016-09-07T11:33:15Z","pushed_at":"2016-09-07T17:44:27Z","git_url":"git://github.com/dcos/dcos.git","ssh_url":"git@github.com:dcos/dcos.git","clone_url":"https://github.com/dcos/dcos.git","svn_url":"https://github.com/dcos/dcos","homepage":"https://dcos.io","size":2424,"stargazers_count":844,"watchers_count":844,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":148,"mirror_url":null,"open_issues_count":37,"forks":148,"open_issues":37,"watchers":844,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos/pulls/240"},"html":{"href":"https://github.com/dcos/dcos/pull/240"},"issue":{"href":"https://api.github.com/repos/dcos/dcos/issues/240"},"comments":{"href":"https://api.github.com/repos/dcos/dcos/issues/240/comments"},"review_comments":{"href":"https://api.github.com/repos/dcos/dcos/pulls/240/comments"},"review_comment":{"href":"https://api.github.com/repos/dcos/dcos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dcos/dcos/pulls/240/commits"},"statuses":{"href":"https://api.github.com/repos/dcos/dcos/statuses/69dacd21eeae74b5f16180049fecbfe5e8f03209"}}}}
{"actor":{"display_login":"cmaloney"}}