[PATCH] On Fedora have ONBOOT=yes as default for wired devices (#963952)
by Radek Vykydal
The case from BZ is installation without connection (link) and
desire to connect automatically after reboot.
---
anaconda | 2 +-
pyanaconda/__init__.py | 2 --
pyanaconda/installclass.py | 4 ----
pyanaconda/installclasses/fedora.py | 26 --------------------------
pyanaconda/network.py | 14 ++++++--------
5 files changed, 7 insertions(+), 41 deletions(-)
diff --git a/anaconda b/anaconda
index ac90d72..19aa601 100755
--- a/anaconda
+++ b/anaconda
@@ -1037,7 +1037,7 @@ if __name__ == "__main__":
else:
cleanPStore()
- networkInitialize(ksdata)
+ networkInitialize(ksdata, anaconda.instClass)
if not flags.dirInstall:
threadMgr.add(AnacondaThread(name=constants.THREAD_STORAGE, target=storageInitialize, args=(anaconda.storage, ksdata, anaconda.protected)))
threadMgr.add(AnacondaThread(name=constants.THREAD_WAIT_FOR_CONNECTING_NM, target=wait_for_connecting_NM_thread, args=(ksdata,)))
diff --git a/pyanaconda/__init__.py b/pyanaconda/__init__.py
index f5a81a5..e28130f 100644
--- a/pyanaconda/__init__.py
+++ b/pyanaconda/__init__.py
@@ -240,6 +240,4 @@ class Anaconda(object):
network.write_sysconfig_network()
network.disableIPV6()
network.copyConfigToPath(ROOT_PATH)
- if not self.ksdata:
- self.instClass.setNetworkOnbootDefault()
self.desktop.write()
diff --git a/pyanaconda/installclass.py b/pyanaconda/installclass.py
index 6d0b1e8..739b705 100644
--- a/pyanaconda/installclass.py
+++ b/pyanaconda/installclass.py
@@ -100,10 +100,6 @@ class BaseInstallClass(object):
anaconda.bootloader.timeout = self.bootloaderTimeoutDefault
anaconda.bootloader.boot_args.update(self.bootloaderExtraArgs)
- # sets default ONBOOT values and updates ksdata accordingly
- def setNetworkOnbootDefault(self, ksdata):
- pass
-
def __init__(self):
pass
diff --git a/pyanaconda/installclasses/fedora.py b/pyanaconda/installclasses/fedora.py
index 6f95f85..1509581 100644
--- a/pyanaconda/installclasses/fedora.py
+++ b/pyanaconda/installclasses/fedora.py
@@ -45,31 +45,5 @@ class InstallClass(BaseInstallClass):
def setGroupSelection(self, anaconda):
BaseInstallClass.setGroupSelection(self, anaconda)
- def setNetworkOnbootDefault(self, ksdata):
- # if something's already enabled, we can just leave the config alone
- for devName in nm.nm_devices():
- if not nm.nm_device_type_is_wifi(devName) and \
- network.get_ifcfg_value(devName, "ONBOOT", ROOT_PATH) == "yes":
- return
-
- # the default otherwise: bring up the first wired netdev with link
- for devName in nm.nm_devices():
- if nm.nm_device_type_is_wifi(devName):
- continue
- try:
- link_up = nm.nm_device_carrier(devName)
- except ValueError as e:
- continue
- if link_up:
- dev = network.NetworkDevice(ROOT_PATH + network.netscriptsDir, devName)
- dev.loadIfcfgFile()
- dev.set(('ONBOOT', 'yes'))
- dev.writeIfcfgFile()
- for nd in ksdata.network.network:
- if nd.device == dev.iface:
- nd.onboot = True
- break
- break
-
def __init__(self):
BaseInstallClass.__init__(self)
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 6f73143..2c1ab0c 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -290,7 +290,7 @@ class NetworkDevice(IfcfgFile):
return content
-def dumpMissingDefaultIfcfgs():
+def dumpMissingDefaultIfcfgs(instclass):
"""
Dump missing default ifcfg file for wired devices.
For default auto connections created by NM upon start - which happens
@@ -317,8 +317,9 @@ def dumpMissingDefaultIfcfgs():
try:
nm.nm_update_settings_of_device(devname, 'connection', 'id', devname)
log.debug("network: dumping ifcfg file for default autoconnection on %s" % devname)
- nm.nm_update_settings_of_device(devname, 'connection', 'autoconnect', False)
- log.debug("network: setting autoconnect of %s to False" % devname)
+ if instclass.id == "rhel":
+ nm.nm_update_settings_of_device(devname, 'connection', 'autoconnect', False)
+ log.debug("network: setting autoconnect of %s to False" % devname)
except nm.DeviceSettingsNotFoundError as e:
log.debug("network: no ifcfg file for %s" % devname)
rv = True
@@ -758,9 +759,6 @@ def write_network_config(storage, ksdata, instClass, rootpath):
copyIfcfgFiles(rootpath)
copyDhclientConfFiles(rootpath)
copyFileToPath("/etc/resolv.conf", rootpath, overwrite=flags.livecdInstall)
- # TODO the default for ONBOOT needs to be lay down
- # before newui we didn't set it for kickstart installs
- instClass.setNetworkOnbootDefault(ksdata)
# NM_CONTROLLED is not mirrored in ksdata
disableNMForStorageDevices(rootpath, storage)
autostartFCoEDevices(rootpath, storage, ksdata)
@@ -873,13 +871,13 @@ def setOnboot(ksdata):
except nm.DeviceSettingsNotFoundError as e:
log.debug("setOnboot: %s" % e)
-def networkInitialize(ksdata):
+def networkInitialize(ksdata, instclass):
log.debug("network: devices found %s" % nm.nm_devices())
logIfcfgFiles("network initialization")
if not flags.imageInstall:
- if dumpMissingDefaultIfcfgs():
+ if dumpMissingDefaultIfcfgs(instclass):
logIfcfgFiles("ifcfgs created")
# For kickstart network --activate option we set ONBOOT=yes
--
1.7.11.7
11 years
[PATCH] Create empty /etc/sysconfig/network for network service (#957897)
by Radek Vykydal
---
pyanaconda/network.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 6f73143..6532e6e 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -750,9 +750,20 @@ def usedByRootOnISCSI(iface, storage):
return False
+def write_sysconfig_network(rootpath, overwrite=False):
+
+ cfgfile = os.path.normpath(rootpath + networkConfFile)
+ if (os.path.isfile(cfgfile) and not overwrite):
+ return False
+
+ with open(cfgfile, "w") as f:
+ f.write("# Created by anaconda\n")
+ return True
+
def write_network_config(storage, ksdata, instClass, rootpath):
write_hostname(rootpath, ksdata, overwrite=flags.livecdInstall)
set_hostname(ksdata.network.hostname)
+ write_sysconfig_network(rootpath, overwrite=flags.livecdInstall)
disableIPV6(rootpath)
if not flags.imageInstall:
copyIfcfgFiles(rootpath)
--
1.7.11.7
11 years
[PATCH] Remove testing leftover (#963503)
by Radek Vykydal
---
pyanaconda/nm.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyanaconda/nm.py b/pyanaconda/nm.py
index 90a93c3..0932a2e 100644
--- a/pyanaconda/nm.py
+++ b/pyanaconda/nm.py
@@ -24,7 +24,7 @@ from gi.repository import NetworkManager
import struct
import socket
-DEFAULT_DBUS_TIMEOUT = 30
+from pyanaconda.constants import DEFAULT_DBUS_TIMEOUT
device_type_interfaces = {
NetworkManager.DeviceType.ETHERNET: "org.freedesktop.NetworkManager.Device.Wired",
--
1.7.11.7
11 years
[PATCH 1/7] Don't allow setting labels for btrfs subvolumes. (#960601)
by David Lehman
The volume label can be set in the modify volume dialog.
---
pyanaconda/ui/gui/spokes/custom.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 0f270b3..ac006f9 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -1634,12 +1634,12 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
self._mountPointEntry.set_text(getattr(device.format, "mountpoint", "") or "")
fancy_set_sensitive(self._mountPointEntry, device.format.mountable)
- # FIXME: Make sure you cannot set a label for specific btrfs subvols
self._labelEntry.set_text(getattr(device.format, "label", "") or "")
# We could label existing formats that have a labelFsProg if we added an
# ActionLabelFormat class.
can_label = (hasattr(device.format, "label") and
- not device.format.exists)
+ not device.format.exists and
+ device.format.type != "btrfs")
fancy_set_sensitive(self._labelEntry, can_label)
if hasattr(device.format, "label"):
@@ -2495,7 +2495,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
label_active = active
if active:
fmt = getFormat(self._fsCombo.get_active_text())
- label_active = active and hasattr(fmt, "label")
+ label_active = (active and hasattr(fmt, "label") and
+ fmt.type != "btrfs")
fancy_set_sensitive(self._labelEntry, label_active)
@@ -2509,8 +2510,10 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
log.debug("fs type changed: %s" % new_type)
fmt = getFormat(new_type)
# FIXME: can't set a label on an existing format as of now
- fancy_set_sensitive(self._labelEntry, self._reformatCheckbox.get_active() and
- hasattr(fmt, "label"))
+ label_active = (self._reformatCheckbox.get_active() and
+ hasattr(fmt, "label") and
+ fmt.type != "btrfs")
+ fancy_set_sensitive(self._labelEntry, label_active)
fancy_set_sensitive(self._mountPointEntry, fmt.mountable)
def _populate_container(self, device=None):
--
1.8.1.4
11 years
[blivet] total_memory calculation needs to round up (#962231)
by Brian C. Lane
From: "Brian C. Lane" <bcl(a)redhat.com>
This matches the logic used by Anaconda's isys total_memory function.
---
blivet/util.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/blivet/util.py b/blivet/util.py
index c27d9f3..1c39f56 100644
--- a/blivet/util.py
+++ b/blivet/util.py
@@ -129,6 +129,13 @@ def total_memory():
if line.startswith("MemTotal:"):
mem = long(line.split()[1])
+ # Because /proc/meminfo only gives us the MemTotal (total physical RAM
+ # minus the kernel binary code), we need to round this up. Assuming
+ # every machine has the total RAM MB number divisible by 128. */
+ mem /= 1024;
+ mem = (mem / 128 + 1) * 128;
+ mem *= 1024;
+
return mem
##
--
1.8.1.4
11 years
[PATCH] The dev.node attribute for iscsi devices is not copyable (#962865).
by Chris Lumens
libiscsi doesn't provide a way to copy this, so when we copy it, the new
attribute ends up filled with garbage.
---
blivet/devices.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blivet/devices.py b/blivet/devices.py
index ef5db99..635cd19 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -245,7 +245,7 @@ class Device(object):
"""
new = self.__class__.__new__(self.__class__)
memo[id(self)] = new
- dont_copy_attrs = ('_raidSet',)
+ dont_copy_attrs = ('_raidSet', 'node')
shallow_copy_attrs = ('_partedDevice', '_partedPartition')
for (attr, value) in self.__dict__.items():
if attr in dont_copy_attrs:
--
1.8.1.2
11 years
[PATCH] Wipe partitions before they are created (#950145)
by Brian C. Lane
From: "Brian C. Lane" <bcl(a)redhat.com>
If a partition is created in the same position as a previous filesystem,
eg. a LVM pv, udev will activate it and cause the device to be busy,
preventing us from using it.
This uses the parted information from parted to calculate the start of
the partition and calls dd to write zeros to the first 10MiB of the
partition.
This also rescans the pv to make sure things stay in sync with the
filesystem when creating and removing pvs.
---
blivet/devicelibs/lvm.py | 10 ++++++++++
blivet/devices.py | 21 +++++++++++++++++++++
blivet/formats/lvmpv.py | 12 ++++++++----
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
index d16b659..eaafad1 100644
--- a/blivet/devicelibs/lvm.py
+++ b/blivet/devicelibs/lvm.py
@@ -192,6 +192,16 @@ def pvremove(device):
except LVMError as msg:
raise LVMError("pvremove failed for %s: %s" % (device, msg))
+def pvscan(device):
+ args = ["pvscan", "--cache",] + \
+ _getConfigArgs() + \
+ [device]
+
+ try:
+ lvm(args)
+ except LVMError as msg:
+ raise LVMError("pvscan failed for %s: %s" % (device, msg))
+
def pvinfo(device):
"""
If the PV was created with '--metadacopies 0', lvm will do some
diff --git a/blivet/devices.py b/blivet/devices.py
index ef5db99..9bd0d79 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -1461,12 +1461,33 @@ class PartitionDevice(StorageDevice):
self._bootable = self.getFlag(parted.PARTITION_BOOT)
+ def _wipe(self):
+ """ Wipe the partition. """
+ log_method_call(self, self.name, status=self.status)
+
+ start = self.partedPartition.geometry.start
+ part_len = self.partedPartition.geometry.end - start
+ bs = self.partedPartition.geometry.device.sectorSize
+ device = self.partedPartition.geometry.device.path
+
+ # Erase 10M or to end of partition
+ count = 10 * 1024 * 1024 / bs
+ count = min(count, part_len)
+
+ cmd = ["dd", "if=/dev/zero", "of=%s" % device, "bs=%s" % bs,
+ "seek=%s" % start, "count=%s" % count]
+ try:
+ util.run_program(cmd)
+ except OSError as e:
+ log.error(str(e))
+
def _create(self):
""" Create the device. """
log_method_call(self, self.name, status=self.status)
self.disk.format.addPartition(self.partedPartition)
try:
+ self._wipe()
self.disk.format.commit()
except DiskLabelCommitError:
part = self.disk.format.partedDisk.getPartitionByPath(self.path)
diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py
index e610f66..300b849 100644
--- a/blivet/formats/lvmpv.py
+++ b/blivet/formats/lvmpv.py
@@ -109,13 +109,15 @@ class LVMPhysicalVolume(DeviceFormat):
# lvm has issues with persistence of metadata, so here comes the
# hammer...
DeviceFormat.destroy(self, *args, **kwargs)
-
+ lvm.pvscan(self.device)
lvm.pvcreate(self.device)
except Exception:
raise
- else:
- self.exists = True
- self.notifyKernel()
+ finally:
+ lvm.pvscan(self.device)
+
+ self.exists = True
+ self.notifyKernel()
def destroy(self, *args, **kwargs):
""" Destroy the format. """
@@ -132,6 +134,8 @@ class LVMPhysicalVolume(DeviceFormat):
lvm.pvremove(self.device)
except LVMError:
DeviceFormat.destroy(self, *args, **kwargs)
+ finally:
+ lvm.pvscan(self.device)
self.exists = False
self.notifyKernel()
--
1.8.1.4
11 years
[pykickstart] Two new options for the rootpw command
by Vratislav Podzimek
This patch adds two new options: --frozen and --allow-changes for the rootpw
command. Both determine the policy of changing the password from the kickstart
in the UI. --frozen means that the password cannot be changed at all,
--allow-changes means that the password can be changed without any other
actions. When using none of them retyping the password should be required to
enable changes.
The patch seems to add a lot of code, but it really just streamlines the code
from the previous versions of the command. The code and tests were adjusted in a
way that the --plaintext and --iscrypted options appear just before the password
itself consistently. Also it is better prepared for additional extending (e.g.
minimal length restrictions, etc.).
Vratislav Podzimek (1):
Two new options for the rootpw command
pykickstart/commands/rootpw.py | 63 ++++++++++++++++++++++++++++++++++++++++-
pykickstart/handlers/control.py | 4 +--
tests/commands/rootpw.py | 31 ++++++++++++++++++++
3 files changed, 95 insertions(+), 3 deletions(-)
--
1.7.11.7
11 years
[master] Patches for the root password spoke
by Vratislav Podzimek
Patches 1/3 and 2/3 are just minor changes. The PATCH 3/3 changes the root
password spoke to respect the policy for changing password from the kickstart.
If --allow-changes is used in the kickstart, the password can be changed freely.
If --frozen is used, the password cannot be changed at all. If none of these
options is used, the password from the kickstart is required before the changes
are allowed. This should resolve all complaints that we now allow changing the
password entered in the kickstart (as oposed to the old UI). I believe both
options will appear to be useful, mainly in corporate environment. The same
should be implemented also in the text mode, but I'm leaving this for an
additional patch
This video preview shows the no option case:
http://vpodzime.fedorapeople.org/retype_rootpw.webm
The PATCH 3/3 requires the pykickstart patch I'm sending as well.
Vratislav Podzimek (3):
Remove the commented CapsLock handling
Move the really_hide and really_show functions to utils
Require root password from kickstart to allow changes
pyanaconda/kickstart.py | 2 +-
pyanaconda/ui/gui/spokes/custom.py | 17 +------
pyanaconda/ui/gui/spokes/password.glade | 46 ++++++++++++------
pyanaconda/ui/gui/spokes/password.py | 82 +++++++++++++++++++++++++++------
pyanaconda/ui/gui/utils.py | 16 +++++++
pyanaconda/users.py | 24 ++++++++++
6 files changed, 140 insertions(+), 47 deletions(-)
--
1.7.11.7
11 years
[PATCH] Pass ROOT_PATH as an argument instead of importing it.
by Chris Lumens
Right now, it's being set before enable_installer_mode is called which means
ROOT_PATH is still set to / when iscsi.write is called, which causes the
contents of the installation media to be deleted.
Related: rhbz#962865
---
blivet/__init__.py | 13 ++++++++-----
blivet/dasd.py | 3 +--
blivet/fcoe.py | 3 +--
blivet/iscsi.py | 3 +--
blivet/zfcp.py | 3 +--
5 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/blivet/__init__.py b/blivet/__init__.py
index 08f3a05..45614d6 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -24,7 +24,10 @@ __version__ = '0.13'
##
## Default stub values for installer-specific stuff that gets set up in
-## enable_installer_mode.
+## enable_installer_mode. These constants are only for use inside this file.
+## For use in other blivet files, they must either be passed to the function
+## in question or care must be taken so they are imported only after
+## enable_installer_mode is called.
##
isys = None
ROOT_PATH = '/'
@@ -1619,10 +1622,10 @@ class Blivet(object):
self.fsset.write()
self.makeMtab()
- self.iscsi.write(self)
- self.fcoe.write()
- self.zfcp.write()
- self.dasd.write()
+ self.iscsi.write(ROOT_PATH, self)
+ self.fcoe.write(ROOT_PATH)
+ self.zfcp.write(ROOT_PATH)
+ self.dasd.write(ROOT_PATH)
def turnOnSwap(self, upgrading=None):
self.fsset.turnOnSwap(rootPath=ROOT_PATH,
diff --git a/blivet/dasd.py b/blivet/dasd.py
index 8370e9b..46a23d5 100644
--- a/blivet/dasd.py
+++ b/blivet/dasd.py
@@ -25,7 +25,6 @@ from .errors import DasdFormatError
from .devices import deviceNameToDiskByPath
from . import util
from . import arch
-from . import ROOT_PATH
from .udev import udev_trigger
import logging
@@ -187,7 +186,7 @@ class DASD:
""" Clear the device list to force re-populate on next access. """
self._devices = []
- def write(self):
+ def write(self, ROOT_PATH):
""" Write /etc/dasd.conf to target system for all DASD devices
configured during installation.
"""
diff --git a/blivet/fcoe.py b/blivet/fcoe.py
index 188b41b..4bbd8c3 100644
--- a/blivet/fcoe.py
+++ b/blivet/fcoe.py
@@ -21,7 +21,6 @@ import os
from . import util
from .udev import udev_settle
#from pyanaconda import isys
-from . import ROOT_PATH
import logging
import time
log = logging.getLogger("blivet")
@@ -134,7 +133,7 @@ class fcoe(object):
self._stabilize()
self.nics.append((nic, dcb, auto_vlan))
- def write(self):
+ def write(self, ROOT_PATH):
if not self.nics:
return
diff --git a/blivet/iscsi.py b/blivet/iscsi.py
index 654de63..d35dbea 100644
--- a/blivet/iscsi.py
+++ b/blivet/iscsi.py
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-from . import ROOT_PATH
from udev import udev_settle
from . import util
from .flags import flags
@@ -377,7 +376,7 @@ class iscsi(object):
self.stabilize()
- def write(self, storage):
+ def write(self, ROOT_PATH, storage):
if not self.initiatorSet:
return
diff --git a/blivet/zfcp.py b/blivet/zfcp.py
index f635a1a..cf8ec40 100644
--- a/blivet/zfcp.py
+++ b/blivet/zfcp.py
@@ -21,7 +21,6 @@
import string
import os
-from . import ROOT_PATH
from udev import udev_settle
from . import util
@@ -410,7 +409,7 @@ class ZFCP:
except ValueError as e:
log.warn(str(e))
- def write(self):
+ def write(self, ROOT_PATH):
if len(self.fcpdevs) == 0:
return
f = open(ROOT_PATH + zfcpconf, "w")
--
1.8.1.2
11 years