in VMExtension/hpcnodemanager.py [0:0]
def get_dist_info():
try:
return get_distro()
except:
pass
errCode, info = waagent.RunGetOutput("cat /etc/*-release")
if errCode != 0:
raise Exception('Failed to get Linux Distro info by running command "cat /etc/*release", error code: {}'.format(errCode))
distroName = ''
distroVersion = ''
for line in info.splitlines():
if line.startswith('PRETTY_NAME='):
line = line.lower()
if 'ubuntu' in line:
distroName = 'ubuntu'
elif 'centos' in line:
distroName = 'centos'
elif 'red hat' in line:
distroName = 'redhat'
elif 'suse' in line:
distroName = 'suse'
elif 'alma' in line:
distroName = 'alma'
elif 'rocky' in line:
distroName = 'rocky'
elif 'fedora' in line:
distroName = 'fedora'
elif 'freebsd' in line:
distroName = 'freebsd'
else:
raise Exception('Unknown linux distribution with {}'.format(line))
if line.startswith('VERSION_ID='):
line = line.strip(' ')
quoteIndex = line.index('"')
if quoteIndex >= 0:
distroVersion = line[quoteIndex+1:-1]
return distroName, distroVersion, ""