]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: get_full_location by name
authorSage Weil <sage@redhat.com>
Mon, 13 Nov 2017 15:27:56 +0000 (09:27 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:09 +0000 (14:44 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h

index 4262783d6908c69b0ee6baeff72946c376e71dfe..c72a8acedf2d4ff8e9904f9be47f8b03fb62bc40 100644 (file)
@@ -684,6 +684,18 @@ map<string, string> CrushWrapper::get_full_location(int id) const
   return full_location;
 }
 
+int CrushWrapper::get_full_location(const string& name,
+                                   map<string,string> *ploc)
+{
+  build_rmaps();
+  auto p = name_rmap.find(name);
+  if (p == name_rmap.end()) {
+    return -ENOENT;
+  }
+  *ploc = get_full_location(p->second);
+  return 0;
+}
+
 int CrushWrapper::get_full_location_ordered(int id, vector<pair<string, string> >& path) const
 {
   if (!item_exists(id))
index 8671306455fbf2bdce3ca39ba4f947b1d4762578..5d306c50846fe3f529a104ebf269f49bd46debec 100644 (file)
@@ -698,6 +698,13 @@ public:
    */
   map<string, string> get_full_location(int id) const;
 
+  /**
+   * return location map for a item, by name
+   */
+  int get_full_location(
+    const string& name,
+    std::map<string,string> *ploc);
+
   /*
    * identical to get_full_location(int id) although it returns the type/name
    * pairs in the order they occur in the hierarchy.
@@ -906,6 +913,7 @@ public:
   static int parse_loc_multimap(const std::vector<string>& args,
                                std::multimap<string,string> *ploc);
 
+
   /**
    * get an item's weight
    *