Browse Source

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

Sometimes udev places devices symlinks into a directory
/dev/disk/by-id/foo/device_symlink and we must be able
to go through this directories recursively and find all
symlinks.

Change-Id: I0749ab94e05fdf6fd12dc89c2c788a61a128b77d
Closes-Bug: #1642391
Vladimir Kozhukalov 2 years ago
parent
commit
402eb1f423
1 changed files with 9 additions and 9 deletions
  1. 9
    9
      agent

+ 9
- 9
agent View File

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

Loading…
Cancel
Save