[multipathd] add "reinstate/fail path $path" CLI commands
authorChristophe Varoqui <root@xa-s05.(none)>
Mon, 31 Oct 2005 08:16:06 +0000 (09:16 +0100)
committerChristophe Varoqui <root@xa-s05.(none)>
Mon, 31 Oct 2005 08:16:06 +0000 (09:16 +0100)
multipathd/cli.c
multipathd/cli.h
multipathd/cli_handlers.c
multipathd/cli_handlers.h
multipathd/main.c

index 714df66..561b1b1 100644 (file)
@@ -123,6 +123,8 @@ load_keys (void)
        r += add_key(keys, "switchgroup", SWITCH, 0);
        r += add_key(keys, "suspend", SUSPEND, 0);
        r += add_key(keys, "resume", RESUME, 0);
+       r += add_key(keys, "reinstate", REINSTATE, 0);
+       r += add_key(keys, "fail", FAIL, 0);
        r += add_key(keys, "paths", PATHS, 0);
        r += add_key(keys, "maps", MAPS, 0);
        r += add_key(keys, "path", PATH, 1);
index 3090c48..d0ad850 100644 (file)
@@ -5,6 +5,8 @@ enum {
        __SWITCH,
        __SUSPEND,
        __RESUME,
+       __REINSTATE,
+       __FAIL,
        __PATHS,
        __MAPS,
        __PATH,
@@ -21,6 +23,8 @@ enum {
 #define SWITCH         (1 << __SWITCH)
 #define SUSPEND                (1 << __SUSPEND)
 #define RESUME         (1 << __RESUME)
+#define REINSTATE      (1 << __REINSTATE)
+#define FAIL           (1 << __FAIL)
 #define PATHS          (1 << __PATHS)
 #define MAPS           (1 << __MAPS)
 #define PATH           (1 << __PATH)
index a0fd1c4..810d458 100644 (file)
@@ -128,3 +128,39 @@ cli_resume(void * v, char ** reply, int * len, void * data)
        mpp->dmstate = MAPSTATE_ACTIVE;
        return 0;
 }
+
+int
+cli_reinstate(void * v, char ** reply, int * len, void * data)
+{
+       struct vectors * vecs = (struct vectors *)data;
+       char * param = get_keyparam(v, PATH);
+       struct path * pp;
+       
+       pp = find_path_by_dev(vecs->pathvec, param);
+
+       if (!pp)
+                pp = find_path_by_devt(vecs->pathvec, param);
+
+       if (!pp || !pp->mpp || !pp->mpp->alias)
+               return 1;
+
+       return dm_reinstate(pp->mpp->alias, pp->dev_t);
+}
+
+int
+cli_fail(void * v, char ** reply, int * len, void * data)
+{
+       struct vectors * vecs = (struct vectors *)data;
+       char * param = get_keyparam(v, PATH);
+       struct path * pp;
+       
+       pp = find_path_by_dev(vecs->pathvec, param);
+
+       if (!pp)
+                pp = find_path_by_devt(vecs->pathvec, param);
+
+       if (!pp || !pp->mpp || !pp->mpp->alias)
+               return 1;
+
+       return dm_fail_path(pp->mpp->alias, pp->dev_t);
+}
index 745daa7..5b9a66c 100644 (file)
@@ -9,3 +9,5 @@ int cli_dump_pathvec(void * v, char ** reply, int * len, void * data);
 int cli_reconfigure(void * v, char ** reply, int * len, void * data);
 int cli_suspend(void * v, char ** reply, int * len, void * data);
 int cli_resume(void * v, char ** reply, int * len, void * data);
+int cli_reinstate(void * v, char ** reply, int * len, void * data);
+int cli_fail(void * v, char ** reply, int * len, void * data);
index ecc5a9e..f167817 100644 (file)
@@ -1063,6 +1063,8 @@ uxlsnrloop (void * ap)
        add_handler(RECONFIGURE, cli_reconfigure);
        add_handler(SUSPEND+MAP, cli_suspend);
        add_handler(RESUME+MAP, cli_resume);
+       add_handler(REINSTATE+PATH, cli_reinstate);
+       add_handler(FAIL+PATH, cli_fail);
 
        uxsock_listen(&uxsock_trigger, ap);