{"action":"created","comment":{"url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/comments/63747780","id":63747780,"diff_hunk":"@@ -1,16 +1,106 @@\n from threepio import logger\n \n-from core.models import IdentityMembership, Identity, Provider\n-\n+from core.models import IdentityMembership, Identity\n+from core.models.quota import (\n+    has_floating_ip_count_quota,\n+    has_port_count_quota,\n+    has_instance_count_quota,\n+    has_cpu_quota,\n+    has_mem_quota,\n+    has_storage_quota,\n+    has_storage_count_quota,\n+    has_snapshot_count_quota\n+    )\n from service.cache import get_cached_driver\n from service.driver import get_account_driver\n \n+\n+def check_over_instance_quota(\n+        username, identity_uuid,\n+        esh_size=None, action=None):\n+    \"\"\"\n+    Checks quota based on current limits (and an instance of size, if passed).\n+\n+    return or raise exc\n+    \"\"\"\n+    membership = IdentityMembership.objects.get(\n+        identity__uuid=identity_uuid,\n+        member__name=username)\n+    quota = membership.quota\n+    identity = membership.identity\n+    driver = get_cached_driver(identity=identity)\n+    new_port = new_floating_ip = new_instance = new_cpu = new_ram = 0\n+    if esh_size:\n+        new_cpu += esh_size.cpu\n+        new_ram += esh_size.ram\n+    if action in ['launch', 'resume', 'reboot', 'unshelve']:","path":"service/quota.py","position":38,"original_position":38,"commit_id":"ec4eba6909ee5c43e849069904278f40ba9858ae","original_commit_id":"ec4eba6909ee5c43e849069904278f40ba9858ae","user":{"login":"lenards","id":5923,"avatar_url":"https://avatars.githubusercontent.com/u/5923?v=3","gravatar_id":"","url":"https://api.github.com/users/lenards","html_url":"https://github.com/lenards","followers_url":"https://api.github.com/users/lenards/followers","following_url":"https://api.github.com/users/lenards/following{/other_user}","gists_url":"https://api.github.com/users/lenards/gists{/gist_id}","starred_url":"https://api.github.com/users/lenards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lenards/subscriptions","organizations_url":"https://api.github.com/users/lenards/orgs","repos_url":"https://api.github.com/users/lenards/repos","events_url":"https://api.github.com/users/lenards/events{/privacy}","received_events_url":"https://api.github.com/users/lenards/received_events","type":"User","site_admin":false},"body":"Will the list of actions change per ☁️ provider? ","created_at":"2016-05-18T17:37:11Z","updated_at":"2016-05-18T17:37:11Z","html_url":"https://github.com/iPlantCollaborativeOpenSource/atmosphere/pull/146#discussion_r63747780","pull_request_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/146","_links":{"self":{"href":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/comments/63747780"},"html":{"href":"https://github.com/iPlantCollaborativeOpenSource/atmosphere/pull/146#discussion_r63747780"},"pull_request":{"href":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/146"}}},"pull_request":{"url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/146","id":70230915,"html_url":"https://github.com/iPlantCollaborativeOpenSource/atmosphere/pull/146","diff_url":"https://github.com/iPlantCollaborativeOpenSource/atmosphere/pull/146.diff","patch_url":"https://github.com/iPlantCollaborativeOpenSource/atmosphere/pull/146.patch","issue_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/issues/146","number":146,"state":"open","locked":false,"title":"Expand quota to include Compute, Storage & Network values","user":{"login":"steve-gregory","id":2889930,"avatar_url":"https://avatars.githubusercontent.com/u/2889930?v=3","gravatar_id":"","url":"https://api.github.com/users/steve-gregory","html_url":"https://github.com/steve-gregory","followers_url":"https://api.github.com/users/steve-gregory/followers","following_url":"https://api.github.com/users/steve-gregory/following{/other_user}","gists_url":"https://api.github.com/users/steve-gregory/gists{/gist_id}","starred_url":"https://api.github.com/users/steve-gregory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steve-gregory/subscriptions","organizations_url":"https://api.github.com/users/steve-gregory/orgs","repos_url":"https://api.github.com/users/steve-gregory/repos","events_url":"https://api.github.com/users/steve-gregory/events{/privacy}","received_events_url":"https://api.github.com/users/steve-gregory/received_events","type":"User","site_admin":false},"body":"Highlight Reel:\r\n* Add new Compute Quota values: Instance Count\r\n* Add new Volume Quota values: Snapshot Count & Volume Count\r\n* Add new Network Quota values: Floating IP Count & Port Count\r\n* Remove Suspended Count (artificial value)\r\n* Clean up complicated logic revolving around suspended_count and 'disappearing quota'.\r\n\r\nOnce set, Quota values will be saved to the cloud via `service.tasks.admin.set_provider_quota`.\r\n\r\nSlated for the \"Second release of N\".","created_at":"2016-05-16T17:32:42Z","updated_at":"2016-05-18T17:37:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"10a7db4b44632f6ec2d12c3420bb30a3893767e5","assignee":{"login":"lenards","id":5923,"avatar_url":"https://avatars.githubusercontent.com/u/5923?v=3","gravatar_id":"","url":"https://api.github.com/users/lenards","html_url":"https://github.com/lenards","followers_url":"https://api.github.com/users/lenards/followers","following_url":"https://api.github.com/users/lenards/following{/other_user}","gists_url":"https://api.github.com/users/lenards/gists{/gist_id}","starred_url":"https://api.github.com/users/lenards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lenards/subscriptions","organizations_url":"https://api.github.com/users/lenards/orgs","repos_url":"https://api.github.com/users/lenards/repos","events_url":"https://api.github.com/users/lenards/events{/privacy}","received_events_url":"https://api.github.com/users/lenards/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/milestones/1","html_url":"https://github.com/iPlantCollaborativeOpenSource/atmosphere/milestones/nautical-nighthawk","labels_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/milestones/1/labels","id":1686258,"number":1,"title":"nautical-nighthawk","description":null,"creator":{"login":"steve-gregory","id":2889930,"avatar_url":"https://avatars.githubusercontent.com/u/2889930?v=3","gravatar_id":"","url":"https://api.github.com/users/steve-gregory","html_url":"https://github.com/steve-gregory","followers_url":"https://api.github.com/users/steve-gregory/followers","following_url":"https://api.github.com/users/steve-gregory/following{/other_user}","gists_url":"https://api.github.com/users/steve-gregory/gists{/gist_id}","starred_url":"https://api.github.com/users/steve-gregory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steve-gregory/subscriptions","organizations_url":"https://api.github.com/users/steve-gregory/orgs","repos_url":"https://api.github.com/users/steve-gregory/repos","events_url":"https://api.github.com/users/steve-gregory/events{/privacy}","received_events_url":"https://api.github.com/users/steve-gregory/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":5,"state":"open","created_at":"2016-04-06T02:08:32Z","updated_at":"2016-05-17T04:15:57Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/146/commits","review_comments_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/146/comments","review_comment_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/issues/146/comments","statuses_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/statuses/ec4eba6909ee5c43e849069904278f40ba9858ae","head":{"label":"steve-gregory:expand_quota","ref":"expand_quota","sha":"ec4eba6909ee5c43e849069904278f40ba9858ae","user":{"login":"steve-gregory","id":2889930,"avatar_url":"https://avatars.githubusercontent.com/u/2889930?v=3","gravatar_id":"","url":"https://api.github.com/users/steve-gregory","html_url":"https://github.com/steve-gregory","followers_url":"https://api.github.com/users/steve-gregory/followers","following_url":"https://api.github.com/users/steve-gregory/following{/other_user}","gists_url":"https://api.github.com/users/steve-gregory/gists{/gist_id}","starred_url":"https://api.github.com/users/steve-gregory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steve-gregory/subscriptions","organizations_url":"https://api.github.com/users/steve-gregory/orgs","repos_url":"https://api.github.com/users/steve-gregory/repos","events_url":"https://api.github.com/users/steve-gregory/events{/privacy}","received_events_url":"https://api.github.com/users/steve-gregory/received_events","type":"User","site_admin":false},"repo":{"id":52845000,"name":"atmosphere","full_name":"steve-gregory/atmosphere","owner":{"login":"steve-gregory","id":2889930,"avatar_url":"https://avatars.githubusercontent.com/u/2889930?v=3","gravatar_id":"","url":"https://api.github.com/users/steve-gregory","html_url":"https://github.com/steve-gregory","followers_url":"https://api.github.com/users/steve-gregory/followers","following_url":"https://api.github.com/users/steve-gregory/following{/other_user}","gists_url":"https://api.github.com/users/steve-gregory/gists{/gist_id}","starred_url":"https://api.github.com/users/steve-gregory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steve-gregory/subscriptions","organizations_url":"https://api.github.com/users/steve-gregory/orgs","repos_url":"https://api.github.com/users/steve-gregory/repos","events_url":"https://api.github.com/users/steve-gregory/events{/privacy}","received_events_url":"https://api.github.com/users/steve-gregory/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/steve-gregory/atmosphere","description":"Where cloud lives.","fork":true,"url":"https://api.github.com/repos/steve-gregory/atmosphere","forks_url":"https://api.github.com/repos/steve-gregory/atmosphere/forks","keys_url":"https://api.github.com/repos/steve-gregory/atmosphere/keys{/key_id}","collaborators_url":"https://api.github.com/repos/steve-gregory/atmosphere/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/steve-gregory/atmosphere/teams","hooks_url":"https://api.github.com/repos/steve-gregory/atmosphere/hooks","issue_events_url":"https://api.github.com/repos/steve-gregory/atmosphere/issues/events{/number}","events_url":"https://api.github.com/repos/steve-gregory/atmosphere/events","assignees_url":"https://api.github.com/repos/steve-gregory/atmosphere/assignees{/user}","branches_url":"https://api.github.com/repos/steve-gregory/atmosphere/branches{/branch}","tags_url":"https://api.github.com/repos/steve-gregory/atmosphere/tags","blobs_url":"https://api.github.com/repos/steve-gregory/atmosphere/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/steve-gregory/atmosphere/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/steve-gregory/atmosphere/git/refs{/sha}","trees_url":"https://api.github.com/repos/steve-gregory/atmosphere/git/trees{/sha}","statuses_url":"https://api.github.com/repos/steve-gregory/atmosphere/statuses/{sha}","languages_url":"https://api.github.com/repos/steve-gregory/atmosphere/languages","stargazers_url":"https://api.github.com/repos/steve-gregory/atmosphere/stargazers","contributors_url":"https://api.github.com/repos/steve-gregory/atmosphere/contributors","subscribers_url":"https://api.github.com/repos/steve-gregory/atmosphere/subscribers","subscription_url":"https://api.github.com/repos/steve-gregory/atmosphere/subscription","commits_url":"https://api.github.com/repos/steve-gregory/atmosphere/commits{/sha}","git_commits_url":"https://api.github.com/repos/steve-gregory/atmosphere/git/commits{/sha}","comments_url":"https://api.github.com/repos/steve-gregory/atmosphere/comments{/number}","issue_comment_url":"https://api.github.com/repos/steve-gregory/atmosphere/issues/comments{/number}","contents_url":"https://api.github.com/repos/steve-gregory/atmosphere/contents/{+path}","compare_url":"https://api.github.com/repos/steve-gregory/atmosphere/compare/{base}...{head}","merges_url":"https://api.github.com/repos/steve-gregory/atmosphere/merges","archive_url":"https://api.github.com/repos/steve-gregory/atmosphere/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/steve-gregory/atmosphere/downloads","issues_url":"https://api.github.com/repos/steve-gregory/atmosphere/issues{/number}","pulls_url":"https://api.github.com/repos/steve-gregory/atmosphere/pulls{/number}","milestones_url":"https://api.github.com/repos/steve-gregory/atmosphere/milestones{/number}","notifications_url":"https://api.github.com/repos/steve-gregory/atmosphere/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/steve-gregory/atmosphere/labels{/name}","releases_url":"https://api.github.com/repos/steve-gregory/atmosphere/releases{/id}","deployments_url":"https://api.github.com/repos/steve-gregory/atmosphere/deployments","created_at":"2016-03-01T03:26:55Z","updated_at":"2016-03-01T03:26:57Z","pushed_at":"2016-05-18T17:37:02Z","git_url":"git://github.com/steve-gregory/atmosphere.git","ssh_url":"git@github.com:steve-gregory/atmosphere.git","clone_url":"https://github.com/steve-gregory/atmosphere.git","svn_url":"https://github.com/steve-gregory/atmosphere","homepage":"https://atmo.iplantcollaborative.org","size":177584,"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":"iPlantCollaborativeOpenSource:nautical-nighthawk","ref":"nautical-nighthawk","sha":"66dff75aaf9d7faa3943d091c11c5dbfc9eefff6","user":{"login":"iPlantCollaborativeOpenSource","id":669032,"avatar_url":"https://avatars.githubusercontent.com/u/669032?v=3","gravatar_id":"","url":"https://api.github.com/users/iPlantCollaborativeOpenSource","html_url":"https://github.com/iPlantCollaborativeOpenSource","followers_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/followers","following_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/following{/other_user}","gists_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/gists{/gist_id}","starred_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/subscriptions","organizations_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/orgs","repos_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/repos","events_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/events{/privacy}","received_events_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/received_events","type":"Organization","site_admin":false},"repo":{"id":8279795,"name":"atmosphere","full_name":"iPlantCollaborativeOpenSource/atmosphere","owner":{"login":"iPlantCollaborativeOpenSource","id":669032,"avatar_url":"https://avatars.githubusercontent.com/u/669032?v=3","gravatar_id":"","url":"https://api.github.com/users/iPlantCollaborativeOpenSource","html_url":"https://github.com/iPlantCollaborativeOpenSource","followers_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/followers","following_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/following{/other_user}","gists_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/gists{/gist_id}","starred_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/subscriptions","organizations_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/orgs","repos_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/repos","events_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/events{/privacy}","received_events_url":"https://api.github.com/users/iPlantCollaborativeOpenSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iPlantCollaborativeOpenSource/atmosphere","description":"Where cloud lives.","fork":false,"url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere","forks_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/forks","keys_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/teams","hooks_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/hooks","issue_events_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/issues/events{/number}","events_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/events","assignees_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/assignees{/user}","branches_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/branches{/branch}","tags_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/tags","blobs_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/git/refs{/sha}","trees_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/statuses/{sha}","languages_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/languages","stargazers_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/stargazers","contributors_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/contributors","subscribers_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/subscribers","subscription_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/subscription","commits_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/commits{/sha}","git_commits_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/git/commits{/sha}","comments_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/comments{/number}","issue_comment_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/issues/comments{/number}","contents_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/contents/{+path}","compare_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/merges","archive_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/downloads","issues_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/issues{/number}","pulls_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls{/number}","milestones_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/milestones{/number}","notifications_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/labels{/name}","releases_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/releases{/id}","deployments_url":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/deployments","created_at":"2013-02-18T23:54:07Z","updated_at":"2016-05-16T04:01:19Z","pushed_at":"2016-05-18T17:37:06Z","git_url":"git://github.com/iPlantCollaborativeOpenSource/atmosphere.git","ssh_url":"git@github.com:iPlantCollaborativeOpenSource/atmosphere.git","clone_url":"https://github.com/iPlantCollaborativeOpenSource/atmosphere.git","svn_url":"https://github.com/iPlantCollaborativeOpenSource/atmosphere","homepage":"https://atmo.iplantcollaborative.org","size":177585,"stargazers_count":121,"watchers_count":121,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":60,"mirror_url":null,"open_issues_count":7,"forks":60,"open_issues":7,"watchers":121,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/146"},"html":{"href":"https://github.com/iPlantCollaborativeOpenSource/atmosphere/pull/146"},"issue":{"href":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/issues/146"},"comments":{"href":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/issues/146/comments"},"review_comments":{"href":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/146/comments"},"review_comment":{"href":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/pulls/146/commits"},"statuses":{"href":"https://api.github.com/repos/iPlantCollaborativeOpenSource/atmosphere/statuses/ec4eba6909ee5c43e849069904278f40ba9858ae"}}}}