[2.0-devel 1/2] Do not use deprecated pyudev methods
by dashea
From: Vojtech Trefny <vtrefny(a)redhat.com>
'pyudev.Device.from_sys_path' and 'pyudev.Device.from_device_file'
are deprecated since pyudev 0.18.
---
blivet/devices/storage.py | 4 ++--
blivet/udev.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index d20a52e..7469df3 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -279,8 +279,8 @@ def update_sysfs_path(self):
raise errors.DeviceError("device has not been created", self.name)
try:
- udev_device = pyudev.Device.from_device_file(udev.global_udev,
- self.path)
+ udev_device = pyudev.Devices.from_device_file(udev.global_udev,
+ self.path)
# from_device_file() does not process exceptions but just propagates
# any errors that are raised.
diff --git a/blivet/udev.py b/blivet/udev.py
index 7a3e38c..748ab65 100644
--- a/blivet/udev.py
+++ b/blivet/udev.py
@@ -41,7 +41,7 @@
def get_device(sysfs_path):
try:
- dev = pyudev.Device.from_sys_path(global_udev, sysfs_path)
+ dev = pyudev.Devices.from_sys_path(global_udev, sysfs_path)
except pyudev.DeviceNotFoundError as e:
log.error(e)
dev = None
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/79ea30d07f295be4392ac97dfd7b...
8 years
[PATCH rhel7-branch] (v2) network: add support for --no-activate kickstart opton (#1277975)
by Radek Vykydal
Resolves: rhbz#1277975
This will allow to override special default of first network command
which is --activate.
---
dracut/parse-kickstart | 3 ++-
pyanaconda/network.py | 2 +-
pyanaconda/ui/gui/spokes/network.py | 8 +++++++-
pyanaconda/ui/tui/spokes/network.py | 7 ++++++-
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart
index 250274e..bc9cbdd 100755
--- a/dracut/parse-kickstart
+++ b/dracut/parse-kickstart
@@ -178,7 +178,8 @@ class Network(commands.network.RHEL7_Network, DracutArgsMixin):
# first 'network' line
if len(self.network) == 1:
- net.activate = True
+ if net.activate is None:
+ net.activate = True
# Note that there may be no net.device and no ksdevice if inst.ks=file:/ks.cfg
# If that is the case, fall into ksnet_to_dracut with net.device=None and let
# it handle things.
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index f04b1c7..38e3a18 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -1236,7 +1236,7 @@ def apply_kickstart(ksdata):
# If we have kickstart ifcfg from initramfs
if "Generated by parse-kickstart" in f.read():
# and we should activate the device
- if i == 0 or network_data.activate:
+ if network_data.activate or (i == 0 and network_data.activate is None):
ifcfg = IfcfgFile(ifcfg_path)
ifcfg.read()
con_uuid = ifcfg.get("UUID")
diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index 052a375..e2f3504 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -1673,13 +1673,19 @@ class NetworkStandaloneSpoke(StandaloneSpoke):
def _update_network_data(data, ncb):
data.network.network = []
- for dev_cfg in ncb.dev_cfgs:
+ for i, dev_cfg in enumerate(ncb.dev_cfgs):
devname = dev_cfg.get_iface()
nd = network.ksdata_from_ifcfg(devname, dev_cfg.con_uuid)
if not nd:
continue
if devname in nm.nm_activated_devices():
nd.activate = True
+ else:
+ # First network command defaults to --activate so we must
+ # use --no-activate explicitly to prevent the default
+ if i == 0:
+ nd.activate = False
+
data.network.network.append(nd)
hostname = ncb.hostname
network.update_hostname_data(data, hostname)
diff --git a/pyanaconda/ui/tui/spokes/network.py b/pyanaconda/ui/tui/spokes/network.py
index f60b9ec..b0067fe 100644
--- a/pyanaconda/ui/tui/spokes/network.py
+++ b/pyanaconda/ui/tui/spokes/network.py
@@ -252,12 +252,17 @@ class NetworkSpoke(FirstbootSpokeMixIn, EditTUISpoke):
hostname = self.data.network.hostname
self.data.network.network = []
- for name in nm.nm_devices():
+ for i, name in enumerate(nm.nm_devices()):
nd = network.ksdata_from_ifcfg(name)
if not nd:
continue
if name in nm.nm_activated_devices():
nd.activate = True
+ else:
+ # First network command defaults to --activate so we must
+ # use --no-activate explicitly to prevent the default
+ if i == 0:
+ nd.activate = False
self.data.network.network.append(nd)
(valid, error) = network.sanityCheckHostname(self.hostname_dialog.value)
--
2.4.3
8 years
Re: [rhinstaller/blivet/pulls/428 rhel7-branch] Improved handling of
corrupt or otherwise unsupported disklabels (rhel7)
by dashea
> @@ -409,30 +427,15 @@ def endAlignment(self):
>
> @property
> def free(self):
> - def read_int_from_sys(path):
> - return int(open(path).readline().strip())
> + if not self.supported:
> + return Size(0)
>
> try:
> free = sum(Size(f.getLength(unit="B"))
> for f in self.partedDisk.getFreeSpacePartitions())
> except Exception: # pylint: disable=broad-except
> log_exception_info()
> - sys_block_root = "/sys/class/block/"
> -
> - # FIXME: /dev/mapper/foo won't work without massaging
> - disk_name = self.device.split("/")[-1]
> -
> - disk_root = sys_block_root + disk_name
> - disk_length = read_int_from_sys("%s/size" % disk_root)
> - sector_size = read_int_from_sys("%s/queue/logical_block_size" % disk_root)
> - partition_names = [n for n in os.listdir(disk_root) if n.startswith(disk_name)]
> - used_sectors = 0
> - for partition_name in partition_names:
> - partition_root = sys_block_root + partition_name
> - partition_length = read_int_from_sys("%s/size" % partition_root)
> - used_sectors += partition_length
> -
> - free = Size((disk_length - used_sectors) * sector_size)
Makes sense.
--
To view this pull request on github, visit https://github.com/rhinstaller/blivet/pull/428#discussion_r65508481
8 years