{"action":"created","comment":{"url":"https://api.github.com/repos/vmware/nsxansible/pulls/comments/91704497","pull_request_review_id":12214893,"id":91704497,"diff_hunk":"@@ -0,0 +1,80 @@\n+#!/usr/bin/env python\n+# coding=utf-8\n+#\n+# Copyright © 2015 VMware, Inc. All Rights Reserved.\n+#\n+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n+# documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation\n+# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and\n+# to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n+#\n+# The above copyright notice and this permission notice shall be included in all copies or substantial portions\n+# of the Software.\n+#\n+# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\n+# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\n+# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n+# IN THE SOFTWARE.\n+\n+def get_logical_switch(client_session, logical_switch_name):\n+    \"\"\"\n+    :param client_session: An instance of an NsxClient Session\n+    :param logical_switch_name: The name of the logical switch searched\n+    :return: A tuple, with the first item being the logical switch id as string of the first Scope found with the\n+             right name and the second item being a dictionary of the logical parameters as return by the NSX API\n+    \"\"\"\n+    all_lswitches = client_session.read_all_pages('logicalSwitchesGlobal', 'read')\n+    try:\n+        logical_switch_params = [scope for scope in all_lswitches if scope['name'] == logical_switch_name][0]\n+        logical_switch_id = logical_switch_params['objectId']\n+    except IndexError:\n+        return None\n+\n+    return logical_switch_id\n+\n+def main():\n+    module = AnsibleModule(\n+        argument_spec=dict(\n+            state=dict(default='present', choices=['present', 'absent']),\n+            nsxmanager_spec=dict(required=True, no_log=True, type='dict'),\n+            portgroup_id=dict(default=None),\n+            logicalswitch=dict(default=None),\n+            objectUUID=dict(required=True),\n+        ),\n+        supports_check_mode=False\n+    )\n+\n+    portgroup_id = module.params['portgroup_id']\n+    logicalswitch = module.params['logicalswitch']\n+    \n+    if portgroup_id != None and logicalswitch != None:","path":"library/nsx_attach_vm_switch.py","position":51,"original_position":51,"commit_id":"5935c3bcb2f786ff91aeaa79b6f740af1481f0e5","original_commit_id":"1d9266526f28ccc1ac4886e04c69ee48b8901600","user":{"login":"yfauser","id":2316520,"avatar_url":"https://avatars.githubusercontent.com/u/2316520?v=3","gravatar_id":"","url":"https://api.github.com/users/yfauser","html_url":"https://github.com/yfauser","followers_url":"https://api.github.com/users/yfauser/followers","following_url":"https://api.github.com/users/yfauser/following{/other_user}","gists_url":"https://api.github.com/users/yfauser/gists{/gist_id}","starred_url":"https://api.github.com/users/yfauser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yfauser/subscriptions","organizations_url":"https://api.github.com/users/yfauser/orgs","repos_url":"https://api.github.com/users/yfauser/repos","events_url":"https://api.github.com/users/yfauser/events{/privacy}","received_events_url":"https://api.github.com/users/yfauser/received_events","type":"User","site_admin":false},"body":"In all other modules I generally use ```if variable:``` to check if the variable is not None or Flase, or ```if not variable:``` to check if it's None or False. For consistency can you please change this to : ```if portgroup_id and logicalswitch:```?","created_at":"2016-12-09T11:57:55Z","updated_at":"2016-12-09T11:57:55Z","html_url":"https://github.com/vmware/nsxansible/pull/35#discussion_r91704497","pull_request_url":"https://api.github.com/repos/vmware/nsxansible/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/vmware/nsxansible/pulls/comments/91704497"},"html":{"href":"https://github.com/vmware/nsxansible/pull/35#discussion_r91704497"},"pull_request":{"href":"https://api.github.com/repos/vmware/nsxansible/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/vmware/nsxansible/pulls/35","id":96091615,"html_url":"https://github.com/vmware/nsxansible/pull/35","diff_url":"https://github.com/vmware/nsxansible/pull/35.diff","patch_url":"https://github.com/vmware/nsxansible/pull/35.patch","issue_url":"https://api.github.com/repos/vmware/nsxansible/issues/35","number":35,"state":"open","locked":false,"title":"Add library to attach a VM to a logical switch","user":{"login":"scornelissen85","id":5145555,"avatar_url":"https://avatars.githubusercontent.com/u/5145555?v=3","gravatar_id":"","url":"https://api.github.com/users/scornelissen85","html_url":"https://github.com/scornelissen85","followers_url":"https://api.github.com/users/scornelissen85/followers","following_url":"https://api.github.com/users/scornelissen85/following{/other_user}","gists_url":"https://api.github.com/users/scornelissen85/gists{/gist_id}","starred_url":"https://api.github.com/users/scornelissen85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scornelissen85/subscriptions","organizations_url":"https://api.github.com/users/scornelissen85/orgs","repos_url":"https://api.github.com/users/scornelissen85/repos","events_url":"https://api.github.com/users/scornelissen85/events{/privacy}","received_events_url":"https://api.github.com/users/scornelissen85/received_events","type":"User","site_admin":false},"body":"I've build a library to add a VM to a virtualswitch. The input that the library need is portgroup_id or logicalswitch-name with the UUID of the VM.","created_at":"2016-12-01T13:48:17Z","updated_at":"2016-12-09T11:57:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf994d661883fecc67e0b5b7cc628ae1d35cb624","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vmware/nsxansible/pulls/35/commits","review_comments_url":"https://api.github.com/repos/vmware/nsxansible/pulls/35/comments","review_comment_url":"https://api.github.com/repos/vmware/nsxansible/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vmware/nsxansible/issues/35/comments","statuses_url":"https://api.github.com/repos/vmware/nsxansible/statuses/5935c3bcb2f786ff91aeaa79b6f740af1481f0e5","head":{"label":"scornelissen85:feature/attach-vm-to-LS","ref":"feature/attach-vm-to-LS","sha":"5935c3bcb2f786ff91aeaa79b6f740af1481f0e5","user":{"login":"scornelissen85","id":5145555,"avatar_url":"https://avatars.githubusercontent.com/u/5145555?v=3","gravatar_id":"","url":"https://api.github.com/users/scornelissen85","html_url":"https://github.com/scornelissen85","followers_url":"https://api.github.com/users/scornelissen85/followers","following_url":"https://api.github.com/users/scornelissen85/following{/other_user}","gists_url":"https://api.github.com/users/scornelissen85/gists{/gist_id}","starred_url":"https://api.github.com/users/scornelissen85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scornelissen85/subscriptions","organizations_url":"https://api.github.com/users/scornelissen85/orgs","repos_url":"https://api.github.com/users/scornelissen85/repos","events_url":"https://api.github.com/users/scornelissen85/events{/privacy}","received_events_url":"https://api.github.com/users/scornelissen85/received_events","type":"User","site_admin":false},"repo":{"id":75289547,"name":"nsxansible","full_name":"scornelissen85/nsxansible","owner":{"login":"scornelissen85","id":5145555,"avatar_url":"https://avatars.githubusercontent.com/u/5145555?v=3","gravatar_id":"","url":"https://api.github.com/users/scornelissen85","html_url":"https://github.com/scornelissen85","followers_url":"https://api.github.com/users/scornelissen85/followers","following_url":"https://api.github.com/users/scornelissen85/following{/other_user}","gists_url":"https://api.github.com/users/scornelissen85/gists{/gist_id}","starred_url":"https://api.github.com/users/scornelissen85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scornelissen85/subscriptions","organizations_url":"https://api.github.com/users/scornelissen85/orgs","repos_url":"https://api.github.com/users/scornelissen85/repos","events_url":"https://api.github.com/users/scornelissen85/events{/privacy}","received_events_url":"https://api.github.com/users/scornelissen85/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scornelissen85/nsxansible","description":"A set of example Ansible Modules using the above two projects as the basis","fork":true,"url":"https://api.github.com/repos/scornelissen85/nsxansible","forks_url":"https://api.github.com/repos/scornelissen85/nsxansible/forks","keys_url":"https://api.github.com/repos/scornelissen85/nsxansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scornelissen85/nsxansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scornelissen85/nsxansible/teams","hooks_url":"https://api.github.com/repos/scornelissen85/nsxansible/hooks","issue_events_url":"https://api.github.com/repos/scornelissen85/nsxansible/issues/events{/number}","events_url":"https://api.github.com/repos/scornelissen85/nsxansible/events","assignees_url":"https://api.github.com/repos/scornelissen85/nsxansible/assignees{/user}","branches_url":"https://api.github.com/repos/scornelissen85/nsxansible/branches{/branch}","tags_url":"https://api.github.com/repos/scornelissen85/nsxansible/tags","blobs_url":"https://api.github.com/repos/scornelissen85/nsxansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scornelissen85/nsxansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scornelissen85/nsxansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/scornelissen85/nsxansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scornelissen85/nsxansible/statuses/{sha}","languages_url":"https://api.github.com/repos/scornelissen85/nsxansible/languages","stargazers_url":"https://api.github.com/repos/scornelissen85/nsxansible/stargazers","contributors_url":"https://api.github.com/repos/scornelissen85/nsxansible/contributors","subscribers_url":"https://api.github.com/repos/scornelissen85/nsxansible/subscribers","subscription_url":"https://api.github.com/repos/scornelissen85/nsxansible/subscription","commits_url":"https://api.github.com/repos/scornelissen85/nsxansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/scornelissen85/nsxansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/scornelissen85/nsxansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/scornelissen85/nsxansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/scornelissen85/nsxansible/contents/{+path}","compare_url":"https://api.github.com/repos/scornelissen85/nsxansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scornelissen85/nsxansible/merges","archive_url":"https://api.github.com/repos/scornelissen85/nsxansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scornelissen85/nsxansible/downloads","issues_url":"https://api.github.com/repos/scornelissen85/nsxansible/issues{/number}","pulls_url":"https://api.github.com/repos/scornelissen85/nsxansible/pulls{/number}","milestones_url":"https://api.github.com/repos/scornelissen85/nsxansible/milestones{/number}","notifications_url":"https://api.github.com/repos/scornelissen85/nsxansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scornelissen85/nsxansible/labels{/name}","releases_url":"https://api.github.com/repos/scornelissen85/nsxansible/releases{/id}","deployments_url":"https://api.github.com/repos/scornelissen85/nsxansible/deployments","created_at":"2016-12-01T12:15:47Z","updated_at":"2016-12-01T12:15:48Z","pushed_at":"2016-12-01T13:54:53Z","git_url":"git://github.com/scornelissen85/nsxansible.git","ssh_url":"git@github.com:scornelissen85/nsxansible.git","clone_url":"https://github.com/scornelissen85/nsxansible.git","svn_url":"https://github.com/scornelissen85/nsxansible","homepage":null,"size":199,"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":"vmware:master","ref":"master","sha":"004dc6e1319f0b49f44ccfd345b1a4c2427df3e4","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":41574429,"name":"nsxansible","full_name":"vmware/nsxansible","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/nsxansible","description":"A set of example Ansible Modules using the above two projects as the basis","fork":false,"url":"https://api.github.com/repos/vmware/nsxansible","forks_url":"https://api.github.com/repos/vmware/nsxansible/forks","keys_url":"https://api.github.com/repos/vmware/nsxansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/nsxansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/nsxansible/teams","hooks_url":"https://api.github.com/repos/vmware/nsxansible/hooks","issue_events_url":"https://api.github.com/repos/vmware/nsxansible/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/nsxansible/events","assignees_url":"https://api.github.com/repos/vmware/nsxansible/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/nsxansible/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/nsxansible/tags","blobs_url":"https://api.github.com/repos/vmware/nsxansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/nsxansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/nsxansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/nsxansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/nsxansible/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/nsxansible/languages","stargazers_url":"https://api.github.com/repos/vmware/nsxansible/stargazers","contributors_url":"https://api.github.com/repos/vmware/nsxansible/contributors","subscribers_url":"https://api.github.com/repos/vmware/nsxansible/subscribers","subscription_url":"https://api.github.com/repos/vmware/nsxansible/subscription","commits_url":"https://api.github.com/repos/vmware/nsxansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/nsxansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/nsxansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/nsxansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/nsxansible/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/nsxansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/nsxansible/merges","archive_url":"https://api.github.com/repos/vmware/nsxansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/nsxansible/downloads","issues_url":"https://api.github.com/repos/vmware/nsxansible/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/nsxansible/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/nsxansible/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/nsxansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/nsxansible/labels{/name}","releases_url":"https://api.github.com/repos/vmware/nsxansible/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/nsxansible/deployments","created_at":"2015-08-29T00:07:08Z","updated_at":"2016-12-09T03:06:43Z","pushed_at":"2016-12-09T10:48:52Z","git_url":"git://github.com/vmware/nsxansible.git","ssh_url":"git@github.com:vmware/nsxansible.git","clone_url":"https://github.com/vmware/nsxansible.git","svn_url":"https://github.com/vmware/nsxansible","homepage":null,"size":173,"stargazers_count":39,"watchers_count":39,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":10,"forks":25,"open_issues":10,"watchers":39,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vmware/nsxansible/pulls/35"},"html":{"href":"https://github.com/vmware/nsxansible/pull/35"},"issue":{"href":"https://api.github.com/repos/vmware/nsxansible/issues/35"},"comments":{"href":"https://api.github.com/repos/vmware/nsxansible/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/vmware/nsxansible/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/vmware/nsxansible/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vmware/nsxansible/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/vmware/nsxansible/statuses/5935c3bcb2f786ff91aeaa79b6f740af1481f0e5"}}}}
{"actor":{"display_login":"yfauser"}}