ah, exception loading json
[mirror/dsa-puppet.git] / modules / debian-org / lib / facter / cluster.rb
index d7ef867..dfff436 100644 (file)
@@ -1,16 +1,19 @@
 if FileTest.exist?('/usr/sbin/gnt-cluster') and FileTest.exist?('/var/lib/ganeti/config.data')
-  if system('/usr/sbin/gnt-cluster getmaster >/dev/null')
-    require 'json'
-    json = JSON.parse(File.read('/var/lib/ganeti/config.data'))
-    Facter.add('cluster') do
-      setcode do
-        json['cluster']['cluster_name']
-      end
-    end
-    Facter.add('cluster_nodes') do
-      setcode do
-        json['nodes'].keys.join(' ')
-      end
-    end
-  end
+       begin
+               if system('/usr/sbin/gnt-cluster getmaster >/dev/null')
+                       require 'json'
+                       json = JSON.parse(File.read('/var/lib/ganeti/config.data'))
+                       Facter.add('cluster') do
+                               setcode do
+                                       json['cluster']['cluster_name']
+                               end
+                               end
+                               Facter.add('cluster_nodes') do
+                               setcode do
+                                       json['nodes'].keys.join(' ')
+                               end
+                       end
+               end
+       rescue Exception => e
+       end
 end