File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -115,15 +115,19 @@ def execute(self):
115115 self .log .info ("Host FQDN = %s" % socket .getfqdn ())
116116 self .log .info ("WorkingDir = %s" % self .pp .workingDir ) # this could be different than rootPath
117117
118- fileName = "/etc/redhat-release"
119- if os .path .exists (fileName ):
120- with open (fileName , "r" ) as f :
121- self .log .info ("RedHat Release = %s" % f .read ().strip ())
122-
123- fileName = "/etc/lsb-release"
124- if os .path .isfile (fileName ):
125- with open (fileName , "r" ) as f :
126- self .log .info ("Linux release:\n %s" % f .read ().strip ())
118+ for fileName in ["/etc/os-release" , "/usr/lib/os-release" ]:
119+ if os .path .isfile (fileName ):
120+ try :
121+ with open (fileName , "r" ) as f :
122+ for line in f :
123+ line = line .strip ()
124+ if line .startswith (("NAME=" , "VERSION=" , "PRETTY_NAME=" )):
125+ self .log .info (
126+ "OS Release = %s" % line .split ("=" , 1 )[1 ].strip ('"' )
127+ )
128+ break
129+ except (OSError , IOError ):
130+ self .log .debug ("Could not read %s" % fileName )
127131
128132 fileName = "/proc/cpuinfo"
129133 if os .path .exists (fileName ):
You can’t perform that action at this time.
0 commit comments