Dominik Holler has uploaded a new change for review. Change subject: storage: prepare iscsi for IPv6 targets ......................................................................
storage: prepare iscsi for IPv6 targets The used iscsiadm tool expects IPv6 addresses in square brackets if a port is appended. For this reason this patch encapsulates hostnames given as IPv6 addresses in square brackets. Change-Id: I1e1e1ffe1c5d09b7bc3767d84a99711986eaef97 Bug-Url: https://bugzilla.redhat.com/1308306 Signed-off-by: Dominik Holler <[email protected]> --- M vdsm/storage/iscsi.py 1 file changed, 29 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/96/65696/5 diff --git a/vdsm/storage/iscsi.py b/vdsm/storage/iscsi.py index 4df844c..72320ff 100644 --- a/vdsm/storage/iscsi.py +++ b/vdsm/storage/iscsi.py @@ -35,6 +35,8 @@ from vdsm import supervdsm from vdsm.config import config from vdsm.network.netinfo.routes import getRouteDeviceTo +from vdsm.network.errors import ConfigNetworkError +from vdsm.network.ip.address import IPv6 from vdsm.password import ProtectedPassword from vdsm.storage import devicemapper from vdsm.storage import misc @@ -53,6 +55,28 @@ _iscsiadmTransactionLock = RLock() log = logging.getLogger('storage.ISCSI') + +def getTargetString(portal, tpgt=None, iqn=None): + hostname = portal.hostname + try: + IPv6.validateAddress(hostname) + hostname = "[%s]" % hostname + except ConfigNetworkError: + pass + + portalStr = "%s:%d" % (hostname, portal.port) + + if tpgt is None: + tpgtStr = "" + else: + tpgtStr = ",%d" % tpgt + + if iqn is None: + iqnStr= "" + else: + iqnStr = " %s" % iqn + + return "%s%s%s" % (portalStr, tpgtStr, iqnStr) def getDevIscsiSessionId(dev): @@ -189,8 +213,7 @@ # bounded iface. Explicitly specifying tpgt on iSCSI login imposes creation # of the node record in the new style format which enables to access a # portal through multiple ifaces for multipathing. - portalStr = "%s:%d,%d" % (target.portal.hostname, target.portal.port, - target.tpgt) + portalStr = getTargetString(target.portal, target.tpgt) with _iscsiadmTransactionLock: iscsiadm.node_new(iface.name, portalStr, target.iqn) try: @@ -216,8 +239,7 @@ # Basically this command deleting a node record (see addIscsiNode). # Once we create a record in the new style format by specifying a tpgt, # we delete it in the same way. - portalStr = "%s:%d,%d" % (target.portal.hostname, target.portal.port, - target.tpgt) + portalStr = getTargetString(target.portal, target.tpgt) with _iscsiadmTransactionLock: try: iscsiadm.node_disconnect(iface.name, portalStr, target.iqn) @@ -230,7 +252,7 @@ def addIscsiPortal(iface, portal, credentials=None): discoverType = "sendtargets" - portalStr = "%s:%d" % (portal.hostname, portal.port) + portalStr = getTargetString(portal) with _iscsiadmTransactionLock: iscsiadm.discoverydb_new(discoverType, iface.name, portalStr) @@ -251,7 +273,7 @@ def deleteIscsiPortal(iface, portal): discoverType = "sendtargets" - portalStr = "%s:%d" % (portal.hostname, portal.port) + portalStr = getTargetString(portal) iscsiadm.discoverydb_delete(discoverType, iface.name, portalStr) @@ -259,7 +281,7 @@ # Because proper discovery actually has to clear the DB having multiple # discoveries at once will cause unpredictable results discoverType = "sendtargets" - portalStr = "%s:%d" % (portal.hostname, portal.port) + portalStr = getTargetString(portal) with _iscsiadmTransactionLock: addIscsiPortal(iface, portal, credentials) -- To view, visit https://gerrit.ovirt.org/65696 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1e1e1ffe1c5d09b7bc3767d84a99711986eaef97 Gerrit-PatchSet: 5 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dominik Holler <[email protected]> _______________________________________________ vdsm-patches mailing list -- [email protected] To unsubscribe send an email to [email protected]
