a )gb!@sddlmZmZmZeZddlZddlZddlZddl Z ddl m Z m Z ddl mZddlmZeeedddedddedddd eddded d ed ddeddded d gd ed d gd eddded dded d gd ed d gd ed d gd ed ddedddeddded d ed d dggdeddedddeddded dgddedddgdeddddedddedddeddddgdgdd ggddZGdd d ee eZdS)!)absolute_importdivisionprint_functionN)ABCMetaabstractmethod) to_native)with_metaclassboolF)typedefault)requiredr r str)r list)r elementsr /Tpkg)r raliasesr )r )absentZ installedZlatestpresentZremoved)r r choicesz expire-cache)r r rno)r r r int)allow_downgrade autoremovebugfix cacheonly conf_filedisable_excludesdisable_gpg_checkdisable_plugin disablerepo download_only download_dir enable_plugin enablerepoexclude installrootinstall_repoqueryinstall_weak_depsrname releaseversecurity skip_brokenstate update_cache update_onlyvalidate_certs sslverify lock_timeout)r*rr/r*)Z argument_specZrequired_one_ofZmutually_exclusiveZsupports_check_modec@sHeZdZdZddZeddZddZdd Zd d Z ed d Z dS)YumDnfz Abstract class that handles the population of instance variables that should be identical between both YUM and DNF modules because of the feature parity and shared argument spec csd||_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_ |jj d g|_ |jjd |_ |jjd |_ |jjd |_|jj d g|_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_dd|jjdD|_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_|jjd|_||j|_||j |_ ||j|_||j|_|jD]4dvrt fd d!d"Ds|j!d#d$q|jdur6|jr0d%|_nd&|_|jrZ|jd%krZ|jj!d'gd(d)|_"dS)*Nrrrrrrrr r!r"r#r$r%r&r'r(r)rcSsg|] }|qSstrip).0pr5r5?/usr/lib/python3.9/site-packages/ansible/module_utils/yumdnf.py [z#YumDnf.__init__..r*r+r,r-r.r0r/r1r2r3 c3s|]}|vVqdSNr5)r8specr*r5r: pr<z"YumDnf.__init__..)@><=zIt appears that a space separated string of packages was passed in as an argument. To operate on several packages, pass a comma separated string of packages or a list of packages.msgrrz4Autoremove should be used alone or with state=absent)rGresultsz/var/run/yum.pid)#moduleparamsrrrrrrrr getr!r"r#r$r%r&r'r(r)rnamesr+r,r-r.r0r/r1r2r3!listify_comma_sep_strings_in_listany fail_jsonlockfile)selfrIr5r@r:__init__Es` "  zYumDnf.__init__cCsdSr>r5rQr5r5r:is_lockfile_pid_validszYumDnf.is_lockfile_pid_validcCs"tj|jst|jo |Sr>)ospathisfilerPglobrTrSr5r5r:_is_lockfile_presentszYumDnf._is_lockfile_presentcCsZ|s dS|jdkr@td|jD]}td|s"dSq"|jjd|jddS)z>Poll until the lock is removed if timeout is a positive numberNrz'{0} lockfile is held by another processrF) rYr3rangetimesleeprIrOformatZ pkg_mgr_name)rQZ iterationr5r5r: wait_for_locks  zYumDnf.wait_for_lockcCsng}g}|D]0}d|vr |||dd|dDq |D]}||qB|||dgkrjgS|S)z method to accept a list of strings as the parameter, find any strings in that list that are comma separated, remove them from the list and add their comma separated elements to the original list ,cSsg|] }|qSr5r6)r8er5r5r:r;r<z.)appendextendsplitremove)rQZ some_listZnew_listZremove_from_original_listelementr5r5r:rMs    z(YumDnf.listify_comma_sep_strings_in_listcCstdSr>)NotImplementedErrorrSr5r5r:runsz YumDnf.runN) __name__ __module__ __qualname____doc__rRrrTrYr_rMrir5r5r5r:r4>sC r4)Z __future__rrrr Z __metaclass__rUr\rXZtempfileabcrrZansible.module_utils._textrZansible.module_utils.sixrdictZyumdnf_argument_specobjectr4r5r5r5r: sX                        &