@@ -0,0 +1,1475 @@
+import re%0Afrom libs.tools import read_cmdblock_from_log%0A%0Acommand_end_mark = %22COMMAND EXECUTED%22%0A%0Aclass FlexiNS(object):%0A    %22%22%22%0A    %22%22%22%0A    def __init__(self,logfile=None):%0A        self.logfile = logfile%0A        self._data = %7B%7D%0A%0A        if logfile:%0A            self.parse_log(logfile)%0A%0A    def parse_log(self,logfile):%0A        loglines = file(logfile).readlines()%0A        self._data%5B'hostname'%5D = 'DummyHost'%0A        self._data%5B'version'%5D = get_ns_version(loglines)%0A%0A    def get(self,key):%0A        return self._data.get(key,None)%0A%0A    def match_version(self,versionlist):%0A        for ver in versionlist:%0A            if re.match(ver,self.version):%0A                return True%0A        return False%0A        %0A    def __repr__(self):%0A        return %22FlexiNSObj:%3C%25s%3E%22 %25 self.hostname%0A%0A    @property%0A    def hostname(self):%0A        return self._data%5B'hostname'%5D%0A%0A    @property%0A    def version(self):%0A        return self._data%5B'version'%5D%0A    %0A    %0Adef get_ns_version(loglines):%0A    %22%22%22This function will parse the FlexiNS version info from logfile.%0Aparameters:%0A    configlog    config logfiler%0Areturn:%0A    return  a dict include package's status and id info.%0A    %0A    example: %7B'BU': 'N5 1.17-5', 'FB': 'N5 1.17-5', 'NW': 'N4 1.19-2', 'UT': 'N4 1.19-2'%7D%0A    %0A    %22%22%22%0A    pkgid_pat = re.compile(%22%5Cs+(BU%7CFB%7CNW)%5Cs+.*?%5Cn%5Cs+(%5Cw%5Cd %5B%5Cd%5C.-%5D+)%22)%0A%0A    logtxt = read_cmdblock_from_log(loglines,'WQO:CR;',command_end_mark)%0A    version = dict(pkgid_pat.findall(logtxt))%0A    %0A    return version%0A%0A%0A%0A

add basic module libs/flexins.py for collecting basic info of FlexiNS