]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librbd/fsx: add support for cluster and client id optionals
authorJason Dillaman <dillaman@redhat.com>
Tue, 24 Apr 2018 16:05:21 +0000 (12:05 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 27 Apr 2018 12:33:38 +0000 (08:33 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librbd/fsx.cc

index 94ff1c2312c859460c71e47fc96f6de65a5b6fb2..aa283af43ba74537c7fbd21f2d2f496e51659ff1 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <sys/types.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <limits.h>
 #include <time.h>
 #include <strings.h>
@@ -147,6 +148,9 @@ off_t               file_size = 0;
 off_t          biggest = 0;
 unsigned long  testcalls = 0;          /* calls to function "test" */
 
+const char* cluster_name = "ceph";      /* --cluster optional */
+const char* client_id = "admin";        /* --id optional */
+
 unsigned long  simulatedopcount = 0;   /* -b flag */
 int    closeprob = 0;                  /* -c flag */
 int    debug = 0;                      /* -d flag */
@@ -1893,8 +1897,11 @@ create_image()
        int r;
        int order = 0;
        char buf[32];
+       char client_name[256];
+
+       sprintf(client_name, "client.%s", client_id);
 
-       r = rados_create(&cluster, NULL);
+       r = rados_create2(&cluster, cluster_name, client_name, 0);
        if (r < 0) {
                simple_err("Could not create cluster handle", r);
                return r;
@@ -3003,11 +3010,21 @@ void remove_image(rados_ioctx_t ioctx, char *imagename, bool remove_snap,
 int
 main(int argc, char **argv)
 {
+       enum {
+               LONG_OPT_CLUSTER = 1000,
+               LONG_OPT_ID = 1001
+       };
+
        int     i, style, ch, ret;
        char    *endp;
        char goodfile[1024];
        char logfile[1024];
 
+       const char* optstring = "b:c:dfgh:jkl:m:no:p:qr:s:t:w:xyCD:FGHKMLN:OP:RS:UWZ";
+       const struct option longopts[] = {
+               {"cluster", 1, NULL, LONG_OPT_CLUSTER},
+               {"id", 1, NULL, LONG_OPT_ID}};
+
        goodfile[0] = 0;
        logfile[0] = 0;
 
@@ -3017,9 +3034,14 @@ main(int argc, char **argv)
 
        setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
 
-       while ((ch = getopt(argc, argv, "b:c:dfgh:jkl:m:no:p:qr:s:t:w:xyCD:FGHKMLN:OP:RS:UWZ"))
-              != EOF)
+       while ((ch = getopt_long(argc, argv, optstring, longopts, NULL)) != EOF) {
                switch (ch) {
+               case LONG_OPT_CLUSTER:
+                       cluster_name = optarg;
+                       break;
+               case LONG_OPT_ID:
+                       client_id = optarg;
+                       break;
                case 'b':
                        simulatedopcount = getnum(optarg, &endp);
                        if (!quiet)
@@ -3213,6 +3235,7 @@ main(int argc, char **argv)
                        usage();
                        /* NOTREACHED */
                }
+       }
        argc -= optind;
        argv += optind;
        if (argc != 2)