Skip to content

Commit

Permalink
set RESET_LIP as env
Browse files Browse the repository at this point in the history
Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com>
  • Loading branch information
27149chen committed Mar 8, 2019
1 parent 71e6172 commit ae27edc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
7 changes: 4 additions & 3 deletions remote/mounter/initiator/linuxfc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (

const SYSTOOL = "systool"
const SYSTOOL_TIMEOUT = 5 * 1000

var RESET_LIP = true
const KeyResetLIP = "RESET_LIP"

var FC_HOST_SYSFS_PATH = "/sys/class/fc_host"
var SCSI_HOST_SYSFS_PATH = "/sys/class/scsi_host"
Expand Down Expand Up @@ -112,11 +111,13 @@ func (lfc *linuxFibreChannel) getFcHBAsByPath() []string {
func (lfc *linuxFibreChannel) RescanHosts(hbas []string, volumeMountProperties *resources.VolumeMountProperties) error {
defer lfc.logger.Trace(logs.DEBUG)()

resetLIP := os.Getenv(KeyResetLIP)

ctl := lfc.getHBAChannelScsiTarget(volumeMountProperties)

for _, hba := range hbas {

if RESET_LIP {
if resetLIP != "" {
lfc.lipReset(hba)
}

Expand Down
14 changes: 2 additions & 12 deletions remote/mounter/initiator/linuxfc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ var _ = Describe("Test FC Initiator", func() {
var scanFile = scanPath + "/scan"
var lipPath = FAKE_FC_HOST_SYSFS_PATH + "/" + hbas[0]
var lipFile = lipPath + "/issue_lip"
var realLipResetBool bool

BeforeEach(func() {
err := os.MkdirAll(scanPath, os.ModePerm)
Expand All @@ -176,12 +175,11 @@ var _ = Describe("Test FC Initiator", func() {

Context("RESET_LIP is true", func() {
BeforeEach(func() {
realLipResetBool = initiator.RESET_LIP
initiator.RESET_LIP = true
os.Setenv("RESET_LIP", "true")
})

AfterEach(func() {
initiator.RESET_LIP = realLipResetBool
os.Setenv("RESET_LIP", "")
})

It("should write '- - lunid' to the hba scan file", func() {
Expand All @@ -202,14 +200,6 @@ var _ = Describe("Test FC Initiator", func() {
})

Context("RESET_LIP is false", func() {
BeforeEach(func() {
realLipResetBool = initiator.RESET_LIP
initiator.RESET_LIP = false
})

AfterEach(func() {
initiator.RESET_LIP = realLipResetBool
})

It("should write nothing to the hba lip file", func() {
err := fcInitiator.RescanHosts(hbas, volumeMountProperties)
Expand Down

0 comments on commit ae27edc

Please sign in to comment.