{"action":"created","comment":{"url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/comments/41788440","id":41788440,"diff_hunk":"@@ -106,6 +107,44 @@ def read_info(self, **kwargs):\n             info['lb_vips'] = self.get_lb_vips()\n         return info\n \n+    def show_quota(self, tenant_id=''):\n+        return self.neutron_client.show_quota(tenant_id)\n+\n+    def list_quotas(self):\n+        return self.neutron_client.list_quotas()['quotas']\n+\n+    def get_quota(self, tenant_id):\n+        # return structure {'name_tenant': {'subnet': 10, ...}, ...}\n+        tenants = {}\n+        if not tenant_id:\n+            tenants_obj = self.identity_client.get_tenants_list()\n+            tenants = {t.id: t.name for t in tenants_obj}\n+        else:\n+            tenants[tenant_id] = self.identity_client.\\\n+                try_get_tenant_name_by_id(tenant_id)\n+        data = {\n+        }\n+        if self.config.network.get_all_quota:\n+            for t_id, t_val in tenants.iteritems():\n+                data[t_val] = self.neutron_client.show_quota(t_id)\n+        else:\n+            for t in self.neutron_client.list_quotas()['quotas']:\n+                if (not tenant_id) or (tenant_id == t['tenant_id']):\n+                    tenant_name = self.identity_client.\\\n+                        try_get_tenant_name_by_id(t['tenant_id'])\n+                    del t['tenant_id']\n+                    data[tenant_name] = t\n+        return data\n+\n+    def upload_quota(self, quota):\n+        identity = self.identity_client\n+        for q_name, q_val in quota.iteritems():\n+            tenant_id = identity.get_tenant_id_by_name(q_name)\n+            self.neutron_client.update_quota(tenant_id, q_val)\n+\n+    def create_quota(self, tenant_id, quota):\n+        return self.neutron_client.update_quota(tenant_id, quota)\n+","path":"cloudferrylib/os/network/neutron.py","position":50,"original_position":49,"commit_id":"ec76eebff902cf1452fa0e2640915e6005c08335","original_commit_id":"af535a85acd0051cff2a69bc948c4b1265773711","user":{"login":"roman-verchikov","id":386276,"avatar_url":"https://avatars.githubusercontent.com/u/386276?v=3","gravatar_id":"","url":"https://api.github.com/users/roman-verchikov","html_url":"https://github.com/roman-verchikov","followers_url":"https://api.github.com/users/roman-verchikov/followers","following_url":"https://api.github.com/users/roman-verchikov/following{/other_user}","gists_url":"https://api.github.com/users/roman-verchikov/gists{/gist_id}","starred_url":"https://api.github.com/users/roman-verchikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roman-verchikov/subscriptions","organizations_url":"https://api.github.com/users/roman-verchikov/orgs","repos_url":"https://api.github.com/users/roman-verchikov/repos","events_url":"https://api.github.com/users/roman-verchikov/events{/privacy}","received_events_url":"https://api.github.com/users/roman-verchikov/received_events","type":"User","site_admin":false},"body":"> Do I need to make in separate entities if the network subnet, router, and etc?\r\n\r\nYes at some point, but not with this pull request. Separation of concerns is one of the primary object oriented design patterns, and [blob objects](https://sourcemaking.com/antipatterns/the-blob) are one of the most common anti-patterns. By introducing more functionality (adding quota functionality) into a blob class (`NeutronNetwork` in this case) you simply follow traditional anti-pattern instead of resolving it.","created_at":"2015-10-12T18:49:38Z","updated_at":"2015-10-12T18:49:38Z","html_url":"https://github.com/MirantisWorkloadMobility/CloudFerry/pull/457#discussion_r41788440","pull_request_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/457","_links":{"self":{"href":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/comments/41788440"},"html":{"href":"https://github.com/MirantisWorkloadMobility/CloudFerry/pull/457#discussion_r41788440"},"pull_request":{"href":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/457"}}},"pull_request":{"url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/457","id":46639715,"html_url":"https://github.com/MirantisWorkloadMobility/CloudFerry/pull/457","diff_url":"https://github.com/MirantisWorkloadMobility/CloudFerry/pull/457.diff","patch_url":"https://github.com/MirantisWorkloadMobility/CloudFerry/pull/457.patch","issue_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/issues/457","number":457,"state":"open","locked":false,"title":"[SAIC-308]Migrate quotas network","user":{"login":"mirrorcoder","id":1520281,"avatar_url":"https://avatars.githubusercontent.com/u/1520281?v=3","gravatar_id":"","url":"https://api.github.com/users/mirrorcoder","html_url":"https://github.com/mirrorcoder","followers_url":"https://api.github.com/users/mirrorcoder/followers","following_url":"https://api.github.com/users/mirrorcoder/following{/other_user}","gists_url":"https://api.github.com/users/mirrorcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/mirrorcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirrorcoder/subscriptions","organizations_url":"https://api.github.com/users/mirrorcoder/orgs","repos_url":"https://api.github.com/users/mirrorcoder/repos","events_url":"https://api.github.com/users/mirrorcoder/events{/privacy}","received_events_url":"https://api.github.com/users/mirrorcoder/received_events","type":"User","site_admin":false},"body":"It has a function of getting quotas and their loading.\r\nImplemented unit tests.","created_at":"2015-10-02T14:14:52Z","updated_at":"2015-10-12T18:49:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e253ee96b025482c9172959c5297242370a88122","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/457/commits","review_comments_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/457/comments","review_comment_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/issues/457/comments","statuses_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/statuses/ec76eebff902cf1452fa0e2640915e6005c08335","head":{"label":"mirrorcoder:next_task_2","ref":"next_task_2","sha":"ec76eebff902cf1452fa0e2640915e6005c08335","user":{"login":"mirrorcoder","id":1520281,"avatar_url":"https://avatars.githubusercontent.com/u/1520281?v=3","gravatar_id":"","url":"https://api.github.com/users/mirrorcoder","html_url":"https://github.com/mirrorcoder","followers_url":"https://api.github.com/users/mirrorcoder/followers","following_url":"https://api.github.com/users/mirrorcoder/following{/other_user}","gists_url":"https://api.github.com/users/mirrorcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/mirrorcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirrorcoder/subscriptions","organizations_url":"https://api.github.com/users/mirrorcoder/orgs","repos_url":"https://api.github.com/users/mirrorcoder/repos","events_url":"https://api.github.com/users/mirrorcoder/events{/privacy}","received_events_url":"https://api.github.com/users/mirrorcoder/received_events","type":"User","site_admin":false},"repo":{"id":23152774,"name":"CloudFerry","full_name":"mirrorcoder/CloudFerry","owner":{"login":"mirrorcoder","id":1520281,"avatar_url":"https://avatars.githubusercontent.com/u/1520281?v=3","gravatar_id":"","url":"https://api.github.com/users/mirrorcoder","html_url":"https://github.com/mirrorcoder","followers_url":"https://api.github.com/users/mirrorcoder/followers","following_url":"https://api.github.com/users/mirrorcoder/following{/other_user}","gists_url":"https://api.github.com/users/mirrorcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/mirrorcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirrorcoder/subscriptions","organizations_url":"https://api.github.com/users/mirrorcoder/orgs","repos_url":"https://api.github.com/users/mirrorcoder/repos","events_url":"https://api.github.com/users/mirrorcoder/events{/privacy}","received_events_url":"https://api.github.com/users/mirrorcoder/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mirrorcoder/CloudFerry","description":"CloudFerry is a cloud virtual workloads migration tool designed and developed by Mirantis Inc. ","fork":true,"url":"https://api.github.com/repos/mirrorcoder/CloudFerry","forks_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/forks","keys_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/teams","hooks_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/hooks","issue_events_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/issues/events{/number}","events_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/events","assignees_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/assignees{/user}","branches_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/branches{/branch}","tags_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/tags","blobs_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/git/refs{/sha}","trees_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/statuses/{sha}","languages_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/languages","stargazers_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/stargazers","contributors_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/contributors","subscribers_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/subscribers","subscription_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/subscription","commits_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/commits{/sha}","git_commits_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/git/commits{/sha}","comments_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/comments{/number}","issue_comment_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/issues/comments{/number}","contents_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/contents/{+path}","compare_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/merges","archive_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/downloads","issues_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/issues{/number}","pulls_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/pulls{/number}","milestones_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/milestones{/number}","notifications_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/labels{/name}","releases_url":"https://api.github.com/repos/mirrorcoder/CloudFerry/releases{/id}","created_at":"2014-08-20T15:00:38Z","updated_at":"2015-03-16T14:47:41Z","pushed_at":"2015-10-12T14:56:10Z","git_url":"git://github.com/mirrorcoder/CloudFerry.git","ssh_url":"git@github.com:mirrorcoder/CloudFerry.git","clone_url":"https://github.com/mirrorcoder/CloudFerry.git","svn_url":"https://github.com/mirrorcoder/CloudFerry","homepage":null,"size":2867,"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":"MirantisWorkloadMobility:devel","ref":"devel","sha":"3cb2f6a0e0a308d8ea4725381ce63b9d7b5e0def","user":{"login":"MirantisWorkloadMobility","id":8500817,"avatar_url":"https://avatars.githubusercontent.com/u/8500817?v=3","gravatar_id":"","url":"https://api.github.com/users/MirantisWorkloadMobility","html_url":"https://github.com/MirantisWorkloadMobility","followers_url":"https://api.github.com/users/MirantisWorkloadMobility/followers","following_url":"https://api.github.com/users/MirantisWorkloadMobility/following{/other_user}","gists_url":"https://api.github.com/users/MirantisWorkloadMobility/gists{/gist_id}","starred_url":"https://api.github.com/users/MirantisWorkloadMobility/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MirantisWorkloadMobility/subscriptions","organizations_url":"https://api.github.com/users/MirantisWorkloadMobility/orgs","repos_url":"https://api.github.com/users/MirantisWorkloadMobility/repos","events_url":"https://api.github.com/users/MirantisWorkloadMobility/events{/privacy}","received_events_url":"https://api.github.com/users/MirantisWorkloadMobility/received_events","type":"User","site_admin":false},"repo":{"id":23142392,"name":"CloudFerry","full_name":"MirantisWorkloadMobility/CloudFerry","owner":{"login":"MirantisWorkloadMobility","id":8500817,"avatar_url":"https://avatars.githubusercontent.com/u/8500817?v=3","gravatar_id":"","url":"https://api.github.com/users/MirantisWorkloadMobility","html_url":"https://github.com/MirantisWorkloadMobility","followers_url":"https://api.github.com/users/MirantisWorkloadMobility/followers","following_url":"https://api.github.com/users/MirantisWorkloadMobility/following{/other_user}","gists_url":"https://api.github.com/users/MirantisWorkloadMobility/gists{/gist_id}","starred_url":"https://api.github.com/users/MirantisWorkloadMobility/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MirantisWorkloadMobility/subscriptions","organizations_url":"https://api.github.com/users/MirantisWorkloadMobility/orgs","repos_url":"https://api.github.com/users/MirantisWorkloadMobility/repos","events_url":"https://api.github.com/users/MirantisWorkloadMobility/events{/privacy}","received_events_url":"https://api.github.com/users/MirantisWorkloadMobility/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MirantisWorkloadMobility/CloudFerry","description":"CloudFerry is a cloud virtual workloads migration tool designed and developed by Mirantis Inc. ","fork":false,"url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry","forks_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/forks","keys_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/teams","hooks_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/hooks","issue_events_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/issues/events{/number}","events_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/events","assignees_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/assignees{/user}","branches_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/branches{/branch}","tags_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/tags","blobs_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/git/refs{/sha}","trees_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/statuses/{sha}","languages_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/languages","stargazers_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/stargazers","contributors_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/contributors","subscribers_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/subscribers","subscription_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/subscription","commits_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/commits{/sha}","git_commits_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/git/commits{/sha}","comments_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/comments{/number}","issue_comment_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/issues/comments{/number}","contents_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/contents/{+path}","compare_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/merges","archive_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/downloads","issues_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/issues{/number}","pulls_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls{/number}","milestones_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/milestones{/number}","notifications_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/labels{/name}","releases_url":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/releases{/id}","created_at":"2014-08-20T09:00:38Z","updated_at":"2015-09-19T20:39:53Z","pushed_at":"2015-10-12T18:27:39Z","git_url":"git://github.com/MirantisWorkloadMobility/CloudFerry.git","ssh_url":"git@github.com:MirantisWorkloadMobility/CloudFerry.git","clone_url":"https://github.com/MirantisWorkloadMobility/CloudFerry.git","svn_url":"https://github.com/MirantisWorkloadMobility/CloudFerry","homepage":null,"size":6316,"stargazers_count":11,"watchers_count":11,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":13,"forks":25,"open_issues":13,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/457"},"html":{"href":"https://github.com/MirantisWorkloadMobility/CloudFerry/pull/457"},"issue":{"href":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/issues/457"},"comments":{"href":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/issues/457/comments"},"review_comments":{"href":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/457/comments"},"review_comment":{"href":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/pulls/457/commits"},"statuses":{"href":"https://api.github.com/repos/MirantisWorkloadMobility/CloudFerry/statuses/ec76eebff902cf1452fa0e2640915e6005c08335"}}}}