Skip to content

Commit

Permalink
iscsi: Allow changing iSCSI initiator name once set
Browse files Browse the repository at this point in the history
Blivet (and UDisks) now allow changing of the initiator name which
can now be changed unless an active session already exists.
  • Loading branch information
vojtechtrefny committed Aug 7, 2023
1 parent f076f51 commit aa89273
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 4 additions & 3 deletions pyanaconda/modules/storage/iscsi/iscsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def set_initiator(self, initiator):
:param initiator: a name of the initiator
"""
if not iscsi.initiator_set:
if not iscsi.initiator_set or (initiator != iscsi.initiator and self.can_set_initiator()):
iscsi.initiator = initiator
self.initiator_changed.emit()
log.debug("The iSCSI initiator is set to '%s'.", initiator)
Expand All @@ -79,9 +79,10 @@ def set_initiator(self, initiator):
def can_set_initiator(self):
"""Can the initiator be set?
Once the initiator name is set it can't be changed.
Initiator name can be changed when no sessions are active.
"""
return not iscsi.initiator_set
active = iscsi._get_active_sessions()
return not active

def get_interface_mode(self):
"""Get the mode of interfaces used for iSCSI operations.
Expand Down
6 changes: 1 addition & 5 deletions pyanaconda/modules/storage/iscsi/iscsi_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ def Initiator(self, initiator: Str):
def CanSetInitiator(self) -> Bool:
"""Can the iSCSI initator be set?
Once the initiator name is set it can't be changed.
FIXME
Investigate if it needs to be so strict? Perhaps it has to be frozen only
once there are active nodes logged in, or once any nodes were discovered.
This would need to be changed in blivet/iscsi.py.
Initiator name can be changed when no sessions are active.
"""
return self.implementation.can_set_initiator()

Expand Down

0 comments on commit aa89273

Please sign in to comment.