{"action":"created","comment":{"url":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/comments/85221828","pull_request_review_id":5950001,"id":85221828,"diff_hunk":"@@ -723,38 +731,341 @@ def get_version():\n     except:\n         return NOT_AVAILABLE\n \n+def get_tenant_from_db(name):\n+    auth.connect_auth_db()\n+    error_info, tenant = auth._auth_mgr.get_tenant(name)\n+    return error_info, tenant\n+\n+def operation_fail(error_info):\n+    print error_info\n+    return error_info\n+\n+def tenant_ls_headers():\n+    \"\"\" Return column names for tenant ls command \"\"\"\n+    headers = ['Uuid', 'Name', 'Description', 'Default_datastore', 'VM_list']\n+    return headers\n+\n+def generate_vm_list(vms):\n+    \"\"\" Generate a comma separated string with given list \"\"\"\n+    res = \"\"\n+    for vm in vms:\n+        # vm[1] is vm_name, vm has format (vm_uuid, vm_name)\n+        res = res + vm[1]\n+        res = res + \",\"\n+        \n+    if res:\n+        res = res[:-1]\n+\n+    return res    \n+\n+def generate_tenant_ls_rows(tenant_list):\n+    \"\"\" Generate output for tenant ls command \"\"\"\n+    rows = []\n+    for tenant in tenant_list:\n+        uuid = tenant.id\n+        name = tenant.name\n+        description = tenant.description\n+        default_datastore = tenant.default_datastore\n+        vm_list = generate_vm_list(tenant.vms)\n+        rows.append([uuid, name, description, default_datastore, vm_list])\n+    \n+    return rows\n \n-NOT_IMPLEMENTED = \"Not implemented\"\n+def generate_tuple_from_vm_list(vm_list):\n+    \"\"\" Generate a list of (vm_uuid, vm_name) pair \"\"\"\n+    vms = []\n+    for vm_name in vm_list:\n+        vm_uuid = vmdk_utils.get_vm_uuid_by_name(vm_name)\n+        if not vm_uuid:\n+            error_info =  \"Cannot find vm_uuid for vm {0}, tenant_create failed\".format(vm_name)\n+            return error_info, None\n+        vms.append((vm_uuid, vm_name))\n+    \n+    return None, vms\n \n def tenant_create(args):\n-    print(NOT_IMPLEMENTED)\n-\n+    \"\"\" Handle tenant create command \"\"\"\n+    error_info, vms = generate_tuple_from_vm_list(args.vm_list)\n+    if error_info:\n+        return operation_fail(error_info)\n+      \n+    name = args.name \n+    description = \"\" \n+    default_datastore =\"default_ds\" \n+    default_privileges =  {}\n+    privileges = []\n+\n+    auth.connect_auth_db()\n+    error_info, tenant = auth._auth_mgr.create_tenant(name, description, default_datastore, default_privileges, vms, privileges)\n+    \n+    if error_info:\n+        return operation_fail(error_info)\n+ \n def tenant_rm(args):\n-    print(NOT_IMPLEMENTED)\n+    \"\"\" Handle tenant rm command \"\"\"\n+    error_info, tenant = get_tenant_from_db(args.name)\n+    if error_info:\n+        return operation_fail(error_info)\n+\n+    remove_volumes = False","path":"esx_service/cli/vmdkops_admin.py","position":219,"original_position":162,"commit_id":"270e044fc73aa94fe1dd3d4d115f9e45769afb81","original_commit_id":"df39995ca6d31e73d98cc36b8913c0165bdb8fa3","user":{"login":"lipingxue","id":4754483,"avatar_url":"https://avatars.githubusercontent.com/u/4754483?v=3","gravatar_id":"","url":"https://api.github.com/users/lipingxue","html_url":"https://github.com/lipingxue","followers_url":"https://api.github.com/users/lipingxue/followers","following_url":"https://api.github.com/users/lipingxue/following{/other_user}","gists_url":"https://api.github.com/users/lipingxue/gists{/gist_id}","starred_url":"https://api.github.com/users/lipingxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lipingxue/subscriptions","organizations_url":"https://api.github.com/users/lipingxue/orgs","repos_url":"https://api.github.com/users/lipingxue/repos","events_url":"https://api.github.com/users/lipingxue/events{/privacy}","received_events_url":"https://api.github.com/users/lipingxue/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2016-10-26T21:13:42Z","updated_at":"2016-10-26T21:13:42Z","html_url":"https://github.com/vmware/docker-volume-vsphere/pull/645#discussion_r85221828","pull_request_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/645","_links":{"self":{"href":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/comments/85221828"},"html":{"href":"https://github.com/vmware/docker-volume-vsphere/pull/645#discussion_r85221828"},"pull_request":{"href":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/645"}}},"pull_request":{"url":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/645","id":90908636,"html_url":"https://github.com/vmware/docker-volume-vsphere/pull/645","diff_url":"https://github.com/vmware/docker-volume-vsphere/pull/645.diff","patch_url":"https://github.com/vmware/docker-volume-vsphere/pull/645.patch","issue_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues/645","number":645,"state":"open","locked":false,"title":"AdminCLI change to support multitenancy","user":{"login":"lipingxue","id":4754483,"avatar_url":"https://avatars.githubusercontent.com/u/4754483?v=3","gravatar_id":"","url":"https://api.github.com/users/lipingxue","html_url":"https://github.com/lipingxue","followers_url":"https://api.github.com/users/lipingxue/followers","following_url":"https://api.github.com/users/lipingxue/following{/other_user}","gists_url":"https://api.github.com/users/lipingxue/gists{/gist_id}","starred_url":"https://api.github.com/users/lipingxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lipingxue/subscriptions","organizations_url":"https://api.github.com/users/lipingxue/orgs","repos_url":"https://api.github.com/users/lipingxue/repos","events_url":"https://api.github.com/users/lipingxue/events{/privacy}","received_events_url":"https://api.github.com/users/lipingxue/received_events","type":"User","site_admin":false},"body":"This is a follow up review for the following PR. \r\nhttps://github.com/vmware/docker-volume-vsphere/pull/640\r\n\r\nPR 640 was closed by a merge which I did by accident. \r\n\r\n@msterin Mark has reviewed PR640 and gave some comments. I have addressed all his comments and create this new PR for review.\r\n\r\nFor the unit test, please see the original PR640. ","created_at":"2016-10-25T23:04:57Z","updated_at":"2016-10-26T21:13:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d6b882d42ab32f51cf31ce798b4399e1eb93a98e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/645/commits","review_comments_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/645/comments","review_comment_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues/645/comments","statuses_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/statuses/270e044fc73aa94fe1dd3d4d115f9e45769afb81","head":{"label":"vmware:cli-auth.liping","ref":"cli-auth.liping","sha":"270e044fc73aa94fe1dd3d4d115f9e45769afb81","user":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"repo":{"id":49599693,"name":"docker-volume-vsphere","full_name":"vmware/docker-volume-vsphere","owner":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vmware/docker-volume-vsphere","description":"Docker Volume Driver for vSphere.","fork":false,"url":"https://api.github.com/repos/vmware/docker-volume-vsphere","forks_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/forks","keys_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/teams","hooks_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/hooks","issue_events_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/events","assignees_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/tags","blobs_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/languages","stargazers_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/stargazers","contributors_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/contributors","subscribers_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/subscribers","subscription_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/subscription","commits_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/merges","archive_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/downloads","issues_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/labels{/name}","releases_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/deployments","created_at":"2016-01-13T20:25:36Z","updated_at":"2016-10-26T08:21:38Z","pushed_at":"2016-10-26T21:12:29Z","git_url":"git://github.com/vmware/docker-volume-vsphere.git","ssh_url":"git@github.com:vmware/docker-volume-vsphere.git","clone_url":"https://github.com/vmware/docker-volume-vsphere.git","svn_url":"https://github.com/vmware/docker-volume-vsphere","homepage":"https://vmware.github.io/docker-volume-vsphere","size":8318,"stargazers_count":76,"watchers_count":76,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":90,"forks":14,"open_issues":90,"watchers":76,"default_branch":"master"}},"base":{"label":"vmware:master","ref":"master","sha":"92d48ed5fbc8625d13632e92da590c6654b58e89","user":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"repo":{"id":49599693,"name":"docker-volume-vsphere","full_name":"vmware/docker-volume-vsphere","owner":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vmware/docker-volume-vsphere","description":"Docker Volume Driver for vSphere.","fork":false,"url":"https://api.github.com/repos/vmware/docker-volume-vsphere","forks_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/forks","keys_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/teams","hooks_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/hooks","issue_events_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/events","assignees_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/tags","blobs_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/languages","stargazers_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/stargazers","contributors_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/contributors","subscribers_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/subscribers","subscription_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/subscription","commits_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/merges","archive_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/downloads","issues_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/labels{/name}","releases_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/docker-volume-vsphere/deployments","created_at":"2016-01-13T20:25:36Z","updated_at":"2016-10-26T08:21:38Z","pushed_at":"2016-10-26T21:12:29Z","git_url":"git://github.com/vmware/docker-volume-vsphere.git","ssh_url":"git@github.com:vmware/docker-volume-vsphere.git","clone_url":"https://github.com/vmware/docker-volume-vsphere.git","svn_url":"https://github.com/vmware/docker-volume-vsphere","homepage":"https://vmware.github.io/docker-volume-vsphere","size":8318,"stargazers_count":76,"watchers_count":76,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":90,"forks":14,"open_issues":90,"watchers":76,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/645"},"html":{"href":"https://github.com/vmware/docker-volume-vsphere/pull/645"},"issue":{"href":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues/645"},"comments":{"href":"https://api.github.com/repos/vmware/docker-volume-vsphere/issues/645/comments"},"review_comments":{"href":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/645/comments"},"review_comment":{"href":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vmware/docker-volume-vsphere/pulls/645/commits"},"statuses":{"href":"https://api.github.com/repos/vmware/docker-volume-vsphere/statuses/270e044fc73aa94fe1dd3d4d115f9e45769afb81"}}}}
{"actor":{"display_login":"lipingxue"}}