Browse Source

Merge "Check if /dev/disk/*/ item is a symlink"

Jenkins 2 years ago
parent
commit
214c9c7517
1 changed files with 9 additions and 9 deletions
  1. 9
    9
      agent

+ 9
- 9
agent View File

@@ -297,13 +297,13 @@ class NodeAgent
297 297
       res[:interfaces][ifname] = _get_iface_info(ifname)
298 298
     end
299 299
     %w[inet inet6].each do |family|
300
-      #default via 10.109.3.1 dev br-ex 
301
-      #10.109.0.0/24 dev br-fw-admin  proto kernel  scope link  src 10.109.0.4 
302
-      #10.109.1.0/24 dev br-mgmt  proto kernel  scope link  src 10.109.1.3 
303
-      #10.109.2.0/24 dev br-storage  proto kernel  scope link  src 10.109.2.3 
304
-      #10.109.3.0/24 dev br-ex  proto kernel  scope link  src 10.109.3.3 
305
-      #240.0.0.0/30 dev hapr-host  proto kernel  scope link  src 240.0.0.1 
306
-      #240.0.0.4/30 dev vr-host-base  proto kernel  scope link  src 240.0.0.5 
300
+      #default via 10.109.3.1 dev br-ex
301
+      #10.109.0.0/24 dev br-fw-admin  proto kernel  scope link  src 10.109.0.4
302
+      #10.109.1.0/24 dev br-mgmt  proto kernel  scope link  src 10.109.1.3
303
+      #10.109.2.0/24 dev br-storage  proto kernel  scope link  src 10.109.2.3
304
+      #10.109.3.0/24 dev br-ex  proto kernel  scope link  src 10.109.3.3
305
+      #240.0.0.0/30 dev hapr-host  proto kernel  scope link  src 240.0.0.1
306
+      #240.0.0.4/30 dev vr-host-base  proto kernel  scope link  src 240.0.0.5
307 307
       `ip -f #{family} route show`.each_line do |line|
308 308
         if line =~ /^([^\s]+)\s(.*)$/
309 309
           rdest = $1
@@ -876,13 +876,13 @@ class NodeAgent
876 876
 
877 877
   def _disk_id_by_name(name)
878 878
     dn = "/dev/disk/by-id"
879
-    basepath = Dir["#{dn}/**?"].select{|f| /\/#{name}$/.match(File.readlink(f))}
879
+    basepath = Dir["#{dn}/**/*?"].select{|f| File.symlink?(f) and /\/#{name}$/.match(File.readlink(f))}
880 880
     basepath.map{|p| p.split("/")[2..-1].join("/")}
881 881
   end
882 882
 
883 883
   def _disk_path_by_name(name)
884 884
     dn = "/dev/disk/by-path"
885
-    basepath = Dir["#{dn}/**?"].find{|f| /\/#{name}$/.match(File.readlink(f))}
885
+    basepath = Dir["#{dn}/**/*?"].find{|f| File.symlink?(f) and /\/#{name}$/.match(File.readlink(f))}
886 886
     basepath.split("/")[2..-1].join("/") if basepath
887 887
   end
888 888
 

Loading…
Cancel
Save