a >h@sXddlZddlmZddlmZdZGdddeZGdddeZGd d d eZdS) N)quote)Clusterz(/etc/pki/ovirt-engine/keys/engine_id_rsac@sleZdZdZdZdZdZgdZddZdd Z d d Z d d Z ddZ ddZ ddZddZddZdS)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) datacenterrz*Only collect from hosts in this datacenter)no-hypervisorsFzDo not collect from hypervisors)spm-onlyFzOnly collect from SPM host(s)cCs"|jdt|}|j|ddS)z Wrapper for running DB queries on the manager. Any scrubbing of the query should be done _before_ passing the query to this method.  TZ need_root)db_execrexec_primary_cmd)selfquerycmdr@/usr/lib/python3.9/site-packages/sos/collector/clusters/ovirt.py _run_db_query<szovirt._run_db_querycs@|sdSgdtfdd|Dr<|d|ddS|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 %)\  "'c3s|]}|vVqdS)Nr).0xZ invalid_charsrr Mz#ovirt._sql_scrub..zWARNING: Cluster option 'z2' contains invalid characters. Using '%%' instead.)anyZlog_warn)rvalrrr _sql_scrubDszovirt._sql_scrubcCsF|jjrBt|jj|jj|jjgsB|jtrB| t| ddS)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"ZoptsZssh_keypasswordZpassword_per_nodeZ file_exists ENGINE_KEYZadd_default_ssh_key log_debugrrrr_check_for_engine_keysTs  zovirt._check_for_engine_keyscCs.d|_|ds||_||dS)NFr)Zpg_pass get_option parse_db_confconf format_db_cmdr+r*rrrsetupes   z ovirt.setupcCsb||d}||d}d|d|d|_|drL|jd7_|d|jdS) Nrrz_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: )r$r,dbqueryr))rrrrrrr/ls  zovirt.format_db_cmdcCs^|drgS||j}|ddkrH|ddd}dd|DStd |ddS) Nr statusroutputcSsg|]}|ddqS)(r)splitstrip)rnrrr r!z#ovirt.get_nodes..z$database query failed, return code: )r,rr1 splitlines Exception)rresZnodesrrr get_nodes{s   zovirt.get_nodescCs|ds|jr|SdS)NrF)r,r.collect_databaser*rrr run_extra_cmdszovirt.run_extra_cmdc Csi}d}|jd|dd}|ddkr|d}|D]P}z8t|dd}t|dd d d }|||<Wq8tyYq80q8|Sd S) Nz6/etc/ovirt-engine/engine.conf.d/10-setup-database.confzcat Tr r2rr3=rrF)rr;strr7replace IndexError)rr.Zengconfr=Zconfiglinekvrrrr-s    zovirt.parse_db_confcCsd}d|d|jdd|d|jdd|d|jd d|d |jd }d |jd d|}|j|dd}|dD]:}t|dr|}|jjd|dd|Sq| ddS)NZ postgresqlz-k z.dbname=ZENGINE_DB_DATABASEz -k z.dbhost=ZENGINE_DB_HOSTz.dbport=ZENGINE_DB_PORTz.dbuser=ZENGINE_DB_USERz PGPASSWORD=ZENGINE_DB_PASSWORDz> /usr/sbin/sos report --name=postgresql --batch -o postgresql Tr r3z*sosreport-*tar*Zpostgresql_dump/r5zFailed to gather database dumpF) r.rr;fnmatchr8r%ZmanifestZ add_fieldr7Z log_error)rZpluginZsos_optrZdb_sosrFZ_pg_dumprrrr?s:     zovirt.collect_databaseN)__name__ __module__ __qualname____doc__ cluster_namepackagesr Z option_listrr$r+r0r/r>r@r-r?rrrrrs rc@s eZdZdZdZdZddZdS)rhvzRed Hat Virtualization)ZrhevmrhvmcCs$|j|jjkrdS|dr dSdS)NZmanagerzovirt-node-ng-nodectlZrhvhZrhelh)addressr% is_installed)rZnoderrrset_node_labels  zrhv.set_node_labelN)rKrLrMrOrP sos_presetrUrrrrrQsrQc@s0eZdZdZdZddiZdZddZdd Zd S) rhhi_virtz6Red Hat Hyperconverged Infrastructure - Virtualization)Zglusterz gluster.dumpZonrQcCs|jdo|S)NrR)r%rT_check_for_rhhivr*rrr check_enabledszrhhi_virt.check_enabledcCs2|d}|ddkr.|dddkSdS)Nz+SELECT count(server_id) FROM gluster_serverr2rr3r40F)rr;r8)rretrrrrXs  zrhhi_virt._check_for_rhhivN) rKrLrMrOZ sos_pluginsZsos_plugin_optionsrVrYrXrrrrrWs rW) rJZshlexrZsos.collector.clustersrr(rrQrWrrrr s