[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH rhel5] Fix parsing of optional portnr in iscsi target IP (#525054)



This patch fixes 2 issues with the parsing of the optional portnr in
iscsi target IP's:
1) We don't want to include the : in the portno, so port = target[idx:]
   should be port = target[idx+1:]
2) An IPV6 IP always includes the : character, so specifying the port
   was mandatory with IPV6, this patch looks for "]:" inside the
   string to determine if a port is present for IPV6 strings.
---
 iw/autopart_type.py     |   11 +++++++++--
 textw/partition_text.py |   11 +++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/iw/autopart_type.py b/iw/autopart_type.py
index e8692eb..6ac1b2a 100644
--- a/iw/autopart_type.py
+++ b/iw/autopart_type.py
@@ -156,10 +156,17 @@ class PartitionTypeWindow(InstallWindow):
 
             err = None
             try:
-                idx = target.rfind(":")
+                count = len(target.split(":"))
+                idx = target.rfind("]:")
+                # Check for IPV6 [IPV6-ip]:port
                 if idx != -1:
+                    ip = target[1:idx]
+                    port = target[idx+2:]
+                # Check for IPV4 aaa.bbb.ccc.ddd:port
+                elif count == 2:
+                    idx = target.rfind(":")
                     ip = target[:idx]
-                    port = target[idx:]
+                    port = target[idx+1:]
                 else:
                     ip = target
                     port = "3260"
diff --git a/textw/partition_text.py b/textw/partition_text.py
index 1fba143..5f2d1db 100644
--- a/textw/partition_text.py
+++ b/textw/partition_text.py
@@ -1721,10 +1721,17 @@ class PartitionTypeWindow:
 
         target = entries[0].strip()
         try:
-            idx = target.rfind(":")
+            count = len(target.split(":"))
+            idx = target.rfind("]:")
+            # Check for IPV6 [IPV6-ip]:port
             if idx != -1:
+                ip = target[1:idx]
+                port = target[idx+2:]
+            # Check for IPV4 aaa.bbb.ccc.ddd:port
+            elif count == 2:
+                idx = target.rfind(":")
                 ip = target[:idx]
-                port = target[idx:]
+                port = target[idx+1:]
             else:
                 ip = target
                 port = "3260"
-- 
1.6.5.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]