Merge pull request #95 from utkarshmani1997/configuredIP
Listen on configured IP and close conn on error
This commit is contained in:
@@ -60,6 +60,7 @@ type ISCSITargetDriver struct {
|
|||||||
state uint8
|
state uint8
|
||||||
OpCode int
|
OpCode int
|
||||||
TargetStats scsi.Stats
|
TargetStats scsi.Stats
|
||||||
|
clusterIP string
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -128,6 +129,10 @@ func (s *ISCSITargetDriver) NewTarget(tgtName string, configInfo *config.Config)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ISCSITargetDriver) SetClusterIP(ip string) {
|
||||||
|
s.clusterIP = ip
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ISCSITargetDriver) RereadTargetLUNMap() {
|
func (s *ISCSITargetDriver) RereadTargetLUNMap() {
|
||||||
s.SCSI.RereadTargetLUNMap()
|
s.SCSI.RereadTargetLUNMap()
|
||||||
}
|
}
|
||||||
@@ -185,6 +190,7 @@ func (s *ISCSITargetDriver) Run() error {
|
|||||||
log.Error(err)
|
log.Error(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
s.l = l
|
s.l = l
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
@@ -197,6 +203,7 @@ func (s *ISCSITargetDriver) Run() error {
|
|||||||
if err, ok := err.(net.Error); ok {
|
if err, ok := err.(net.Error); ok {
|
||||||
if !err.Temporary() {
|
if !err.Temporary() {
|
||||||
log.Warning("Closing connection with initiator...")
|
log.Warning("Closing connection with initiator...")
|
||||||
|
conn.Close()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -463,11 +470,27 @@ func (s *ISCSITargetDriver) iscsiExecText(conn *iscsiConnection) error {
|
|||||||
log.Debugf("iscsi target: %v", name)
|
log.Debugf("iscsi target: %v", name)
|
||||||
//log.Debugf("iscsi target portals: %v", tgt.Portals)
|
//log.Debugf("iscsi target portals: %v", tgt.Portals)
|
||||||
|
|
||||||
result = append(result, util.KeyValue{"TargetName", name})
|
result = append(result, util.KeyValue{
|
||||||
for _, tpgt := range tgt.TPGTs {
|
Key: "TargetName",
|
||||||
for portal := range tpgt.Portals {
|
Value: name,
|
||||||
targetPort := fmt.Sprintf("%s,%d", portal, tpgt.TPGT)
|
})
|
||||||
result = append(result, util.KeyValue{"TargetAddress", targetPort})
|
if s.clusterIP == "" {
|
||||||
|
for _, tpgt := range tgt.TPGTs {
|
||||||
|
for portal := range tpgt.Portals {
|
||||||
|
targetPort := fmt.Sprintf("%s,%d", portal, tpgt.TPGT)
|
||||||
|
result = append(result, util.KeyValue{
|
||||||
|
Key: "TargetAddress",
|
||||||
|
Value: targetPort,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, tpgt := range tgt.TPGTs {
|
||||||
|
targetPort := fmt.Sprintf("%s,%d", s.clusterIP, tpgt.TPGT)
|
||||||
|
result = append(result, util.KeyValue{
|
||||||
|
Key: "TargetAddress",
|
||||||
|
Value: targetPort,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ type SCSITargetDriver interface {
|
|||||||
Close() error
|
Close() error
|
||||||
Resize(uint64) error
|
Resize(uint64) error
|
||||||
Stats() Stats
|
Stats() Stats
|
||||||
|
SetClusterIP(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user