{"action":"created","comment":{"url":"https://api.github.com/repos/onefinestay/gonzo/pulls/comments/31529866","id":31529866,"diff_hunk":"@@ -146,8 +147,47 @@ def create_instance(self, image_name, name, owner, user_data=None,\n         )\n         self.compute_session.wait_until_running([instance])\n         new_instance = self.get_instance_by_uuid(instance.uuid)\n+\n+        if volume_size is not None:\n+            self.create_and_attach_volume(new_instance, volume_size)\n+\n         return new_instance\n \n+    def create_and_attach_volume(self, instance, vol_size, vol_type=None,\n+                                 vol_name=None):\n+        created_volume = self.create_volume(\n+            instance, instance.name,\n+            vol_size, vol_type)\n+\n+        self.wait_until_volume_available(created_volume)\n+\n+        self.compute_session.attach_volume(\n+            node=instance,\n+            volume=created_volume,\n+            device='/dev/xvdf'\n+        )\n+\n+    def wait_until_volume_available(self, volume):\n+        while not self.volume_is_created(volume):\n+            print \"Volume Being Created\"\n+        return True\n+\n+    def volume_is_created(self, volume):\n+        for vol in self.compute_session.list_volumes():\n+            if vol.id == volume.id:\n+                if vol.extra['state'] == 'available':\n+                    return True\n+\n+    def get_az_of_instance(self, instance):\n+        instance_az = instance.extra['gonzo_az']\n+\n+        if len(self.list_availability_zones()) == 1:\n+            return self.list_availability_zones()[0]\n+\n+        for az in self.list_availability_zones():\n+            if az.name == instance_az:\n+                return az","path":"gonzo/clouds/compute.py","position":53,"original_position":53,"commit_id":"933e6d78abe0916f5c0e8bdbf6845794153a8dc7","original_commit_id":"933e6d78abe0916f5c0e8bdbf6845794153a8dc7","user":{"login":"davidszotten","id":412005,"avatar_url":"https://avatars.githubusercontent.com/u/412005?v=3","gravatar_id":"","url":"https://api.github.com/users/davidszotten","html_url":"https://github.com/davidszotten","followers_url":"https://api.github.com/users/davidszotten/followers","following_url":"https://api.github.com/users/davidszotten/following{/other_user}","gists_url":"https://api.github.com/users/davidszotten/gists{/gist_id}","starred_url":"https://api.github.com/users/davidszotten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidszotten/subscriptions","organizations_url":"https://api.github.com/users/davidszotten/orgs","repos_url":"https://api.github.com/users/davidszotten/repos","events_url":"https://api.github.com/users/davidszotten/events{/privacy}","received_events_url":"https://api.github.com/users/davidszotten/received_events","type":"User","site_admin":false},"body":"again, what happens if we don't find it?","created_at":"2015-06-02T14:43:38Z","updated_at":"2015-06-02T14:43:38Z","html_url":"https://github.com/onefinestay/gonzo/pull/49#discussion_r31529866","pull_request_url":"https://api.github.com/repos/onefinestay/gonzo/pulls/49","_links":{"self":{"href":"https://api.github.com/repos/onefinestay/gonzo/pulls/comments/31529866"},"html":{"href":"https://github.com/onefinestay/gonzo/pull/49#discussion_r31529866"},"pull_request":{"href":"https://api.github.com/repos/onefinestay/gonzo/pulls/49"}}},"pull_request":{"url":"https://api.github.com/repos/onefinestay/gonzo/pulls/49","id":36674775,"html_url":"https://github.com/onefinestay/gonzo/pull/49","diff_url":"https://github.com/onefinestay/gonzo/pull/49.diff","patch_url":"https://github.com/onefinestay/gonzo/pull/49.patch","issue_url":"https://api.github.com/repos/onefinestay/gonzo/issues/49","number":49,"state":"open","locked":false,"title":"ability to create + attach volume to new instance","user":{"login":"amitofs","id":2317722,"avatar_url":"https://avatars.githubusercontent.com/u/2317722?v=3","gravatar_id":"","url":"https://api.github.com/users/amitofs","html_url":"https://github.com/amitofs","followers_url":"https://api.github.com/users/amitofs/followers","following_url":"https://api.github.com/users/amitofs/following{/other_user}","gists_url":"https://api.github.com/users/amitofs/gists{/gist_id}","starred_url":"https://api.github.com/users/amitofs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitofs/subscriptions","organizations_url":"https://api.github.com/users/amitofs/orgs","repos_url":"https://api.github.com/users/amitofs/repos","events_url":"https://api.github.com/users/amitofs/events{/privacy}","received_events_url":"https://api.github.com/users/amitofs/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-01T21:50:12Z","updated_at":"2015-06-02T14:43:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d9542e2b822757ad048455c290eb3b5fc061f1b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/onefinestay/gonzo/pulls/49/commits","review_comments_url":"https://api.github.com/repos/onefinestay/gonzo/pulls/49/comments","review_comment_url":"https://api.github.com/repos/onefinestay/gonzo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/onefinestay/gonzo/issues/49/comments","statuses_url":"https://api.github.com/repos/onefinestay/gonzo/statuses/933e6d78abe0916f5c0e8bdbf6845794153a8dc7","head":{"label":"onefinestay:ebs_functionality","ref":"ebs_functionality","sha":"933e6d78abe0916f5c0e8bdbf6845794153a8dc7","user":{"login":"onefinestay","id":634153,"avatar_url":"https://avatars.githubusercontent.com/u/634153?v=3","gravatar_id":"","url":"https://api.github.com/users/onefinestay","html_url":"https://github.com/onefinestay","followers_url":"https://api.github.com/users/onefinestay/followers","following_url":"https://api.github.com/users/onefinestay/following{/other_user}","gists_url":"https://api.github.com/users/onefinestay/gists{/gist_id}","starred_url":"https://api.github.com/users/onefinestay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onefinestay/subscriptions","organizations_url":"https://api.github.com/users/onefinestay/orgs","repos_url":"https://api.github.com/users/onefinestay/repos","events_url":"https://api.github.com/users/onefinestay/events{/privacy}","received_events_url":"https://api.github.com/users/onefinestay/received_events","type":"Organization","site_admin":false},"repo":{"id":9224196,"name":"gonzo","full_name":"onefinestay/gonzo","owner":{"login":"onefinestay","id":634153,"avatar_url":"https://avatars.githubusercontent.com/u/634153?v=3","gravatar_id":"","url":"https://api.github.com/users/onefinestay","html_url":"https://github.com/onefinestay","followers_url":"https://api.github.com/users/onefinestay/followers","following_url":"https://api.github.com/users/onefinestay/following{/other_user}","gists_url":"https://api.github.com/users/onefinestay/gists{/gist_id}","starred_url":"https://api.github.com/users/onefinestay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onefinestay/subscriptions","organizations_url":"https://api.github.com/users/onefinestay/orgs","repos_url":"https://api.github.com/users/onefinestay/repos","events_url":"https://api.github.com/users/onefinestay/events{/privacy}","received_events_url":"https://api.github.com/users/onefinestay/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/onefinestay/gonzo","description":"Instance and release management made easy","fork":false,"url":"https://api.github.com/repos/onefinestay/gonzo","forks_url":"https://api.github.com/repos/onefinestay/gonzo/forks","keys_url":"https://api.github.com/repos/onefinestay/gonzo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/onefinestay/gonzo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/onefinestay/gonzo/teams","hooks_url":"https://api.github.com/repos/onefinestay/gonzo/hooks","issue_events_url":"https://api.github.com/repos/onefinestay/gonzo/issues/events{/number}","events_url":"https://api.github.com/repos/onefinestay/gonzo/events","assignees_url":"https://api.github.com/repos/onefinestay/gonzo/assignees{/user}","branches_url":"https://api.github.com/repos/onefinestay/gonzo/branches{/branch}","tags_url":"https://api.github.com/repos/onefinestay/gonzo/tags","blobs_url":"https://api.github.com/repos/onefinestay/gonzo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/onefinestay/gonzo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/onefinestay/gonzo/git/refs{/sha}","trees_url":"https://api.github.com/repos/onefinestay/gonzo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/onefinestay/gonzo/statuses/{sha}","languages_url":"https://api.github.com/repos/onefinestay/gonzo/languages","stargazers_url":"https://api.github.com/repos/onefinestay/gonzo/stargazers","contributors_url":"https://api.github.com/repos/onefinestay/gonzo/contributors","subscribers_url":"https://api.github.com/repos/onefinestay/gonzo/subscribers","subscription_url":"https://api.github.com/repos/onefinestay/gonzo/subscription","commits_url":"https://api.github.com/repos/onefinestay/gonzo/commits{/sha}","git_commits_url":"https://api.github.com/repos/onefinestay/gonzo/git/commits{/sha}","comments_url":"https://api.github.com/repos/onefinestay/gonzo/comments{/number}","issue_comment_url":"https://api.github.com/repos/onefinestay/gonzo/issues/comments{/number}","contents_url":"https://api.github.com/repos/onefinestay/gonzo/contents/{+path}","compare_url":"https://api.github.com/repos/onefinestay/gonzo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/onefinestay/gonzo/merges","archive_url":"https://api.github.com/repos/onefinestay/gonzo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/onefinestay/gonzo/downloads","issues_url":"https://api.github.com/repos/onefinestay/gonzo/issues{/number}","pulls_url":"https://api.github.com/repos/onefinestay/gonzo/pulls{/number}","milestones_url":"https://api.github.com/repos/onefinestay/gonzo/milestones{/number}","notifications_url":"https://api.github.com/repos/onefinestay/gonzo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/onefinestay/gonzo/labels{/name}","releases_url":"https://api.github.com/repos/onefinestay/gonzo/releases{/id}","created_at":"2013-04-04T17:56:06Z","updated_at":"2015-05-21T10:12:41Z","pushed_at":"2015-06-01T21:59:46Z","git_url":"git://github.com/onefinestay/gonzo.git","ssh_url":"git@github.com:onefinestay/gonzo.git","clone_url":"https://github.com/onefinestay/gonzo.git","svn_url":"https://github.com/onefinestay/gonzo","homepage":null,"size":1983,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":14,"default_branch":"master"}},"base":{"label":"onefinestay:master","ref":"master","sha":"7ac4b4a7035724511ebcab31a828d2cd53ae2498","user":{"login":"onefinestay","id":634153,"avatar_url":"https://avatars.githubusercontent.com/u/634153?v=3","gravatar_id":"","url":"https://api.github.com/users/onefinestay","html_url":"https://github.com/onefinestay","followers_url":"https://api.github.com/users/onefinestay/followers","following_url":"https://api.github.com/users/onefinestay/following{/other_user}","gists_url":"https://api.github.com/users/onefinestay/gists{/gist_id}","starred_url":"https://api.github.com/users/onefinestay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onefinestay/subscriptions","organizations_url":"https://api.github.com/users/onefinestay/orgs","repos_url":"https://api.github.com/users/onefinestay/repos","events_url":"https://api.github.com/users/onefinestay/events{/privacy}","received_events_url":"https://api.github.com/users/onefinestay/received_events","type":"Organization","site_admin":false},"repo":{"id":9224196,"name":"gonzo","full_name":"onefinestay/gonzo","owner":{"login":"onefinestay","id":634153,"avatar_url":"https://avatars.githubusercontent.com/u/634153?v=3","gravatar_id":"","url":"https://api.github.com/users/onefinestay","html_url":"https://github.com/onefinestay","followers_url":"https://api.github.com/users/onefinestay/followers","following_url":"https://api.github.com/users/onefinestay/following{/other_user}","gists_url":"https://api.github.com/users/onefinestay/gists{/gist_id}","starred_url":"https://api.github.com/users/onefinestay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onefinestay/subscriptions","organizations_url":"https://api.github.com/users/onefinestay/orgs","repos_url":"https://api.github.com/users/onefinestay/repos","events_url":"https://api.github.com/users/onefinestay/events{/privacy}","received_events_url":"https://api.github.com/users/onefinestay/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/onefinestay/gonzo","description":"Instance and release management made easy","fork":false,"url":"https://api.github.com/repos/onefinestay/gonzo","forks_url":"https://api.github.com/repos/onefinestay/gonzo/forks","keys_url":"https://api.github.com/repos/onefinestay/gonzo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/onefinestay/gonzo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/onefinestay/gonzo/teams","hooks_url":"https://api.github.com/repos/onefinestay/gonzo/hooks","issue_events_url":"https://api.github.com/repos/onefinestay/gonzo/issues/events{/number}","events_url":"https://api.github.com/repos/onefinestay/gonzo/events","assignees_url":"https://api.github.com/repos/onefinestay/gonzo/assignees{/user}","branches_url":"https://api.github.com/repos/onefinestay/gonzo/branches{/branch}","tags_url":"https://api.github.com/repos/onefinestay/gonzo/tags","blobs_url":"https://api.github.com/repos/onefinestay/gonzo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/onefinestay/gonzo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/onefinestay/gonzo/git/refs{/sha}","trees_url":"https://api.github.com/repos/onefinestay/gonzo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/onefinestay/gonzo/statuses/{sha}","languages_url":"https://api.github.com/repos/onefinestay/gonzo/languages","stargazers_url":"https://api.github.com/repos/onefinestay/gonzo/stargazers","contributors_url":"https://api.github.com/repos/onefinestay/gonzo/contributors","subscribers_url":"https://api.github.com/repos/onefinestay/gonzo/subscribers","subscription_url":"https://api.github.com/repos/onefinestay/gonzo/subscription","commits_url":"https://api.github.com/repos/onefinestay/gonzo/commits{/sha}","git_commits_url":"https://api.github.com/repos/onefinestay/gonzo/git/commits{/sha}","comments_url":"https://api.github.com/repos/onefinestay/gonzo/comments{/number}","issue_comment_url":"https://api.github.com/repos/onefinestay/gonzo/issues/comments{/number}","contents_url":"https://api.github.com/repos/onefinestay/gonzo/contents/{+path}","compare_url":"https://api.github.com/repos/onefinestay/gonzo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/onefinestay/gonzo/merges","archive_url":"https://api.github.com/repos/onefinestay/gonzo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/onefinestay/gonzo/downloads","issues_url":"https://api.github.com/repos/onefinestay/gonzo/issues{/number}","pulls_url":"https://api.github.com/repos/onefinestay/gonzo/pulls{/number}","milestones_url":"https://api.github.com/repos/onefinestay/gonzo/milestones{/number}","notifications_url":"https://api.github.com/repos/onefinestay/gonzo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/onefinestay/gonzo/labels{/name}","releases_url":"https://api.github.com/repos/onefinestay/gonzo/releases{/id}","created_at":"2013-04-04T17:56:06Z","updated_at":"2015-05-21T10:12:41Z","pushed_at":"2015-06-01T21:59:46Z","git_url":"git://github.com/onefinestay/gonzo.git","ssh_url":"git@github.com:onefinestay/gonzo.git","clone_url":"https://github.com/onefinestay/gonzo.git","svn_url":"https://github.com/onefinestay/gonzo","homepage":null,"size":1983,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":15,"forks":3,"open_issues":15,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/onefinestay/gonzo/pulls/49"},"html":{"href":"https://github.com/onefinestay/gonzo/pull/49"},"issue":{"href":"https://api.github.com/repos/onefinestay/gonzo/issues/49"},"comments":{"href":"https://api.github.com/repos/onefinestay/gonzo/issues/49/comments"},"review_comments":{"href":"https://api.github.com/repos/onefinestay/gonzo/pulls/49/comments"},"review_comment":{"href":"https://api.github.com/repos/onefinestay/gonzo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/onefinestay/gonzo/pulls/49/commits"},"statuses":{"href":"https://api.github.com/repos/onefinestay/gonzo/statuses/933e6d78abe0916f5c0e8bdbf6845794153a8dc7"}}}}