{"action":"created","comment":{"url":"https://api.github.com/repos/rhinstaller/anaconda/pulls/comments/149082051","pull_request_review_id":74419896,"id":149082051,"diff_hunk":"@@ -0,0 +1,195 @@\n+#\n+# Copyright (C) 2017  Red Hat, Inc.\n+#\n+# This copyrighted material is made available to anyone wishing to use,\n+# modify, copy, or redistribute it subject to the terms and conditions of\n+# the GNU General Public License v.2, or (at your option) any later version.\n+# This program is distributed in the hope that it will be useful, but WITHOUT\n+# ANY WARRANTY expressed or implied, including the implied warranties of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General\n+# Public License for more details.  You should have received a copy of the\n+# GNU General Public License along with this program; if not, write to the\n+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n+# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the\n+# source code or documentation are not subject to the GNU General Public\n+# License and may only be used or replicated with the express permission of\n+# Red Hat, Inc.\n+#\n+# Red Hat Author(s): Vendula Poncova <vponcova@redhat.com>\n+#\n+\n+import gi\n+gi.require_version(\"BlockDev\", \"2.0\")\n+from gi.repository import BlockDev as blockdev\n+\n+from blivet import arch\n+from blivet.osinstall import storage_initialize\n+\n+from pyanaconda.flags import flags\n+from pyanaconda.ui.lib.disks import getDisks\n+from pyanaconda.isignal import Signal\n+from pyanaconda.storage_utils import on_disk_storage\n+from pyanaconda.i18n import _\n+\n+from pyanaconda.anaconda_loggers import get_module_logger\n+log = get_module_logger(__name__)\n+\n+\n+class DasdFormatting(object):\n+    \"\"\"Class for formatting DASDs.\"\"\"\n+\n+    def __init__(self):\n+        self._dasds = []\n+\n+        self._can_format_unformatted = True\n+        self._can_format_ldl = True\n+\n+        self._report = Signal()\n+        self._report.connect(log.debug)\n+\n+    @staticmethod\n+    def is_supported():\n+        \"\"\"Is DASD formatting supported on this machine?\"\"\"\n+        return arch.is_s390()\n+\n+    @property\n+    def report(self):\n+        \"\"\"Signal for the progress reporting.\n+\n+        Emits messages during the formatting.\n+        \"\"\"\n+        return self._report\n+\n+    @property\n+    def dasds(self):\n+        \"\"\"List of found DASDs to format.\"\"\"\n+        return self._dasds\n+\n+    @property\n+    def dasds_summary(self):\n+        \"\"\"Returns a string summary of DASDs to format.\"\"\"\n+        return \"\\n\".join(map(self.get_dasd_info, self.dasds))\n+\n+    def get_dasd_info(self, disk):\n+        \"\"\"Returns a string with description of a DASD,\"\"\"\n+        return \"/dev/\" + disk.name + \" (\" + disk.busid + \")\"\n+\n+    def _is_dasd(self, disk):\n+        \"\"\"Is it a DASD disk?\"\"\"\n+        return disk.type == \"dasd\"\n+\n+    def _is_unformatted_dasd(self, disk):\n+        \"\"\"Is it an unformatted DASD?\"\"\"\n+        return self._is_dasd(disk) and blockdev.s390.dasd_needs_format(disk.busid)\n+\n+    def _is_ldl_dasd(self, disk):\n+        \"\"\"Is it an LDL DASD?\"\"\"\n+        return self._is_dasd(disk) and blockdev.s390.dasd_is_ldl(disk.name)\n+\n+    def _get_unformatted_dasds(self, disks):\n+        \"\"\"Returns a list of unformatted DASDs.\"\"\"\n+        result = []\n+\n+        if not self._can_format_unformatted:\n+            log.debug(\"We are not allowed to format unformatted DASDs.\")\n+            return result\n+\n+        for disk in disks:\n+            if self._is_unformatted_dasd(disk):\n+                log.debug(\"Found unformatted DASD: %s\", self.get_dasd_info(disk))\n+                result.append(disk)\n+\n+        return result\n+\n+    def _get_ldl_dasds(self, disks):\n+        \"\"\"Returns a list of LDL DASDs.\"\"\"\n+        result = []\n+\n+        if not self._can_format_ldl:\n+            log.debug(\"We are not allowed to format LDL DASDs.\")\n+            return result\n+\n+        for disk in disks:\n+            if self._is_ldl_dasd(disk):\n+                log.debug(\"Found LDL DASD: %s\", self.get_dasd_info(disk))\n+                result.append(disk)\n+\n+        return result\n+\n+    def update_restrictions(self, data):\n+        \"\"\"Read kickstart data to update the restrictions.\"\"\"\n+        self._can_format_unformatted = data.zerombr.zerombr\n+        self._can_format_ldl = data.clearpart.cdl\n+\n+    def search_disks(self, disks):\n+        \"\"\"Search for a list of disks for DASDs to format.\"\"\"\n+        self._dasds = list(set(self._get_unformatted_dasds(disks) + self._get_ldl_dasds(disks)))\n+\n+    def should_run(self):\n+        \"\"\"Should we run the formatting?\"\"\"\n+        return bool(self._dasds)\n+\n+    def do_format(self, disk):\n+        \"\"\"Format a disk.\"\"\"\n+        try:\n+            self.report.emit(_(\"Formatting %s\") % self.get_dasd_info(disk))\n+            blockdev.s390.dasd_format(disk.name)\n+        except blockdev.S390Error as err:\n+            self.report.emit(_(\"Failed formatting %s\") % self.get_dasd_info(disk))\n+            log.error(err)\n+\n+    def run(self, storage, data):","path":"pyanaconda/format_dasd.py","position":141,"original_position":141,"commit_id":"c1cade4ad7e76c98b18bb15dfb8d911eac3f0ce0","original_commit_id":"36d10efe775251778a04986d86f25f4f38f36e96","user":{"login":"poncovka","id":7396092,"avatar_url":"https://avatars3.githubusercontent.com/u/7396092?v=4","gravatar_id":"","url":"https://api.github.com/users/poncovka","html_url":"https://github.com/poncovka","followers_url":"https://api.github.com/users/poncovka/followers","following_url":"https://api.github.com/users/poncovka/following{/other_user}","gists_url":"https://api.github.com/users/poncovka/gists{/gist_id}","starred_url":"https://api.github.com/users/poncovka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poncovka/subscriptions","organizations_url":"https://api.github.com/users/poncovka/orgs","repos_url":"https://api.github.com/users/poncovka/repos","events_url":"https://api.github.com/users/poncovka/events{/privacy}","received_events_url":"https://api.github.com/users/poncovka/received_events","type":"User","site_admin":false},"body":"Fixed.","created_at":"2017-11-06T13:47:28Z","updated_at":"2017-11-06T13:47:28Z","html_url":"https://github.com/rhinstaller/anaconda/pull/1228#discussion_r149082051","pull_request_url":"https://api.github.com/repos/rhinstaller/anaconda/pulls/1228","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/rhinstaller/anaconda/pulls/comments/149082051"},"html":{"href":"https://github.com/rhinstaller/anaconda/pull/1228#discussion_r149082051"},"pull_request":{"href":"https://api.github.com/repos/rhinstaller/anaconda/pulls/1228"}},"in_reply_to_id":148215896},"pull_request":{"url":"https://api.github.com/repos/rhinstaller/anaconda/pulls/1228","id":149880830,"html_url":"https://github.com/rhinstaller/anaconda/pull/1228","diff_url":"https://github.com/rhinstaller/anaconda/pull/1228.diff","patch_url":"https://github.com/rhinstaller/anaconda/pull/1228.patch","issue_url":"https://api.github.com/repos/rhinstaller/anaconda/issues/1228","number":1228,"state":"open","locked":false,"title":"Refactor DASD formatting and support detection of LDL DASDs.","user":{"login":"poncovka","id":7396092,"avatar_url":"https://avatars3.githubusercontent.com/u/7396092?v=4","gravatar_id":"","url":"https://api.github.com/users/poncovka","html_url":"https://github.com/poncovka","followers_url":"https://api.github.com/users/poncovka/followers","following_url":"https://api.github.com/users/poncovka/following{/other_user}","gists_url":"https://api.github.com/users/poncovka/gists{/gist_id}","starred_url":"https://api.github.com/users/poncovka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poncovka/subscriptions","organizations_url":"https://api.github.com/users/poncovka/orgs","repos_url":"https://api.github.com/users/poncovka/repos","events_url":"https://api.github.com/users/poncovka/events{/privacy}","received_events_url":"https://api.github.com/users/poncovka/received_events","type":"User","site_admin":false},"body":"The code for DASD formatting was moved to the class DasdFormatting in\r\nthe pyanaconda.format_dasd module. Automatic formatting can be run\r\nwith run_automatically, otherwise UI has to do the steps manually.\r\nThis way the logic is separated from the UI and it is the same for\r\nTUI and GUI. And it will be easier to move the code on DBus.\r\n\r\nAlso, formatting of LDL DASDs is now supported as well. Disks with the\r\nLDL format will be automatically formatted with the clearpart --cdl\r\noption. Otherwise, user can choose to format them if he selects them\r\nin a spoke.\r\n\r\nBased on commits:\r\na4a2e86, 7e28f03, aab9b91, 356e89c, d83e06d, 4ffe0de, 1e0f384","created_at":"2017-10-31T19:03:47Z","updated_at":"2017-11-06T13:47:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fd837a76f2ef1391e2b7dd1462084e1bac2bc632","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/rhinstaller/anaconda/pulls/1228/commits","review_comments_url":"https://api.github.com/repos/rhinstaller/anaconda/pulls/1228/comments","review_comment_url":"https://api.github.com/repos/rhinstaller/anaconda/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rhinstaller/anaconda/issues/1228/comments","statuses_url":"https://api.github.com/repos/rhinstaller/anaconda/statuses/c1cade4ad7e76c98b18bb15dfb8d911eac3f0ce0","head":{"label":"poncovka:master-ldl_dasd_refactoring","ref":"master-ldl_dasd_refactoring","sha":"c1cade4ad7e76c98b18bb15dfb8d911eac3f0ce0","user":{"login":"poncovka","id":7396092,"avatar_url":"https://avatars3.githubusercontent.com/u/7396092?v=4","gravatar_id":"","url":"https://api.github.com/users/poncovka","html_url":"https://github.com/poncovka","followers_url":"https://api.github.com/users/poncovka/followers","following_url":"https://api.github.com/users/poncovka/following{/other_user}","gists_url":"https://api.github.com/users/poncovka/gists{/gist_id}","starred_url":"https://api.github.com/users/poncovka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poncovka/subscriptions","organizations_url":"https://api.github.com/users/poncovka/orgs","repos_url":"https://api.github.com/users/poncovka/repos","events_url":"https://api.github.com/users/poncovka/events{/privacy}","received_events_url":"https://api.github.com/users/poncovka/received_events","type":"User","site_admin":false},"repo":{"id":70139747,"name":"anaconda","full_name":"poncovka/anaconda","owner":{"login":"poncovka","id":7396092,"avatar_url":"https://avatars3.githubusercontent.com/u/7396092?v=4","gravatar_id":"","url":"https://api.github.com/users/poncovka","html_url":"https://github.com/poncovka","followers_url":"https://api.github.com/users/poncovka/followers","following_url":"https://api.github.com/users/poncovka/following{/other_user}","gists_url":"https://api.github.com/users/poncovka/gists{/gist_id}","starred_url":"https://api.github.com/users/poncovka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poncovka/subscriptions","organizations_url":"https://api.github.com/users/poncovka/orgs","repos_url":"https://api.github.com/users/poncovka/repos","events_url":"https://api.github.com/users/poncovka/events{/privacy}","received_events_url":"https://api.github.com/users/poncovka/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/poncovka/anaconda","description":"Graphical system installer","fork":true,"url":"https://api.github.com/repos/poncovka/anaconda","forks_url":"https://api.github.com/repos/poncovka/anaconda/forks","keys_url":"https://api.github.com/repos/poncovka/anaconda/keys{/key_id}","collaborators_url":"https://api.github.com/repos/poncovka/anaconda/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/poncovka/anaconda/teams","hooks_url":"https://api.github.com/repos/poncovka/anaconda/hooks","issue_events_url":"https://api.github.com/repos/poncovka/anaconda/issues/events{/number}","events_url":"https://api.github.com/repos/poncovka/anaconda/events","assignees_url":"https://api.github.com/repos/poncovka/anaconda/assignees{/user}","branches_url":"https://api.github.com/repos/poncovka/anaconda/branches{/branch}","tags_url":"https://api.github.com/repos/poncovka/anaconda/tags","blobs_url":"https://api.github.com/repos/poncovka/anaconda/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/poncovka/anaconda/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/poncovka/anaconda/git/refs{/sha}","trees_url":"https://api.github.com/repos/poncovka/anaconda/git/trees{/sha}","statuses_url":"https://api.github.com/repos/poncovka/anaconda/statuses/{sha}","languages_url":"https://api.github.com/repos/poncovka/anaconda/languages","stargazers_url":"https://api.github.com/repos/poncovka/anaconda/stargazers","contributors_url":"https://api.github.com/repos/poncovka/anaconda/contributors","subscribers_url":"https://api.github.com/repos/poncovka/anaconda/subscribers","subscription_url":"https://api.github.com/repos/poncovka/anaconda/subscription","commits_url":"https://api.github.com/repos/poncovka/anaconda/commits{/sha}","git_commits_url":"https://api.github.com/repos/poncovka/anaconda/git/commits{/sha}","comments_url":"https://api.github.com/repos/poncovka/anaconda/comments{/number}","issue_comment_url":"https://api.github.com/repos/poncovka/anaconda/issues/comments{/number}","contents_url":"https://api.github.com/repos/poncovka/anaconda/contents/{+path}","compare_url":"https://api.github.com/repos/poncovka/anaconda/compare/{base}...{head}","merges_url":"https://api.github.com/repos/poncovka/anaconda/merges","archive_url":"https://api.github.com/repos/poncovka/anaconda/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/poncovka/anaconda/downloads","issues_url":"https://api.github.com/repos/poncovka/anaconda/issues{/number}","pulls_url":"https://api.github.com/repos/poncovka/anaconda/pulls{/number}","milestones_url":"https://api.github.com/repos/poncovka/anaconda/milestones{/number}","notifications_url":"https://api.github.com/repos/poncovka/anaconda/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/poncovka/anaconda/labels{/name}","releases_url":"https://api.github.com/repos/poncovka/anaconda/releases{/id}","deployments_url":"https://api.github.com/repos/poncovka/anaconda/deployments","created_at":"2016-10-06T09:20:46Z","updated_at":"2016-10-06T09:20:52Z","pushed_at":"2017-11-06T12:47:12Z","git_url":"git://github.com/poncovka/anaconda.git","ssh_url":"git@github.com:poncovka/anaconda.git","clone_url":"https://github.com/poncovka/anaconda.git","svn_url":"https://github.com/poncovka/anaconda","homepage":null,"size":141211,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rhinstaller:master","ref":"master","sha":"d3805233974a0c02caaa9bc54bbafb641f9563a9","user":{"login":"rhinstaller","id":10549274,"avatar_url":"https://avatars1.githubusercontent.com/u/10549274?v=4","gravatar_id":"","url":"https://api.github.com/users/rhinstaller","html_url":"https://github.com/rhinstaller","followers_url":"https://api.github.com/users/rhinstaller/followers","following_url":"https://api.github.com/users/rhinstaller/following{/other_user}","gists_url":"https://api.github.com/users/rhinstaller/gists{/gist_id}","starred_url":"https://api.github.com/users/rhinstaller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhinstaller/subscriptions","organizations_url":"https://api.github.com/users/rhinstaller/orgs","repos_url":"https://api.github.com/users/rhinstaller/repos","events_url":"https://api.github.com/users/rhinstaller/events{/privacy}","received_events_url":"https://api.github.com/users/rhinstaller/received_events","type":"Organization","site_admin":false},"repo":{"id":30210846,"name":"anaconda","full_name":"rhinstaller/anaconda","owner":{"login":"rhinstaller","id":10549274,"avatar_url":"https://avatars1.githubusercontent.com/u/10549274?v=4","gravatar_id":"","url":"https://api.github.com/users/rhinstaller","html_url":"https://github.com/rhinstaller","followers_url":"https://api.github.com/users/rhinstaller/followers","following_url":"https://api.github.com/users/rhinstaller/following{/other_user}","gists_url":"https://api.github.com/users/rhinstaller/gists{/gist_id}","starred_url":"https://api.github.com/users/rhinstaller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhinstaller/subscriptions","organizations_url":"https://api.github.com/users/rhinstaller/orgs","repos_url":"https://api.github.com/users/rhinstaller/repos","events_url":"https://api.github.com/users/rhinstaller/events{/privacy}","received_events_url":"https://api.github.com/users/rhinstaller/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rhinstaller/anaconda","description":"Graphical system installer","fork":false,"url":"https://api.github.com/repos/rhinstaller/anaconda","forks_url":"https://api.github.com/repos/rhinstaller/anaconda/forks","keys_url":"https://api.github.com/repos/rhinstaller/anaconda/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rhinstaller/anaconda/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rhinstaller/anaconda/teams","hooks_url":"https://api.github.com/repos/rhinstaller/anaconda/hooks","issue_events_url":"https://api.github.com/repos/rhinstaller/anaconda/issues/events{/number}","events_url":"https://api.github.com/repos/rhinstaller/anaconda/events","assignees_url":"https://api.github.com/repos/rhinstaller/anaconda/assignees{/user}","branches_url":"https://api.github.com/repos/rhinstaller/anaconda/branches{/branch}","tags_url":"https://api.github.com/repos/rhinstaller/anaconda/tags","blobs_url":"https://api.github.com/repos/rhinstaller/anaconda/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rhinstaller/anaconda/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rhinstaller/anaconda/git/refs{/sha}","trees_url":"https://api.github.com/repos/rhinstaller/anaconda/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rhinstaller/anaconda/statuses/{sha}","languages_url":"https://api.github.com/repos/rhinstaller/anaconda/languages","stargazers_url":"https://api.github.com/repos/rhinstaller/anaconda/stargazers","contributors_url":"https://api.github.com/repos/rhinstaller/anaconda/contributors","subscribers_url":"https://api.github.com/repos/rhinstaller/anaconda/subscribers","subscription_url":"https://api.github.com/repos/rhinstaller/anaconda/subscription","commits_url":"https://api.github.com/repos/rhinstaller/anaconda/commits{/sha}","git_commits_url":"https://api.github.com/repos/rhinstaller/anaconda/git/commits{/sha}","comments_url":"https://api.github.com/repos/rhinstaller/anaconda/comments{/number}","issue_comment_url":"https://api.github.com/repos/rhinstaller/anaconda/issues/comments{/number}","contents_url":"https://api.github.com/repos/rhinstaller/anaconda/contents/{+path}","compare_url":"https://api.github.com/repos/rhinstaller/anaconda/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rhinstaller/anaconda/merges","archive_url":"https://api.github.com/repos/rhinstaller/anaconda/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rhinstaller/anaconda/downloads","issues_url":"https://api.github.com/repos/rhinstaller/anaconda/issues{/number}","pulls_url":"https://api.github.com/repos/rhinstaller/anaconda/pulls{/number}","milestones_url":"https://api.github.com/repos/rhinstaller/anaconda/milestones{/number}","notifications_url":"https://api.github.com/repos/rhinstaller/anaconda/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rhinstaller/anaconda/labels{/name}","releases_url":"https://api.github.com/repos/rhinstaller/anaconda/releases{/id}","deployments_url":"https://api.github.com/repos/rhinstaller/anaconda/deployments","created_at":"2015-02-02T21:56:45Z","updated_at":"2017-11-02T03:50:15Z","pushed_at":"2017-11-06T12:47:14Z","git_url":"git://github.com/rhinstaller/anaconda.git","ssh_url":"git@github.com:rhinstaller/anaconda.git","clone_url":"https://github.com/rhinstaller/anaconda.git","svn_url":"https://github.com/rhinstaller/anaconda","homepage":null,"size":141197,"stargazers_count":116,"watchers_count":116,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":129,"mirror_url":null,"archived":false,"open_issues_count":44,"forks":129,"open_issues":44,"watchers":116,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rhinstaller/anaconda/pulls/1228"},"html":{"href":"https://github.com/rhinstaller/anaconda/pull/1228"},"issue":{"href":"https://api.github.com/repos/rhinstaller/anaconda/issues/1228"},"comments":{"href":"https://api.github.com/repos/rhinstaller/anaconda/issues/1228/comments"},"review_comments":{"href":"https://api.github.com/repos/rhinstaller/anaconda/pulls/1228/comments"},"review_comment":{"href":"https://api.github.com/repos/rhinstaller/anaconda/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rhinstaller/anaconda/pulls/1228/commits"},"statuses":{"href":"https://api.github.com/repos/rhinstaller/anaconda/statuses/c1cade4ad7e76c98b18bb15dfb8d911eac3f0ce0"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"poncovka"}}