(self)
return ("", "")
Get guest operating system distribution
Get guest operating system distribution
Get guest operating system distribution
def osdistribution(self):
        """Get guest operating system distribution"""
        for f_path in FileUtil(self._root_dir + "/etc/.+-release").match():
            if os.path.exists(f_path):
                osinfo = FileUtil(f_path).getdata('r')
                match = re.match(r"([^=]+) release (\d+)", osinfo)
                if match and match.group(1):
                    return (match.group(1).split(' ')[0],
                            match.group(2).split('.')[0])
        f_path = self._root_dir + "/etc/lsb-release"
        if os.path.exists(f_path):
            distribution = ""
            version = ""
            osinfo = FileUtil(f_path).getdata('r')
            match = re.search(r"DISTRIB_ID=(.+)(\n|$)",
                              osinfo, re.MULTILINE)
            if match:
                distribution = match.group(1).split(' ')[0]
            match = re.search(r"DISTRIB_RELEASE=(.+)(\n|$)",
                              osinfo, re.MULTILINE)
            if match:
                version = match.group(1).split('.')[0]
            if distribution and version:
                return (distribution, version)
        f_path = self._root_dir + "/etc/os-release"
        if os.path.exists(f_path):
            distribution = ""
            version = ""
            osinfo = FileUtil(f_path).getdata('r')
            match = re.search(r"NAME=\"?([^ \n\"\.]+).*\"?(\n|$)",
                              osinfo, re.MULTILINE)
            if match:
                distribution = match.group(1).split(' ')[0]
            match = re.search(r"VERSION_ID=\"?([^ \n\"\.]+).*\"?(\n|$)",
                              osinfo, re.MULTILINE)
            if match:
                version = match.group(1).split('.')[0]
            if distribution and version:
                return (distribution, version)
        return ("", "")
def osdistribution ( self ) : for f_path in FileUtil ( self . _root_dir + "/etc/.+-release" ) . match ( ) : if os . path . exists ( f_path ) : osinfo = FileUtil ( f_path ) . getdata ( 'r' ) match = re . match ( r"([^=]+) release (\d+)" , osinfo ) if match and match . group ( 1 ) : return ( match . group ( 1 ) . split ( ' ' ) [ 0 ] , match . group ( 2 ) . split ( '.' ) [ 0 ] ) f_path = self . _root_dir + "/etc/lsb-release" if os . path . exists ( f_path ) : distribution = "" version = "" osinfo = FileUtil ( f_path ) . getdata ( 'r' ) match = re . search ( r"DISTRIB_ID=(.+)(\n|$)" , osinfo , re . MULTILINE ) if match : distribution = match . group ( 1 ) . split ( ' ' ) [ 0 ] match = re . search ( r"DISTRIB_RELEASE=(.+)(\n|$)" , osinfo , re . MULTILINE ) if match : version = match . group ( 1 ) . split ( '.' ) [ 0 ] if distribution and version : return ( distribution , version ) f_path = self . _root_dir + "/etc/os-release" if os . path . exists ( f_path ) : distribution = "" version = "" osinfo = FileUtil ( f_path ) . getdata ( 'r' ) match = re . search ( r"NAME=\"?([^ \n\"\.]+).*\"?(\n|$)" , osinfo , re . MULTILINE ) if match : distribution = match . group ( 1 ) . split ( ' ' ) [ 0 ] match = re . search ( r"VERSION_ID=\"?([^ \n\"\.]+).*\"?(\n|$)" , osinfo , re . MULTILINE ) if match : version = match . group ( 1 ) . split ( '.' ) [ 0 ] if distribution and version : return ( distribution , version ) return ( "" , "" )