about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-10-08 15:10:29 -0700
committerEric Wong <normalperson@yhbt.net>2012-10-08 15:10:29 -0700
commitef987fde476bd9d36a6514acd50cf94fc8081063 (patch)
tree930dee6d3c887c94a24b4622006be8b5201293a9
parent735093143695a8e0819d814cb54fbd72c22bfcee (diff)
downloadmogilefs-client-ef987fde476bd9d36a6514acd50cf94fc8081063.tar.gz
Blank observed_state (for dead devices) are mapped to nil.
-rw-r--r--lib/mogilefs/admin.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/mogilefs/admin.rb b/lib/mogilefs/admin.rb
index 1b16765..9855d8c 100644
--- a/lib/mogilefs/admin.rb
+++ b/lib/mogilefs/admin.rb
@@ -57,16 +57,26 @@ class MogileFS::Admin < MogileFS::Client
   #     "devid"=>1,
   #     "hostid"=>1,
   #     "mb_used"=>666,
+  #     "utilization"=>0.0,
+  #     "reject_bad_md5"=>false,
+  #     "observed_state"=>"writeable",
   #     "mb_total"=>666666}]
 
   def get_devices(devid = nil)
     to_i = %w(mb_asof mb_free mb_used mb_total devid weight hostid)
-    want = %w(status).concat(to_i)
+    want = %w(status observed_state).concat(to_i)
     rv = @backend.get_devices(devid ? { :devid => devid } : {})
     rv = clean('devices', 'dev', rv, true, to_i, want)
+    ostates = Hash[%w(readable writeable unreachable).map! { |f| [f,f] }]
+
     rv.each do |row|
       u = row["utilization"] and
         row["utilization"] = nil == u ? nil : u.to_f
+
+      # maps "" to nil (for dead devices)
+      row["observed_state"] = ostates[row["observed_state"]]
+
+      # be sure we do not set this at all for pre-2.60 MogileFS-Server
       case row["reject_bad_md5"]
       when "1"
         row["reject_bad_md5"] = true