Skip to content

Commit

Permalink
Add a cmdline option to enabled blivet's auto_dev_updates flag
Browse files Browse the repository at this point in the history
Resolves: rhbz#2238292
  • Loading branch information
vojtechtrefny committed Sep 12, 2023
1 parent a23f3e7 commit d64d685
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
5 changes: 4 additions & 1 deletion blivet-gui
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def parse_options():
parser = argparse.ArgumentParser(description="blivet-gui")
parser.add_argument("-v", "--version", action="store_true", dest="version", default=False,
help=_("show version information"))
parser.add_argument("--auto-dev-updates", action="store_true", dest="auto_dev_updates", default=False,
help="gather all information about devices even if it requires potentially dangerous operation \
like mounting or filesystem check")
parser.add_argument("disks", metavar="disk", type=str, nargs="*",
help="run blivet-gui only on specified disk(s) (optional)")

Expand Down Expand Up @@ -106,7 +109,7 @@ def main():
sockfile = output.split()[0]

client = BlivetGUIClient(server_socket=sockfile)
BlivetGUI(client, exclusive_disks=options.disks)
BlivetGUI(client, exclusive_disks=options.disks, auto_dev_updates=options.auto_dev_updates)


if __name__ == '__main__':
Expand Down
15 changes: 12 additions & 3 deletions blivetgui/blivet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,11 @@ class BlivetUtils(object):

installer_mode = False

def __init__(self, ignored_disks=None, exclusive_disks=None):
def __init__(self, ignored_disks=None, exclusive_disks=None, flags=None):

self.ignored_disks = ignored_disks
self.exclusive_disks = exclusive_disks

self._resizable_filesystems = None

# create our log now, creating blivet.Blivet instance may fail
# and log some basic information -- version and lsblk output
_log_file, self.log = set_logging(component="blivet-gui-utils")
Expand All @@ -164,9 +162,20 @@ def __init__(self, ignored_disks=None, exclusive_disks=None):
# ignore zram devices
blivet.udev.ignored_device_names.append(r"^zram")

# set blivet flags
if flags:
self._set_blivet_flags(flags)

self._resizable_filesystems = None

self.blivet_reset()
self._update_min_sizes_info()

def _set_blivet_flags(self, flags):
for flag, value in flags.items():
self.log.info("setting blivet flag '%s' to '%s'", flag, value)
setattr(blivet.flags.flags, flag, value)

@property
def resizable_filesystems(self):
if self._resizable_filesystems is None:
Expand Down
8 changes: 6 additions & 2 deletions blivetgui/blivetgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BlivetGUI(object):

installer_mode = False

def __init__(self, client, exclusive_disks=None):
def __init__(self, client, exclusive_disks=None, auto_dev_updates=False):

self.client = client

Expand All @@ -93,6 +93,10 @@ def __init__(self, client, exclusive_disks=None):
# supported filesystems
self._supported_filesystems = []

self.flags = dict()
if auto_dev_updates:
self.flags["auto_dev_updates"] = True

# CSS styles
css_provider = Gtk.CssProvider()
css_provider.load_from_path(locate_css_file("rectangle.css"))
Expand Down Expand Up @@ -787,7 +791,7 @@ def _blivet_init_already_running(self):

def blivet_init(self):
loading_window = LoadingWindow(self.main_window)
ret = self._run_thread(loading_window, self.client.remote_control, ("init", self.ignored_disks, self.exclusive_disks))
ret = self._run_thread(loading_window, self.client.remote_control, ("init", self.ignored_disks, self.exclusive_disks, self.flags))

if not ret.success: # pylint: disable=maybe-no-member
# blivet-gui is already running --> quit
Expand Down
3 changes: 3 additions & 0 deletions man/blivet-gui.1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ show this help information and exit
.TP
.BR \-v ", " \-\-version
show version information and exit
.TP
.BR \-\-auto\-dev\-updates
gather all information about devices even if it requires potentially dangerous operation like mounting or filesystem check

.SH EXAMPLES
You can run blivet-gui from a command line and specify one or more disks.
Expand Down

0 comments on commit d64d685

Please sign in to comment.