summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/gluster-block.c4
-rw-r--r--rpc/block_svc_routines.c23
2 files changed, 22 insertions, 5 deletions
diff --git a/cli/gluster-block.c b/cli/gluster-block.c
index 75bf0d0..129467d 100644
--- a/cli/gluster-block.c
+++ b/cli/gluster-block.c
@@ -133,8 +133,8 @@ glusterBlockHelp(void)
" create <name> Create the gluster block\n"
" volserver [gluster-node] node addr from gluster pool(default: localhost)\n"
" size <size> block storage size in KiB|MiB|GiB|TiB..\n"
- " mpath <count> multi path requirement for high availablity\n"
- " servers <IP1,IP2,IP3...> block servers, clubbed with any option\n"
+ " mpath <count> multipath requirement for high availability\n"
+ " servers <IP1,IP2,IP3...> block servers, where targets are exported\n"
"\n"
" list List available gluster blocks\n"
"\n"
diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c
index cb9a6e8..f77fbb3 100644
--- a/rpc/block_svc_routines.c
+++ b/rpc/block_svc_routines.c
@@ -25,6 +25,7 @@
# define GLFS_PATH "/backstores/user:glfs"
# define TARGETCLI_GLFS "targetcli "GLFS_PATH
# define TARGETCLI_ISCSI "targetcli /iscsi"
+# define TARGETCLI_GLOBALS "targetcli set global auto_add_default_portal=false"
# define TARGETCLI_SAVE "targetcli / saveconfig"
# define ATTRIBUTES "generate_node_acls=1 demo_mode_write_protect=0"
# define IQN_PREFIX "iqn.2016-12.org.gluster-block:"
@@ -695,9 +696,11 @@ blockResponse *
block_create_1_svc(blockCreate *blk, struct svc_req *rqstp)
{
FILE *fp;
- char *backstore = NULL;;
+ char hostname[255];
+ char *backstore = NULL;
char *iqn = NULL;
char *lun = NULL;
+ char *portal = NULL;
char *attr = NULL;
char *exec = NULL;
blockResponse *reply = NULL;
@@ -707,6 +710,12 @@ block_create_1_svc(blockCreate *blk, struct svc_req *rqstp)
goto out;
}
+ if (gethostname(hostname, 255)) {
+ LOG("mgmt", GB_LOG_ERROR, "gethostname failed (%s)", strerror(errno));
+ reply->exit = -1;
+ goto out;
+ }
+
if (asprintf(&backstore, "%s %s %s %zu %s@%s%s/%s %s", TARGETCLI_GLFS,
CREATE, blk->block_name, blk->size, blk->volume,
blk->volfileserver, GB_STOREDIR, blk->gbid, blk->gbid) == -1) {
@@ -728,6 +737,13 @@ block_create_1_svc(blockCreate *blk, struct svc_req *rqstp)
goto out;
}
+ if (asprintf(&portal, "%s/%s%s/tpg1/portals create %s",
+ TARGETCLI_ISCSI, IQN_PREFIX, blk->gbid,
+ hostname) == -1) {
+ reply->exit = -1;
+ goto out;
+ }
+
if (asprintf(&attr, "%s/%s%s/tpg1 set attribute %s",
TARGETCLI_ISCSI, IQN_PREFIX, blk->gbid,
ATTRIBUTES) == -1) {
@@ -736,8 +752,8 @@ block_create_1_svc(blockCreate *blk, struct svc_req *rqstp)
}
- if (asprintf(&exec, "%s && %s && %s && %s && %s", backstore, iqn,
- lun, attr, TARGETCLI_SAVE) == -1) {
+ if (asprintf(&exec, "%s && %s && %s && %s && %s && %s && %s", TARGETCLI_GLOBALS,
+ backstore, iqn, lun, portal, attr, TARGETCLI_SAVE) == -1) {
reply->exit = -1;
goto out;
}
@@ -761,6 +777,7 @@ block_create_1_svc(blockCreate *blk, struct svc_req *rqstp)
out:
GB_FREE(exec);
GB_FREE(attr);
+ GB_FREE(portal);
GB_FREE(lun);
GB_FREE(iqn);
GB_FREE(backstore);