summaryrefslogtreecommitdiffstats
path: root/rpc/block_svc_routines.c
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/block_svc_routines.c')
-rw-r--r--rpc/block_svc_routines.c23
1 files changed, 20 insertions, 3 deletions
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);