Skip to content

Commit

Permalink
Fix to perform discovery on all discoveryIPs returned by CSP (#105) (#…
Browse files Browse the repository at this point in the history
…106)

Signed-off-by: Sneha Rai <[email protected]>
Co-authored-by: Sneha Rai <[email protected]>
  • Loading branch information
shivamerla and Sneha Rai authored Apr 6, 2020
1 parent d7ff47f commit 8f7ccbd
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions linux/iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ func PerformDiscovery(discoveryIPs []string) (a model.IscsiTargets, err error) {

var isDiscoveryIpReachable bool
var out string
var outList []string
for _, discoveryIP := range discoveryIPs {
// find the first discovery ip which is reachable
isDiscoveryIpReachable, err = isReachable("", discoveryIP)
Expand All @@ -662,7 +663,7 @@ func PerformDiscovery(discoveryIPs []string) (a model.IscsiTargets, err error) {
log.Error(err.Error())
continue
}
break
outList = append(outList, out)
}
}

Expand All @@ -674,24 +675,26 @@ func PerformDiscovery(discoveryIPs []string) (a model.IscsiTargets, err error) {
return nil, err
}

log.Trace(out)
log.Trace(outList)

var iscsiTargets model.IscsiTargets
// parse the lines into output
r := regexp.MustCompile(getIscsiadmPattern())

listOut := r.FindAllString(out, -1)

for _, line := range listOut {
result := util.FindStringSubmatchMap(line, r)
target := &model.IscsiTarget{
Name: result["target"],
Address: result["address"],
Port: result["port"],
for _, outItem := range outList {
listOut := r.FindAllString(outItem, -1)
for _, line := range listOut {
result := util.FindStringSubmatchMap(line, r)
target := &model.IscsiTarget{
Name: result["target"],
Address: result["address"],
Port: result["port"],
}
log.Tracef("Name %s Address %s Port %s", target.Name, target.Address, target.Port)
iscsiTargets = append(iscsiTargets, target)
}
log.Tracef("Name %s Address %s Port %s", target.Name, target.Address, target.Port)
iscsiTargets = append(iscsiTargets, target)
}

uniqueIscsiTargets := removeDuplicateTargets(iscsiTargets)

return uniqueIscsiTargets, err
Expand Down Expand Up @@ -982,3 +985,4 @@ func bindIface(network model.NetworkInterface) error {
}
return nil
}

0 comments on commit 8f7ccbd

Please sign in to comment.