Skip to content

Commit 3f1209e

Browse files
authored
Merge pull request #1234 from opensds/development
Merge development branch into master for v0.10.2 release
2 parents d7ab66c + e5629be commit 3f1209e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1801
-200
lines changed

client/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func processListParam(args []interface{}) (string, error) {
130130
if v == "" {
131131
continue
132132
}
133+
v = strings.Replace(v, " ", "%20", -1)
133134
urlParam = append(urlParam, k+"="+v)
134135
}
135136
}

contrib/connector/common.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ func Mount(device, mountpoint, fsType string, mountFlags []string) error {
111111
return err
112112
}
113113

114-
// Make sure the mount is not lost after the host reboots
115-
cmd := fmt.Sprintf("echo \"%s %s %s defaults 0 0\" >> /etc/fstab", device, mountpoint, fsType)
116-
_, err = ExecCmd("/bin/bash", "-c", cmd)
117-
if err != nil {
118-
return err
119-
}
120-
121114
return nil
122115
}
123116

@@ -131,11 +124,6 @@ func Umount(mountpoint string) error {
131124
return err
132125
}
133126

134-
cmd := fmt.Sprintf("cat -n /etc/fstab | grep -w '%s' | awk -F ' ' '{ print $1 }'| xargs -i sed -i '{}d' /etc/fstab", mountpoint)
135-
_, err = ExecCmd("/bin/bash", "-c", cmd)
136-
if err != nil {
137-
return err
138-
}
139127
return nil
140128
}
141129

contrib/connector/connector.go

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const (
4242
type Connector interface {
4343
Attach(map[string]interface{}) (string, error)
4444
Detach(map[string]interface{}) error
45-
GetInitiatorInfo() (string, error)
45+
GetInitiatorInfo() ([]string, error)
4646
}
4747

4848
var cnts = map[string]Connector{}

contrib/connector/fc/fc.go

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ func (f *FC) Detach(conn map[string]interface{}) error {
4141
}
4242

4343
// GetInitiatorInfo ...
44-
func (f *FC) GetInitiatorInfo() (string, error) {
44+
func (f *FC) GetInitiatorInfo() ([]string, error) {
4545
return getInitiatorInfo()
4646
}

contrib/connector/fc/fibreChannel.go

100644100755
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ func connectVolume(connMap map[string]interface{}) (map[string]string, error) {
8181
return nil, err
8282
}
8383

84+
dmPath, err := getMultipathDevice(deviceWWN)
85+
if err != nil {
86+
return nil, err
87+
}
88+
if len(dmPath) > 0 {
89+
devicePath = dmPath
90+
}
91+
8492
return map[string]string{"scsi_wwn": deviceWWN, "path": devicePath}, nil
8593
}
8694

@@ -227,22 +235,23 @@ func getFChbasInfo() ([]map[string]string, error) {
227235
return hbasInfos, nil
228236
}
229237

230-
func getInitiatorInfo() (string, error) {
238+
func getInitiatorInfo() ([]string, error) {
231239
hbas, err := getFChbasInfo()
232240
if err != nil {
233-
return "", err
241+
return nil, err
234242
}
235243

236244
var initiatorInfo []string
237-
238245
for _, hba := range hbas {
239246
if v, ok := hba[connector.PortName]; ok {
240-
initiatorInfo = append(initiatorInfo, "port_name:"+v)
241-
}
242-
if v, ok := hba[connector.NodeName]; ok {
243-
initiatorInfo = append(initiatorInfo, "node_name:"+v)
247+
initiatorInfo = append(initiatorInfo, v)
244248
}
245249
}
246250

247-
return strings.Join(initiatorInfo, ","), nil
251+
//Check for atleast one initiator
252+
if (0 == len(initiatorInfo)){
253+
return nil, errors.New("No initiator info found.")
254+
}
255+
256+
return initiatorInfo, nil
248257
}

contrib/connector/fc/linuxfc.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,28 @@ func trimDoubleQuotesInText(str string) string {
176176
}
177177
return str
178178
}
179+
180+
func getMultipathDevice(deviceWWN string) (string, error) {
181+
cmd := fmt.Sprintf("ls -l /dev/disk/by-id/ | grep %s", deviceWWN)
182+
out, err := connector.ExecCmd("/bin/bash", "-c", cmd)
183+
if err != nil {
184+
msg := fmt.Sprintf("No DM of wwn %s exist", deviceWWN)
185+
log.Println(msg)
186+
return "", nil
187+
}
188+
189+
lines := strings.Split(strings.TrimSpace(out), "\n")
190+
for _, line := range lines {
191+
splits := strings.Split(line, "../../")
192+
if len(splits) == 2 {
193+
name := splits[1]
194+
if strings.HasPrefix(name, "dm") {
195+
return fmt.Sprintf("/dev/%s", name), nil
196+
}
197+
}
198+
}
199+
200+
msg := fmt.Sprintf("No DM of wwn %s exist", deviceWWN)
201+
log.Println(msg)
202+
return "", nil
203+
}

contrib/connector/iscsi/helper.go

100644100755
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,19 @@ func getTgtPortalAndTgtIQN() (string, string, error) {
372372

373373
}
374374

375-
func getInitiatorInfo() (string, error) {
375+
func getInitiatorInfo() ([]string, error) {
376376
initiators, err := getInitiator()
377377
if err != nil {
378-
return "", err
378+
return nil, err
379379
}
380380

381381
if len(initiators) == 0 {
382-
return "", errors.New("No iqn found")
382+
return nil, errors.New("No iqn found")
383383
}
384384

385385
if len(initiators) > 1 {
386-
return "", errors.New("the number of iqn is wrong")
386+
return nil, errors.New("the number of iqn is wrong")
387387
}
388388

389-
return initiators[0], nil
389+
return initiators, nil
390390
}

contrib/connector/iscsi/iscsi.go

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ func (isc *Iscsi) Detach(conn map[string]interface{}) error {
3333
}
3434

3535
// GetInitiatorInfo implementation
36-
func (isc *Iscsi) GetInitiatorInfo() (string, error) {
36+
func (isc *Iscsi) GetInitiatorInfo() ([]string, error) {
3737
return getInitiatorInfo()
3838
}

contrib/connector/nfs/helper.go

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@ func disconnect(conn map[string]interface{}) error {
103103
return errors.New("disconnect method of nfs is not implemented")
104104
}
105105

106-
func getInitiatorInfo() (string, error) {
107-
return "", errors.New("get initiator information method of nfs is not implemented")
106+
func getInitiatorInfo() ([]string, error) {
107+
return nil, errors.New("get initiator information method of nfs is not implemented")
108108
}

contrib/connector/nfs/nfs.go

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ func (n *NFS) Detach(conn map[string]interface{}) error {
3333
}
3434

3535
// GetInitiatorInfo implementation
36-
func (n *NFS) GetInitiatorInfo() (string, error) {
36+
func (n *NFS) GetInitiatorInfo() ([]string, error) {
3737
return getInitiatorInfo()
3838
}

0 commit comments

Comments
 (0)