diff options
author | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2018-02-05 15:07:26 +0530 |
---|---|---|
committer | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2018-02-07 16:49:21 +0530 |
commit | 540e81676b1011dcf85fbe5cd6739a4f2143b2ab (patch) | |
tree | 7eed76faf5483e03bbbe59bb23ede3675ae6ad97 /utils | |
parent | f217c0bf9cf464e21c01fa50643b778f236acedb (diff) |
replace: add replace feature
1. create conf in new node
2. delete conf from old node
3. replace portals from nodes hosting other paths (HA)
$ gluster-block create sample/block ha 3 192.168.124.57,192.168.124.26,192.168.124.30 1GiB --json-pretty
{
"IQN":"iqn.2016-12.org.gluster-block:d516bb5c-5f56-4d9c-96a7-385df19c2e2c",
"PORTAL(S)":[
"192.168.124.57:3260",
"192.168.124.26:3260",
"192.168.124.30:3260"
],
"RESULT":"SUCCESS"
}
$ gluster-block help
gluster-block (0.3)
usage:
gluster-block <command> <volname[/blockname]> [<args>] [--json*]
commands:
[...]
replace <volname/blockname> <old-node> <new-node> [force]
replace operations.
[...]
supported JSON formats:
--json|--json-plain|--json-spaced|--json-pretty
$ gluster-block replace sample/block 192.168.124.26 192.168.124.56 --json-pretty
{
"NAME":"block",
"CREATE SUCCESS":"192.168.124.56",
"DELETE SUCCESS":"192.168.124.26",
"REPLACE PORTAL SUCCESS ON":[
"192.168.124.57",
"192.168.124.30"
],
"RESULT":"SUCCESS"
}
Fixes: #4
Change-Id: I0411d15c407111db0d423052d9a6bc075174bf90
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/capabilities.h | 4 | ||||
-rw-r--r-- | utils/common.c | 40 | ||||
-rw-r--r-- | utils/common.h | 11 | ||||
-rw-r--r-- | utils/gluster-block-caps.info | 12 | ||||
-rw-r--r-- | utils/utils.h | 36 |
5 files changed, 91 insertions, 12 deletions
diff --git a/utils/capabilities.h b/utils/capabilities.h index b157d80..80f03bd 100644 --- a/utils/capabilities.h +++ b/utils/capabilities.h @@ -37,6 +37,8 @@ enum gbCapabilities { GB_MODIFY_CAP, GB_MODIFY_AUTH_CAP, + GB_REPLACE_CAP, + GB_JSON_CAP, GB_CAP_MAX @@ -55,6 +57,8 @@ static const char *const gbCapabilitiesLookup[] = { [GB_MODIFY_CAP] = "modify", [GB_MODIFY_AUTH_CAP] = "modify_auth", + [GB_REPLACE_CAP] = "replace", + [GB_JSON_CAP] = "json", [GB_CAP_MAX] = NULL diff --git a/utils/common.c b/utils/common.c index 98cc0ef..751e2b8 100644 --- a/utils/common.c +++ b/utils/common.c @@ -157,3 +157,43 @@ convertStringToTrillianParse(const char *opt) return -1; } + + +void +blockServerDefFree(blockServerDefPtr blkServers) +{ + size_t i; + + + if (!blkServers) { + return; + } + + for (i = 0; i < blkServers->nhosts; i++) { + GB_FREE(blkServers->hosts[i]); + } + GB_FREE(blkServers->hosts); + GB_FREE(blkServers); +} + + +bool +blockhostIsValid(char *status) +{ + switch (blockMetaStatusEnumParse(status)) { + case GB_CONFIG_SUCCESS: + case GB_CLEANUP_INPROGRESS: + case GB_AUTH_ENFORCEING: + case GB_AUTH_ENFORCED: + case GB_AUTH_ENFORCE_FAIL: + case GB_AUTH_CLEAR_ENFORCED: + case GB_AUTH_CLEAR_ENFORCEING: + case GB_AUTH_CLEAR_ENFORCE_FAIL: + case GB_RP_SUCCESS: + case GB_RP_FAIL: + case GB_RP_INPROGRESS: + return TRUE; + } + + return FALSE; +} diff --git a/utils/common.h b/utils/common.h index 2d1202a..02940c0 100644 --- a/utils/common.h +++ b/utils/common.h @@ -16,6 +16,13 @@ # include "block.h" +typedef struct blockServerDef { + size_t nhosts; + char **hosts; +} blockServerDef; +typedef blockServerDef *blockServerDefPtr; + + static const char *const JsonResponseFormatLookup[] = { [GB_JSON_NONE] = "", @@ -82,4 +89,8 @@ char* glusterBlockFormatSize(const char *dom, size_t bytes); int convertStringToTrillianParse(const char *opt); +void blockServerDefFree(blockServerDefPtr blkServers); + +bool blockhostIsValid(char *status); + # endif /* _COMMON_H */ diff --git a/utils/gluster-block-caps.info b/utils/gluster-block-caps.info index 2dcdbd4..ffdf679 100644 --- a/utils/gluster-block-caps.info +++ b/utils/gluster-block-caps.info @@ -96,3 +96,15 @@ modify_auth: true # Since: 0.2 ## json: true + + +## +# Nature: cli command +# +# Label: 'replace' +# +# Description: capability to replace node for a given block +# +# Since: 0.4 +## +replace: true diff --git a/utils/utils.h b/utils/utils.h index 7141a3f..7693b5c 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -85,6 +85,10 @@ # define FAILED_DELETING_FILE "failed while deleting block file from gluster volume" # define FAILED_DELETING_META "failed while deleting block meta file from volume" +/* Target Replace */ +# define FAILED_REPLACE "failed in replace" +# define FAILED_REMOTE_REPLACE "failed in remote replace portal" + # define FAILED_DEPENDENCY "failed dependency, check if you have targetcli and tcmu-runner installed" # define FMT_WARN(fmt...) do { if (0) printf (fmt); } while (0) @@ -328,18 +332,19 @@ extern struct gbConf gbConf; typedef enum gbCliCmdlineOption { - GB_CLI_UNKNOWN = 0, - GB_CLI_CREATE = 1, - GB_CLI_LIST = 2, - GB_CLI_INFO = 3, - GB_CLI_DELETE = 4, - GB_CLI_MODIFY = 5, - GB_CLI_HELP = 6, - GB_CLI_HYPHEN_HELP = 7, - GB_CLI_VERSION = 8, - GB_CLI_HYPHEN_VERSION = 9, - GB_CLI_USAGE = 10, - GB_CLI_HYPHEN_USAGE = 11, + GB_CLI_UNKNOWN = 0, + GB_CLI_CREATE, + GB_CLI_LIST, + GB_CLI_INFO, + GB_CLI_DELETE, + GB_CLI_MODIFY, + GB_CLI_REPLACE, + GB_CLI_HELP, + GB_CLI_HYPHEN_HELP, + GB_CLI_VERSION, + GB_CLI_HYPHEN_VERSION, + GB_CLI_USAGE, + GB_CLI_HYPHEN_USAGE, GB_CLI_OPT_MAX } gbCliCmdlineOption; @@ -351,6 +356,7 @@ static const char *const gbCliCmdlineOptLookup[] = { [GB_CLI_INFO] = "info", [GB_CLI_DELETE] = "delete", [GB_CLI_MODIFY] = "modify", + [GB_CLI_REPLACE] = "replace", [GB_CLI_HELP] = "help", [GB_CLI_HYPHEN_HELP] = "--help", [GB_CLI_VERSION] = "version", @@ -442,6 +448,9 @@ typedef enum MetaStatus { GB_CLEANUP_SUCCESS = 9, GB_CLEANUP_FAIL = 10, GB_CLEANUP_INPROGRESS = 11, + GB_RP_SUCCESS = 12, + GB_RP_INPROGRESS = 13, + GB_RP_FAIL = 14, GB_METASTATUS_MAX } MetaStatus; @@ -459,6 +468,9 @@ static const char *const MetaStatusLookup[] = { [GB_CLEANUP_INPROGRESS] = "CLEANUPINPROGRESS", [GB_CLEANUP_SUCCESS] = "CLEANUPSUCCESS", [GB_CLEANUP_FAIL] = "CLEANUPFAIL", + [GB_RP_SUCCESS] = "RPSUCCESS", + [GB_RP_INPROGRESS] = "RPINPROGRESS", + [GB_RP_FAIL] = "RPFAIL", [GB_METASTATUS_MAX] = NULL, }; |