{"action":"created","comment":{"url":"https://api.github.com/repos/ansible/ansible/pulls/comments/171897516","pull_request_review_id":100828667,"id":171897516,"diff_hunk":"@@ -0,0 +1,164 @@\n+#!/usr/bin/python\n+# -*- coding: utf-8 -*-\n+# pylint: disable=invalid-name, too-many-instance-attributes, broad-except\n+# Prasanna Nanda <pnanda@cloudsimple.com>\n+\n+# This file is part of Ansible\n+#\n+# Ansible is free software: you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation, either version 3 of the License, or\n+# (at your option) any later version.\n+#\n+# Ansible is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n+\"\"\"Manages Storage Profiles\"\"\"\n+\n+from ansible.module_utils.vmware import vmware_argument_spec, connect_to_api, find_datastore_by_name\n+from ansible.module_utils.basic import AnsibleModule\n+from ansible.module_utils._text import to_native\n+from ansible.module_utils.spbm_client import SPBMClient\n+\n+try:\n+    from pyVmomi import vmodl\n+    HAS_PYVMOMI = True\n+except ImportError:\n+    HAS_PYVMOMI = False\n+\n+\n+ANSIBLE_METADATA = {'metadata_version': '1.0',\n+                    'status': ['preview'],\n+                    'supported_by': 'community'}\n+\n+DOCUMENTATION = '''\n+---\n+module: vmware_spbm\n+short_description: VMware Storage Profile Utilities\n+description:\n+    - Create, Destroy VM Storage Profiles\n+version_added: 2.6\n+author:\n+    - Prasanna Nanda <pnanda@cloudsimple.com>\n+notes:\n+    - Tested on vSphere 6.5\n+requirements:\n+    - \"python >= 2.7\"\n+    - PyVmomi\n+options:\n+    profile_name:\n+        description:\n+            - Name of the storage profile to Create\n+        required: True\n+    state:\n+        description:\n+            - Valid values are present or absent\n+        required: True\n+    description:\n+        description:\n+            - Some Text Describing the Storage profile\n+        required: False\n+extends_documentation_fragment: vmware.documentation\n+'''\n+\n+EXAMPLES = r'''\n+  - name: Create a Storage Profile\n+    vmware_spbm:\n+      hostname: A vCenter host\n+      username: vCenter username\n+      password: vCenter password\n+      profile_name: Name of the storage profile to create\n+      description: Text Describing Storage Profile\n+      state: present|absent\n+'''\n+\n+class vmware_spbm(object):\n+    \"\"\"VMware Storage Profile Methods\"\"\"\n+    def __init__(self, module):\n+        self.module = module\n+        self.name = module.params['profile_name']\n+        self.description = module.params['description']\n+        self.desiredstate = module.params['state']\n+        self.rules = module.params['rules']\n+        self.currentstate = 'absent'\n+        self.content = None\n+        try:\n+            service_instance, content = connect_to_api(module, return_service_instance=True)\n+            self.content = content\n+            self.spbmclient = SPBMClient(vc_si=service_instance, hostname=module.params['hostname'])\n+        except vmodl.RuntimeFault as runtime_fault:\n+            module.fail_json(msg=runtime_fault.msg)\n+        except vmodl.MethodFault as method_fault:\n+            module.fail_json(msg=method_fault.msg)\n+        except Exception as e:\n+            module.fail_json(msg=to_native(e))\n+\n+    def force_provision(self):\n+        \"\"\"Allow Force Provision on vsanDatastore\"\"\"\n+        datastore = find_datastore_by_name(self.content, \"vsanDatastore\")\n+        vsan_profile_id = self.spbmclient.get_ds_default_profile(datastore)\n+        rules = [{'forceProvisioning': True}]\n+        self.spbmclient.update_storage_profile(profile_id=vsan_profile_id, rules=rules)\n+\n+    def process_state(self):\n+        \"\"\"Process Current State of Profiles\"\"\"\n+        profiles = self.spbmclient.get_profiles()\n+        if not profiles:\n+            self.module.fail_json(changed=False, msg=\"Could not retrieve \\","path":"lib/ansible/modules/cloud/vmware/vmware_spbm.py","position":111,"original_position":111,"commit_id":"0a395893f93beb1654e4ffd9752cf7b288f5f2dd","original_commit_id":"0a395893f93beb1654e4ffd9752cf7b288f5f2dd","user":{"login":"pdellaert","id":942391,"avatar_url":"https://avatars1.githubusercontent.com/u/942391?v=4","gravatar_id":"","url":"https://api.github.com/users/pdellaert","html_url":"https://github.com/pdellaert","followers_url":"https://api.github.com/users/pdellaert/followers","following_url":"https://api.github.com/users/pdellaert/following{/other_user}","gists_url":"https://api.github.com/users/pdellaert/gists{/gist_id}","starred_url":"https://api.github.com/users/pdellaert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pdellaert/subscriptions","organizations_url":"https://api.github.com/users/pdellaert/orgs","repos_url":"https://api.github.com/users/pdellaert/repos","events_url":"https://api.github.com/users/pdellaert/events{/privacy}","received_events_url":"https://api.github.com/users/pdellaert/received_events","type":"User","site_admin":false},"body":"Please don't use `\\`, there are better ways","created_at":"2018-03-02T16:39:31Z","updated_at":"2018-03-02T16:41:03Z","html_url":"https://github.com/ansible/ansible/pull/36640#discussion_r171897516","pull_request_url":"https://api.github.com/repos/ansible/ansible/pulls/36640","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible/pulls/comments/171897516"},"html":{"href":"https://github.com/ansible/ansible/pull/36640#discussion_r171897516"},"pull_request":{"href":"https://api.github.com/repos/ansible/ansible/pulls/36640"}}},"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/36640","id":171029696,"html_url":"https://github.com/ansible/ansible/pull/36640","diff_url":"https://github.com/ansible/ansible/pull/36640.diff","patch_url":"https://github.com/ansible/ansible/pull/36640.patch","issue_url":"https://api.github.com/repos/ansible/ansible/issues/36640","number":36640,"state":"open","locked":false,"title":"VMware SPBM Module","user":{"login":"cspnanda","id":1474416,"avatar_url":"https://avatars0.githubusercontent.com/u/1474416?v=4","gravatar_id":"","url":"https://api.github.com/users/cspnanda","html_url":"https://github.com/cspnanda","followers_url":"https://api.github.com/users/cspnanda/followers","following_url":"https://api.github.com/users/cspnanda/following{/other_user}","gists_url":"https://api.github.com/users/cspnanda/gists{/gist_id}","starred_url":"https://api.github.com/users/cspnanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cspnanda/subscriptions","organizations_url":"https://api.github.com/users/cspnanda/orgs","repos_url":"https://api.github.com/users/cspnanda/repos","events_url":"https://api.github.com/users/cspnanda/events{/privacy}","received_events_url":"https://api.github.com/users/cspnanda/received_events","type":"User","site_admin":false},"body":"##### VMware SPBM Module to Create/Delete storage Profile\r\nVMware SPBM Module to Create/Delete storage Profile.\r\n\r\nThe SPBM Module needs access to service instance. So I have refactored ```connect_to_api``` to return a ```service_instance``` and ```content``` both if ```return_service_instance``` is set. By default it is false so all existing functionalities work.\r\n\r\n##### ISSUE TYPE\r\n - New Module Pull Request\r\n\r\n##### COMPONENT NAME\r\nvmware_spbm\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible 2.6.0\r\n  config file = None\r\n  configured module search path = [u'/home/pnanda/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible-2.6.0-py2.7.egg/ansible\r\n  executable location = /usr/local/bin/ansible\r\n  python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]\r\n```\r\n\r\n\r\n##### ADDITIONAL INFORMATION\r\n<!--- Paste verbatim command output below, e.g. before and after your change -->\r\n```\r\n  - name: Create a Storage Profile\r\n    vmware_spbm:\r\n      hostname: A vCenter host\r\n      username: vCenter username\r\n      password: vCenter password\r\n      name: Name of the storage profile to create\r\n      description: Text Describing Storage Profile\r\n      state: present|absent\r\n```\r\n","created_at":"2018-02-23T14:36:17Z","updated_at":"2018-03-02T16:41:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d8e16a5f0ea5db84b9d7ed7d25df9fccd1326af","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":530145226,"url":"https://api.github.com/repos/ansible/ansible/labels/ci_verified","name":"ci_verified","color":"b60205","default":false},{"id":61528803,"url":"https://api.github.com/repos/ansible/ansible/labels/cloud","name":"cloud","color":"c7def8","default":false},{"id":496359346,"url":"https://api.github.com/repos/ansible/ansible/labels/module","name":"module","color":"1d76db","default":false},{"id":61436281,"url":"https://api.github.com/repos/ansible/ansible/labels/needs_revision","name":"needs_revision","color":"eb6450","default":false},{"id":723150340,"url":"https://api.github.com/repos/ansible/ansible/labels/new_contributor","name":"new_contributor","color":"ededed","default":false},{"id":473225334,"url":"https://api.github.com/repos/ansible/ansible/labels/new_module","name":"new_module","color":"ededed","default":false},{"id":153577825,"url":"https://api.github.com/repos/ansible/ansible/labels/new_plugin","name":"new_plugin","color":"bfe5bf","default":false},{"id":636327968,"url":"https://api.github.com/repos/ansible/ansible/labels/support:community","name":"support:community","color":"ededed","default":false},{"id":636352796,"url":"https://api.github.com/repos/ansible/ansible/labels/support:core","name":"support:core","color":"ededed","default":false},{"id":427121291,"url":"https://api.github.com/repos/ansible/ansible/labels/vmware","name":"vmware","color":"d93f0b","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ansible/ansible/pulls/36640/commits","review_comments_url":"https://api.github.com/repos/ansible/ansible/pulls/36640/comments","review_comment_url":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/36640/comments","statuses_url":"https://api.github.com/repos/ansible/ansible/statuses/0a395893f93beb1654e4ffd9752cf7b288f5f2dd","head":{"label":"cspnanda:devel","ref":"devel","sha":"0a395893f93beb1654e4ffd9752cf7b288f5f2dd","user":{"login":"cspnanda","id":1474416,"avatar_url":"https://avatars0.githubusercontent.com/u/1474416?v=4","gravatar_id":"","url":"https://api.github.com/users/cspnanda","html_url":"https://github.com/cspnanda","followers_url":"https://api.github.com/users/cspnanda/followers","following_url":"https://api.github.com/users/cspnanda/following{/other_user}","gists_url":"https://api.github.com/users/cspnanda/gists{/gist_id}","starred_url":"https://api.github.com/users/cspnanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cspnanda/subscriptions","organizations_url":"https://api.github.com/users/cspnanda/orgs","repos_url":"https://api.github.com/users/cspnanda/repos","events_url":"https://api.github.com/users/cspnanda/events{/privacy}","received_events_url":"https://api.github.com/users/cspnanda/received_events","type":"User","site_admin":false},"repo":{"id":122631064,"name":"ansible","full_name":"cspnanda/ansible","owner":{"login":"cspnanda","id":1474416,"avatar_url":"https://avatars0.githubusercontent.com/u/1474416?v=4","gravatar_id":"","url":"https://api.github.com/users/cspnanda","html_url":"https://github.com/cspnanda","followers_url":"https://api.github.com/users/cspnanda/followers","following_url":"https://api.github.com/users/cspnanda/following{/other_user}","gists_url":"https://api.github.com/users/cspnanda/gists{/gist_id}","starred_url":"https://api.github.com/users/cspnanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cspnanda/subscriptions","organizations_url":"https://api.github.com/users/cspnanda/orgs","repos_url":"https://api.github.com/users/cspnanda/repos","events_url":"https://api.github.com/users/cspnanda/events{/privacy}","received_events_url":"https://api.github.com/users/cspnanda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cspnanda/ansible","description":"Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.","fork":true,"url":"https://api.github.com/repos/cspnanda/ansible","forks_url":"https://api.github.com/repos/cspnanda/ansible/forks","keys_url":"https://api.github.com/repos/cspnanda/ansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cspnanda/ansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cspnanda/ansible/teams","hooks_url":"https://api.github.com/repos/cspnanda/ansible/hooks","issue_events_url":"https://api.github.com/repos/cspnanda/ansible/issues/events{/number}","events_url":"https://api.github.com/repos/cspnanda/ansible/events","assignees_url":"https://api.github.com/repos/cspnanda/ansible/assignees{/user}","branches_url":"https://api.github.com/repos/cspnanda/ansible/branches{/branch}","tags_url":"https://api.github.com/repos/cspnanda/ansible/tags","blobs_url":"https://api.github.com/repos/cspnanda/ansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cspnanda/ansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cspnanda/ansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/cspnanda/ansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cspnanda/ansible/statuses/{sha}","languages_url":"https://api.github.com/repos/cspnanda/ansible/languages","stargazers_url":"https://api.github.com/repos/cspnanda/ansible/stargazers","contributors_url":"https://api.github.com/repos/cspnanda/ansible/contributors","subscribers_url":"https://api.github.com/repos/cspnanda/ansible/subscribers","subscription_url":"https://api.github.com/repos/cspnanda/ansible/subscription","commits_url":"https://api.github.com/repos/cspnanda/ansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/cspnanda/ansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/cspnanda/ansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/cspnanda/ansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/cspnanda/ansible/contents/{+path}","compare_url":"https://api.github.com/repos/cspnanda/ansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cspnanda/ansible/merges","archive_url":"https://api.github.com/repos/cspnanda/ansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cspnanda/ansible/downloads","issues_url":"https://api.github.com/repos/cspnanda/ansible/issues{/number}","pulls_url":"https://api.github.com/repos/cspnanda/ansible/pulls{/number}","milestones_url":"https://api.github.com/repos/cspnanda/ansible/milestones{/number}","notifications_url":"https://api.github.com/repos/cspnanda/ansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cspnanda/ansible/labels{/name}","releases_url":"https://api.github.com/repos/cspnanda/ansible/releases{/id}","deployments_url":"https://api.github.com/repos/cspnanda/ansible/deployments","created_at":"2018-02-23T14:23:57Z","updated_at":"2018-02-23T14:24:30Z","pushed_at":"2018-02-23T23:40:58Z","git_url":"git://github.com/cspnanda/ansible.git","ssh_url":"git@github.com:cspnanda/ansible.git","clone_url":"https://github.com/cspnanda/ansible.git","svn_url":"https://github.com/cspnanda/ansible","homepage":"https://www.ansible.com/","size":111886,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"ansible:devel","ref":"devel","sha":"1abc47c5d3a6f3b6465e0ccb1c81048250bf9db1","user":{"login":"ansible","id":1507452,"avatar_url":"https://avatars2.githubusercontent.com/u/1507452?v=4","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"repo":{"id":3638964,"name":"ansible","full_name":"ansible/ansible","owner":{"login":"ansible","id":1507452,"avatar_url":"https://avatars2.githubusercontent.com/u/1507452?v=4","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ansible/ansible","description":"Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.","fork":false,"url":"https://api.github.com/repos/ansible/ansible","forks_url":"https://api.github.com/repos/ansible/ansible/forks","keys_url":"https://api.github.com/repos/ansible/ansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ansible/ansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ansible/ansible/teams","hooks_url":"https://api.github.com/repos/ansible/ansible/hooks","issue_events_url":"https://api.github.com/repos/ansible/ansible/issues/events{/number}","events_url":"https://api.github.com/repos/ansible/ansible/events","assignees_url":"https://api.github.com/repos/ansible/ansible/assignees{/user}","branches_url":"https://api.github.com/repos/ansible/ansible/branches{/branch}","tags_url":"https://api.github.com/repos/ansible/ansible/tags","blobs_url":"https://api.github.com/repos/ansible/ansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ansible/ansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ansible/ansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/ansible/ansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ansible/ansible/statuses/{sha}","languages_url":"https://api.github.com/repos/ansible/ansible/languages","stargazers_url":"https://api.github.com/repos/ansible/ansible/stargazers","contributors_url":"https://api.github.com/repos/ansible/ansible/contributors","subscribers_url":"https://api.github.com/repos/ansible/ansible/subscribers","subscription_url":"https://api.github.com/repos/ansible/ansible/subscription","commits_url":"https://api.github.com/repos/ansible/ansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/ansible/ansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/ansible/ansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/ansible/ansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/ansible/ansible/contents/{+path}","compare_url":"https://api.github.com/repos/ansible/ansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ansible/ansible/merges","archive_url":"https://api.github.com/repos/ansible/ansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ansible/ansible/downloads","issues_url":"https://api.github.com/repos/ansible/ansible/issues{/number}","pulls_url":"https://api.github.com/repos/ansible/ansible/pulls{/number}","milestones_url":"https://api.github.com/repos/ansible/ansible/milestones{/number}","notifications_url":"https://api.github.com/repos/ansible/ansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ansible/ansible/labels{/name}","releases_url":"https://api.github.com/repos/ansible/ansible/releases{/id}","deployments_url":"https://api.github.com/repos/ansible/ansible/deployments","created_at":"2012-03-06T14:58:02Z","updated_at":"2018-03-02T15:20:04Z","pushed_at":"2018-03-02T16:36:51Z","git_url":"git://github.com/ansible/ansible.git","ssh_url":"git@github.com:ansible/ansible.git","clone_url":"https://github.com/ansible/ansible.git","svn_url":"https://github.com/ansible/ansible","homepage":"https://www.ansible.com/","size":120174,"stargazers_count":28742,"watchers_count":28742,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10384,"mirror_url":null,"archived":false,"open_issues_count":4831,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":10384,"open_issues":4831,"watchers":28742,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible/pulls/36640"},"html":{"href":"https://github.com/ansible/ansible/pull/36640"},"issue":{"href":"https://api.github.com/repos/ansible/ansible/issues/36640"},"comments":{"href":"https://api.github.com/repos/ansible/ansible/issues/36640/comments"},"review_comments":{"href":"https://api.github.com/repos/ansible/ansible/pulls/36640/comments"},"review_comment":{"href":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ansible/ansible/pulls/36640/commits"},"statuses":{"href":"https://api.github.com/repos/ansible/ansible/statuses/0a395893f93beb1654e4ffd9752cf7b288f5f2dd"}},"author_association":"NONE"}}
{"actor":{"display_login":"pdellaert"}}