]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: expand CEPH_RELEASE_ names; rename helper
authorSage Weil <sage@redhat.com>
Sat, 27 May 2017 18:53:24 +0000 (14:53 -0400)
committerSage Weil <sage@redhat.com>
Wed, 31 May 2017 02:47:26 +0000 (22:47 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/ceph_strings.cc
src/include/rados.h
src/osd/OSDMap.cc

index 3ed1542073979cc0047dbb119f66257980b0cb03..422ccace661296443163269b80bf82fcd7c0a454 100644 (file)
@@ -49,9 +49,27 @@ const char *ceph_osd_state_name(int s)
        }       
 }
 
-const char *ceph_osd_release_name(int r)
+const char *ceph_release_name(int r)
 {
        switch (r) {
+       case CEPH_RELEASE_ARGONAUT:
+               return "argonaut";
+       case CEPH_RELEASE_BOBTAIL:
+               return "bobtail";
+       case CEPH_RELEASE_CUTTLEFISH:
+               return "cuttlefish";
+       case CEPH_RELEASE_DUMPLING:
+               return "dumpling";
+       case CEPH_RELEASE_EMPEROR:
+               return "emperor";
+       case CEPH_RELEASE_FIREFLY:
+               return "firefly";
+       case CEPH_RELEASE_GIANT:
+               return "giant";
+       case CEPH_RELEASE_HAMMER:
+               return "hammer";
+       case CEPH_RELEASE_INFERNALIS:
+               return "infernalis";
        case CEPH_RELEASE_JEWEL:
                return "jewel";
        case CEPH_RELEASE_KRAKEN:
@@ -65,6 +83,50 @@ const char *ceph_osd_release_name(int r)
        }
 }
 
+int ceph_release_from_name(const char *s)
+{
+       if (!s) {
+               return -1;
+       }
+       if (strcmp(s, "luminous") == 0) {
+               return CEPH_RELEASE_LUMINOUS;
+       }
+       if (strcmp(s, "kraken") == 0) {
+               return CEPH_RELEASE_KRAKEN;
+       }
+       if (strcmp(s, "jewel") == 0) {
+               return CEPH_RELEASE_JEWEL;
+       }
+       if (strcmp(s, "infernalis") == 0) {
+               return CEPH_RELEASE_INFERNALIS;
+       }
+       if (strcmp(s, "hammer") == 0) {
+               return CEPH_RELEASE_HAMMER;
+       }
+       if (strcmp(s, "giant") == 0) {
+               return CEPH_RELEASE_GIANT;
+       }
+       if (strcmp(s, "firefly") == 0) {
+               return CEPH_RELEASE_FIREFLY;
+       }
+       if (strcmp(s, "emperor") == 0) {
+               return CEPH_RELEASE_EMPEROR;
+       }
+       if (strcmp(s, "dumpling") == 0) {
+               return CEPH_RELEASE_DUMPLING;
+       }
+       if (strcmp(s, "cuttlefish") == 0) {
+               return CEPH_RELEASE_CUTTLEFISH;
+       }
+       if (strcmp(s, "bobtail") == 0) {
+               return CEPH_RELEASE_BOBTAIL;
+       }
+       if (strcmp(s, "argonaut") == 0) {
+               return CEPH_RELEASE_ARGONAUT;
+       }
+       return -1;
+}
+
 const char *ceph_osd_watch_op_name(int o)
 {
        switch (o) {
index 8e4aedf4b5118b4cb9ee3ee6a18fdae14e64fa83..426ba45308d2b2f0fbc5e1afac7e07ef88fc04a3 100644 (file)
@@ -163,12 +163,22 @@ extern const char *ceph_osd_state_name(int s);
 /*
  * major ceph release numbers
  */
-#define CEPH_RELEASE_JEWEL    10
-#define CEPH_RELEASE_KRAKEN   11
-#define CEPH_RELEASE_LUMINOUS 12
-#define CEPH_RELEASE_MIMIC    13
-
-extern const char *ceph_osd_release_name(int r);
+#define CEPH_RELEASE_ARGONAUT    1
+#define CEPH_RELEASE_BOBTAIL     2
+#define CEPH_RELEASE_CUTTLEFISH  3
+#define CEPH_RELEASE_DUMPLING    4
+#define CEPH_RELEASE_EMPEROR     5
+#define CEPH_RELEASE_FIREFLY     6
+#define CEPH_RELEASE_GIANT       7
+#define CEPH_RELEASE_HAMMER      8
+#define CEPH_RELEASE_INFERNALIS  9
+#define CEPH_RELEASE_JEWEL      10
+#define CEPH_RELEASE_KRAKEN     11
+#define CEPH_RELEASE_LUMINOUS   12
+#define CEPH_RELEASE_MIMIC      13
+
+extern const char *ceph_release_name(int r);
+extern int ceph_release_from_name(const char *s);
 
 /*
  * The error code to return when an OSD can't handle a write
index 0f121291da37612f845187fe9015fe9dca8c7bdd..572dbb4d87f99d92587b15048c2355a87a16b672 100644 (file)
@@ -2658,8 +2658,8 @@ void OSDMap::dump(Formatter *f) const
   f->dump_string("min_compat_client", mv.first);
   f->dump_string("min_compat_client_version", mv.second);
   f->dump_int("require_osd_release", require_osd_release);
-  f->dump_string("require_osd_release_name",
-                ceph_osd_release_name(require_osd_release));
+  f->dump_string("require_osd_release",
+                ceph_release_name(require_osd_release));
 
   f->open_array_section("pools");
   for (const auto &pool : pools) {