@@ -86,6 +86,14 @@ func (t *tgtTarget) getTgtConfPath(volId string) string {
8686
8787type configMap map [string ][]string
8888
89+ func CreateScsiIDFromVolID (volID string ) string {
90+ //Construct a 32 digit NAA.6 ( Network Addressing Authority) Identifier for the volume.
91+ scsi_id := strings .Replace (volID , "-" , "" , - 1 )
92+ out := []rune (scsi_id )
93+ // Make the first digit 6 , which specifies the IEEE registerd extended format for WWN.
94+ out [0 ] = '6'
95+ return string (out )
96+ }
8997func (t * tgtTarget ) CreateISCSITarget (volId , tgtIqn , path , hostIp , initiator string , chapAuth []string ) error {
9098 // Multi-attach require a specific ip
9199 if hostIp == "" || hostIp == "ALL" {
@@ -108,6 +116,7 @@ func (t *tgtTarget) CreateISCSITarget(volId, tgtIqn, path, hostIp, initiator str
108116 config := make (configMap )
109117
110118 configFile := t .getTgtConfPath (volId )
119+ scsiID := CreateScsiIDFromVolID (volId )
111120
112121 if IsExist (configFile ) {
113122 data , err := ioutil .ReadFile (configFile )
@@ -127,6 +136,7 @@ func (t *tgtTarget) CreateISCSITarget(volId, tgtIqn, path, hostIp, initiator str
127136 config .updateConfigmap ("driver" , "iscsi" )
128137 config .updateConfigmap ("backing-store" , path )
129138 config .updateConfigmap ("write-cache" , "on" )
139+ config .updateConfigmap ("scsi_id" , scsiID )
130140
131141 err := config .writeConfig (configFile , tgtIqn )
132142 if err != nil {
0 commit comments