Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct/use better struct fields/variables in iscsi driver #10

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions pkg/iscsi/iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ func getISCSIInfo(req *csi.NodePublishVolumeRequest) (*iscsiDisk, error) {
}

return &iscsiDisk{
VolName: volName,
Portals: bkportal,
Iqn: iqn,
lun: lun,
Iface: iface,
chap_discovery: chapDiscovery,
chap_session: chapSession,
secret: secret,
InitiatorName: initiatorName}, nil
VolName: volName,
Portals: bkportal,
Iqn: iqn,
lun: lun,
Iface: iface,
chapDiscovery: chapDiscovery,
chapSession: chapSession,
secret: secret,
InitiatorName: initiatorName}, nil
}

func getISCSIDiskMounter(iscsiInfo *iscsiDisk, req *csi.NodePublishVolumeRequest) *iscsiDiskMounter {
Expand Down Expand Up @@ -119,15 +119,15 @@ func parseSecret(secretParams string) map[string]string {
}

type iscsiDisk struct {
Portals []string
Iqn string
lun string
Iface string
chap_discovery bool
chap_session bool
secret map[string]string
InitiatorName string
VolName string
Portals []string
Iqn string
lun string
Iface string
chapDiscovery bool
chapSession bool
secret map[string]string
InitiatorName string
VolName string
}

type iscsiDiskMounter struct {
Expand Down
16 changes: 8 additions & 8 deletions pkg/iscsi/iscsi_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import (
)

var (
chap_st = []string{
chapSt = []string{
"discovery.sendtargets.auth.username",
"discovery.sendtargets.auth.password",
"discovery.sendtargets.auth.username_in",
"discovery.sendtargets.auth.password_in"}
chap_sess = []string{
chapSess = []string{
"node.session.auth.username",
"node.session.auth.password",
"node.session.auth.username_in",
Expand All @@ -46,15 +46,15 @@ var (
)

func updateISCSIDiscoverydb(b iscsiDiskMounter, tp string) error {
if !b.chap_discovery {
if !b.chapDiscovery {
return nil
}
out, err := b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "update", "-n", "discovery.sendtargets.auth.authmethod", "-v", "CHAP")
if err != nil {
return fmt.Errorf("iscsi: failed to update discoverydb with CHAP, output: %v", string(out))
}

for _, k := range chap_st {
for _, k := range chapSt {
v := b.secret[k]
if len(v) > 0 {
out, err := b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "update", "-n", k, "-v", v)
Expand All @@ -67,7 +67,7 @@ func updateISCSIDiscoverydb(b iscsiDiskMounter, tp string) error {
}

func updateISCSINode(b iscsiDiskMounter, tp string) error {
if !b.chap_session {
if !b.chapSession {
return nil
}

Expand All @@ -76,7 +76,7 @@ func updateISCSINode(b iscsiDiskMounter, tp string) error {
return fmt.Errorf("iscsi: failed to update node with CHAP, output: %v", string(out))
}

for _, k := range chap_sess {
for _, k := range chapSess {
v := b.secret[k]
if len(v) > 0 {
out, err := b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-I", b.Iface, "-o", "update", "-n", k, "-v", v)
Expand Down Expand Up @@ -143,7 +143,7 @@ func (util *ISCSIUtil) persistISCSI(conf iscsiDisk, mnt string) error {
defer fp.Close()
encoder := json.NewEncoder(fp)
if err = encoder.Encode(conf); err != nil {
return fmt.Errorf("iscsi: encode err: %v.", err)
return fmt.Errorf("iscsi: encode err: %v", err)
}
return nil
}
Expand All @@ -158,7 +158,7 @@ func (util *ISCSIUtil) loadISCSI(conf *iscsiDisk, mnt string) error {
defer fp.Close()
decoder := json.NewDecoder(fp)
if err = decoder.Decode(conf); err != nil {
return fmt.Errorf("iscsi: decode err: %v.", err)
return fmt.Errorf("iscsi: decode err: %v", err)
}
return nil
}
Expand Down