diff --git a/0001-Use-correct-type-for-port-in-GVariant-tuple.patch b/0001-Use-correct-type-for-port-in-GVariant-tuple.patch new file mode 100644 index 0000000..47f14af --- /dev/null +++ b/0001-Use-correct-type-for-port-in-GVariant-tuple.patch @@ -0,0 +1,28 @@ +From cf32290dd3a0561585837fddfcdb08b3389f356a Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Wed, 26 Oct 2016 16:17:46 -0700 +Subject: [PATCH 1/4] Use correct type for port in GVariant tuple + +The type is `(sqa{sv})`, where `q` (according to the docs) is +"an unsigned 16 bit integer", so this should be an int, not a +string. +--- + blivet/iscsi.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/blivet/iscsi.py b/blivet/iscsi.py +index 8773509..14c4b9a 100644 +--- a/blivet/iscsi.py ++++ b/blivet/iscsi.py +@@ -369,7 +369,7 @@ class iSCSI(object): + if r_password: + auth_info["r_password"] = GLib.Variant("s", r_password) + +- args = GLib.Variant("(sqa{sv})", (ipaddr, port, auth_info)) ++ args = GLib.Variant("(sqa{sv})", (ipaddr, int(port), auth_info)) + nodes, _n_nodes = self._call_initiator_method("DiscoverSendTargets", args) + + found_nodes = _to_node_infos(nodes) +-- +2.7.4 + diff --git a/0002-iSCSI-Store-auth-info-in-NodeInfo-tuples.patch b/0002-iSCSI-Store-auth-info-in-NodeInfo-tuples.patch new file mode 100644 index 0000000..79d0a95 --- /dev/null +++ b/0002-iSCSI-Store-auth-info-in-NodeInfo-tuples.patch @@ -0,0 +1,122 @@ +From 5eaadad9218210ed2a616104a6e56665c38f9277 Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Wed, 26 Oct 2016 20:42:53 -0700 +Subject: [PATCH 2/4] iSCSI: Store auth info in NodeInfo tuples + +This seems to have been overlooked in 9280eff7 . When we were +using libiscsi, the `node` objects were `PyIscsiNode` instances +(I think), with `getAuth` and `setAuth` methods that let you +read and set the authentication information for the node. We +used `getAuth` in `iScsiDiskDevice.dracut_setup_args()` to +include the auth information in the `netroot` arg. anaconda +also expects the `node` attribute of an `iScsiDiskDevice` +instance to be a `PyIscsiNode` and calls its `getAuth` method +to populate the kickstart data for the node. + +When we ditched libiscsi and turned the `node` objects into +`NodeInfo` namedtuples, this was missed and not handled at all. +Both blivet and anaconda are still trying to call methods that +these node objects just don't have any more. The blivet call +was changed from `getAuth()` to `get_auth()` in 4e8f941b , but +apparently whoever did that didn't notice that neither method +exists at all for these objects any more... + +Here's my attempt to fix this: basically, just stuff the auth +information into the `NodeInfo` instances when we log in. I +thought of several different ways to do this, but I think in +the end it always has to boil down to storing the auth details +on the node object when we log in, so let's just go with the +obvious way. We could mimic the `getAuth` and `setAuth` methods +pretty easily for 'compatibility', but it doesn't seem worth +it, we'd probably still be missing other bits of the interface. +--- + blivet/devices/disk.py | 11 +++++------ + blivet/iscsi.py | 33 +++++++++++++++++++++++++++++++-- + 2 files changed, 36 insertions(+), 8 deletions(-) + +diff --git a/blivet/devices/disk.py b/blivet/devices/disk.py +index 6880e1e..acf31ee 100644 +--- a/blivet/devices/disk.py ++++ b/blivet/devices/disk.py +@@ -452,12 +452,11 @@ class iScsiDiskDevice(DiskDevice, NetworkStorageDevice): + address = "[%s]" % address + + netroot = "netroot=iscsi:" +- auth = self.node.get_auth() +- if auth: +- netroot += "%s:%s" % (auth.username, auth.password) +- if len(auth.reverse_username) or len(auth.reverse_password): +- netroot += ":%s:%s" % (auth.reverse_username, +- auth.reverse_password) ++ if self.node.username and self.node.password: ++ netroot += "%s:%s" % (self.node.username, self.node.password) ++ if self.node.r_username and self.node.r_password: ++ netroot += ":%s:%s" % (self.node.r_username, ++ self.node.r_password) + + iface_spec = "" + if self.nic != "default": +diff --git a/blivet/iscsi.py b/blivet/iscsi.py +index 14c4b9a..1969fc8 100644 +--- a/blivet/iscsi.py ++++ b/blivet/iscsi.py +@@ -66,10 +66,31 @@ def has_iscsi(): + return True + + +-NodeInfo = namedtuple("NodeInfo", ["name", "tpgt", "address", "port", "iface"]) + TargetInfo = namedtuple("TargetInfo", ["ipaddr", "port"]) + + ++class NodeInfo(object): ++ """Simple representation of node information.""" ++ def __init__(self, name, tpgt, address, port, iface): ++ self.name = name ++ self.tpgt = tpgt ++ self.address = address ++ self.port = port ++ self.iface = iface ++ # These get set by log_into_node, but *NOT* _login ++ self.username = None ++ self.password = None ++ self.r_username = None ++ self.r_password = None ++ ++ @property ++ def conn_info(self): ++ """The 5-tuple of connection info (no auth info). This form ++ is useful for interacting with storaged. ++ """ ++ return (self.name, self.tpgt, self.address, self.port, self.iface) ++ ++ + class LoginInfo(object): + def __init__(self, node, logged_in): + self.node = node +@@ -239,7 +260,7 @@ class iSCSI(object): + extra = dict() + extra["node.startup"] = GLib.Variant("s", "automatic") + +- args = GLib.Variant("(sisisa{sv})", tuple(list(node_info) + [extra])) ++ args = GLib.Variant("(sisisa{sv})", node_info.conn_info + (extra,)) + self._call_initiator_method("Login", args) + + @storaged_iscsi_required(critical=False, eval_mode=util.EvalMode.onetime) +@@ -414,6 +435,14 @@ class iSCSI(object): + node.name, node.address, node.port, node.iface) + if not self._mark_node_active(node): + log.error("iSCSI: node not found among discovered") ++ if username: ++ node.username = username ++ if password: ++ node.password = password ++ if r_username: ++ node.r_username = r_username ++ if r_password: ++ node.r_password = r_password + except safe_dbus.DBusCallError as e: + msg = str(e) + log.warning("iSCSI: could not log into %s: %s", node.name, msg) +-- +2.7.4 + diff --git a/0003-iSCSI-turn-iscsi.initiator_set-into-a-property.patch b/0003-iSCSI-turn-iscsi.initiator_set-into-a-property.patch new file mode 100644 index 0000000..ba0d7f8 --- /dev/null +++ b/0003-iSCSI-turn-iscsi.initiator_set-into-a-property.patch @@ -0,0 +1,71 @@ +From 4d0b9f8338bfc1634340bb191058b888094ca81d Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Thu, 27 Oct 2016 15:17:29 -0700 +Subject: [PATCH 3/4] iSCSI: turn `iscsi.initiator_set` into a property + +The iSCSI class has an `initiator_set` attribute whose meaning +feels a bit slippery these days. It has always been set to +True in `__init__()` if iBFT is active, right after we get the +initiator name from the firmware. Prior to 9280eff7, it was +also set true by `startup()` after it wrote out INITIATOR_FILE. +In 9280eff7, that was removed, without any kind of replacement. +Now `initiator_set` will never be True unless iBFT is being +used. + +This is a problem because `iscsi.write()` checks if it's True, +and immediately bails if it isn't. The result of this is that +when you do an iSCSI install with anaconda, the contents of +`/var/lib/iscsi` from the installer environment are no longer +copied in the installed system. + +vpodzime asked for this fix: making it into a property which +returns True if `self._initiator` is set, otherwise False. +I used `== ""` as the test because that's what we use in other +places, though in my own code I'd normally just use +`if self._initiator:`. + +Note that `if iscsi.initiator_set:` and `if iscsi.initiator:` +are not quite equivalent, as the `initiator` property will try +and read the initiator name from storaged if `self._initiator` +is not set, but `initiator_set` will not. This best matches +the previous behaviour, but I'm not sure if all of this makes +any logical sense when considered from scratch. +--- + blivet/iscsi.py | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/blivet/iscsi.py b/blivet/iscsi.py +index 1969fc8..b221fd4 100644 +--- a/blivet/iscsi.py ++++ b/blivet/iscsi.py +@@ -149,7 +149,6 @@ class iSCSI(object): + # This list contains nodes discovered through iBFT (or other firmware) + self.ibft_nodes = [] + self._initiator = "" +- self.initiator_set = False + self.started = False + self.ifaces = {} + +@@ -159,7 +158,6 @@ class iSCSI(object): + try: + initiatorname = self._call_initiator_method("GetFirmwareInitiatorName")[0] + self._initiator = initiatorname +- self.initiator_set = True + except Exception: # pylint: disable=broad-except + log_exception_info(fmt_str="failed to get initiator name from iscsi firmware") + +@@ -197,6 +195,11 @@ class iSCSI(object): + connection=self._connection) + + @property ++ def initiator_set(self): ++ """True if initiator is set at our level.""" ++ return self._initiator != "" ++ ++ @property + @storaged_iscsi_required(critical=False, eval_mode=util.EvalMode.onetime) + def initiator(self): + if self._initiator != "": +-- +2.7.4 + diff --git a/0004-Add-device-symlinks-to-the-PVs-dictionary-for-MD-RAI.patch b/0004-Add-device-symlinks-to-the-PVs-dictionary-for-MD-RAI.patch new file mode 100644 index 0000000..be02058 --- /dev/null +++ b/0004-Add-device-symlinks-to-the-PVs-dictionary-for-MD-RAI.patch @@ -0,0 +1,45 @@ +From 274b0bfb6aa923a82662e754030ebce4d8694901 Mon Sep 17 00:00:00 2001 +From: Vratislav Podzimek +Date: Thu, 3 Nov 2016 12:53:03 +0100 +Subject: [PATCH 4/4] Add device symlinks to the PVs dictionary for MD RAID PVs + (#1389130) + +Otherwise if the symlink is used to search for the PV info, it's not found and +everything on that PV is ignored which leads e.g. to issues when removing the PV +(as described in the bug) and others. +--- + blivet/static_data/lvm_info.py | 18 +++++++++++++++++- + 1 file changed, 17 insertions(+), 1 deletion(-) + +diff --git a/blivet/static_data/lvm_info.py b/blivet/static_data/lvm_info.py +index ed2e995..4f5a274 100644 +--- a/blivet/static_data/lvm_info.py ++++ b/blivet/static_data/lvm_info.py +@@ -57,7 +57,23 @@ class PVsInfo(object): + def cache(self): + if self._pvs_cache is None: + pvs = blockdev.lvm.pvs() +- self._pvs_cache = dict((pv.pv_name, pv) for pv in pvs) # pylint: disable=attribute-defined-outside-init ++ self._pvs_cache = dict() # pylint: disable=attribute-defined-outside-init ++ for pv in pvs: ++ self._pvs_cache[pv.pv_name] = pv ++ # TODO: add get_all_device_symlinks() and resolve_device_symlink() functions to ++ # libblockdev and use them here ++ if pv.pv_name.startswith("/dev/md/"): ++ try: ++ md_node = blockdev.md.node_from_name(pv.pv_name[len("/dev/md/"):]) ++ self._pvs_cache["/dev/" + md_node] = pv ++ except blockdev.MDRaidError: ++ pass ++ elif pv.pv_name.startswith("/dev/md"): ++ try: ++ md_named_dev = blockdev.md.name_from_node(pv.pv_name[len("/dev/"):]) ++ self._pvs_cache["/dev/md/" + md_named_dev] = pv ++ except blockdev.MDRaidError: ++ pass + + return self._pvs_cache + +-- +2.7.4 + diff --git a/python-blivet.spec b/python-blivet.spec index 8462ac6..7eccd27 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -5,7 +5,7 @@ Version: 2.1.6 #%%global prerelease .b1 # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2 -Release: 1%{?prerelease}%{?dist} +Release: 2%{?prerelease}%{?dist} Epoch: 1 License: LGPLv2+ Group: System Environment/Libraries @@ -13,6 +13,11 @@ Group: System Environment/Libraries %global realversion %{version}%{?prerelease} Source0: http://github.com/rhinstaller/blivet/archive/%{realname}-%{realversion}.tar.gz +Patch0: 0001-Use-correct-type-for-port-in-GVariant-tuple.patch +Patch1: 0002-iSCSI-Store-auth-info-in-NodeInfo-tuples.patch +Patch2: 0003-iSCSI-turn-iscsi.initiator_set-into-a-property.patch +Patch3: 0004-Add-device-symlinks-to-the-PVs-dictionary-for-MD-RAI.patch + # Versions of required components (done so we make sure the buildrequires # match the requires versions of things). %global pykickstartver 1.99.22 @@ -61,6 +66,10 @@ configuration. %prep %setup -q -n %{realname}-%{realversion} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 rm -rf %{py3dir} cp -a . %{py3dir} @@ -78,6 +87,12 @@ make PYTHON=%{__python3} DESTDIR=%{buildroot} install %{python3_sitelib}/* %changelog +* Mon Nov 07 2016 David Lehman - 2.1.6-2 +- Use correct type for port in GVariant tuple (awilliam) +- iSCSI: Store auth info in NodeInfo tuples (awilliam) +- iSCSI: turn `iscsi.initiator_set` into a property (awilliam) +- Add device symlinks to the PVs dictionary for MD RAID PVs (#1389130) (vpodzime) + * Tue Oct 04 2016 David Lehman - 2.1.6-1 - add missing populators to populator.helpers (awilliam)