gHddlZddlZddlmZmZgdZGddZdS)N)ExternalProgramFailed run_command)z/usr/sbin/mysqldz/usr/libexec/mysqldz/usr/local/bin/mysqldcHeZdZdZedZdZdZdZdZ dZ dS) MysqlInfoc8||_dS)N)retrieve_server_infomysqld_vselfs py/clconfig/db_info_lib.py__init__zMysqlInfo.__init__s1133 c tD]%}tj|r|cS&tdS#t$rtdcYSwxYw)zP Find mysql server binary :return: path to mysql binary )MYSQL_BINARIESospathexistsOSError)binarys r get_binaryzMysqlInfo.get_binarysq  %( " "7>>&))"!MMM"!!$ $ % % %!!$ $ $ $ %s+< <AAcp |}t|dgS#t$rYdSwxYw)zx Get server information through ` -V` command :return: full command output z-VN)rrr)r mysql_binarys r rzMysqlInfo.retrieve_server_info%sK  ??,,L d344 4$   44 s $' 55cz|||dS)a& Return gathered data :return: dict( 'vendor': MySQL|MariaDB|Percona, 'version': server version in the form of {major}.{minor} or {major}.{minor}-{release} for percona, 'cll-lve': patches from CL applied or not (True|False) ) )vendorversioncll-lve) get_vendor get_version is_patchedr s r getz MysqlInfo.get1s7//++8H8H8J8JW[WfWfWhWhiiirc|jdStjd} ||jddS#t $rYdSwxYw)z Extract MySQL vendor from server info :return: MySQL|MariaDB|Percona or `unknown` if failed to apply regex or None if there is no server info (this usually means that there are no MySQL installed) Nz(?<=\().+(?=\sServer)runknown)r recompilefindallsplit IndexErrorr ps r rzMysqlInfo.get_vendor<st = 4 J/ 0 0 99T]++A.4466q9 9   99 s7A A%$A%c|jdStjd} ||jddS#t $rYdSwxYw)aF Retrieve MySQL server version from server info :return: X.X.X e.g. 10.2.16|5.6.39, includes release for percona (X.X.X-X.X e.g. 5.6.40-84.0) or `unknown` if failed to apply regex or None if there is no server info (this usually means that there are no MySQL installed) Nz(?<=Ver\s)[0-9\.\-]+r-r#)r r$r%r&rstripr(r)s r rzMysqlInfo.get_versionNsq = 4 J. / / 99T]++A.55c:: :   99 s2A A A c&|jdSd|jvS)a  Retrieve information about CL patch by `cll-lve` in server info :return: True if contains `cll-lve` seq False otherwise or None if there is no server info (this usually means that there are no MySQL installed) Nr)r r s r r zMysqlInfo.is_patched`s = 4DM))rN) __name__ __module__ __qualname__r staticmethodrrr!rrr rr rrs444 % %\ %    j j j$$ * * * * *rr)rr$clcommon.utilsrrrrr3rr r5s~ ========V*V*V*V*V*V*V*V*V*V*r