]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
start of crush map manip from perl
authorMichael Rodriguez <michael@newdream.net>
Tue, 4 Mar 2008 23:45:53 +0000 (15:45 -0800)
committerMichael Rodriguez <michael@newdream.net>
Tue, 4 Mar 2008 23:45:53 +0000 (15:45 -0800)
src/crush/crushmap.pl

index c1f4be33649369b47855024ef3338ffb05ee8c83..25e35fe1faaee4af1b0de252cea5b206c008c536 100755 (executable)
@@ -3,6 +3,8 @@
 use CrushWrapper;
 use Config::General;
 use Tie::DxHash;
+use Data::Dumper;
+
 tie my %conf, "Tie::DxHash";
 
 my $wrap = new CrushWrapper::CrushWrapper;
@@ -12,22 +14,47 @@ $wrap->create();
 %conf = Config::General::ParseConfig( -ConfigFile => "sample.txt", -Tie => "Tie::DxHash" );
 
 my $arr = \%conf;
+my @ritems;
 
-use Data::Dumper;
+#print Dumper $arr;
+@nums = (1, -4, 11, 17, 1, -92, -15, 48);
+print "length: " . scalar(@nums) ."\n";
 
-print Dumper $arr;
+#print Dumper $arr;
 
+#first argument must be zero for auto bucket_id
+my $i=0;
+foreach my $osd (keys %{$arr->{'osd'}}) {
+       $ritems[$i] = $wrap->add_bucket(0,4,0,0,[],[]);
+       $wrap->set_item_name($ritems[$i], $osd);
+       print "bucket_id: $ritems[$i]\n";
+       print $wrap->get_item_name($ritems[$i]) ."\n";
+       $i++;
+}
+
+print Dumper @ritems;
 
-=item
-@nums = (
-    1, -4, 11, 17, 1, -92, -15, 48
-    );
 
-print "length: " . scalar(@nums) ."\n";
-($result, $min, $max, $avg) = $wrap->add_bucket('1','1','1',scalar(@nums),\@nums,\@nums);
 
-print join(" : ", ($result, $min, $max, $avg) );
-print "\n";
-=cut
 
+=item
 
+/*** BUCKETS ***/
+enum {
+    CRUSH_BUCKET_UNIFORM = 1,
+    CRUSH_BUCKET_LIST = 2,
+    CRUSH_BUCKET_TREE = 3,
+    CRUSH_BUCKET_STRAW = 4
+};
+
+/*** RULES ***/
+enum {
+    CRUSH_RULE_NOOP = 0,
+    CRUSH_RULE_TAKE = 1,          /* arg1 = value to start with */
+    CRUSH_RULE_CHOOSE_FIRSTN = 2, /* arg1 = num items to pick */
+                                  /* arg2 = type */
+    CRUSH_RULE_CHOOSE_INDEP = 3,  /* same */
+    CRUSH_RULE_EMIT = 4           /* no args */
+};
+
+=cut