id jddlZddlmZddlmZdZGddeZGddeZGd d eZy) N)quote)Clusterz(/etc/pki/ovirt-engine/keys/engine_id_rsacZeZdZdZdZdZdZgdZdZdZ dZ d Z d Z d Z d Zd ZdZy)ovirta This cluster profile is for the oVirt/RHV project which provides for a virtualization cluster built ontop of KVM. Nodes enumerated will be hypervisors within the envrionment, not virtual machines running on those hypervisors. By default, ALL hypervisors within the environment are returned. This may be influenced by the 'cluster' and 'datacenter' cluster options, which will limit enumeration to hypervisors within the specific cluster and/or datacenter. The spm-only cluster option may also be used to only collect from hypervisors currently holding the SPM role. Optionally, to only collect an archive from manager and the postgresql database, use the no-hypervisors cluster option. By default, a second archive from the manager will be collected that is just the postgresql plugin configured in such a way that a dump of the manager's database that can be explored and restored to other systems will be collected. The ovirt profile focuses on the upstream, community ovirt project. The rhv profile is for Red Hat customers running RHV (formerly RHEV). The rhhi_virt profile is for Red Hat customers running RHV in a hyper-converged setup and enables gluster collections. zCommunity oVirt)z ovirt-enginez3/usr/share/ovirt-engine/dbscripts/engine-psql.sh -c)) no-databaseFzDo not collect a database dump)clusterz'Only collect from hosts in this cluster) datacenterr z*Only collect from hosts in this datacenter)no-hypervisorsFzDo not collect from hypervisors)spm-onlyFzOnly collect from SPM host(s)c\|jdt|}|j|dS)z Wrapper for running DB queries on the manager. Any scrubbing of the query should be done _before_ passing the query to this method.  T need_root)db_execrexec_primary_cmd)selfquerycmds >/usr/lib/python3/dist-packages/sos/collector/clusters/ovirt.py _run_db_queryzovirt._run_db_query<s, uU|4$$SD$99ch|sygdtfd|Dr|jd|zy|S)z Manually sanitize SQL queries since we can't leave this up to the driver since we do not have an actual DB connection %)\  "'c3&K|]}|v yw)N).0x invalid_charss r z#ovirt._sql_scrub..Ms/aqM!/szMWARNING: Cluster option '%s' contains invalid characters. Using '%%' instead.)anylog_warn)rvalr&s @r _sql_scrubzovirt._sql_scrubDsA E /3/ / MM<>AB C rcT|jjrt|jj|jj |jj gsG|jjtr'|jt|jdyyyy)a Checks for the presence of the VDSM ssh keys the manager uses for communication with hypervisors. This only runs if we're locally on the RHV-M, *and* if no ssh-keys are called out on the command line, *and* no --password option is given. z]Found engine SSH key. User command line does not specify a key or password, using engine key.N) primarylocalr(optsssh_keypasswordpassword_per_node file_exists ENGINE_KEYadd_default_ssh_key log_debugrs r_check_for_engine_keyszovirt._check_for_engine_keysTs <<   ))499+=+= 3356<<++J7,,Z8NN$2386 rcd|_|jds|j|_|j |j y)NFr)pg_pass get_option parse_db_confconf format_db_cmdr8r7s rsetupz ovirt.setupes= }-**,DI  ##%rc(|j|jd}|j|jd}d|d|d|_|jdr|xjdz c_|jd|jzy) Nrr z_SELECT host_name from vds where cluster_id in (select cluster_id FROM cluster WHERE name like 'zG' and storage_pool_id in (SELECT id FROM storage_pool WHERE name like 'z'))r z AND spm_status = 2z%Query command for ovirt DB set to: %s)r+r;dbqueryr6)rrr s rr>zovirt.format_db_cmdlsv//$//)"<=__T__\%BC 5MNrc&|jdrgS|j|j}|ddk(rF|djdd}|Dcgc]$}|j ddj &c}St d|dzcc}w) Nr statusroutput(z&database query failed, return code: %s)r;rrA splitlinessplitstrip Exception)rresnodesns r get_nodeszovirt.get_nodes{s ??+ ,I  . x=A M,,.q4E5:;AGGCLO))+; ;D!(m,- -i}d}|jd|zd}|ddk(rl|dj}|D]R} t|jdd}t|jdd j d d }|||<T|Sy #t $rYcwxYw) Nz6/etc/ovirt-engine/engine.conf.d/10-setup-database.confzcat %sTrrCrrD=r r F)rrHstrrIreplace IndexError)rr=engconfrLconfiglinekvs rr<zovirt.parse_db_confsJ##Hw$6$#G x=A ]--/F DJJsOA./ADJJsOA.66sB?@ADG  K"sAB BBcdjd|jd|jd|jd|jd}dj|jd |}|j|d }|d jD]d}t j|d s|j }|j jjd|jdd|cS|jdy)Nzn-k {plugin}.dbname={db} -k {plugin}.dbhost={dbhost} -k {plugin}.dbport={dbport} -k {plugin}.username={dbuser} postgresqlENGINE_DB_DATABASEENGINE_DB_HOSTENGINE_DB_PORTENGINE_DB_USER)plugindbdbhostdbportdbuserzLPGPASSWORD={} /usr/sbin/sosreport --name=postgresql --batch -o postgresql {}ENGINE_DB_PASSWORDTrrDz*sosreport-*tar*postgresql_dump/rFzFailed to gather database dumpF) formatr=rrHfnmatchrJr-manifest add_fieldrI log_error)rsos_optrdb_sosr[_pg_dumps rrQzovirt.collect_databases4V<#yy)=>#'99-=#>#'99-=#>#'99-=#>  * "67A &&sd&;8$//1 Dt%78::< %%//0A08s0CB0GI  78rN)__name__ __module__ __qualname____doc__ cluster_namepackagesr option_listrr+r8r?r>rOrRr<rQr#rrrrsM8%L HCGK: 3"& O -  rrceZdZdZdZdZdZy)rhvzRed Hat Virtualization)rhevmrhvmcp|j|jjk(ry|jdryy)Nmanagerzovirt-node-ng-nodectlrhvhrhelh)addressr- is_installed)rnodes rset_node_labelzrhv.set_node_labels0 <<4<<// /   4 5rN)rtrurvrxry sos_presetrr#rrr|r|s+L HJrr|c,eZdZdZdZddiZdZdZdZy) rhhi_virtz6Red Hat Hyperconverged Infrastructure - Virtualization)glusterz gluster.dumponr|c\|jjdxr|jS)Nr~)r-r_check_for_rhhivr7s r check_enabledzrhhi_virt.check_enableds% ))&1Md6K6K6MNrc|jd}|ddk(r'|djdjdk7Sy)Nz+SELECT count(server_id) FROM gluster_serverrCrrDrE0F)rrHrJ)rrets rrzrhhi_virt._check_for_rhhivsH  !NO x=A x=++-a0668C? ?rN) rtrurvrx sos_pluginssos_plugin_optionsrrrr#rrrrs'KLK($/JOrr) rmpipesrsos.collector.clustersrr4rr|rr#rrrs<* 7 _G_D % r