Skip to content

Commit

Permalink
Merge pull request #7 from opensds/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NajmudheenCT authored Jan 6, 2020
2 parents ee11562 + c1f3bf6 commit 3dea184
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
10 changes: 7 additions & 3 deletions csi/plugins/file/fileshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ import (
csi "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/glog"
"github.com/opensds/nbp/csi/util"
nbputil "github.com/opensds/nbp/util"
"github.com/opensds/opensds/client"
nbputil "github.com/opensds/nbp/util"
"github.com/opensds/opensds/contrib/connector"
"github.com/opensds/opensds/pkg/model"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

const (
DefaultAttachMode = "Read,Write"
)

type FileShare struct {
Client *client.Client
}
Expand All @@ -46,7 +50,7 @@ func (f *FileShare) CreateFileShare(req *csi.CreateVolumeRequest) (*csi.CreateVo
// fileshare name
name = strings.Replace(req.GetName(), "-", "_", -1)

var attachMode = "read,write"
var attachMode = DefaultAttachMode
for k, v := range req.GetParameters() {
switch k {
case common.ParamProfile:
Expand All @@ -60,7 +64,7 @@ func (f *FileShare) CreateFileShare(req *csi.CreateVolumeRequest) (*csi.CreateVo
case common.PublishAttachMode:
if strings.ToLower(v) == "read" {
// attach mode
attachMode = "read"
attachMode = "Read"
} else {
glog.Infof("use default attach mode: %s", attachMode)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,15 @@ JSONObject getStoragePool(String poolId) throws Exception {
JSONObject getHost(String hostName) throws Exception {
logger.info(String.format("----------OpenSDS Getting Host %s----------", hostName));

JSONArray response = (JSONArray)request.get(String.format("/host/hosts?hostName=%s", hostName));
logger.debug(String.format("OpenSDS Getting Host %s Response: %s", hostName,
// replace all "_" to "-" from hostName as OpenSDS does not support.
String osdsHostName = hostName.replaceAll("_","-");
JSONArray response = (JSONArray)request.get(String.format("/host/hosts?hostName=%s", osdsHostName));
logger.debug(String.format("OpenSDS Getting Host %s Response: %s", osdsHostName,
response));

if (response.isEmpty()) {
String msg = String.format("No Host Found");
logger.info(String.format("OpenSDS Get Host for %s Error: %s", hostName, msg));
logger.info(String.format("OpenSDS Get Host for %s Error: %s", osdsHostName, msg));
return new JSONObject();
}

Expand All @@ -345,8 +347,10 @@ JSONObject getHost(String hostName) throws Exception {
}

JSONObject createHost(ConnectMO connect) throws Exception {
JSONObject requestData = new JSONObject();
requestData.put("hostName", connect.name);
// replace all "_" to "-" from hostName as OpenSDS does not support.
String hostName = connect.name.replaceAll("_","-");
JSONObject requestData = new JSONObject();
requestData.put("hostName", hostName);
requestData.put("ip", connect.initiatorIp);
requestData.put("osType", connect.osType.toString().toLowerCase());
requestData.put("accessMode", OPENSDS_HOST_ACCESSMODE.getValue());
Expand All @@ -373,7 +377,7 @@ JSONObject createHost(ConnectMO connect) throws Exception {

if (isFailed(response)) {
String msg = String.format("Create Host %s Error %d: %s",
connect.name, getErrorCode(response), getErrorMessage(response));
hostName, getErrorCode(response), getErrorMessage(response));
logger.error(msg);
throw new Exception(msg);
}
Expand Down

0 comments on commit 3dea184

Please sign in to comment.