You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qubes-installer-qubes-os/blivet/0003-iSCSI-turn-iscsi.initi...

72 lines
2.8 KiB

From 4d0b9f8338bfc1634340bb191058b888094ca81d Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
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