{"action":"created","comment":{"url":"https://api.github.com/repos/scality/manila/pulls/comments/41269582","id":41269582,"diff_hunk":"@@ -191,26 +324,88 @@ def delete_share(self, context, share, share_server=None):\n                 raise exception.ShareBackendException(msg=msg)\n \n             elif e.exit_code == self.EXPORT_NOT_FOUND:\n-                msg = _(\"Share '%s' not found\" % share['id'])\n+                msg = _(\"'%(name)s' (%(id)s) not found\") % {\n+                    'name': share['name'], 'id': share['id']}\n                 raise exception.InvalidShare(reason=msg)\n \n             else:\n                 raise\n \n-    def _update_share_stats(self):\n-        backend_name = self.configuration.safe_get(\n-            'share_backend_name') or 'Scality Ring Driver'\n+    def create_share(self, share):\n+        command = 'create %s' % share['id']\n \n-        stats = {\n-            'share_backend_name': backend_name,\n-            'vendor_name': 'Scality',\n-            'storage_protocol': self.NFS_PROTOCOL,\n-            'driver_version': self.VERSION,\n-        }\n+        try:\n+            self._management_call(command)\n+        except processutils.ProcessExecutionError as e:\n+            if e.exit_code == self.EXPORT_EXISTS:\n+                msg = _(\"Share '%(name)s' (%(id)s) already defined.\") % {\n+                    'name': share['name'], 'id': share['id']}\n+                raise exception.ShareBackendException(msg=msg)\n+            else:\n+                raise\n \n-        super(ScalityShareDriver, self)._update_share_stats(stats)\n+        return self._location_from_id(share['id'])\n \n-    def _enforce_ip_acl(self, access):\n-        \"\"\"Check that the access is IP based.\"\"\"\n-        if access['access_type'] != 'ip':\n-            raise exception.ManilaException('Only IP restrictions supported')\n+    def ensure_share(self, share):\n+        # Export locations are derived from the `export_ip` configuration\n+        # parameter, and may thus change between service restarts. It is\n+        # therefor always returned here if the share exists.\n+        try:\n+            self._management_call('get %s' % share['id'])\n+\n+        except processutils.ProcessExecutionError as e:\n+            if e.exit_code == self.EXPORT_NOT_FOUND:\n+                msg = _(\"'%(name)s' (%(id)s) not found\") % {\n+                    'name': share['name'], 'id': share['id']}\n+                raise exception.InvalidShare(reason=msg)\n+\n+            else:\n+                raise\n+\n+        return self._location_from_id(share['id'])\n+\n+    def _location_from_id(self, share_id):\n+        \"\"\"Format an export location from a share_id.\n+\n+        :param share_id: share id to format\n+        :type share_id: string\n+        :returns: string\n+        \"\"\"\n+        raise NotImplementedError()\n+\n+\n+class CIFSHelper(NASHelperBase):\n+\n+    PROTOCOL = \"SMB\"\n+\n+    def __init__(self, ssh_pool, export_ip, export_root):\n+        super(CIFSHelper, self).__init__(ssh_pool, export_ip)\n+        self.optional_args = \"--root-export %s\" % export_root\n+\n+    def allow_access(self, share, access):\n+        if access['access_level'] != const.ACCESS_LEVEL_RW:\n+            raise exception.InvalidShareAccessLevel(\n+                level=access['access_level'])\n+\n+        access = copy.deepcopy(access)\n+        # The scality-manila-utils implicitely set the access level to RW\n+        # Hence, it doesn\"t expect another CLI argument\n+        access['access_level'] = \"\"\n+        super(CIFSHelper, self).allow_access(share, access)\n+\n+    def deny_access(self, share, access):\n+        if access['access_level'] != const.ACCESS_LEVEL_RW:\n+            return\n+\n+        super(CIFSHelper, self).deny_access(share, access)\n+\n+    def _location_from_id(self, share_id):\n+        return '\\\\\\\\%s\\\\%s' % (self.export_ip, share_id)\n+\n+\n+class NFSHelper(NASHelperBase):","path":"manila/share/drivers/scality/driver.py","position":476,"original_position":476,"commit_id":"dfba726b7a1ed939dac30f2ae2d18e39b18de8dc","original_commit_id":"dfba726b7a1ed939dac30f2ae2d18e39b18de8dc","user":{"login":"JordanP","id":221981,"avatar_url":"https://avatars.githubusercontent.com/u/221981?v=3","gravatar_id":"","url":"https://api.github.com/users/JordanP","html_url":"https://github.com/JordanP","followers_url":"https://api.github.com/users/JordanP/followers","following_url":"https://api.github.com/users/JordanP/following{/other_user}","gists_url":"https://api.github.com/users/JordanP/gists{/gist_id}","starred_url":"https://api.github.com/users/JordanP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JordanP/subscriptions","organizations_url":"https://api.github.com/users/JordanP/orgs","repos_url":"https://api.github.com/users/JordanP/repos","events_url":"https://api.github.com/users/JordanP/events{/privacy}","received_events_url":"https://api.github.com/users/JordanP/received_events","type":"User","site_admin":false},"body":"What in the `NASHelperBase` class leads you think it's more a NFSHelper ? I don't see any reference to NFS in the `NASHelperBase`\r\n\r\nIf I define a \"base class\" with only abstract methods, I would have to duplicate a lot of code in the NFS and CIFS class because they really look the same.","created_at":"2015-10-06T14:18:49Z","updated_at":"2015-10-06T14:18:49Z","html_url":"https://github.com/scality/manila/pull/4#discussion_r41269582","pull_request_url":"https://api.github.com/repos/scality/manila/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/scality/manila/pulls/comments/41269582"},"html":{"href":"https://github.com/scality/manila/pull/4#discussion_r41269582"},"pull_request":{"href":"https://api.github.com/repos/scality/manila/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/scality/manila/pulls/4","id":46776916,"html_url":"https://github.com/scality/manila/pull/4","diff_url":"https://github.com/scality/manila/pull/4.diff","patch_url":"https://github.com/scality/manila/pull/4.patch","issue_url":"https://api.github.com/repos/scality/manila/issues/4","number":4,"state":"open","locked":false,"title":"Initial SMB driver","user":{"login":"JordanP","id":221981,"avatar_url":"https://avatars.githubusercontent.com/u/221981?v=3","gravatar_id":"","url":"https://api.github.com/users/JordanP","html_url":"https://github.com/JordanP","followers_url":"https://api.github.com/users/JordanP/followers","following_url":"https://api.github.com/users/JordanP/following{/other_user}","gists_url":"https://api.github.com/users/JordanP/gists{/gist_id}","starred_url":"https://api.github.com/users/JordanP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JordanP/subscriptions","organizations_url":"https://api.github.com/users/JordanP/orgs","repos_url":"https://api.github.com/users/JordanP/repos","events_url":"https://api.github.com/users/JordanP/events{/privacy}","received_events_url":"https://api.github.com/users/JordanP/received_events","type":"User","site_admin":false},"body":"Guys,\r\nI am opening this for review. The code is good and all the Tempest tests pass. I am writing the unit tests now. I'd like your opinion on this, better early than late :)","created_at":"2015-10-05T12:55:54Z","updated_at":"2015-10-06T14:18:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d986bf992ff3c7a57f2003ab58cec61679cd9793","assignee":{"login":"sbjorn","id":3911596,"avatar_url":"https://avatars.githubusercontent.com/u/3911596?v=3","gravatar_id":"","url":"https://api.github.com/users/sbjorn","html_url":"https://github.com/sbjorn","followers_url":"https://api.github.com/users/sbjorn/followers","following_url":"https://api.github.com/users/sbjorn/following{/other_user}","gists_url":"https://api.github.com/users/sbjorn/gists{/gist_id}","starred_url":"https://api.github.com/users/sbjorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbjorn/subscriptions","organizations_url":"https://api.github.com/users/sbjorn/orgs","repos_url":"https://api.github.com/users/sbjorn/repos","events_url":"https://api.github.com/users/sbjorn/events{/privacy}","received_events_url":"https://api.github.com/users/sbjorn/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/scality/manila/pulls/4/commits","review_comments_url":"https://api.github.com/repos/scality/manila/pulls/4/comments","review_comment_url":"https://api.github.com/repos/scality/manila/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scality/manila/issues/4/comments","statuses_url":"https://api.github.com/repos/scality/manila/statuses/dfba726b7a1ed939dac30f2ae2d18e39b18de8dc","head":{"label":"scality:smb","ref":"smb","sha":"dfba726b7a1ed939dac30f2ae2d18e39b18de8dc","user":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"repo":{"id":36364592,"name":"manila","full_name":"scality/manila","owner":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scality/manila","description":"Shared filesystem management project for OpenStack.","fork":true,"url":"https://api.github.com/repos/scality/manila","forks_url":"https://api.github.com/repos/scality/manila/forks","keys_url":"https://api.github.com/repos/scality/manila/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scality/manila/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scality/manila/teams","hooks_url":"https://api.github.com/repos/scality/manila/hooks","issue_events_url":"https://api.github.com/repos/scality/manila/issues/events{/number}","events_url":"https://api.github.com/repos/scality/manila/events","assignees_url":"https://api.github.com/repos/scality/manila/assignees{/user}","branches_url":"https://api.github.com/repos/scality/manila/branches{/branch}","tags_url":"https://api.github.com/repos/scality/manila/tags","blobs_url":"https://api.github.com/repos/scality/manila/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scality/manila/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scality/manila/git/refs{/sha}","trees_url":"https://api.github.com/repos/scality/manila/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scality/manila/statuses/{sha}","languages_url":"https://api.github.com/repos/scality/manila/languages","stargazers_url":"https://api.github.com/repos/scality/manila/stargazers","contributors_url":"https://api.github.com/repos/scality/manila/contributors","subscribers_url":"https://api.github.com/repos/scality/manila/subscribers","subscription_url":"https://api.github.com/repos/scality/manila/subscription","commits_url":"https://api.github.com/repos/scality/manila/commits{/sha}","git_commits_url":"https://api.github.com/repos/scality/manila/git/commits{/sha}","comments_url":"https://api.github.com/repos/scality/manila/comments{/number}","issue_comment_url":"https://api.github.com/repos/scality/manila/issues/comments{/number}","contents_url":"https://api.github.com/repos/scality/manila/contents/{+path}","compare_url":"https://api.github.com/repos/scality/manila/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scality/manila/merges","archive_url":"https://api.github.com/repos/scality/manila/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scality/manila/downloads","issues_url":"https://api.github.com/repos/scality/manila/issues{/number}","pulls_url":"https://api.github.com/repos/scality/manila/pulls{/number}","milestones_url":"https://api.github.com/repos/scality/manila/milestones{/number}","notifications_url":"https://api.github.com/repos/scality/manila/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scality/manila/labels{/name}","releases_url":"https://api.github.com/repos/scality/manila/releases{/id}","created_at":"2015-05-27T12:13:10Z","updated_at":"2015-05-28T22:28:07Z","pushed_at":"2015-10-05T12:55:54Z","git_url":"git://github.com/scality/manila.git","ssh_url":"git@github.com:scality/manila.git","clone_url":"https://github.com/scality/manila.git","svn_url":"https://github.com/scality/manila","homepage":"http://openstack.org","size":7218,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"scality:master","ref":"master","sha":"6ae62aa03aefba50a37ec53b77b36d9ebddf99a0","user":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"repo":{"id":36364592,"name":"manila","full_name":"scality/manila","owner":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scality/manila","description":"Shared filesystem management project for OpenStack.","fork":true,"url":"https://api.github.com/repos/scality/manila","forks_url":"https://api.github.com/repos/scality/manila/forks","keys_url":"https://api.github.com/repos/scality/manila/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scality/manila/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scality/manila/teams","hooks_url":"https://api.github.com/repos/scality/manila/hooks","issue_events_url":"https://api.github.com/repos/scality/manila/issues/events{/number}","events_url":"https://api.github.com/repos/scality/manila/events","assignees_url":"https://api.github.com/repos/scality/manila/assignees{/user}","branches_url":"https://api.github.com/repos/scality/manila/branches{/branch}","tags_url":"https://api.github.com/repos/scality/manila/tags","blobs_url":"https://api.github.com/repos/scality/manila/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scality/manila/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scality/manila/git/refs{/sha}","trees_url":"https://api.github.com/repos/scality/manila/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scality/manila/statuses/{sha}","languages_url":"https://api.github.com/repos/scality/manila/languages","stargazers_url":"https://api.github.com/repos/scality/manila/stargazers","contributors_url":"https://api.github.com/repos/scality/manila/contributors","subscribers_url":"https://api.github.com/repos/scality/manila/subscribers","subscription_url":"https://api.github.com/repos/scality/manila/subscription","commits_url":"https://api.github.com/repos/scality/manila/commits{/sha}","git_commits_url":"https://api.github.com/repos/scality/manila/git/commits{/sha}","comments_url":"https://api.github.com/repos/scality/manila/comments{/number}","issue_comment_url":"https://api.github.com/repos/scality/manila/issues/comments{/number}","contents_url":"https://api.github.com/repos/scality/manila/contents/{+path}","compare_url":"https://api.github.com/repos/scality/manila/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scality/manila/merges","archive_url":"https://api.github.com/repos/scality/manila/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scality/manila/downloads","issues_url":"https://api.github.com/repos/scality/manila/issues{/number}","pulls_url":"https://api.github.com/repos/scality/manila/pulls{/number}","milestones_url":"https://api.github.com/repos/scality/manila/milestones{/number}","notifications_url":"https://api.github.com/repos/scality/manila/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scality/manila/labels{/name}","releases_url":"https://api.github.com/repos/scality/manila/releases{/id}","created_at":"2015-05-27T12:13:10Z","updated_at":"2015-05-28T22:28:07Z","pushed_at":"2015-10-05T12:55:54Z","git_url":"git://github.com/scality/manila.git","ssh_url":"git@github.com:scality/manila.git","clone_url":"https://github.com/scality/manila.git","svn_url":"https://github.com/scality/manila","homepage":"http://openstack.org","size":7218,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scality/manila/pulls/4"},"html":{"href":"https://github.com/scality/manila/pull/4"},"issue":{"href":"https://api.github.com/repos/scality/manila/issues/4"},"comments":{"href":"https://api.github.com/repos/scality/manila/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/scality/manila/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/scality/manila/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scality/manila/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/scality/manila/statuses/dfba726b7a1ed939dac30f2ae2d18e39b18de8dc"}}}}